使用张量流的v0.12.1版本,我试图使用http://download.tensorflow.org/models/vgg_16_2016_08_28.tar.gz处的检查点来微调预训练的vgg16模型。
我收到以下错误:
W tensorflow/core/framework/op_kernel.cc:975] Not found: Tensor name "Variable" not found in checkpoint files /home/code/tensorflow/vgg-tensorflow/vgg_16.ckpt
[[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_INT32], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save/Const_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]
W tensorflow/core/framework/op_kernel.cc:975] Not found: Tensor name "Variable" not found in checkpoint files /home/code/tensorflow/vgg-tensorflow/vgg_16.ckpt
[[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_INT32], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save/Const_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]
需要帮助。几个月前我发布了一个类似的问题 - 我已经过去了,但找不到好的解决方案。我使用
中给出的模型定义tensorflow.contrib.slim.nets
我知道有两个版本的ckpt files..v1和v2。这可能是个问题吗?如何解决这个问题?
答案 0 :(得分:0)
模型定义生成的变量与存储在ckpt文件中的变量之间存在不匹配。具体来说,这是第一个变量。解决这个问题:
variables_to_restore = slim.get_variables_to_restore(exclude=['vgg_16/fc6','vgg_16/fc7','vgg_16/fc8'])
print [v.name for v in variables_to_restore]
restorer = tf.train.Saver(variables_to_restore[1:]) # remove first entry !