tensorflow / tensor2tensor

Library of deep learning models and datasets designed to make deep learning more accessible and accelerate ML research.
Apache License 2.0
15.5k stars 3.49k forks source link

AttributeError: 'HParams' object has no attribute 'decode_reference' #1139

Open wingsyuan opened 6 years ago

wingsyuan commented 6 years ago

Description

...when i run t2t-decoder, an error occur, why and what happen? here is the command: t2t-decoder --data_dir=data --problem=translate_enzh_wmt32k --model=transformer --hparams_set=transformer_base_single_gpu --output_dir=train --decode_hparams="beam_size=4,alpha=0.6" --decode_from_file=test10.10 --decode_to_file=translation_test.en

and the error: INFO:tensorflow:Inference results OUTPUT: 翻版 INFO:tensorflow:Inference results INPUT: C INFO:tensorflow:Inference results OUTPUT: C INFO:tensorflow:Inference results INPUT: B INFO:tensorflow:Inference results OUTPUT: B INFO:tensorflow:Inference results INPUT: A INFO:tensorflow:Inference results OUTPUT: A INFO:tensorflow:Elapsed Time: 5906.26919 INFO:tensorflow:Averaged Single Token Generation Time: 0.0030321 INFO:tensorflow:Writing decodes into translation_test.en INFO:tensorflow:Running decode hooks. Traceback (most recent call last): File "/home/zhangshaoyuan/anaconda3/bin/t2t-decoder", line 17, in tf.app.run() File "/home/zhangshaoyuan/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run _sys.exit(main(argv)) File "/home/zhangshaoyuan/anaconda3/bin/t2t-decoder", line 12, in main t2t_decoder.main(argv) File "/home/zhangshaoyuan/anaconda3/lib/python3.6/site-packages/tensor2tensor/bin/t2t_decoder.py", line 190, in main decode(estimator, hp, decode_hp) File "/home/zhangshaoyuan/anaconda3/lib/python3.6/site-packages/tensor2tensor/bin/t2t_decoder.py", line 90, in decode checkpoint_path=FLAGS.checkpoint_path) File "/home/zhangshaoyuan/anaconda3/lib/python3.6/site-packages/tensor2tensor/utils/decoding.py", line 443, in decode_from_file ), None) File "/home/zhangshaoyuan/anaconda3/lib/python3.6/site-packages/tensor2tensor/utils/decoding.py", line 823, in run_postdecode_hooks summaries = hook(decode_hook_args) File "/home/zhangshaoyuan/anaconda3/lib/python3.6/site-packages/tensor2tensor/data_generators/translate.py", line 80, in compute_bleu_summaries if (decode_hparams.decode_reference is None or AttributeError: 'HParams' object has no attribute 'decode_reference'

Environment information

Name: tensor2tensor Version: 1.9.0 Name: tensorflow Version: 1.11.0

anyone tell me why? thanks very much!

gonglinyuan commented 6 years ago

I met the same problem, too

lkluo commented 6 years ago

Same problem with t2t-decoder; however, the translation file can be produced eventually.

lkluo commented 6 years ago

One more finding, when using --checkpoint_path rather than --output_dir, there will be no error.

Wistral commented 3 years ago

One more finding, when using --checkpoint_path rather than --output_dir, there will be no error.

Yes, I tried this approach, it works...

More specific, change --output_dir=model-dir to --checkpoint_path=model-dir/model-name, model-name without extension name (eg. --checkpoint_path=./basemodule/model.ckpt-180000. Hope my exp. can help more people:smile:

Wistral commented 3 years ago

My platform info:

Ubuntu 18.04.5 LTS Linux spc 5.4.0-62-generic #70~18.04.1-Ubuntu SMP Tue Jan 12 17:18:00 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

tensor2tensor 1.9.0 tensorboard 1.12.2 tensorflow-gpu 1.12.0 tensorflow-probability 0.7.0