Pytorch的item()方法

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

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

 

1 torch.arange(3)[0].item()

0

注:返回元素0.

 

posted @ 2020-12-10 21:24  vv_869  阅读(631)  评论(0编辑  收藏  举报