2

Using v0.12.1 version of tensorflow, I'm trying to finetune a pre-trained vgg16 model using checkpoint available at http://download.tensorflow.org/models/vgg_16_2016_08_28.tar.gz.

I'm getting the following errors:

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

Need help. I posted a similar question a few months ago - I'm past that but couldn't find a good solution. I use the model definition given in

tensorflow.contrib.slim.nets

I understand that there are two versions of ckpt files..v1 and v2. could this be an issue? How to solve this please?

HuckleberryFinn
  • 1,489
  • 2
  • 16
  • 26

1 Answers1

0

There was a mismatch between the variables generated by the model definition and the variables stored in the ckpt file. Specifically, this was the first variable. Solved it by doing this:

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  !
HuckleberryFinn
  • 1,489
  • 2
  • 16
  • 26