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

Error when running main.py #3

Open
ghost opened this issue Oct 25, 2017 · 5 comments
Open

Error when running main.py #3

ghost opened this issue Oct 25, 2017 · 5 comments

Comments

@ghost
Copy link

ghost commented Oct 25, 2017

Hi, I am using pytorch 0.2 and when I run the script, it generated following errors:

Traceback (most recent call last):
  File "main.py", line 142, in <module>
    main()
  File "main.py", line 116, in main
    meta_model = meta_optimizer.meta_update(model, loss.data)
  File "/home/rvl224/pytorch-meta-optimizer/meta_optimizer.py", line 135, in meta_update
    inputs = Variable(torch.cat((preprocess_gradients(flat_grads), flat_params.data, loss), 1))
  File "/home/rvl224/pytorch-meta-optimizer/utils.py", line 11, in preprocess_gradients
    return torch.cat((x1, x2), 1)
RuntimeError: dim out of range - got 1 but the tensor is only 1D

Is it because I am using a different version of pytorch?

@ikostrikov
Copy link
Owner

I think that it happened because they changed default parameters for some functions recently. Try to check all "sum", "mean" and similar functions and set keep dim to True.

@RadZaeem
Copy link

RadZaeem commented Dec 9, 2017

which pytorch version are you using?

Tried putting keepdim=True with pytorch 0.3, did not work.

@cstsunfu
Copy link

I got the same error. And the pytorch version is 0.2.

@yunhunJang
Copy link

Try this.
return torch.cat((x1.view(-1,1), x2.view(-1,1), 1)

@VeritasXu
Copy link

I solved this problem, use return torch.cat((x1.view(-1,1), x2.view(-1,1)), 1) to update utils.py‘s output.
And update meta_optimizer.py line135 to inputs = Variable(torch.cat((preprocess_gradients(flat_grads), flat_params.data.unsqueeze(1), loss.unsqueeze(1)), 1))

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

5 participants