finetuner.tuner.callback.best_model_checkpoint module#
- class finetuner.tuner.callback.best_model_checkpoint.BestModelCheckpoint(save_dir, monitor='val_loss', mode='auto', verbose=False)[source]#
Bases:
finetuner.tuner.callback.base.BaseCallback
Callback to save the best model across all epochs
An option this callback provides include: - Definition of ‘best’; which quantity to monitor and whether it should be
maximized or minimized.
- Parameters
save_dir (
str
) – string, path to save the model file.monitor (
str
) – if monitor=’train_loss’ best model saved will be according to the training loss, while if monitor=’val_loss’ best model saved will be according to the validation loss. If monitor is set to an evaluation metric, best model saved will be according to this metric.mode (
str
) – one of {‘auto’, ‘min’, ‘max’}. The decision to overwrite the currently saved model is made based on either the maximization or the minimization of the monitored quantity. For an evaluation metric, this should be max, for val_loss this should be min, etc. In auto mode, the mode is set to min if monitor=’loss’ or monitor=’val_loss’ and to min otherwise.verbose (
bool
) – Whether to log notifications when a checkpoint is saved.