kefirski / pytorch_RVAE

Recurrent Variational Autoencoder that generates sequential data implemented with pytorch
MIT License
357 stars 87 forks source link

Got a RuntimeError when running train.py #7

Open mnqu opened 6 years ago

mnqu commented 6 years ago

Hi, I am very interested in the codes. But when I run train.py, I got a runtime error, which is listed below:

preprocessed data was found and loaded Traceback (most recent call last): File "train.py", line 59, in cross_entropy, kld, coef = train_step(iteration, args.batch_size, args.use_cuda, args.dropout) File "/shared/data/mengqu2/projects/rvae/model/rvae.py", line 113, in train loss.backward() File "/home/mengqu2/.local/lib/python3.5/site-packages/torch/autograd/variable.py", line 167, in backward torch.autograd.backward(self, gradient, retain_graph, create_graph, retain_variables) File "/home/mengqu2/.local/lib/python3.5/site-packages/torch/autograd/init.py", line 99, in backward variables, grad_variables, retain_graph) RuntimeError: invalid argument 1: the number of sizes provided must be greater or equal to the number of dimensions in the tensor at /pytorch/torch/lib/THC/generic/THCTensor.c:309

Could you help fix the problem? Thank you so much!

ruotianluo commented 6 years ago

https://github.com/kefirski/pytorch_RVAE/blob/master/model/rvae.py#L78 remove the .squeeze()

(This sounds like a bug of pytorch, but I actually can't reproduce it in simple snippets.)