Skip to content

Instantly share code, notes, and snippets.

@akiatoji
Created December 21, 2019 19:36
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 akiatoji/eea9c73535a6834b980d9d0bca758eb5 to your computer and use it in GitHub Desktop.
Save akiatoji/eea9c73535a6834b980d9d0bca758eb5 to your computer and use it in GitHub Desktop.
Simple callback in Keras
# Sometimes EarlyStopping is too much hassle
class myCallback(tf.keras.callbacks.Callback):
def on_epoch_end(self, epoch, logs={}):
if (logs.get('acc') >= 0.998):
print("\nReached 99.8% accuracy so cancelling training!")
self.model.stop_training = True
cb = myCallback()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment