TypeError: __init__() got an unexpected keyword argument 'reduction', when using pre-trained embeddings on OpenNMT-py


(Negacy Hailu) #1

I am loading pre-trained character embedding to OpenNMT-py framework so that to perform character based translation. However, I am having the following error message, any thoughts?
Traceback (most recent call last):
File “train.py”, line 118, in
File “train.py”, line 53, in main
single_main(opt, -1)
File “/home/nhailu/git/OpenNMT-py/onmt/train_single.py”, line 124, in main
optim, data_type, model_saver=model_saver)
File “/home/nhailu/git/OpenNMT-py/onmt/trainer.py”, line 36, in build_trainer
model, fields[“tgt”].vocab, opt)
File “/home/nhailu/git/OpenNMT-py/onmt/utils/loss.py”, line 32, in build_loss_compute
label_smoothing=opt.label_smoothing if train else 0.0)
File “/home/nhailu/git/OpenNMT-py/onmt/utils/loss.py”, line 226, in init
ignore_index=self.padding_idx, reduction=‘sum’
TypeError: init() got an unexpected keyword argument ‘reduction’

(Vincent Nguyen) #2

you need pytorch 0.4.1