mapping_networks.callbacks.Callback

class mapping_networks.callbacks.Callback

Base class for training lifecycle callbacks.

All hooks are no-ops by default — subclass and override the ones you need. Callbacks receive the trainer instance so they can inspect or modify state (e.g. set trainer.should_stop = True for early termination).

Hook execution order within each event:

  1. on_fit_start

  2. For each epoch: a. on_epoch_start b. For each batch: on_batch_starton_batch_end c. on_validation_starton_validation_end d. on_epoch_end

  3. on_fit_end

__init__()

Methods

__init__()

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.