mapping_networks.callbacks.EarlyStopping

class mapping_networks.callbacks.EarlyStopping(monitor: str = 'val_loss', patience: int = 10, min_delta: float = 0.0, mode: str = 'min')

Stop training when a monitored metric stops improving.

Parameters:
  • monitor – Name of the metric to monitor (e.g. "val_loss").

  • patience – Number of epochs with no improvement before stopping.

  • min_delta – Minimum change to qualify as an improvement.

  • mode"min" to minimize the metric, "max" to maximize it.

Example:

trainer = MappingTrainer(
    ...,
    callbacks=[EarlyStopping(monitor="val_loss", patience=5)],
)
__init__(monitor: str = 'val_loss', patience: int = 10, min_delta: float = 0.0, mode: str = 'min') None

Methods

__init__([monitor, patience, min_delta, mode])

on_batch_end(trainer, batch_idx, loss_output)

Called after processing each batch with the loss output.

on_batch_start(trainer, batch_idx)

Called before processing each batch.

on_epoch_end(trainer, epoch, metrics)

Called at the end of each epoch with aggregated metrics.

on_epoch_start(trainer, epoch)

Called at the beginning of each epoch.

on_fit_end(trainer)

Called once at the end of fit().

on_fit_start(trainer)

Called once at the beginning of fit().

on_validation_end(trainer, metrics)

Called after the validation loop with validation metrics.

on_validation_start(trainer)

Called before the validation loop.