IndexError: invalid index of a 0-dim tensor. Use `tensor.item()` in Python or `tensor.item<T>()` in C++ to convert a 0-dim tensor to a number

时间:2021-04-23 16:41:28   收藏:0   阅读:292

报错的时候,是因为loss.data[0]

技术分享图片

 

 修改后变为loss.item()

技术分享图片

 

原文:https://www.cnblogs.com/hao-lingguang19/p/14692631.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!