Two questions on this parameter.
- When the early stopping rounds parameter is 10, how could the model know round 16 has the best evaluation metric when it stops training at 10th round?
- I asked ChatGPT how this parameter works and the reply says the model rolls back to best iteration instead of the last one which is different from what is written in the notebook. Which one is correct?
Hi @flyunicorn great question!
So, the way it works is that you specify after how many rounds without improvement you want the model to stop training.
In this case, the model will stop after 10 rounds without improving, and then it will look back at the best round.
The state is the last one, meaning if you save the model as it is it will return the last state, that’s why you need to add a checkpoint so it saves the best only parameter
python - Saving best model in keras - Stack Overflow
I didn’t confirm this code, but the idea is that you specify if you want to store the best weights
early_stopping_monitor = EarlyStopping(
monitor='val_loss',
min_delta=0,
patience=0,
verbose=0,
mode='auto',
baseline=None,
restore_best_weights=True
)
1 Like