OpenNMT / OpenNMT-py

Open Source Neural Machine Translation and (Large) Language Models in PyTorch
https://opennmt.net/
MIT License
6.76k stars 2.25k forks source link

data type error #2077

Closed kevinGit777 closed 3 years ago

kevinGit777 commented 3 years ago

hi, I get this error when running:

Traceback (most recent call last): File "/home/hxw170013/APR/chai/src/lib/OpenNMT-py/translate.py", line 35, in main(opt) File "/home/hxw170013/APR/chai/src/lib/OpenNMT-py/translate.py", line 15, in main translator.translate( File "/home/hxw170013/APR/chai/src/lib/OpenNMT-py/onmt/translate/translator.py", line 209, in translate batch_data = self.translate_batch( File "/home/hxw170013/APR/chai/src/lib/OpenNMT-py/onmt/translate/translator.py", line 354, in translate_batch return self._translate_batch(batch, data) File "/home/hxw170013/APR/chai/src/lib/OpenNMT-py/onmt/translate/translator.py", line 707, in _translate_batch out, beam_attn = self._decode_and_generate( File "/home/hxw170013/APR/chai/src/lib/OpenNMT-py/onmt/translate/translator.py", line 397, in _decode_and_generate dec_out, dec_attn = self.model.decoder( File "/home/hxw170013/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 722, in _call_impl result = self.forward(*input, kwargs) File "/home/hxw170013/APR/chai/src/lib/OpenNMT-py/onmt/decoders/decoder.py", line 160, in forward dec_state, dec_outs, attns = self._run_forward_pass( File "/home/hxw170013/APR/chai/src/lib/OpenNMT-py/onmt/decoders/decoder.py", line 323, in _run_forward_pass emb = self.embeddings(tgt) File "/home/hxw170013/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 722, in _call_impl result = self.forward(*input, *kwargs) File "/home/hxw170013/APR/chai/src/lib/OpenNMT-py/onmt/modules/embeddings.py", line 205, in forward source = self.make_embedding(source) File "/home/hxw170013/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 722, in _call_impl result = self.forward(input, kwargs) File "/home/hxw170013/miniconda3/lib/python3.8/site-packages/torch/nn/modules/container.py", line 117, in forward input = module(input) File "/home/hxw170013/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 722, in _call_impl result = self.forward(*input, *kwargs) File "/home/hxw170013/APR/chai/src/lib/OpenNMT-py/onmt/modules/utilclass.py", line 26, in forward outputs = [f(x) for f, x in zip(self, inputs)] File "/home/hxw170013/APR/chai/src/lib/OpenNMT-py/onmt/modules/utilclass.py", line 26, in outputs = [f(x) for f, x in zip(self, inputs)] File "/home/hxw170013/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 722, in _call_impl result = self.forward(input, **kwargs) File "/home/hxw170013/miniconda3/lib/python3.8/site-packages/torch/nn/modules/sparse.py", line 124, in forward return F.embedding( File "/home/hxw170013/miniconda3/lib/python3.8/site-packages/torch/nn/functional.py", line 1814, in embedding return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse) RuntimeError: Expected tensor for argument #1 'indices' to have scalar type Long; but got torch.FloatTensor instead (while checking arguments for embedding)

my pytorch version is: 1.6.0+cu101 and python version is 3.8 64 bit. Please help!

kevinGit777 commented 3 years ago

just realized that I clone an older version, the problem was solved by downgrading PyTorch...