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


使用一个pytorch写的模型时,报错:RuntimeError:one of the variables needed for gradient computation has been modified by an inplace operation

解决方法一:如果使用的是pytorch0.4.0版本,回退到pytorch0.3.0版本

解决方法二:如果有inreplace参数,设为False

解决方法三:报错原因是pytorch0.4.0版本后tensor不支持inplace操作了,所以把所有inplace错作去掉。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM