Is there a way to reload the weights from a certain epoch or the best weights from the model checkpoint files created by ModelCheckpoint once the training is over?
I have trained that trained for 10 epochs and created a checkpoint that only saved weights after each epoch. The final epoch's val_categorical_accuracy is a bit lower than epoch no. 5. I know I should have set save_best_only=True but I missed that.
- So now, is there a way to get the weights from the best epoch or the epoch number 5?
- Also, does
ModelCheckpointoverwrites weights after each epoch in the checkpoint file?
What are my options here? Thanks for your help in advance.
Below is my implementation:
checkpoint_path = 'saved_model/cp.ckpt'
checkpoint_dir = os.path.dirname(checkpoint_path)
print(checkpoint_dir)
lstm_model.fit(X_train_seq_pad, y_train_cat,
epochs=100,
validation_data=(X_val_seq_pad, y_val_cat),
callbacks=[callbacks.EarlyStopping(monitor='val_loss', patience=3),
callbacks.ModelCheckpoint(filepath=checkpoint_path,
save_weights_only=True,
verbose=1)])