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

原有:

pytorch 换了一个网络跑模型

整个项目是模块化编程

对应的网络都是有自己的模块的,因为替换了一下网络,结果报了这个错,很尴尬,明明什么都没动,就是换了一下网络,也报这个错。

参考链接:

https://discuss.pytorch.org/t/one-of-the-variables-needed-for-gradient-computation-has-been-modified-by-an-inplace-operation/12578/5

解决:

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

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace o_模块化编程_02