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

inconsistent tensor size #2

Closed
wangxiaoyunanne opened this issue Jan 19, 2018 · 6 comments
Closed

inconsistent tensor size #2

wangxiaoyunanne opened this issue Jan 19, 2018 · 6 comments

Comments

@wangxiaoyunanne
Copy link

Hi,
When I run train.py there is a error message says:
Loading cora dataset...
Traceback (most recent call last):
File "train.py", line 104, in
train(epoch)
File "train.py", line 69, in train
output = model(features, adj)
File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 206, in call
result = self.forward(*input, **kwargs)
File "build/bdist.linux-x86_64/egg/pygcn/models.py", line 15, in forward
x = F.relu(self.gc1(x, adj))
File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 206, in call
result = self.forward(*input, **kwargs)
File "build/bdist.linux-x86_64/egg/pygcn/layers.py", line 61, in forward
return output + self.bias
File "/usr/local/lib/python2.7/dist-packages/torch/autograd/variable.py", line 745, in add
return self.add(other)
File "/usr/local/lib/python2.7/dist-packages/torch/autograd/variable.py", line 283, in add
return self._add(other, False)
File "/usr/local/lib/python2.7/dist-packages/torch/autograd/variable.py", line 277, in _add
return Add(inplace)(self, other)
File "/usr/local/lib/python2.7/dist-packages/torch/autograd/_functions/basic_ops.py", line 20, in forward
return a.add(b)
RuntimeError: inconsistent tensor size at /b/wheel/pytorch-src/torch/lib/TH/generic/THTensorMath.c:831

@tkipf
Copy link
Owner

tkipf commented Jan 19, 2018

Interesting, thanks for reporting. Did you perform any changes to the code? What steps can I take to reproduce this error?

@wangxiaoyunanne
Copy link
Author

wangxiaoyunanne commented Jan 19, 2018

I changed line 46 in train.py from
model = GCN(nfeat=features.shape[1],
to
model = GCN(nfeat=features.size()[1],

otherwise there will be an error message says tensorflow object does not have 'shape'.

That's the only thing I changed.

@tkipf
Copy link
Owner

tkipf commented Jan 19, 2018

Might be a PyTorch version issue. I only tested this with 0.2.0. Are you on 0.3.0?

@tkipf
Copy link
Owner

tkipf commented Jan 19, 2018

I checked with PyTorch 0.3.0 (latest release version) and it still works fine. features.shape[1] is a supported operation in my environment. Can you check which version you are on?

@wangxiaoyunanne
Copy link
Author

I use 0.1.12_2
I think I need to upgrade it.
Thank you very much for your reply.

@tkipf
Copy link
Owner

tkipf commented Jan 19, 2018

Glad we found the issue. I would certainly recommend upgrading.

@tkipf tkipf closed this as completed Jan 19, 2018
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