best_model_saver
BestModelSaver
¶
Bases: Trace
Save the weights of best model based on a given evaluation metric.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Union[Model, Module]
|
A model instance compiled with fe.build. |
required |
save_dir
|
str
|
Folder path into which to save the model. |
required |
metric
|
Optional[str]
|
Eval metric name to monitor. If None, the model's loss will be used. |
None
|
save_best_mode
|
str
|
Can be 'min' or 'max'. |
'min'
|
weights_name
|
Optional[str]
|
The exact name used to save model weights. If None default model prefix will be used. |
None
|
load_best_final
|
bool
|
Whether to automatically reload the best model (if available) after training. |
False
|
save_architecture
|
bool
|
Whether to save the full model architecture in addition to the model weights. This option is
only available for TensorFlow models at present, and will generate a folder containing several files. The
model can then be re-instantiated even without access to the original code by calling:
tf.keras.models.load_model( |
False
|
Raises:
Type | Description |
---|---|
AssertionError
|
If a |
ValueError
|
If |