Fabrizio
Fabrizio

Reputation: 1074

Can't load checkpoint files in Tensorflow. (OSError: file signature not found)

I followed the basic tutorial of https://www.tensorflow.org/text/tutorials/text_generation#train_the_model, which leads to the generation of a basic RNN model. I followed the tutorial line by line (only changing the model parameters and dataset). I stopped the training three-quarters of the way through. The model has generated 14 checkpoints files and 14 checkpoint indices files.

I tried to load the checkpoint back using model.load_weights(os.path.join(checkpoint_dir, "checkpoint")) but I get the following error OSError: Unable to open file (file signature not found), which, by looking online I found out it refers to the fact that the file isn't encoded in the required encoding. But the main checkpoint file has no file extension nor encoding.

Am I doing something wrong?

Upvotes: 3

Views: 1136

Answers (1)

Jérémy
Jérémy

Reputation: 405

I had this same error after saving my weights manually using model.save_weights("weights"). The solution for me was to use:

model.load_weights("weights")

instead of:

model.load_weights("checkpoint")

So the error was in the fact that I was using the wrong name in the model.load_weights() function. I guess you had the same issue and that your "checkpoint" in your model.load_weights() had to be replaced by a different name.

Upvotes: 1

Related Questions