finetuner.tuner.callback.base module

class finetuner.tuner.callback.base.BaseCallback[source]

Bases: abc.ABC

The base callback class.

This class defines the different callback methods that can be overriden, however there is no method that the subclass would be required to override.

The callback instance should be passed to the tuner in the fit method, in a list that contains all callbacks and is passed to the callbacks argument.

All methods receive the tuner instance to which the callback has been added as an argument. The most relevant property of the tuner instance is the state, which is an instance of TunerState and contains relevant training statistics, such as current loss, epoch number, number of batches and batch number.

on_fit_begin(tuner)[source]

Called at the start of the fit method call, after all setup has been done, but before the training has started.

on_epoch_begin(tuner)[source]

Called at the start of an epoch.

on_train_epoch_begin(tuner)[source]

Called at the begining of training part of the epoch.

on_train_batch_begin(tuner)[source]

Called at the start of a training batch, after the data for the batch has already been loaded.

on_train_batch_end(tuner)[source]

Called at the end of a training batch, after the backward pass.

on_train_epoch_end(tuner)[source]

Called at the end of training part of the epoch.

on_val_begin(tuner)[source]

Called at the start of the evaluation.

on_val_batch_begin(tuner)[source]

Called at the start of a evaluation batch.

on_val_batch_end(tuner)[source]

Called at the end of an evaluation batch.

on_val_end(tuner)[source]

Called at the end of the evaluation.

on_epoch_end(tuner)[source]

Called at the end of an epoch, after both training and validation (or just training if no validaton is provided).

on_fit_end(tuner)[source]

Called at the end of the fit method call, after finishing all the epochs.

on_keyboard_interrupt(tuner)[source]

Called when the tuner is interrupted by the user

on_exception(tuner, exception)[source]

Called when the tuner encounters an exception during execution.