gpt4 book ai didi

tensorflow - 不成功的 TensorSliceReader 构造函数 : Failed to find any matching files for

转载 作者:行者123 更新时间:2023-12-04 01:54:34 26 4
gpt4 key购买 nike

我尝试保存我的模型,然后尝试恢复它,但似乎 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] Not found: Unsuccessful TensorSliceReader constructor: Failed to find any matching files for model.ckpt

W tensorflow/core/framework/op_kernel.cc:975] Not found: Unsuccessful TensorSliceReader constructor: Failed to find any matching files for model.ckpt

最佳答案

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

关于tensorflow - 不成功的 TensorSliceReader 构造函数 : Failed to find any matching files for,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42053709/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com