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()之后,泪目,几天了,终于改好了。