1

I want to get a model which works best, what should I go for while training the model, ModelCheckpoint, EarlyStopping, or both?

nbro
  • 42,615
  • 12
  • 119
  • 217
Sadaf Shafi
  • 218
  • 2
  • 10

1 Answers1

3
  • Early stopping: stop the training when a condition is met
  • Checkpoint : frequently save the model

The purpose of Early Stopping is to avoid overfitting by stopping the model before it happens using a defined condition. If you use it, and then you save the model when the training is stopped*, you will get a model that is assumed to be good enough and not overfitted.

The purpose of the class ModelCheckpoint is to save models several times while training. This can be useful to find at which epoch the model gets the best performance. So, if you use it, you will get several models that are saved at different epochs (or, more generally, "checkpoints").

Even after using both methods, you will get some models, but they have a different purpose. None of them is better than the other. I almost always use both methods at the same time. You can use early stopping to stop the training and save a lot of models while training using ModelCheckpoint. In most of my cases, the best model is around the epoch during early stopping.

*note: the model saving process is not done by EarlyStopping

malioboro
  • 2,859
  • 3
  • 23
  • 47