Source code for deep_bottleneck.callbacks.earlystopping_manual

from tensorflow.python.keras.callbacks import Callback


[docs]def load(monitor='val_acc', value=0.94): return EarlyStoppingAtSpecificAccuracy(monitor, value)
[docs]class EarlyStoppingAtSpecificAccuracy(Callback):
[docs] @classmethod def load(cls, monitor='val_acc', value=0.94): return cls(monitor, value)
def __init__(self, monitor, value): super().__init__() self.monitor = monitor self.value = value
[docs] def on_epoch_end(self, epoch, logs): current = logs.get(self.monitor) print('current = ', current) print('Defined value: ', self.value) if current > self.value: print('Current is higher than the defined value. Current = ', current, ', value = ', self.value) self.model.stop_training = True