深度学习框架_PyTorch_item()函数

item()函数是得到一个元素张量里面的元素值。

下面我们来举一个例子:

>>> x = torch.randn(1)
>>> print(x)
tensor([0.6328])
>>> print(x.item())
0.632796049118042
发布了103 篇原创文章 · 获赞 37 · 访问量 4606

猜你喜欢

转载自blog.csdn.net/Rocky6688/article/details/104077296