OpenNMT Forum

Error while using translate.py file

I am working on the Machine Translation task,
The command I gave for translation:
python3 translate.py -model fr_eng_model_step_116480.pt -src data/fr_test.txt -fp32 -tgt data/eng_test.txt -output pred.txt -replace_unk -verbose -batch_size 32

It throws an Error:
File “translate.py”, line 6, in
main()
File “/home/ravneet/Documents/MT/onmt/bin/translate.py”, line 48, in main
translate(opt)
File “/home/ravneet/Documents/MT/onmt/bin/translate.py”, line 32, in translate
align_debug=opt.align_debug
File “/home/ravneet/Documents/MT/onmt/translate/translator.py”, line 354, in translate
translations = xlation_builder.from_batch(batch_data)
File “/home/ravneet/Documents/MT/onmt/translate/translation.py”, line 100, in from_batch
for n in range(self.n_best)]
File “/home/ravneet/Documents/MT/onmt/translate/translation.py”, line 100, in
for n in range(self.n_best)]
File “/home/ravneet/Documents/MT/onmt/translate/translation.py”, line 51, in _build_target_tokens
_, max_index = attn[i][:len(src_raw)].max(0)
RuntimeError: cannot perform reduction function max on tensor with no elements because the operation does not have an identity

Duplicate of https://github.com/OpenNMT/OpenNMT-py/issues/1711