From a2796a703a4293b309c0ae91982b92bc21125690 Mon Sep 17 00:00:00 2001 From: "Sean (Seok-Won) Yi" Date: Wed, 7 Aug 2024 09:54:52 +0900 Subject: [PATCH] Refactor and simplify code. Co-authored-by: Zach Mueller --- src/transformers/trainer.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/transformers/trainer.py b/src/transformers/trainer.py index 31843c52cf7603..ea5e25a128d5a3 100755 --- a/src/transformers/trainer.py +++ b/src/transformers/trainer.py @@ -2799,10 +2799,7 @@ def _maybe_log_save_evaluate(self, tr_loss, grad_norm, model, trial, epoch, igno new_best_metric = self._determine_best_metric(metrics=metrics, trial=trial) if self.args.save_strategy == SaveStrategy.BEST: - if new_best_metric: - self.control.should_save = True - else: - self.control_should_save = False + self.control.should_save = new_best_metric if self.control.should_save: self._save_checkpoint(model, trial)