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: Expected object of type torch.cuda.LongTensor but found type torch.LongTensor for argument #3 'index' #2

Open
GITJolly opened this issue Nov 23, 2018 · 2 comments

Comments

@GITJolly
Copy link

This error occurs when I run train.py

Traceback (most recent call last):
File "train.py", line 208, in
main(opt)
File "train.py", line 72, in main
train_loss, train_sents = train(model, criterion, optimizer, train_iter, model_state)
File "train.py", line 113, in train
dec_inputs, dec_inputs_len)
File "C:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "D:\transformer-master\transformer\models.py", line 152, in forward
enc_outputs, enc_self_attns = self.encoder(enc_inputs, enc_inputs_len, return_attn)
File "C:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "D:\transformer-master\transformer\models.py", line 59, in forward
enc_outputs = self.src_emb(enc_inputs)
File "C:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "C:\Anaconda3\lib\site-packages\torch\nn\modules\sparse.py", line 110, in forward
self.norm_type, self.scale_grad_by_freq, self.sparse)
File "C:\Anaconda3\lib\site-packages\torch\nn\functional.py", line 1110, in embedding
return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
RuntimeError: Expected object of type torch.cuda.LongTensor but found type torch.LongTensor for argument #3 'index'

@GITJolly
Copy link
Author

Have you tried running with your code?Do you have any results?

@liuqingpu
Copy link

Have you tried running with your code?Do you have any results?
I want change others codes. I think this author do this thing for himself

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