From 58405a527bc4f52bd8c99dc330e7b37b7ce22fc6 Mon Sep 17 00:00:00 2001 From: Wissam Antoun Date: Wed, 23 Sep 2020 20:17:00 +0300 Subject: [PATCH] Fixed evaluation_strategy on epoch end bug (#7340) * Fixed evaluation_strategy on epoch end bug move the evaluation script outside the the iteration loop * black formatting --- src/transformers/trainer.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/transformers/trainer.py b/src/transformers/trainer.py index cdfce528a8..6e97e13d04 100755 --- a/src/transformers/trainer.py +++ b/src/transformers/trainer.py @@ -826,13 +826,15 @@ class Trainer: torch.save(self.lr_scheduler.state_dict(), os.path.join(output_dir, "scheduler.pt")) epoch_pbar.update(1) - if self.args.evaluation_strategy == EvaluationStrategy.EPOCH: - metrics = self.evaluate() - self._report_to_hp_search(trial, epoch, metrics) if self.args.max_steps > 0 and self.global_step >= self.args.max_steps: break epoch_pbar.close() train_pbar.update(1) + + if self.args.evaluation_strategy == EvaluationStrategy.EPOCH: + metrics = self.evaluate() + self._report_to_hp_search(trial, epoch, metrics) + if self.args.tpu_metrics_debug or self.args.debug: if is_torch_tpu_available(): # tpu-comment: Logging debug metrics for PyTorch/XLA (compile, execute times, ops, etc.)