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

pytorch报错:RuntimeError: one of the variables needed for gradient computation has been modified by an,第1张

修改网络时
pytroch报错

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [1600, 16, 256]], which is output 0 of CudnnConvolutionBackward, is at version 1; expected version 0 instead

解决方案一:

检查被报错的那个tensor的所有 *** 作,如果出现了x += mx=x+m的加法或者减法运算,全部改为以下格式:

x = x.clone() + m

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/886223.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-14
下一篇 2022-05-14

发表评论

登录后才能评论

评论列表(0条)

保存