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