pytorch报错:IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number
是你的torch版本的不同造成的。
解决:将loss.data[0] 改成loss.item()
IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python
最新推荐文章于 2023-08-08 10:36:16 发布