Models: latest_checkpoint returns None even though checkpoint file exists.

Created on 3 Feb 2017  ·  12Comments  ·  Source: tensorflow/models

Please let us know which model this issue is about (specify the top-level directory)

Its im2txt model

checkpoint_path = tf.train.latest_checkpoint(checkpoint_path) is giving None even though the checkpoint file is present.

im using pretrained model from @psycharo from #466 .

the checkpoint file is inside im2txt/model/train/

awaiting model gardener

Most helpful comment

i passed the full path of checkpoint file instead of its directory and it worked.

All 12 comments

This is clearly not a TensorFlow core/Saver issue; I suspect something's wrong with the pretrained model. Also, check if a file named checkpoint is under your checkpoint dir (and if it, if it contains the right content).

i passed the full path of checkpoint file instead of its directory and it worked.

I had the very same problem with my code. Then I figured out that the checkpoint file was saved with .txt format. I renamed the 'checkpoint.txt' to 'checkpoint' and it worked!!

I used a pretrained model and I found that the path in the file "checkpoint" is not correct. changing the model path in this file should work

@landwash what changes did you make? thanks

I used a pretrained model provided by others, and I opend the file
"checkpoint" and found that the paths in it was wrong.
After changing the paths to mine, the code started to work.

Shaoning Zeng notifications@github.com 于2018年5月31日周四 下午4:28写道:

@landwash https://github.com/landwash what changes did you make? thanks


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/tensorflow/models/issues/974#issuecomment-393454189,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGf-bx7aLF19_-tnLV2WlQS7j1zsiQF9ks5t36mugaJpZM4L2lZo
.

@landwash OK, thank you.

Issue still persists in Tensorflow 1.8.0.

Ex:

# Below path consists of checkpoint files.

# Valid Path:
/tmp/fs/model/flow/runner/saves/dl/

# Invalid Path:
/tmp/fs//model/flow///runner/saves/dl//

Since unix resolves path containing redundant '/', Tensorflow internally should be able to resolve redundant '/', instead of throwing Error.

os.path.normpath(path)

resolves the issue noted by @kingspp

Meet the same problem following the tutorial. tf.train.latest_checkpoint always return None when the checkpoint files exist using tensorflow-1.2-cpu.

I have an issue where tf.train.latest_checkpoint works on one directory, but if I copy and rename that directory, it will return None for the copy, even though the directory contains the exact same files.

Edit: It turns out that Tensorflow stores the directory path inside your checkpoint directory for some reason. If you move or rename the directory. Tensorflow will pretend that it doesn't exist and return None.

Wanted to follow up with a comment, and a request for more explanation if someone is able to provide it.

I also experience this issue, but only when attempting to load a checkpoint, which was written using a tf.train.CheckpointManager, from a different location where the model was originally trained. The loading works fine when it is done on the machine where the model was originally trained, but fails when executed on a copy of the checkpoint files in another machine.

It isn't entirely clear why this process fails, but as @Storyyeller mentioned, it seems that somehow the path to the checkpoints is encoded somewhere (although it doesn't seem tto be in the checkpoint file itself.

Could someone, either from TensorFlow or otherwise, explain what's going on here, perhaps providing some information about the structure of the checkpoint files and how one might copy checkpoint files to another location and use them to restore the model?

Was this page helpful?
0 / 5 - 0 ratings