Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix early_stop when the metric is the larger the better #374

Merged
merged 3 commits into from
Sep 13, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions federatedscope/core/monitors/early_stopper.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def __track_and_check_best(self, history_result):
# by default: add(val_loss, -delta) < new_result
self.counter_no_improve += 1
elif not self.the_smaller_the_better and self.comparator(
self.improvement_operator(self.best_metric, self.delta),
new_result):
new_result,
self.improvement_operator(self.best_metric, self.delta)):
# typical case: add(eval_score, delta) > new_result
self.counter_no_improve += 1
else:
Expand All @@ -80,9 +80,10 @@ def __track_and_check_mean(self, history_result):
-self.delta), new_result):
self.early_stopped = True
elif not self.the_smaller_the_better and self.comparator(
new_result,
self.improvement_operator(
np.mean(history_result[-self.patience - 1:-1]),
self.delta), new_result):
self.delta)):
self.early_stopped = True
else:
self.early_stopped = False
Expand Down