pytorch 之 RuntimeError: one of the variables needed for gradient computation has been modified by an

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [1, 64, 92, 122]], which is output 0 of LeakyReluBackward0, is at version 1; expected version 0 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient
————————————————
版权声明:本文为CSDN博主「nachifur」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/superjunenaruto/article/details/111409938

在网络forward函数中,不要出现x+=1,使用x=x+1
比如我的代码原来是这么写的:error
 

out += x

改成

out =out+ x

你可能感兴趣的:(pytorch)