def test_early_stopping_patience_of_1(self): earlystopper = EarlyStopping(monitor='val_loss', min_delta=0, patience=1, verbose=False) val_losses = [8, 4, 5, 2] early_stop_epoch = 3 self._test_early_stopping(earlystopper, val_losses, early_stop_epoch)
def test_early_stopping_with_delta(self): earlystopper = EarlyStopping(monitor='val_loss', min_delta=3, patience=2, verbose=False) val_losses = [8, 4, 5, 2, 2] early_stop_epoch = 4 self._test_early_stopping(earlystopper, val_losses, early_stop_epoch)
def test_integration(self): train_gen = some_data_generator(20) valid_gen = some_data_generator(20) earlystopper = EarlyStopping(monitor='val_loss', min_delta=0, patience=2, verbose=False) self.model.fit_generator(train_gen, valid_gen, epochs=10, steps_per_epoch=5, callbacks=[earlystopper])