繁体   English   中英

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

[英]Tensor name “seq_embedding/map” not found in checkpoint files inception_v3.ckpt

我正在使用这里描述的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)]]

您错误地使用了Inception V3模型的检查点为Show and Tell模型运行推理。
由于Inception V3检查点文件中没有网络的LSTM部分的权重(请参见下图),因此您很难运行它。
为使您成功地进行推理,请从头开始训练im2txt模型使用像这样的预训练网络 我希望它得到澄清。

当您的检查点文件不包含张量时,通常会发生此类错误,您可以在存储库自身中对缺少的张量进行注释。 因此,我建议您检查检查点文件中是否缺少张量。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM