报错内容
RuntimeError:one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [128, 64, 8, 8]], which is output 0 of ReluBackward0, 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).
我是在去掉ResNet的BN层出现这个问题的,针对我的这个问题,我的修改内容是:
将out+=residual
修改为out=out+residual
就奇迹般地不报错了