EarlyStopper updates (#4679)
This commit is contained in:
1 parent
f64fab5825
commit
548745181a
2 files changed
+8
-5
No files matched your search
@@ -298,13 +298,16 @@ class EarlyStopping:
|
||||
def __init__(self, patience=30):
|
||||
self.best_fitness = 0.0 # i.e. mAP
|
||||
self.best_epoch = 0
|
||||
self.patience = patience # epochs to wait after fitness stops improving to stop
|
||||
self.patience = patience or float('inf') # epochs to wait after fitness stops improving to stop
|
||||
self.possible_stop = False # possible stop may occur next epoch
|
||||
|
||||
def __call__(self, epoch, fitness):
|
||||
if fitness >= self.best_fitness: # >= 0 to allow for early zero-fitness stage of training
|
||||
self.best_epoch = epoch
|
||||
self.best_fitness = fitness
|
||||
stop = (epoch - self.best_epoch) >= self.patience # stop training if patience exceeded
|
||||
delta = epoch - self.best_epoch # epochs without improvement
|
||||
self.possible_stop = delta >= (self.patience - 1) # possible stop may occur next epoch
|
||||
stop = delta >= self.patience # stop training if patience exceeded
|
||||
if stop:
|
||||
LOGGER.info(f'EarlyStopping patience {self.patience} exceeded, stopping training.')
|
||||
return stop
|
||||
|
||||
Reference in new issue
Block a user