Hi, I'm trying to adapt your code to a Regression problem. I'm getting the following error.
/pytorch/torch/csrc/autograd/python_anomaly_mode.cpp:57: UserWarning: Traceback of forward call that caused the error:
File "bayesian_specnet.py", line 141, in
run()
File "bayesian_specnet.py", line 125, in run
train_loss, train_kl = train_model(net, optimizer, criterion, train_loader, num_ens=train_ens, beta_type=beta_type, epoch=epoch, num_epochs=n_epochs)
File "bayesian_specnet.py", line 41, in train_model
net_out, _kl = net(inputs)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 541, in call
result = self.forward(*input, *kwargs)
File "/content/probabilistic-nn-cars/layers/misc.py", line 19, in forward
x = module(x)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 541, in call
result = self.forward(input, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/activation.py", line 603, in forward
return F.softplus(input, self.beta, self.threshold)
Traceback (most recent call last):
File "bayesian_specnet.py", line 141, in
run()
File "bayesian_specnet.py", line 125, in run
train_loss, train_kl = train_model(net, optimizer, criterion, train_loader, num_ens=train_ens, beta_type=beta_type, epoch=epoch, num_epochs=n_epochs)
File "bayesian_specnet.py", line 53, in train_model
loss.backward()
File "/usr/local/lib/python3.6/dist-packages/torch/tensor.py", line 166, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph)
File "/usr/local/lib/python3.6/dist-packages/torch/autograd/init.py", line 99, in backward
allow_unreachable=True) # allow_unreachable flag
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [256, 16, 573]], which is output 0 of SoftplusBackward, is at version 1; expected version 0 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later. Good luck!
Is this a version-related error? Could anyone give a suggestion?
Thanks
Hi, I'm trying to adapt your code to a Regression problem. I'm getting the following error.
/pytorch/torch/csrc/autograd/python_anomaly_mode.cpp:57: UserWarning: Traceback of forward call that caused the error: File "bayesian_specnet.py", line 141, in
run()
File "bayesian_specnet.py", line 125, in run
train_loss, train_kl = train_model(net, optimizer, criterion, train_loader, num_ens=train_ens, beta_type=beta_type, epoch=epoch, num_epochs=n_epochs)
File "bayesian_specnet.py", line 41, in train_model
net_out, _kl = net(inputs)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 541, in call
result = self.forward(*input, *kwargs)
File "/content/probabilistic-nn-cars/layers/misc.py", line 19, in forward
x = module(x)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 541, in call
result = self.forward(input, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/activation.py", line 603, in forward
return F.softplus(input, self.beta, self.threshold)
Traceback (most recent call last): File "bayesian_specnet.py", line 141, in
run()
File "bayesian_specnet.py", line 125, in run
train_loss, train_kl = train_model(net, optimizer, criterion, train_loader, num_ens=train_ens, beta_type=beta_type, epoch=epoch, num_epochs=n_epochs)
File "bayesian_specnet.py", line 53, in train_model
loss.backward()
File "/usr/local/lib/python3.6/dist-packages/torch/tensor.py", line 166, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph)
File "/usr/local/lib/python3.6/dist-packages/torch/autograd/init.py", line 99, in backward
allow_unreachable=True) # allow_unreachable flag
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [256, 16, 573]], which is output 0 of SoftplusBackward, is at version 1; expected version 0 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later. Good luck!
Is this a version-related error? Could anyone give a suggestion? Thanks