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

Runtime Error : Index tensor must have same dimensions as input tensor #2

Open
Ashutosh-Adhikari opened this issue Mar 20, 2018 · 1 comment

Comments

@Ashutosh-Adhikari
Copy link

Hi If i run the code for breakout, i am getting the following error.

Traceback (most recent call last):
File "main.py", line 120, in
main()
File "main.py", line 117, in main
atari_learn(env, task.env_id, num_timesteps=task.max_timesteps, double_dqn=double_dqn, dueling_dqn=dueling_dqn)
File "main.py", line 72, in atari_learn
dueling_dqn=dueling_dqn
File "/home/ashutosh/repos/DQN_pytorch/learn.py", line 229, in dqn_learning
q_s_a.backward(clipped_error.data.unsqueeze(1))
File "/usr/local/lib/python2.7/dist-packages/torch/autograd/variable.py", line 167, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph, retain_variables)
File "/usr/local/lib/python2.7/dist-packages/torch/autograd/init.py", line 99, in backward
variables, grad_variables, retain_graph)
RuntimeError: invalid argument 3: Index tensor must have same dimensions as input tensor at /pytorch/torch/lib/THC/generic/THCTensorScatterGather.cu:199

@bgreenawald
Copy link

I had the same problem and found out it was because I was using a newer version of Pytorch. Assuming you're having the same issue, you can either revert to Pytorch version 0.2.0, or you can change line 229 in "learn.py" from
q_s_a.backward(clipped_error.data.unsqueeze(1))
to
q_s_a.backward(clipped_error.data)

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