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 (
DictConfig
) – Config to instantiate an optimizer and optionally a scheduler.classifier (
DictConfig
) – Config to instantiate a classifier.input_name (
str
, optional) – Name of the representation to evaluate from the model outputs.Default:'h'
precision (
int
, 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)])