mattertune.callbacks.early_stopping

Classes

EarlyStoppingConfig(*[, monitor, min_delta, ...])

class mattertune.callbacks.early_stopping.EarlyStoppingConfig(*, monitor='val/total_loss', min_delta=0.0, patience=3, verbose=False, mode='min', strict=True, check_finite=True, stopping_threshold=None, divergence_threshold=None, check_on_train_epoch_end=None, log_rank_zero_only=False)[source]
Parameters:
  • monitor (str)

  • min_delta (float)

  • patience (int)

  • verbose (bool)

  • mode (Literal['min', 'max'])

  • strict (bool)

  • check_finite (bool)

  • stopping_threshold (float | None)

  • divergence_threshold (float | None)

  • check_on_train_epoch_end (bool | None)

  • log_rank_zero_only (bool)

monitor: str

Quantity to be monitored.

min_delta: float

Minimum change in monitored quantity to qualify as an improvement. Changes of less than or equal to min_delta will count as no improvement. Default: 0.0.

patience: int

3.

Type:

Number of validation checks with no improvement after which training will be stopped. Default

verbose: bool

False.

Type:

Whether to print messages when improvement is found or early stopping is triggered. Default

mode: Literal['min', 'max']

One of ‘min’ or ‘max’. In ‘min’ mode, training stops when monitored quantity stops decreasing; in ‘max’ mode it stops when the quantity stops increasing. Default: 'min'.

strict: bool

True.

Type:

Whether to raise an error if monitored metric is not found in validation metrics. Default

check_finite: bool

True.

Type:

Whether to stop training when the monitor becomes NaN or infinite. Default

stopping_threshold: float | None

None.

Type:

Stop training immediately once the monitored quantity reaches this threshold. Default

divergence_threshold: float | None

None.

Type:

Stop training as soon as the monitored quantity becomes worse than this threshold. Default

check_on_train_epoch_end: bool | None

Whether to run early stopping at the end of training epoch. If False, check runs at validation end. Default: None.

log_rank_zero_only: bool

False.

Type:

Whether to log the status of early stopping only for rank 0 process. Default

create_callback()[source]