xnn.common.train.callbacks.EarlyStopping#

class xnn.common.train.callbacks.EarlyStopping(monitor=None, mode=None, patience=10, min_delta=0.0, stopping_threshold=None, check_finite=True)[source]#

Bases: Callback

Stops training when a monitored value stops improving, reaches a threshold, or is not finite.

Parameters:
  • monitor (str or None, optional) – The value to monitor; defaults to the trainer’s.

  • mode (str or None, optional) – "min" or "max"; defaults to the trainer’s.

  • patience (int, optional) – Evaluations without improvement before stopping; 0 disables this rule. Defaults to 10.

  • min_delta (float, optional) – The least change that counts as an improvement. Defaults to 0.0.

  • stopping_threshold (float or None, optional) – Stop as soon as the value is better than this. Defaults to None.

  • check_finite (bool, optional) – Stop when the value is NaN or infinite. Defaults to True.

Variables:
  • stopped_epoch (int or None) – The epoch training stopped after, None if it ran to the end.

  • reason (str or None) – Why it stopped.

on_fit_start(trainer)[source]#

Fill the defaults from the trainer.

Return type:

None

on_epoch_end(trainer, epoch, metrics)[source]#

Count evaluations without improvement and stop when a rule fires.

Parameters:
Return type:

None