Skip to content

Core

The main module that has the definition of the Callback base class as well as all the Exceptions that a callback may raise.

Callback

Base class for all callbacks.

name: str property

Returns the name of the callback after removing the word callback and then convert it to snake (split words by underscores).

__getattr__(k)

This would allow us to use self.obj instead of self.learner.obj when we know obj is in learner because it will only be called when getattribute returns AttributeError.

camel2snake(name) staticmethod

Convert name of callback by inserting underscores between small and capital letters. For example, TestCallback becomes test_callback.

set_learner(learner)

Set the learner as an attribute so that callbacks can access learner's attributes without the need to pass learner for every single method in every callback.

Parameters:

Name Type Description Default
learner Learner

Learner that the callback will be called when some events happens.

required

CancelBackwardException

Bases: Exception

Skip the backward pass and move to after_backward.

CancelBatchException

Bases: Exception

Stop current batch and move to after_batch.

CancelEpochException

Bases: Exception

Stop current epoch and move to after_epoch.

CancelFitException

Bases: Exception

Stop training and move to after_fit.

CancelStepException

Bases: Exception

Skip stepping the optimizer and move to after_step.

CancelTrainException

Bases: Exception

Stop training current epoch and move to after_train.

CancelValidateException

Bases: Exception

Stop validation phase and move to after_validate.