Pytorch的item()方法

pytorch中.item()方法 是得到一个元素张量里面的元素值

1 import torch
2 torch.arange(3)
1 tensor([0, 1, 2])
1 torch.arange(3)[0].item()

0

注:返回元素0.

原文地址:https://www.cnblogs.com/vvzhang/p/14117472.html