pytorch .item() 的用法

torch.Tensor.item()
得到一个元素张量里面的元素值
注意只能是一个值(多个值会报错 “only one element tensors can be converted to Python scalars”),适合返回loss,acc

猜你喜欢

转载自blog.csdn.net/qq_35762060/article/details/109693077