SaveBestWeights
minnt.callbacks.SaveBestWeights
Bases: Callback
A callback that saves best model weights to a file.
Source code in minnt/callbacks/save_best_weights.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
__init__
__init__(
path: str,
metric: str,
mode: Literal["max", "min"] = "max",
optimizer_path: str | None = None,
) -> None
Create the SaveBestWeights callback.
Parameters:
-
path(str) –A path where weights will be saved using the minnt.TrainableModule.save_weights method after each epoch. Note that you can use templates like
{logdir}and{epoch[:formatting]}. -
metric(str) –The metric name from
logsdictionary to monitor. -
mode(Literal['max', 'min'], default:'max') –One of
"max"or"min", indicating whether the monitored metric should be maximized or minimized. -
optimizer_path(str | None, default:None) –An optional path passed to minnt.TrainableModule.save_weights to save also the optimizer state; it is relative to
path.
Source code in minnt/callbacks/save_best_weights.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
best_value
class-attribute
instance-attribute
best_value: float | None = None
The best metric value seen so far.