I wish to implement early stopping with Keras and sklean\'s GridSearchCV
.
The working code example below is modified from How to Grid Search Hyperparame
I disagree with desertnaut's answer above. With early stopping it is true that for a set of epoch counts you cannot tell which of them contributed to the best hyperparameter set found. But this was not the question to begin with. What the method did ask was "Given at maximum n epochs and using early stopping, what are the best hyperparameters?". Yes, early stopping will introduce further hyper parameters that you might or might not want to optimize with grid search, but this is true for any hyperparameter in your model. In fact I think early stopping during grid search makes way more sense than not doing so first but after grid search, since you can (at least mildly) reason about the hyperparameters it introduces.