pytorch-avitm
pytorch-avitm copied to clipboard
RuntimeError: undefined Tensor
I am getting following error with pytorch 1.2.0 in python 3.7. Any help will be appreciated:
/workspace/topic-modeling-/pytorch_model.py:60: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument. p = F.softmax(z) # mixture probability /workspace/topic-modeling-/pytorch_model.py:65: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument. recon = F.softmax(self.decoder_bn(self.decoder(p))) # reconstructed distribution over vocabulary
RuntimeError Traceback (most recent call last)
~/anaconda3/lib/python3.7/site-packages/torch/tensor.py in backward(self, gradient, retain_graph, create_graph)
116 products. Defaults to False
.
117 """
--> 118 torch.autograd.backward(self, gradient, retain_graph, create_graph)
119
120 def register_hook(self, hook):
~/anaconda3/lib/python3.7/site-packages/torch/autograd/init.py in backward(tensors, grad_tensors, retain_graph, create_graph, grad_variables) 91 Variable._execution_engine.run_backward( 92 tensors, grad_tensors, retain_graph, create_graph, ---> 93 allow_unreachable=True) # allow_unreachable flag 94 95
RuntimeError: undefined Tensor
I had the same problem.
You can comment out the below lines, and remove these variables from forward function. It works for me.
remove BN's scale parameters
# self.logvar_bn .register_parameter('weight', None)
# self.mean_bn .register_parameter('weight', None)
# self.decoder_bn.register_parameter('weight', None)
# self.decoder_bn.register_parameter('weight', None)