【问题标题】:Unsuccessful TensorSliceReader constructor: Failed to find any matching files for不成功的 TensorSliceReader 构造函数:未能找到任何匹配的文件
【发布时间】:2017-02-05 15:21:42
【问题描述】:

我尝试保存我的模型,然后尝试恢复它,但似乎 tensorflow 无法找到匹配文件的位置:-

保存模型输出的代码:-

import tensorflow as tf

save_file = 'model.ckpt'


weights = tf.Variable(tf.truncated_normal([2, 3]))
bias = tf.Variable(tf.truncated_normal([3]))


saver = tf.train.Saver()


with tf.Session() as sess:

    sess.run(tf.global_variables_initializer())
    saver.save(sess, save_file)

恢复模型的代码

import tensorflow as tf

save_file = 'model.ckpt'
tf.reset_default_graph()
weights = tf.Variable(tf.truncated_normal([2, 3]))
bias = tf.Variable(tf.truncated_normal([3]))
saver = tf.train.Saver()

with tf.Session() as sess:
    saver.restore(sess, 'model.ckpt')

我遇到以下错误:-

W tensorflow/core/framework/op_kernel.cc:975] 未找到:TensorSliceReader 构造函数不成功:找不到任何与 model.ckpt 匹配的文件

W tensorflow/core/framework/op_kernel.cc:975] 未找到:TensorSliceReader 构造函数不成功:找不到任何与 model.ckpt 匹配的文件

【问题讨论】:

  • 如果将'./model.ckpt' 传递给saver.restore() 是否有效?
  • 成功了!我猜张量流在加载时希望提供路径,但在保存时会保存到当前目录。
  • 是的……这是一个很奇怪的不一致,我担心。 This issue 正在跟踪问题,但它在 TensorFlow 1.0 中仍然处于打开状态。

标签: tensorflow


【解决方案1】:

saver.restore() 方法将失败,除非您将路径(而不仅仅是文件名)作为第二个参数传递。要解决此问题,如果您从包含检查点的目录运行脚本,可以调用 saver.restore(sess, './model.ckpt')

【讨论】:

    猜你喜欢
    • 2022-09-23
    • 2017-07-04
    • 2022-08-04
    • 2021-06-11
    • 2019-05-16
    • 2018-10-23
    • 1970-01-01
    • 2020-01-14
    • 1970-01-01
    相关资源
    最近更新 更多