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_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.

Return type

Loss

model

The model, accessed via the training loop.

Return type

Model

optimizer

The optimizer, accessed via the training loop.

Return type

Optimizer

result_tracker

The result tracker, accessed via the training loop.

Return type

ResultTracker

training_loop

The training loop.

Methods Documentation

on_batch(epoch, batch, batch_loss, **kwargs)[source]

Call for training batches.

Return type

None

Parameters
  • epoch (int) –

  • batch_loss (float) –

  • kwargs (Any) –

post_batch(epoch, batch, **kwargs)[source]

Call for training batches.

Return type

None

Parameters
  • epoch (int) –

  • kwargs (Any) –

post_epoch(epoch, epoch_loss, **kwargs)[source]

Call after epoch.

Return type

None

Parameters
  • epoch (int) –

  • epoch_loss (float) –

  • kwargs (Any) –

post_train(losses, **kwargs)[source]

Call after training.

Return type

None

Parameters
pre_step(**kwargs)[source]

Call before the optimizer’s step.

Return type

None

Parameters

kwargs (Any) –

register_training_loop(training_loop)[source]

Register the training loop.

Return type

None