【问题标题】:Error loading saved checkpoint in TFSlim在 TFSlim 中加载保存的检查点时出错
【发布时间】:2017-01-15 11:15:52
【问题描述】:

使用 tensorflow 的 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 文件有两个版本..v1 和 v2。这可能是个问题吗?请问这个怎么解决?

【问题讨论】:

    标签: tensorflow tf-slim


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2017-03-14
      • 1970-01-01
      • 2018-08-13
      • 1970-01-01
      • 1970-01-01
      • 2019-03-16
      • 1970-01-01
      • 2021-09-09
      • 2017-05-07
      相关资源
      最近更新 更多