tensorflow / nmt

TensorFlow Neural Machine Translation Tutorial
Apache License 2.0
6.37k stars 1.96k forks source link

error while running inference on deen_gnmt_model_4_layer #107

Open dDua opened 6 years ago

dDua commented 6 years ago

Hi,

I am new Tensorflow so couldn't really find the problem. I would really appreciate if someone could help me out with it. I downloaded the trained model deen_gnmt_model_4_layer and was trying to run inference on it with following command as described in the Readme.md

python -m nmt.nmt --src=de --tgt=en --ckpt=/media/rohan/Slow\ SSD/dheeru_workspace/nmt/deen_gnmt_model_4_layer/translate.ckpt --hparams_path=nmt/standard_hparams/wmt16.json --out_dir=/media/rohan/Slow\ SSD/dheeru_workspace/deen_gnmt --vocab_prefix=/media/rohan/Slow\ SSD/dheeru_workspace/nmt/wmt16/vocab.bpe.32000 --inference_input_file=/media/rohan/Slow\ SSD/dheeru_workspace/nmt/wmt16/newstest2015.tok.bpe.32000.de --inference_output_file=/media/rohan/Slow\ SSD/dheeru_workspace/deen_gnmt/output_infer --inference_ref_file=/media/rohan/Slow\ SSD/dheeru_workspace/nmt/wmt16/newstest2015.tok.bpe.32000.en

I installed the nightly build of tensorflow as was suggested in Readme

Thanks!

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 "/media/rohan/Slow SSD/dheeru_workspace/nmt/nmt/nmt.py", line 513, 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 "/media/rohan/Slow SSD/dheeru_workspace/nmt/nmt/nmt.py", line 504, in main run_main(FLAGS, default_hparams, train_fn, inference_fn) File "/media/rohan/Slow SSD/dheeru_workspace/nmt/nmt/nmt.py", line 483, in run_main trans_file, hparams, num_workers, jobid) File "nmt/inference.py", line 112, in inference hparams) File "nmt/inference.py", line 138, in single_worker_inference infer_model.model, ckpt, sess, "infer") File "nmt/model_helper.py", line 399, in load_model model.saver.restore(session, ckpt) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1646, in restore {self.saver_def.filename_tensor_name: save_path}) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 889, in run run_metadata_ptr) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1118, in _run feed_dict_tensor, options, run_metadata) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1315, in _do_run options, run_metadata) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1334, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [36551,1024] rhs shape= [36548,1024] [[Node: save/Assign_26 = Assign[T=DT_FLOAT, _class=["loc:@embeddings/encoder/embedding_encoder"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/cpu:0"](embeddings/encoder/embedding_encoder, save/RestoreV2_26)]]

Caused by op u'save/Assign_26', defined at: 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 "/media/rohan/Slow SSD/dheeru_workspace/nmt/nmt/nmt.py", line 513, 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 "/media/rohan/Slow SSD/dheeru_workspace/nmt/nmt/nmt.py", line 504, in main run_main(FLAGS, default_hparams, train_fn, inference_fn) File "/media/rohan/Slow SSD/dheeru_workspace/nmt/nmt/nmt.py", line 483, in run_main trans_file, hparams, num_workers, jobid) File "nmt/inference.py", line 104, in inference infer_model = model_helper.create_infer_model(model_creator, hparams, scope) File "nmt/model_helper.py", line 195, in create_infer_model single_cell_fn=single_cell_fn) File "nmt/gnmt_model.py", line 54, in init single_cell_fn=single_cell_fn) File "nmt/attention_model.py", line 55, in init single_cell_fn=single_cell_fn) File "nmt/model.py", line 185, in init self.saver = tf.train.Saver(tf.global_variables()) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1201, in init self.build() File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1210, in build self._build(self._filename, build_save=True, build_restore=True) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1246, in _build build_save=build_save, build_restore=build_restore) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 738, in _build_internal restore_sequentially, reshape) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 426, in _AddRestoreOps assign_ops.append(saveable.restore(tensors, shapes)) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 160, in restore self.op.get_shape().is_fully_defined()) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/state_ops.py", line 276, in assign validate_shape=validate_shape) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_state_ops.py", line 57, in assign use_locking=use_locking, name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 790, in _apply_op_helper op_def=op_def) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 3077, in create_op op_def=op_def) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1627, in init self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [36551,1024] rhs shape= [36548,1024] [[Node: save/Assign_26 = Assign[T=DT_FLOAT, _class=["loc:@embeddings/encoder/embedding_encoder"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/cpu:0"](embeddings/encoder/embedding_encoder, save/RestoreV2_26)]]

htpauleta commented 6 years ago

I meet this problem too , do you solve this problem ???? thanks

heyuanw commented 5 years ago

do you solve this problem ???? thanks

navreeetkaur commented 5 years ago

See #415

https://github.com/tensorflow/nmt/issues/415#issuecomment-459897565 https://github.com/tensorflow/nmt/issues/415#issuecomment-483018887