Skip to content

Commit

Permalink
Allow configuring accuracy threshold for early stop
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyingPumba committed Sep 16, 2024
1 parent f3c96e8 commit ead6263
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion iit/model_pairs/base_model_pair.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,16 @@ def _check_early_stop_condition(self, test_metrics: MetricStoreCollection) -> bo
"""
Returns True if all types of accuracy metrics reach 100%
"""
early_stop_accuracy_threshold = 99.5
if "early_stop_accuracy_threshold" in self.training_args:
early_stop_accuracy_threshold = float(self.training_args["early_stop_accuracy_threshold"])

got_accuracy_metric = False
for metric in test_metrics:
if metric.type == MetricType.ACCURACY:
got_accuracy_metric = True
val = metric.get_value()
if isinstance(val, float) and val < 99.5:
if isinstance(val, float) and val < early_stop_accuracy_threshold:
return False
if not got_accuracy_metric:
raise ValueError("No accuracy metric found in test_metrics!")
Expand Down

0 comments on commit ead6263

Please sign in to comment.