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 you will need other means to detect and stop it.
Early-stopping evaluation in distributed mode requires changes in
train_and_evaluate API and will be addressed in a future revision.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-10-06 UTC."],[],[],null,["# tf.estimator.experimental.make_early_stopping_hook\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/estimator/tree/master/tensorflow_estimator/python/estimator/early_stopping.py#L29-L95) |\n\nCreates early-stopping hook. (deprecated)\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n\\`tf.compat.v1.estimator.experimental.make_early_stopping_hook\\`\n\n\u003cbr /\u003e\n\n tf.estimator.experimental.make_early_stopping_hook(\n estimator, should_stop_fn, run_every_secs=60, run_every_steps=None\n )\n\n| **Deprecated:** THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use tf.keras instead.\n\nReturns a `SessionRunHook` that stops training when `should_stop_fn` returns\n`True`.\n\n#### Usage example:\n\n estimator = ...\n hook = early_stopping.make_early_stopping_hook(\n estimator, should_stop_fn=make_stop_fn(...))\n train_spec = tf.estimator.TrainSpec(..., hooks=[hook])\n tf.estimator.train_and_evaluate(estimator, train_spec, ...)\n\nCaveat: Current implementation supports early-stopping both training and\nevaluation in local mode. In distributed mode, training can be stopped but\nevaluation (where it's a separate job) will indefinitely wait for new model\ncheckpoints to evaluate, so you will need other means to detect and stop it.\nEarly-stopping evaluation in distributed mode requires changes in\n`train_and_evaluate` API and will be addressed in a future revision.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `estimator` | A [`tf.estimator.Estimator`](../../../tf/estimator/Estimator) instance. |\n| `should_stop_fn` | `callable`, function that takes no arguments and returns a `bool`. If the function returns `True`, stopping will be initiated by the chief. |\n| `run_every_secs` | If specified, calls `should_stop_fn` at an interval of `run_every_secs` seconds. Defaults to 60 seconds. Either this or `run_every_steps` must be set. |\n| `run_every_steps` | If specified, calls `should_stop_fn` every `run_every_steps` steps. Either this or `run_every_secs` must be set. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A `SessionRunHook` that periodically executes `should_stop_fn` and initiates early stopping if the function returns `True`. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|--------------------------------------------------------------------------------------------|\n| `TypeError` | If `estimator` is not of type [`tf.estimator.Estimator`](../../../tf/estimator/Estimator). |\n| `ValueError` | If both `run_every_secs` and `run_every_steps` are set. |\n\n\u003cbr /\u003e"]]