When I train the model in the tutorials, I met such an error.
I have updated my tensorflow to version 1.2.1, and use script to download the data .
Version of my python is 3.6.
python -m nmt.nmt --src=vi --tgt=en --vocab_prefix=/tmp/nmt_data/vocab --train_prefix=/tmp/nmt_data/train --dev_prefix=/tmp/nmt_data/tst2012 --test_prefix=/tmp/nmt_data/tst2013 --out_dir=/tmp/nmt_model --num_train_steps=12000 --steps_per_stats=100 --num_layers=2 --num_units=128 --dropout=0.2 --metrics=bleu
b'# Job id 0'
b'# hparams:'
b' src=vi'
b' tgt=en'
b' train_prefix=/tmp/nmt_data/train'
b' dev_prefix=/tmp/nmt_data/tst2012'
b' test_prefix=/tmp/nmt_data/tst2013'
b' out_dir=/tmp/nmt_model'
b'# Vocab file /tmp/nmt_data/vocab.vi exists'
b'# Vocab file /tmp/nmt_data/vocab.en exists'
b' saving hparams to /tmp/nmt_model/hparams'
b' saving hparams to /tmp/nmt_model/best_bleu/hparams'
Traceback (most recent call last):
File "/Applications/bin/anaconda3/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/Applications/bin/anaconda3/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/jiahaohong/Downloads/nmt-master/nmt/nmt.py", line 479, in
tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
File "/Applications/bin/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "/Users/jiahaohong/Downloads/nmt-master/nmt/nmt.py", line 289, in main
hparams = load_train_hparams(out_dir)
File "/Users/jiahaohong/Downloads/nmt-master/nmt/nmt.py", line 237, in load_train_hparams
utils.print_hparams(hparams)
File "/Users/jiahaohong/Downloads/nmt-master/nmt/utils/misc_utils.py", line 72, in print_hparams
for key in sorted(values.iterkeys()):
AttributeError: 'dict' object has no attribute 'iterkeys'
I got the same error in the same environment...
That's cause there is no iterkeys() for dictionaries in Python 3. See: http://legacy.python.org/dev/peps/pep-0469/
Either use Python 2 or apply those changes: https://github.com/tensorflow/nmt/pull/8
Merged #8.
Most helpful comment
Merged #8.