xnn.common.train.callbacks#

Trainer callbacks: hooks into the training loop (checkpointing, early stopping, progress bar or your own).

Every rank runs the callbacks, and the epoch metrics they see are the all-reduced, dataset-level values, so decisions agree across ranks.

Functions

monitored_value(metrics, monitor)

The value of monitor in metrics, or None when its split was not evaluated.

Classes

Callback()

Base class of the trainer callbacks; override any of the hooks.

EarlyStopping([monitor, mode, patience, ...])

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

ModelCheckpoint([monitor, mode, dirpath, ...])

Saves the best model by a monitored value, the last model, and optional periodic snapshots.

ProgressBar()

A tqdm bar over each epoch's batches with the running training loss (rank 0 only).