编程语言
首页 > 编程语言> > IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python

IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python

作者:互联网

pytorch报错IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number

原因 tersor是0维的

解决办法:

变成tensor.item()就行了

标签:dim,Use,IndexError,tensor,index,item
来源: https://blog.csdn.net/weixin_43914889/article/details/104673546