Fix updating of best epoch during early stopping (#19164)

This commit is contained in:
Victor Costa 2025-02-13 04:40:57 +00:00 committed by GitHub
parent 710b40dcb1
commit 5edf3419f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -746,7 +746,7 @@ class EarlyStopping:
if fitness is None: # check if fitness=None (happens when val=False) if fitness is None: # check if fitness=None (happens when val=False)
return False return False
if fitness >= self.best_fitness: # >= 0 to allow for early zero-fitness stage of training if fitness > self.best_fitness or self.best_fitness == 0: # allow for early zero-fitness stage of training
self.best_epoch = epoch self.best_epoch = epoch
self.best_fitness = fitness self.best_fitness = fitness
delta = epoch - self.best_epoch # epochs without improvement delta = epoch - self.best_epoch # epochs without improvement