Skip to content

Commit 6d86bec

Browse files
Merge pull request #793 from birdnet-team/early-stopping-monitor-loss
Monitor validation loss for early stopping
2 parents d2e49cd + 1673bec commit 6d86bec

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

birdnet_analyzer/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,8 @@ def on_epoch_end(self, epoch, logs=None):
770770
callbacks = [
771771
# EarlyStopping with restore_best_weights
772772
keras.callbacks.EarlyStopping(
773-
monitor="val_AUPRC",
774-
mode="max",
773+
monitor="val_loss",
774+
mode="min",
775775
patience=patience,
776776
verbose=1,
777777
min_delta=min_delta,

birdnet_analyzer/train/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,8 @@ def run_trial(self, trial, *args, **kwargs):
552552

553553
print("...Done.", flush=True)
554554

555-
# Get best validation metrics based on AUPRC instead of loss for more reliable results with imbalanced data
556-
best_epoch = np.argmax(history.history["val_AUPRC"])
555+
# Get best validation metrics based on loss
556+
best_epoch = np.argmin(history.history["val_loss"])
557557
best_val_auprc = history.history["val_AUPRC"][best_epoch]
558558
best_val_auroc = history.history["val_AUROC"][best_epoch]
559559
best_val_loss = history.history["val_loss"][best_epoch]

0 commit comments

Comments
 (0)