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

2023-11-17

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [512, 256, 5, 5]] is at version 6; expected version 5 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).
网上的方法都试了对我没用
[解决]我的解决方法主要是:更改所有optimizer.step()位置,将所有optimizer.step()都放到最后一个loss.backward()之后,泪目,几天了,终于改好了。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace o 的相关文章

随机推荐