Tensorflow 在TFSlim中加载保存的检查点时出错

Tensorflow 在TFSlim中加载保存的检查点时出错,tensorflow,tf-slim,Tensorflow,Tf Slim,使用tensorflow的v0.12.1版本,我试图使用在上提供的检查点对预先训练好的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

使用tensorflow的v0.12.1版本,我试图使用在上提供的检查点对预先训练好的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文件有两个版本..v1和v2。这可能是个问题吗?如何解决此问题?

模型定义生成的变量与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  !