A Keras callback is an object passed to fit() and invoked at defined points during training. It observes model state and performance, then performs actions such as stopping training, saving weights, changing learning rates, or logging metrics. section 7.3.2
callback_model_checkpoint() callback_early_stopping() callback_learning_rate_scheduler() callback_reduce_lr_on_plateau() callback_csv_logger()
Built-in callbacks cover checkpointing, early stopping, learning-rate scheduling, plateau reduction, and CSV logging. section 7.3.2
Stop early and keep the best model
Create a callback list with callback_early_stopping(monitor = "val_accuracy", patience = 1) and callback_model_checkpoint(filepath = "checkpoint_path.keras", monitor = "val_loss", save_best_only = TRUE). Pass it to fit() through callbacks = callbacks_list. EarlyStopping interrupts training when the monitored metric stops improving; ModelCheckpoint preserves the best epoch's model, which can later be restored with load_model(). section 7.3.3
When built-in behavior is insufficient, subclass Callback and implement lifecycle methods such as on_train_begin(), on_batch_end(), and on_epoch_end(). These methods receive logs containing metrics and related training information. A custom callback can collect per-batch losses and plot them after each epoch, or generate and display images for visual inspection. section 7.3.4 section 17.2.6


















