Skip to content

Instantly share code, notes, and snippets.

@esmitt
Last active October 15, 2020 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esmitt/ca4ad82546d48c6305452321a9124f22 to your computer and use it in GitHub Desktop.
Save esmitt/ca4ad82546d48c6305452321a9124f22 to your computer and use it in GitHub Desktop.
Early stopping callback in Tensorflow 2
from tensorflow.keras.callbacks import EarlyStopping
"""
This callback will stop the training when there is no improvement in the validation accuracy across epochs
"""
early_callback = EarlyStopping(monitor='val_auc',
verbose=1,
patience=10,
mode='max',
restore_best_weights=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment