EarlyStopping¶
-
class
tfsnippet.EarlyStopping(param_vars, initial_metric=None, checkpoint_dir=None, smaller_is_better=True, restore_on_error=False, cleanup=True, name=None)¶ Bases:
tfsnippet.utils.concepts.DisposableContextEarly-stopping context object.
This class provides a object for memorizing the parameters for best metric, in an early-stopping context. An example of using this context:
with EarlyStopping(param_vars) as es: ... es.update(loss, global_step) ...
Where
es.update(loss, global_step)should cause the parameters to be saved on disk if loss is better than the current best metric. One may also get the current best metric viaes.best_metric.Notes
If no loss is given via
es.update, then the variables would keep their latest values when closing an early-stopping object.Attributes Summary
best_metricGet the current best loss. ever_updatedCheck whether or not update method has ever been called. Methods Summary
update(metric[, global_step])Update the best metric. Attributes Documentation
-
best_metric¶ Get the current best loss.
-
ever_updated¶ Check whether or not update method has ever been called.
Methods Documentation
-