Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Got a RuntimeError when running train.py #7

Open
mnqu opened this issue Jan 26, 2018 · 1 comment
Open

Got a RuntimeError when running train.py #7

mnqu opened this issue Jan 26, 2018 · 1 comment

Comments

@mnqu
Copy link

mnqu commented Jan 26, 2018

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
Copy link

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants