|TensorFlow 1 version||View source on GitHub|
Creates hook to stop if the given metric is lower than the threshold.
Compat aliases for migration
See Migration guide for more details.
tf.estimator.experimental.stop_if_lower_hook( estimator, metric_name, threshold, eval_dir=None, min_steps=0, run_every_secs=60, run_every_steps=None )
estimator = ... # Hook to stop training if loss becomes lower than 100. hook = early_stopping.stop_if_lower_hook(estimator, "loss", 100) train_spec = tf.estimator.TrainSpec(..., hooks=[hook]) tf.estimator.train_and_evaluate(estimator, train_spec, ...)
Caveat: Current implementation supports early-stopping both training and evaluation in local mode. In distributed mode, training can be stopped but evaluation (where it's a separate job) will indefinitely wait for new model checkpoints to evaluate, so y