I m training a sequence model in Keras using the tensorflow backend. I've also included some callbacks to save checkpoints and revert to best weights if the model starts to overfit (which it will).
My question - when fitting using this set of callbacks, does the final checkpoint contain the version of the model with the best weight? I know that the weights in classif_model
will revert but I'm not sure if that also applies to the final saved state.
from keras import callbacks as kc
classif_model = my_model(input_shape)
# Set up callbacks
checkpointer = kc.ModelCheckpoint(filepath='results/'+name+'.h5', verbose=0)
earlystopping = kc.EarlyStopping(monitor='val_loss', patience=patience, restore_best_weights = True)
callbacks = [checkpointer, earlystopping]
# train the model
hist = classif_model.fit(x = X_tr, y = Y_tr, epochs = epochs, batch_size = batch_size,
callbacks = callbacks, validation_data = (X_val, Y_val),
verbose = 0)