OpenNMT Forum

Getting a keyword error when I try to train a model in OpenNMT-tf model

I’m getting a keyword error when I try to train a model using Open-NMTtf. I did some googling but I didn’t see much on this error.

$onmt-main --model_type Transformer --config data.yml --auto_config train --with_eval

Below is my data.yml file:

model_dir: run/

data:
  train_features_file: src-train.txt
  train_labels_file: tgt-train.txt
  eval_features_file: src-val.txt
  eval_labels_file: tgt-val.txt
  source_vocabulary: src-vocab.txt
  target_vocabulary: tgt-vocab.txt

Below is the error I’m getting.

Traceback (most recent call last):
  File "/home/username/.local/bin/onmt-main", line 8, in <module>
    sys.exit(main())
  File "/home/username/.local/lib/python3.6/site-packages/opennmt/bin/main.py", line 231, in main
hvd=hvd)
  File "/home/username/.local/lib/python3.6/site-packages/opennmt/runner.py", line 199, in train
checkpoint_path=checkpoint_path, weights_only=checkpoint_path is not None)
  File "/home/username/.local/lib/python3.6/site-packages/opennmt/utils/checkpoint.py", line 129, in restore
checkpoint_path, tmp_model, optimizer=tmp_optimizer)
  File "/home/username/.local/lib/python3.6/site-packages/opennmt/utils/checkpoint.py", line 274, in _restore_v1_checkpoint
mapping = model.map_v1_weights(v1_structure)
  File "/home/username/.local/lib/python3.6/site-packages/opennmt/models/transformer.py", line 158, in map_v1_weights
weights["seq2seq"] = weights.pop("transformer")
KeyError: 'transformer'

Can you delete the run/ directory before starting the training?