Skip to content

Callbacks

base

Callback (ABC)

Callback objects define events on which it will run during the model training cycle.

clean(self)

Clean up

on_epoch_cancel(self)

Called after epoch is cancelled

on_epoch_end(self)

Called after each epoch

on_epoch_start(self)

Called Before each Epoch

on_fit_cancel(self)

Called after model.fit(...)is cancelled

on_fit_end(self)

Called after model.fit(...)

on_fit_start(self)

Called on each model.fit(...)

on_forward_cancel(self)

Called after model.forward(...) is cancelled

on_forward_end(self)

Called after model.forward(...)

on_forward_start(self)

Called before model.forward(...)

on_train_epoch_cancel(self)

Called after training epoch is cancelled

on_train_epoch_end(self, *args, **kwargs)

Called after end of training epoch

on_train_epoch_start(self)

Called on start of training epoch

on_train_step_cancel(self)

Called after training step is cancelled

on_train_step_end(self, *args, **kwargs)

Called after training step

on_train_step_start(self)

called before train_step

on_val_epoch_cancel(self)

called after validation epoch cancelled

on_val_epoch_end(self, *args, **kwargs)

called after validation epoch ends

on_val_epoch_start(self)

Called on start of validation epoch

on_val_step_cancel(self)

Called after validation step is cancelled

on_val_step_end(self, *args, **kwargs)

Called after validation step

on_val_step_start(self)

Called on validation step

with_event(self, event_type, func, exception, final_fn=<function dummy at 0x7f6a30285a60>)

Calls a function with event wrapped around. Inspired from FastAI. Ref: https://github.com/fastai/fastai/blob/6e44b354f4d12bdfa2c9530f38f851c54a05764d/fastai/learner.py#L162

comet

CometCallback (Callback)

Comet Logging callback. To use this callback pip install comet-ml.

Parameters:

Name Type Description Default
project_name str

Name of the Project

'awesome-project'
api_key Optional[str]

project API key

None
offline bool

log experiment offline

False

on_epoch_end(self)

Called after each epoch

on_fit_start(self)

Called on each model.fit(...)

on_train_epoch_start(self)

Called on start of training epoch

on_train_step_end(self, outputs=None, **_)

Called after training step

on_val_epoch_start(self)

Called on start of validation epoch

on_val_step_end(self, outputs=None, **_)

Called after validation step

gpu

EmissionTrackerCallback (Callback)

Tracks the carbon emissions produced by deep neural networks using CodeCarbon. To use this callback first install codecarbon using pip install codecarbon. For offline use, you must have to specify the country code.

Parameters:

Name Type Description Default
offline bool

whether to use internet connection or not. You will have to provide the country code country_iso_code for offline use.

False
**kwargs

passed directly to codecarbon class.

{}

on_fit_end(self)

Called after model.fit(...)

logger

CSVLogger (Callback)

Saves Model training metrics as CSV

Parameters:

Name Type Description Default
filename str

filename of the csv

'./experiment.csv'
path str

folder path location of the csv

'/home/docs/checkouts/readthedocs.org/user_builds/gradsflow/checkouts/v0.0.8'
verbose bool

Whether to show output

False

on_epoch_end(self)

Called after each epoch

ModelCheckpoint (Callback)

Saves Model checkpoint

Parameters:

Name Type Description Default
filename Optional[str]

name of checkpoint

None
path str

folder path location of the model checkpoint. Will create a folder if does not exist.

'/home/docs/checkouts/readthedocs.org/user_builds/gradsflow/checkouts/v0.0.8'
save_extra bool

whether to save extra details like tracker

False

on_epoch_end(self)

Called after each epoch

progress

ProgressCallback (Callback)

clean(self)

Clean up

on_epoch_end(self)

Called after each epoch

on_fit_end(self)

Called after model.fit(...)

on_fit_start(self)

Called on each model.fit(...)

on_train_epoch_end(self, *args, **kwargs)

Called after end of training epoch

on_train_epoch_start(self)

Called on start of training epoch

on_train_step_end(self, *args, **kwargs)

Called after training step

on_val_epoch_end(self, *args, **kwargs)

called after validation epoch ends

on_val_epoch_start(self)

Called on start of validation epoch

on_val_step_end(self, *args, **kwargs)

Called after validation step

raytune

TorchTuneCheckpointCallback (Callback)

on_epoch_end(self)

Called after each epoch

TorchTuneReport (Callback)

on_epoch_end(self)

Called after each epoch

runner

CallbackRunner (Callback)

clean(self, keep=None)

Remove all the callbacks except callback names provided in keep

on_epoch_end(self)

Called after each epoch

on_epoch_start(self)

Called Before each Epoch

on_fit_end(self)

Called after model.fit(...)

on_fit_start(self)

Called on each model.fit(...)

on_forward_end(self)

Called after model.forward(...)

on_forward_start(self)

Called before model.forward(...)

on_train_epoch_end(self, *args, **kwargs)

Called after end of training epoch

on_train_epoch_start(self)

Called on start of training epoch

on_train_step_end(self, *args, **kwargs)

Called after training step

on_train_step_start(self)

called before train_step

on_val_epoch_end(self, *args, **kwargs)

called after validation epoch ends

on_val_epoch_start(self)

Called on start of validation epoch

on_val_step_end(self, *args, **kwargs)

Called after validation step

on_val_step_start(self)

Called on validation step

training

TrainEvalCallback (Callback)

on_train_epoch_start(self)

Called on start of training epoch

on_train_step_end(self, *args, *, outputs=None, **kwargs)

Called after training step

on_train_step_start(self)

called before train_step

on_val_epoch_start(self)

Called on start of validation epoch

on_val_step_end(self, *args, *, outputs=None, **kwargs)

Called after validation step

wandb

WandbCallback (Callback)

Weights & Biases Logging callback. To use this callback pip install wandb.

Parameters:

Name Type Description Default
log_model bool

Whether to upload model artifact to Wandb

False
code_file Optional[str]

path of the code you want to upload as artifact to Wandb

None

on_epoch_end(self)

Called after each epoch

on_fit_start(self)

Called on each model.fit(...)

on_train_step_end(self, outputs=None, **_)

Called after training step


Last update: September 29, 2021