[Python] Change in behaviour of EarlyStopping with Keras upgrade from 2 to 3

Discussão em 'Python' iniciado por Stack, Julho 9, 2025.

  1. Stack

    Stack Membro Participativo

    With a simple Sequential model defined in Keras, training was stopping early after upgrading from Keras 2.14 to 3.5 (this also happened recently on Google Colab).

    I had multiple models but each one referenced a single global callback (EarlyStopping) object passed to fit(). In 2.14 Keras, this worked fine but in 3.5, only the first model trained correctly. It appears that the state of the EarlyStopping object is no longer reset with each use and a separate instance of EarlyStopping should be used for each model.

    I was able to reproduce the issue by setting up two simple Sequential models with a single instance of EarlyStopping passed as a callback in the fit function.

    In Keras 2.14, both models train correctly. After upgrading Keras to the latest version (3.5), the second model stopped early after the patience value.

    Continue reading...

Compartilhe esta Página