We may need to load an existing tensorflow model using tf.train.latest_checkpoint(). However, you may get this error: tensorflow.python.framework.errors_impl.NotFoundError: FindFirstFile failed for. In this tutorial, we will introduce how to fix this error to load tensorflow model.
For example, look at code below:
model = 'checkpoints/yelp13/model-1604637275/' checkpoint_file = tf.train.latest_checkpoint(model)
Run this code, you will get an error:
Why does this FindFirstFile failed error occur?
Because tf.train.latest_checkpoint() can not find the model file, tf.train.latest_checkpoint() will load model file by checkpoint file.
How to fix tf.train.latest_checkpoint() FindFirstFile failed error?
Open your model checkpoint file and modify the path of model file.
For example, as to us we will modify it to
model_checkpoint_path: "E:\\workspace-nlp\\Sentiment\\checkpoints\\yelp13\\model\\model-5725" all_model_checkpoint_paths: "E:\\workspace-nlp\\Sentiment\\checkpoints\\yelp13\\model\\model-5725"
Here E:\\workspace-nlp\\Sentiment\\checkpoints\\yelp13\\model\\model-5725 is the absolute path of our model.
Then we load model successfully.