I am using tf.train.get_checkpoint_state to check whether I have a valid checkpoint file to restore a Tensorflow saved model.
ckpt = tf.train.get_checkpoint_state(os.path.dirname('fi/saves'))
if ckpt and ckpt.model_checkpoint_path:
saver.restore(sess, ckpt.model_checkpoint_path)
My issue is that ckpt is always None. Here is the content of my saves directory:
Please note that a call to restore directly works well.
EDIT:
I have tried using the latest_filename argument like this:
tf.train.get_checkpoint_state(os.path.dirname(checkpoint_dir), latest_filename='variables.ckpt.index')
I am still getting None.
I figured out that tf.train.get_checkpoint_state looks for a checkpoint file.
I did not have this file because I was doing this when saving:
saver.save(sess, variables_file_path, write_meta_graph=False, write_state=False)
Instead of:
saver.save(sess, variables_file_path, write_meta_graph=False, write_state=True) # write state is true by default.
This now works !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With