pytorch_pfn_extras.training.extensions.BestValue¶
- class pytorch_pfn_extras.training.extensions.BestValue(key, compare, trigger=(1, 'epoch'))¶
Extension traces the best value of a specific key in the observation.
- Parameters
key (str) – Key of value.
compare (callable) – Compare function which takes current best value and new value and returns whether new value is better than current best.
trigger (TriggerLike) – Trigger that decides the comparison interval between current best value and new value. This must be a tuple in the form of
<int>, 'epoch'
or<int>, 'iteration'
which is passed toBestValueTrigger
.
- Return type
None
- __init__(key, compare, trigger=(1, 'epoch'))¶
- Parameters
key (str) –
compare (Callable[[float, float], bool]) –
trigger (TriggerLike) –
- Return type
None
Methods
__init__
(key, compare[, trigger])finalize
(manager)Finalizes the extension.
initialize
(manager)Initializes up the manager state.
load_state_dict
(to_load)on_error
(manager, exc, tb)Handles the error raised during training before finalization.
state_dict
()Serializes the extension state.
Attributes
best_epoch
Returns the epoch count that the current best value is observed.
best_iteration
Returns the iteration count that the current best value is observed.
best_value
Returns the current best value.
default_name
is_async
name
needs_model_state
priority
trigger