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

RuntimeError: dimension specified as 0 but tensor has no dimensions (backward) #25

Open
ghost opened this issue Dec 27, 2017 · 7 comments

Comments

@ghost
Copy link

ghost commented Dec 27, 2017

Hi,
I was trying to run the train_w.py on ner conll2003 data using this command: python train_w.py --train_file ner-conll2003/train --dev_file ner-conll2003/dev --test_file ner-conll2003/test --checkpoint ./checkpoint/ner_ --caseless --fine_tune --emb_file Glove5g_200.txt --embedding_dim 200 --gpu 1

But I got this error:

Traceback (most recent call last):
File "train_w.py", line 189, in
loss.backward()
File "../py3/lib/python3.6/site-packages/torch/autograd/variable.py", line 167, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph, retain_variables)
File ".../py3/lib/python3.6/site-packages/torch/autograd/init.py", line 99, in backward
variables, grad_variables, retain_graph)
RuntimeError: dimension specified as 0 but tensor has no dimensions

Did you have an idea how can I fix this problem please?
Thank you

@LiyuanLucasLiu
Copy link
Owner

LiyuanLucasLiu commented Dec 27, 2017

Hi,
happy holiday :-)
It should be --word_dim 200 instead of --embedding_dim 200.
Best,
Lucas

oh, sorry i didn't notice that you are using train_w instead of train_wc. Actually, for train_w, i'm not quite sure what causes the problem. would look into it later (if i find some time).

@ghost
Copy link
Author

ghost commented Dec 27, 2017

Hi,
Thank you,

Happy holiday :-)

Sahar

@jerryitp
Copy link

jerryitp commented Jan 2, 2018

I also find the same error "dimension specified as 0 but tensor has no dimensions" using torch-0.3.0. The author used torch-0.2.0 as said in requirement. I guess this is the problem. I haven't try torch-0.2.0 yet.

@assulan
Copy link

assulan commented Jan 26, 2018

@saharghannay amd @jerryitp were you guys able to resolve the error?

@ghost
Copy link
Author

ghost commented Jan 26, 2018

no, not yet

@HuimengZhang
Copy link

HuimengZhang commented Feb 11, 2018

Also got the same issue here. No idea what caused it.

But I did try installing a previous version of PyTorch(0.2.0.post3), the error was avoided.

@jorditg
Copy link

jorditg commented Feb 14, 2018

On Pytorch 0.3.1.post2

With tensors works fine:

a = torch.FloatTensor()
b = torch.rand(2,3)
a=torch.cat([a.clone(),b])

With Variables ERROR:

a = torch.autograd.Variable(torch.FloatTensor(), requires_grad=True)
b = torch.autograd.Variable(torch.rand(2,3), requires_grad=True)
a=torch.cat([a.clone(),b])

RuntimeError: dimension specified as 0 but tensor has no dimensions

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