ModelCheckpoint is a Keras callback that saves model states during training. Configure it to monitor a metric and, with save_best_only = TRUE, retain only the state from the best-performing epoch. section 7.3.2 section 7.3.3
Save the best validation model
callbacks_list <- list( callback_early_stopping( monitor = "val_accuracy", patience = 1 ), callback_model_checkpoint( filepath = "checkpoint_path.keras", monitor = "val_loss", save_best_only = TRUE ) ) model |> fit( train_images, train_labels, epochs = 10, callbacks = callbacks_list, validation_data = list(val_images, val_labels) ) model <- load_model("checkpoint_path.keras") Here, training can stop when validation accuracy stops improving, while the checkpoint preserves the model with the lowest validation loss. section 7.3.3
Use ModelCheckpoint to:
- Save the model after training epochs during a standard fit() run. section 7.3.2 section 8.2.4
- Monitor validation loss and overwrite the saved file only when the current value improves. section 8.2.4
- Reload the saved state later for evaluation instead of retraining after overfitting begins. section 8.2.4
callback_model_checkpoint() callback_early_stopping() callback_learning_rate_scheduler() callback_reduce_lr_on_plateau() callback_csv_logger()
Browse related Keras callbacks for early stopping, learning-rate adjustment, plateau handling, and metric logging. section 7.3.2

