已解决)RuntimeError: one of the variables needed for gradient computation has been modified by an inp

我参考该博客解决问题啦,博客在这:这个哦
我自己定义一个模块,然后加入网络后出现以下报错:在这里插入图片描述
然后看到上面说的博客里面解释:

已解决)RuntimeError: one of the variables needed for gradient computation has been modified by an inp_第1张图片
已解决)RuntimeError: one of the variables needed for gradient computation has been modified by an inp_第2张图片
已解决)RuntimeError: one of the variables needed for gradient computation has been modified by an inp_第3张图片
解决办法:
直接把A+=B操作里面的部分改成A=A即可

已解决)RuntimeError: one of the variables needed for gradient computation has been modified by an inp_第4张图片

然后运行发现可以啦!希望也可以帮你解决问题。
在这里插入图片描述

你可能感兴趣的:(python)