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错作去掉。

posted @ 2018-06-21 11:18  lzp的bky  阅读(17532)  评论(0编辑  收藏  举报