报错:
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [544, 768]], which is output 0 of ViewBackward, is at version 1; expected version 0 instead.
Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).
解决方法:
报错原因是因为我在搭建网络模型时,残差相加的代码是这样写的: x += y
但是在pytorch中这样写会有问题, 改成: x = x+y就好了



