Commit 9ca11f63 authored by Andrei-Claudiu Roibu's avatar Andrei-Claudiu Roibu 🖥
Browse files

introduced min delta for early stopping

parent f214cf4c
......@@ -26,7 +26,7 @@ class EarlyStopping:
patience (int): Metric for keeping track of the number of consecutive epochs the validation loss is allowed to decrease.
verbose (bool): Flag for prinding out useful information.
min_delta (int): Minimum change in the monitored quantity to quality as an improvement (ie. if absolute change is less than min_delta, it will count as no improvement)
early_stop (bool): Flag indicating if the training should be terminated
......@@ -34,23 +34,24 @@ class EarlyStopping:
def __init__(self, patience=5):
def __init__(self, patience=5, min_delta=0):
self.patience = patience
self.counter = 0
self.best_score = None
self.early_stop = False
self.save_checkpoint = False
self.min_delta = min_delta
def __call__(self, validation_loss):
score = - validation_loss
score = validation_loss
if self.best_score is None:
self.best_score = score
self.save_checkpoint = True
elif score <= self.best_score:
elif np.greater(self.min_delta, self.best_score - score):
self.counter += 1
self.save_checkpoint = False
print("Early Stopping Counter: {}/{}".format(self.counter, self.patience))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment