ryuzakinho
ryuzakinho

Reputation: 1919

tf.train.get_checkpoint_state always None

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.

Upvotes: 6

Views: 6491

Answers (1)

ryuzakinho
ryuzakinho

Reputation: 1919

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 !

Upvotes: 4

Related Questions