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

I meet the same problem, how do solve the probelm? thanks a lot.

PLZ delete the replace_unk when you translate.

Were you able to resolve this? I am not sure how to solve this problem. Please help

Training Example of Conv2Conv

python3 …/train.py -data ./data_cnn -save_model ./model/cnn -encoder_type cnn -decoder_type cnn -world_size 1 -gpu_ranks 0 -batch_size 16 -dropout 0.1 -learning_rate 0.001 -max_generator_batches 16 -valid_batch_size 16 -train_steps 200000 -enc_layers 5 -dec_layers 5 -src_word_vec_size 512 -tgt_word_vec_size 512 -rnn_size 512 -optim adam -log_file log_cnn -reset_optim keep_states -learning_rate_decay 0.99 -valid_steps 5000 -save_checkpoint_steps 5000

Translating Example of Conv2Conv (Do not add -replace_unk)

python3 …/translate.py -model ./model/zh-ko_step_50000.pt -src ./DATA/zh-test-sp -output ./pred/zh-ko-cnn-50000

1 Like