google / seq2seq

A general-purpose encoder-decoder framework for Tensorflow
https://google.github.io/seq2seq/
Apache License 2.0
5.61k stars 1.3k forks source link

TypeError: string indices must be integers, not unicode #268

Open inigo-jauregi opened 7 years ago

inigo-jauregi commented 7 years ago

Hello,

I am trying to follow the tutorial in NMT with the toy data. I follow the instructions but when I try to train the model I get the following error:

Traceback (most recent call last):
  File "/usr/local/tensorflow-1.1/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/local/tensorflow-1.1/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/data/ijauregi/Desktop/CMCRC/TensorFlow_Tutorial/Sequence_to_sequence/seq2seq/bin/train.py", line 277, in <module>
    tf.app.run()
  File "/usr/local/tensorflow-1.1/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 44, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "/data/ijauregi/Desktop/CMCRC/TensorFlow_Tutorial/Sequence_to_sequence/seq2seq/bin/train.py", line 272, in main
    schedule=FLAGS.schedule)
  File "/usr/local/tensorflow-1.1/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/learn_runner.py", line 79, in run
    experiment = experiment_fn(output_dir=output_dir)
  File "/data/ijauregi/Desktop/CMCRC/TensorFlow_Tutorial/Sequence_to_sequence/seq2seq/bin/train.py", line 154, in create_experiment
    mode=tf.contrib.learn.ModeKeys.TRAIN)
  File "seq2seq/data/input_pipeline.py", line 53, in make_input_pipeline_from_def
    class_ = def_dict["class"]
TypeError: string indices must be integers, not unicode

I think it may be related with how I run the command in the console:

[ijauregi@phoenix22 seq2seq]$ python -m bin.train --config_paths="./example_configs/nmt_small.yml, ./example_configs/train_seq2seq.yml, ./example_configs/text_metrics_bpe.yml" --model_params "vocab_source:$VOCAB_SOURCE vocab_target:$VOCAB_TARGET" --input_pipeline_train "class:ParallelTextInputPipeline params:source_files:-$TRAIN_SOURCES target_files:-$TRAIN_TARGETS" --input_pipeline_dev "class:ParallelTextInputPipeline params:source_files:-$DEV_SOURCES target_files:-$DEV_TARGETS" --batch_size 32 --train_steps $TRAIN_STEPS --output_dir $MODEL_DIR

Am I writing something wrong? Thank you very much

inigo-jauregi commented 7 years ago

Solved. I wrote the command in a '.sh' file and now it works well.