2017-05-25 22 views
0

我使用的show_and_tell模型描述here和inception_v3使用inference.py推論,但我得到一個張未發現錯誤。我不知道爲什麼會發生此錯誤。錯誤堆棧跟蹤如下:張量名稱「seq_embedding /圖」沒有檢查點文件中找到inception_v3.ckpt

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)]] 

回答

1

您錯誤地使用Inception V3模型的檢查點來運行Show and Tell模型的推理。
因爲網絡的LSTM部分的權重在Inception V3檢查點文件中不存在(請參見下圖),所以難以運行它。
要讓您成功運行推理,請輸入train the im2txt model from scratchuse a pretrained network like this。 我希望澄清。

0

這種錯誤通常發生的檢查點文件不包含張量,你可以在倉庫就缺少張其自評。所以我建議你檢查你的檢查點文件中是否有缺失的張量。

相關問題