keras-team / keras

Deep Learning for humans
http://keras.io/
Apache License 2.0
62.12k stars 19.49k forks source link

EarlyStopping instance is not reusable #20521

Closed maciejbiesek closed 2 hours ago

maciejbiesek commented 2 days ago

From my observations it seems that we cannot use the same instance of EarlyStopping callback when training multiple models. My assumption is that it saves the best value from one training and uses it to compare during the training of the next model.

In on_train_begin we have comment "# Allow instances to be re-used", however the value self.best is not cleared. I think it should be reinitialized with self.best = (float("inf") if self.monitor_op == ops.less else -float("inf")) as in __init__().

hertschuh commented 1 hour ago

@maciejbiesek ,

Thank you for the report. The fix is in and should be in the keras-nightly pip package tomorrow.