Search code examples
pythontensorflowrestore

Load / restore models into tensorflow at specific iteration or checkpoint


I have a model , which I am saving at every 10 iterations . So , i am having following files in my saved directory .

checkpoint  model-50.data-00000-of-00001  model-50.index  model-50.meta
model-60.data-00000-of-00001  model-60.index  model-60.meta

and so on up to 100 . I have to load only the model-50. Because I have got NaN values after 70 iterations. By deafault, when i am restoring the saver will look for the final checkpoint. So, how could I specifically load the model-50. please help, otherwise, i have to run the model gain from scratch, which is time consuming.


Solution

  • Since you are using tf.train.Saver's function restore(), you can make use of the last_checkpoints functions to get a list of all available checkpoints. You will see both model-50 and model-60 in this list.

    Pick the correct model, and pass it directly to restore() like this,

    saver.restore(sess, ckpt_path)