Skip to content

Instantly share code, notes, and snippets.

@Attila94
Last active June 6, 2019 00:07
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 Attila94/1fd1efee13b0c02fdbef4928c773f3b0 to your computer and use it in GitHub Desktop.
Save Attila94/1fd1efee13b0c02fdbef4928c773f3b0 to your computer and use it in GitHub Desktop.
Keras Early Stopping callback with minimum target to reach before starting to monitor target value.
class MyEarlyStopping(EarlyStopping):
def __init__(self, minimum_target=None, **kwargs):
self.minimum_target = minimum_target
super(MyEarlyStopping, self).__init__(**kwargs)
def on_epoch_end(self, epoch, logs):
current = logs.get(self.monitor)
if self.minimum_target and self.monitor_op(self.minimum_target, current):
super(MyEarlyStopping, self).on_epoch_end(epoch, logs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment