該当コード該当コード(torch.autograd.set_detect_anomaly(True)torch.autograd.set_detect_anomaly(True)
によって表示された箇所)
class UnNormfunc(nn.Module):
def init(self):
super(UnNormfunc, self).init()
class UnNormfunc(nn.Module):
def __init__(self):
super(UnNormfunc, self).__init__()
def forward(self, x):
tempx = x.clone()
for i in range(3):
tempx[:,i,:,:] = tempx[:,i,:,:] * std[i] + mean[i]
return tempx
以下,エラーメッセージ
sys:1: RuntimeWarning: Traceback of forward call that caused the error:
File "train.py", line 149, in
B_hat, B_hat_d1, B_hat_d2, B_hat_d3, B_hat_d4 = generator(torch.cat([ Norm(gamma_RF), Rmap, Norm(gamma_RF * Rmap) ], 1))
File "~/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in call
result = self.forward(*input, **kwargs)
File "~/hoge/models.py", line 133, in forward
D4 = self.unNorm(self.final4(x4_0))
File "~/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in callエラーメッセージ
result = self.forward(*input, **kwargs)
File "~/hoge/util.py", line 30, in forward
tempx[:,i,:,:] = tempx[:,i,:,:] * std[i] + mean[i]
Traceback (most recent call last):
File "train.py", line 190, in
loss_G.backward()
File "~/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/tensor.py", line 102, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph)
File "~/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/autograd/init.py", line 90, in backward
allow_unreachable=True) # allow_unreachable flag
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation
sys:1: RuntimeWarning: Traceback of forward call that caused the error:
File "train.py", line 149, in <module>
B_hat, B_hat_d1, B_hat_d2, B_hat_d3, B_hat_d4 = generator(torch.cat([ Norm(gamma_RF), Rmap, Norm(gamma_RF * Rmap) ], 1))
File "~/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in __call__
result = self.forward(*input, **kwargs)
File "~/hoge/models.py", line 133, in forward
D4 = self.unNorm(self.final4(x4_0))
File "~/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in __call__
result = self.forward(*input, **kwargs)
File "~/hoge/util.py", line 30, in forward
tempx[:,i,:,:] = tempx[:,i,:,:] * std[i] + mean[i]
Traceback (most recent call last):
File "train.py", line 190, in <module>
loss_G.backward()
File "~/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/tensor.py", line 102, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph)
File "~/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/autograd/__init__.py", line 90, in backward
allow_unreachable=True) # allow_unreachable flag
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation