OpenNMT Forum

RuntimeError: invalid argument 3: out of range at /pytorch/aten/src/TH/generic/THTensor.cpp:318

I train the model using Conv2Conv.

When I try to translate error is occur.

command

RuntimeError: invalid argument 3: out of range at /pytorch/aten/src/TH/generic/THTensor.cpp:318

error

[2019-09-18 17:58:18,820 INFO] Translating shard 0.
Traceback (most recent call last):
File “…/translate.py”, line 49, in
main(opt)
File “…/translate.py”, line 33, in main
attn_debug=opt.attn_debug
File “/home/chanjun/work/NMT/OpenNMT-py/onmt/translate/translator.py”, line 351, in translate
batch, data.src_vocabs, attn_debug
File “/home/chanjun/work/NMT/OpenNMT-py/onmt/translate/translator.py”, line 544, in translate_batch
return_attention=attn_debug or self.replace_unk)
File “/home/chanjun/work/NMT/OpenNMT-py/onmt/translate/translator.py”, line 695, in _translate_batch
beam.advance(log_probs, attn)
File “/home/chanjun/work/NMT/OpenNMT-py/onmt/translate/beam_search.py”, line 175, in advance
current_attn = attn.index_select(1, self.select_indices)
RuntimeError: invalid argument 3: out of range at /pytorch/aten/src/TH/generic/THTensor.cpp:318

What is the problem?

Do you use -attn_debug or -replace_unk? I don’t think they are compatible with the Conv2Conv model.

I solve the problem. I was use replace_unk