callback_handler

class aitoolbox.torchtrain.train_loop.components.callback_handler.BasicCallbacksHandler(train_loop_obj)[source]

Bases: object

Callback handler used for the callback orchestration inside the TrainLoop

Common use of this handler is to call different methods inside the TrainLoop at different stages of the training process. Thus execute desired callbacks’ functionality at the desired point of the training process.

Parameters

train_loop_obj (aitoolbox.torchtrain.train_loop.TrainLoop) – reference to the encapsulating TrainLoop

register_callbacks(callbacks, cache_callbacks=False)[source]

Register TrainLoop object reference inside the listed callbacks when the TrainLoop is created

Normally, this is called from inside of the train loop by the TrainLoop itself. Basically train loop “registers” itself.

Parameters
  • callbacks (list or None) – list of callbacks

  • cache_callbacks (bool) – should provided callbacks be cached and not yet registered. First subsequent time this method is called without cache_callbacks enabled all the previously cached callbacks are added and also registered with the current list of callbacks.

Returns

None

execute_epoch_begin()[source]
execute_epoch_end()[source]
execute_train_begin()[source]
execute_train_end()[source]
execute_batch_begin()[source]
execute_batch_end()[source]
execute_gradient_update(optimizer_idx=0)[source]
execute_optimizer_step()[source]
execute_multiprocess_start()[source]
mp_filter_callbacks()[source]
enforce_callbacks_quality(callbacks)[source]
static print_callback_info(callback_list)[source]
print_registered_callback_names()[source]
__add__(other)[source]
Parameters

other (list) – callbacks list

Returns

Return type

BasicCallbacksHandler

__iadd__(other)[source]
Parameters

other (list) – callbacks list

Returns

Return type

BasicCallbacksHandler

__contains__(item)[source]
Parameters

item

Returns

Return type

bool

class aitoolbox.torchtrain.train_loop.components.callback_handler.CallbacksHandler(train_loop_obj)[source]

Bases: aitoolbox.torchtrain.train_loop.components.callback_handler.BasicCallbacksHandler

Callback handler used for the callback orchestration inside the TrainLoop

Compared to BasicCallbacksHandler, this handler will at certain TrainLoop stage only execute those callbacks which have implemented the functionality intended to be executed at this particular stage. Thus, CallbacksHandler doesn’t unnecessarily execute callbacks at stages they are not implemented at.

Common use of this handler is to call different methods inside the TrainLoop at different stages of the training process. Thus execute desired callbacks’ functionality at the desired point of the training process.

Parameters

train_loop_obj (aitoolbox.torchtrain.train_loop.TrainLoop) – reference to the encapsulating TrainLoop

register_callbacks(callbacks, cache_callbacks=False)[source]

Register TrainLoop object reference inside the listed callbacks when the TrainLoop is created

Normally, this is called from inside of the train loop by the TrainLoop itself. Basically train loop “registers” itself.

Parameters
  • callbacks (list or None) – list of callbacks

  • cache_callbacks (bool) – should provided callbacks be cached and not yet registered. First subsequent time this method is called without cache_callbacks enabled all the previously cached callbacks are added and also registered with the current list of callbacks.

Returns

None

execute_epoch_begin()[source]
execute_epoch_end()[source]
execute_train_begin()[source]
execute_train_end()[source]
execute_batch_begin()[source]
execute_batch_end()[source]
execute_gradient_update(optimizer_idx=0)[source]
execute_optimizer_step()[source]
execute_multiprocess_start()[source]
split_on_execution_position(callbacks, register_train_loop=False)[source]
mp_filter_callbacks()[source]