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

An error occurred when testing the repo #3

Closed
DexterZeng opened this issue Jun 4, 2018 · 4 comments
Closed

An error occurred when testing the repo #3

DexterZeng opened this issue Jun 4, 2018 · 4 comments

Comments

@DexterZeng
Copy link

Hi
Thank you for sharing the code. However, when I tried to test the repo with "python preprocess.py" and " python train.py --weights --cuda", the first one worked well and generated processed data, whereas the second reported the error as follows:

[Epoch 1]: 0%| | 0/1 [00:00<?, ?it/s]Traceback (most recent call last):
File "train.py", line 93, in train(parse_args())
File "train.py", line 81, in train loss = sgns(iword, owords)
File "/home/weixin/anaconda2/envs/p3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 325, in call
result = self.forward(*input, **kwargs)
File "/home/weixin/Downloads/pytorch-sgns-master/model.py", line 70, in forward
ivectors = self.embedding.forward_i(iword).unsqueeze(2)
File "/home/weixin/Downloads/pytorch-sgns-master/model.py", line 42, in forward_i
return self.ivectors(v)
File "/home/weixin/anaconda2/envs/p3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 325, in call
result = self.forward(*input, **kwargs)
File "/home/weixin/anaconda2/envs/p3/lib/python3.6/site-packages/torch/nn/modules/sparse.py", line 103, in forward
self.scale_grad_by_freq, self.sparse
RuntimeError: save_for_backward can only save input or output tensors, but argument 0 doesn't satisfy this condition

I am quite new to Pytorch so any idea what might go wrong?
Many thanks.

@theeluwin
Copy link
Owner

Can you offer your pytorch version? It seems that the error here looks similar to https://discuss.pytorch.org/t/why-i-cant-use-torch-index-select-in-forward-function/8010

@DexterZeng
Copy link
Author

Hi, thanks for the reply. The pytorch version is 0.3.0.post4.
The error does look similar to the post. Should I wrap the Tensors in the Variables?
Many thanks.

@theeluwin
Copy link
Owner

Yes, you should wrap tensors with Variable properly. I removed all Variable because it was removed in 0.4.0 (see https://pytorch.org/2018/04/22/0_4_0-migration-guide.html).

@DexterZeng
Copy link
Author

Many thanks for your feedback. I will try it later.

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