2017-01-13 52 views
2

使用tensorflow的v0.12.1版本,我試圖使用在http://download.tensorflow.org/models/vgg_16_2016_08_28.tar.gz處提供的檢查點來微調預先訓練的vgg16模型。在TFSlim中加載保存的檢查點時出錯

,我發現了以下錯誤:

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

模型定義生成的變量與存儲在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 !