diff --git a/tensorflow/python/keras/callbacks.py b/tensorflow/python/keras/callbacks.py index 8d33bb22978..6ac81c85c67 100644 --- a/tensorflow/python/keras/callbacks.py +++ b/tensorflow/python/keras/callbacks.py @@ -1019,6 +1019,16 @@ class EarlyStopping(Callback): the epoch with the best value of the monitored quantity. If False, the model weights obtained at the last step of training are used. + + Example: + + ```python + callback = tf.keras.callbacks.EarlyStopping(monitor='val_loss', patience=3) + # This callback will stop the training when there is no improvement in + # the validation loss for three consecutive epochs. + model.fit(data, labels, epochs=100, callbacks=[callback], + validation_data=(val_data, val_labels)) + ``` """ def __init__(self,