biapy.utils.callbacks

This module provides an implementation of an Early Stopping mechanism, a common regularization technique used in machine learning to prevent overfitting during model training.

The EarlyStopping class monitors a validation metric (typically validation loss) and stops the training process if the metric does not improve for a specified number of epochs (patience).

Classes:

  • EarlyStopping: Implements the early stopping logic.

This implementation is adapted from a widely used PyTorch early stopping script.

class biapy.utils.callbacks.EarlyStopping(patience: int = 7, delta: float = 0, trace_func: ~typing.Callable = <built-in function print>)[source]

Bases: object

Early stops the training if validation loss doesn’t improve after a given patience.

This class monitors a specified metric (e.g., validation loss) during training. If the metric does not show improvement (beyond a delta threshold) for a number of epochs defined by patience, the early_stop flag is set to True, signaling that training should be halted.

Copied from: https://github.com/Bjarten/early-stopping-pytorch/blob/master/pytorchtools.py