Plant_Disease_Detection_App / src /train /early_stopping.py
JAMM032's picture
Upload github repo files
97fcc90 verified
raw
history blame contribute delete
465 Bytes
class EarlyStopping:
def __init__(self, patience=3, min_delta=0.0):
self.patience = patience
self.min_delta = float(min_delta)
self.best = None
self.count = 0
def step(self, metric):
if self.best is None or metric > self.best + self.min_delta:
self.best = metric
self.count = 0
return False
self.count += 1
return self.count >= self.patience