Schumi08
Schumi08

Reputation: 101

Unsuccessful TensorSliceReader constructor: Failed to find any matching files for

I tried saving my model out and then tried to restore it, but seems tensorflow is unable to find the location of the matching files :-

Code to save model output :-

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)

Code to restore model

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

I am getting below errors :-

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

Upvotes: 8

Views: 14868

Answers (1)

mrry
mrry

Reputation: 126164

The saver.restore() method will fail unless you pass a path—and not just a filename—as the second argument. To work around this problem, you can call saver.restore(sess, './model.ckpt') if you are running the script from the directory containing the checkpoint.

Upvotes: 4

Related Questions