Callback#
- class braintools.trainer.Callback#
Base class for callbacks.
Callbacks allow you to hook into various stages of the training process. Override the methods you need in your custom callback subclass.
Examples
>>> class MyCallback(Callback): ... def on_train_epoch_end(self, trainer, module): ... print(f"Epoch {module.current_epoch} finished!") ... >>> trainer = Trainer(callbacks=[MyCallback()])
- on_before_backward(trainer, module, loss)[source]#
Called before backward pass (gradient computation).
- on_predict_batch_end(trainer, module, outputs, batch, batch_idx)[source]#
Called at the end of each predict batch.
- on_predict_batch_start(trainer, module, batch, batch_idx)[source]#
Called at the beginning of each predict batch.
- on_test_batch_end(trainer, module, outputs, batch, batch_idx)[source]#
Called at the end of each test batch.
- on_test_batch_start(trainer, module, batch, batch_idx)[source]#
Called at the beginning of each test batch.
- on_train_batch_end(trainer, module, outputs, batch, batch_idx)[source]#
Called at the end of each training batch.
- on_train_batch_start(trainer, module, batch, batch_idx)[source]#
Called at the beginning of each training batch.
- on_validation_batch_end(trainer, module, outputs, batch, batch_idx)[source]#
Called at the end of each validation batch.
- on_validation_batch_start(trainer, module, batch, batch_idx)[source]#
Called at the beginning of each validation batch.