我是靠谱客的博主 冷静酸奶,这篇文章主要介绍Python报错:RuntimeError: one of the variables needed for gradient computation has been modified by,现在分享给大家,希望可以做个参考。

Python报错:

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation 

解决办法:
在inplace为True的时候,将其改为Flase,如dropout时;或者直接去掉所有的inplace操作。

#修改前
""self.dropout = torch.nn.Dropout(p=drop, inplace=True)""
#修改后
self.dropout = torch.nn.Dropout(p=drop)

问题即可解决。

最后

以上就是冷静酸奶最近收集整理的关于Python报错:RuntimeError: one of the variables needed for gradient computation has been modified by的全部内容,更多相关Python报错:RuntimeError:内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(65)

评论列表共有 0 条评论

立即
投稿
返回
顶部