Callbacks#

Eztorch supports callbacks for trainer. It can takes callbacks from pytorch lightning or custom ones.

Custom callbacks#

class eztorch.callbacks.OnlineEvaluator(optimizer, classifier, input_name='h', precision=32)[source]#

Attaches a classifier to evaluate a specific representation from the model during training.

Parameters:
  • optimizer (

    Default:) – Config to instantiate an optimizer and optionally a scheduler.

  • classifier (

    Default:) – Config to instantiate a classifier.

  • input_name (

    Default:, optional) – Name of the representation to evaluate from the model outputs.
    Default: 'h'

  • precision (

    Default:, optional) – Precision for the classifier that must match the model, if \(16\) use automatic mixed precision.
    Default: 32

Example:

optimizer = {...} # config to build an optimizer
classifier = {...} # config to build a classifier
trainer = Trainer(callbacks=[OnlineEvaluator(optimizer, classifier)])