TrainingCallback

class TrainingCallback[source]

Bases: object

An interface for training callbacks.

Initialize the callback.

Attributes Summary

loss

The loss, accessed via the training loop.

model

The model, accessed via the training loop.

optimizer

The optimizer, accessed via the training loop.

result_tracker

The result tracker, accessed via the training loop.

training_loop

The training loop.

Methods Summary

on_batch(epoch, batch, batch_loss, **kwargs)

Call for training batches.

post_batch(epoch, batch, **kwargs)

Call for training batches.

post_epoch(epoch, epoch_loss, **kwargs)

Call after epoch.

post_train(losses, **kwargs)

Call after training.

pre_batch(**kwargs)

Call before training batch.

pre_step(**kwargs)

Call before the optimizer's step.

register_training_loop(training_loop)

Register the training loop.

Attributes Documentation

loss

The loss, accessed via the training loop.

model

The model, accessed via the training loop.

optimizer

The optimizer, accessed via the training loop.

result_tracker

The result tracker, accessed via the training loop.

training_loop

The training loop.

Methods Documentation

on_batch(epoch: int, batch, batch_loss: float, **kwargs: Any) None[source]

Call for training batches.

Parameters:
Return type:

None

post_batch(epoch: int, batch, **kwargs: Any) None[source]

Call for training batches.

Parameters:
Return type:

None

post_epoch(epoch: int, epoch_loss: float, **kwargs: Any) None[source]

Call after epoch.

Parameters:
Return type:

None

post_train(losses: list[float], **kwargs: Any) None[source]

Call after training.

Parameters:
Return type:

None

pre_batch(**kwargs: Any) None[source]

Call before training batch.

Parameters:

kwargs (Any)

Return type:

None

pre_step(**kwargs: Any) None[source]

Call before the optimizer’s step.

Parameters:

kwargs (Any)

Return type:

None

register_training_loop(training_loop: TrainingLoop) None[source]

Register the training loop.

Parameters:

training_loop (TrainingLoop)

Return type:

None