在检查点文件inception_v3.ckpt中找不到张量名称“seq_embedding / map”

时间:2017-05-25 13:26:09

标签: python tensorflow

我使用了here描述的show_and_tell模型和使用inference.py进行推理的inception_v3,但我收到张量未找到错误。我不知道为什么会出现这种错误。错误堆栈跟踪如下:

INFO:tensorflow:Building model.
INFO:tensorflow:Initializing vocabulary from file: /media/bhavya/New_Volume/ICT/UGRP/Implementation/im2txt/im2txt_copy/word_counts.txt
INFO:tensorflow:Created vocabulary with 11508 words
INFO:tensorflow:Running caption generation on 1 files matching /media/bhavya/New_Volume/ICT/UGRP/Implementation/im2txt/im2txt_copy/cliff_man.png
2017-05-25 18:36:49.509778: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-25 18:36:49.509813: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-25 18:36:49.509824: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-05-25 18:36:49.509843: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-25 18:36:49.509862: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
2017-05-25 18:36:49.829698: E tensorflow/stream_executor/cuda/cuda_driver.cc:405] failed call to cuInit: CUDA_ERROR_NO_DEVICE
2017-05-25 18:36:49.829786: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:158] retrieving CUDA diagnostic information for host: gandalf
2017-05-25 18:36:49.829803: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:165] hostname: gandalf
2017-05-25 18:36:49.829854: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:189] libcuda reported version is: 381.9.0
2017-05-25 18:36:49.829916: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:369] driver version file contents: """NVRM version: NVIDIA UNIX x86_64 Kernel Module  381.09  Thu Mar 30 20:07:40 PDT 2017
GCC version:  gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 
"""
2017-05-25 18:36:49.829950: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:193] kernel reported version is: 381.9.0
2017-05-25 18:36:49.829972: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:300] kernel version seems to match DSO: 381.9.0
INFO:tensorflow:Loading model from checkpoint: /media/bhavya/New_Volume/ICT/UGRP/Implementation/im2txt/im2txt_copy/inception_v3.ckpt
INFO:tensorflow:Restoring parameters from /media/bhavya/New_Volume/ICT/UGRP/Implementation/im2txt/im2txt_copy/inception_v3.ckpt
Traceback (most recent call last):
  File "/media/bhavya/New_Volume/ICT/UGRP/Implementation/im2txt/im2txt_copy/bazel-bin/im2txt/run_inference.runfiles/im2txt/im2txt/run_inference.py", line 85, in <module>
    tf.app.run()
  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/bhavya/New_Volume/ICT/UGRP/Implementation/im2txt/im2txt_copy/bazel-bin/im2txt/run_inference.runfiles/im2txt/im2txt/run_inference.py", line 65, in main
    restore_fn(sess)
  File "/media/bhavya/New_Volume/ICT/UGRP/Implementation/im2txt/im2txt_copy/bazel-bin/im2txt/run_inference.runfiles/im2txt/im2txt/inference_utils/inference_wrapper_base.py", line 96, in _restore_fn
    saver.restore(sess, checkpoint_path)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1457, in restore
    {self.saver_def.filename_tensor_name: save_path})
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 778, in run
    run_metadata_ptr)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 982, in _run
    feed_dict_string, options, run_metadata)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1032, in _do_run
    target_list, options, run_metadata)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1052, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.NotFoundError: Tensor name "seq_embedding/map" not found in checkpoint files /media/bhavya/New_Volume/ICT/UGRP/Implementation/im2txt/im2txt_copy/inception_v3.ckpt
     [[Node: save/RestoreV2_382 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save/Const_0, save/RestoreV2_382/tensor_names, save/RestoreV2_382/shape_and_slices)]]

Caused by op u'save/RestoreV2_382', defined at:
  File "/media/bhavya/New_Volume/ICT/UGRP/Implementation/im2txt/im2txt_copy/bazel-bin/im2txt/run_inference.runfiles/im2txt/im2txt/run_inference.py", line 85, in <module>
    tf.app.run()
  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/bhavya/New_Volume/ICT/UGRP/Implementation/im2txt/im2txt_copy/bazel-bin/im2txt/run_inference.runfiles/im2txt/im2txt/run_inference.py", line 51, in main
    FLAGS.checkpoint_path)
  File "/media/bhavya/New_Volume/ICT/UGRP/Implementation/im2txt/im2txt_copy/bazel-bin/im2txt/run_inference.runfiles/im2txt/im2txt/inference_utils/inference_wrapper_base.py", line 116, in build_graph_from_config
    saver = tf.train.Saver()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1056, in __init__
    self.build()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1086, in build
    restore_sequentially=self._restore_sequentially)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 691, in build
    restore_sequentially, reshape)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 407, in _AddRestoreOps
    tensors = self.restore_op(filename_tensor, saveable, preferred_shard)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 247, in restore_op
    [spec.tensor.dtype])[0])
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_io_ops.py", line 669, in restore_v2
    dtypes=dtypes, name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 768, in apply_op
    op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2336, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1228, in __init__
    self._traceback = _extract_stack()

NotFoundError (see above for traceback): Tensor name "seq_embedding/map" not found in checkpoint files /media/bhavya/New_Volume/ICT/UGRP/Implementation/im2txt/im2txt_copy/inception_v3.ckpt
     [[Node: save/RestoreV2_382 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save/Const_0, save/RestoreV2_382/tensor_names, save/RestoreV2_382/shape_and_slices)]]

2 个答案:

答案 0 :(得分:1)

您错误地使用Inception V3模型的检查点来运行Show and Tell模型的推断 由于网络中LSTM部分的权重在初始V3检查点文件中不存在(见下图),因此运行起来很困难。
要成功运行推理,请train the im2txt model from scratchuse a pretrained network like this。 我希望它得到澄清。

答案 1 :(得分:0)

当您的检查点文件不包含张量时,通常会发生这种错误,您可以自行评论关于丢失张量的存储库。因此,我建议您检查缺少张量的检查点文件。