Reputation: 105
I have a doubt when implementing a early stopping using validation accuracy.
Suppose I want to stop a training when the validation accuracy does not improve after 50 epochs. However I can get randomly a good validation accuracy in the second epcoch. For instance:
accuracy training: 0.76 accuracy validation: 0.80
Maybe I do not get a better validation accuracy while the accuracy training is improving. So, when I reach 99% accuracy on training it may happen that the training stops because the 80% of validation accuracy in the second epoch has been too high (epoch = 52).
I would like to insert an offset. For example, early stopping using validation accuracy but starting in epoch = 100.
Is that possible in Keras?
Thanks in advance
Upvotes: 1
Views: 103
Reputation: 1442
Keras callbacks are very flexible, so you could simply modify the built-in EarlyStopping
callback:
from keras.callbacks import EarlyStopping
class DelayedEarlyStopping(EarlyStopping):
def on_epoch_end(self, epoch, logs=None):
if epoch >= 100:
super().on_epoch_end(epoch, logs=logs)
Upvotes: 1