Nmt: TypeError: Expected binary or unicode string, got None

Created on 28 Jul 2017  路  6Comments  路  Source: tensorflow/nmt

I have successfully finished the training task with the following parameters:
drwael@drwael-VirtualBox:~/nmt$ python -m nmt.nmt \

--src=vi --tgt=en \
--vocab_prefix=/home/drwael/mynmt/tmp/nmt_data/vocab  \
--train_prefix=/home/drwael/mynmt/tmp/nmt_data/train \
--dev_prefix=/home/drwael/mynmt/tmp/nmt_data/tst2012  \
--test_prefix=/home/drwael/mynmt/tmp/nmt_data/tst2013 \
--out_dir=/home/drwael/mynmt/tmp/nmt_model \
--num_train_steps=12000 \
--steps_per_stats=100 \
--num_layers=2 \
--num_units=128 \
--dropout=0.2 \
--metrics=bleu

But I recevied the following error when trying to test the model after coping some sentences to my_infer_file.vi:
drwael@drwael-VirtualBox:~/nmt$ python -m nmt.nmt --model_dir=/home/drwael/mynmt/tmp/nmt_model --inference_input_file=/home/drwael/mynmt/tmp/my_infer_file.vi --inference_output_file=/home/drwael/mynmt/tmp/nmt_model/output_infer

Job id 0

Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/drwael/nmt/nmt/nmt.py", line 478, in
tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "/home/drwael/nmt/nmt/nmt.py", line 438, in main
if not tf.gfile.Exists(out_dir): tf.gfile.MakeDirs(out_dir)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/lib/io/file_io.py", line 252, in file_exists
pywrap_tensorflow.FileExists(compat.as_bytes(filename), status)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/util/compat.py", line 65, in as_bytes
(bytes_or_text,))
TypeError: Expected binary or unicode string, got None

Most helpful comment

@zhuoqyin sorry could you elaborate how to change the command line arg name? Got the same problem (:

All 6 comments

Latest code loads hparams from out_dir instead of model_dir.
Simply change the command line arg name would fix it.

@zhuoqyin
Many thanks; it works.

@zhuoqyin sorry could you elaborate how to change the command line arg name? Got the same problem (:

I had the same problem with the the following command
python object_detection/export_tflite_ssd_graph.py \ --pipeline_config_path=$CONFIG_FILE \ --trained_checkpoint_prefix=$CHECKPOINT_PATH \ --output_directory=$OUTPUT_DIR \ --add_postprocessing_op=true

I changed it to the following
python object_detection/export_tflite_ssd_graph.py --pipeline_config_path=$CONFIG_FILE --trained_checkpoint_prefix=$CHECKPOINT_PATH --output_directory=$OUTPUT_DIR --add_postprocessing_op=true

I just removed the '' between the arguments and on the same line not multiline.

The first command gave that error "TypeError: Expected binary or unicode string, got None"

Latest code loads hparams from out_dir instead of model_dir.
Simply change the command line arg name would fix it.

Please elaborate

out_dir=/home/drwael/mynmt/tmp/nmt_model \
replace with
output_directory=/home/drwael/mynmt/tmp/nmt_model \
worked for me

Was this page helpful?
0 / 5 - 0 ratings