From fe2b6666e0c3a47992860a2200ab40ae1c2ea6c7 Mon Sep 17 00:00:00 2001 From: Guy Davidson Date: Thu, 23 Apr 2020 17:52:41 -0400 Subject: [PATCH] Fixing a small issue in trainer logging (#1563) * The epoch was being logged to metrics, which isn't read, rather than to current_metrics. * Updated the tests to account for the epoch arriving at the logger. --- pytorch_lightning/trainer/logging.py | 2 +- tests/loggers/test_all.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pytorch_lightning/trainer/logging.py b/pytorch_lightning/trainer/logging.py index dbe05e4a..a0599f58 100644 --- a/pytorch_lightning/trainer/logging.py +++ b/pytorch_lightning/trainer/logging.py @@ -68,7 +68,7 @@ class TrainerLoggingMixin(ABC): step = scalar_metrics.pop("step") else: # added metrics by Lightning for convenience - metrics['epoch'] = self.current_epoch + scalar_metrics['epoch'] = self.current_epoch step = step if step is not None else self.global_step # log actual metrics if self.proc_rank == 0 and self.logger is not None: diff --git a/tests/loggers/test_all.py b/tests/loggers/test_all.py index b8637ff7..d9bb804b 100644 --- a/tests/loggers/test_all.py +++ b/tests/loggers/test_all.py @@ -62,9 +62,9 @@ def test_loggers_fit_test(tmpdir, monkeypatch, logger_class): trainer.test() log_metric_names = [(s, sorted(m.keys())) for s, m in logger.history] - assert log_metric_names == [(0, ['val_acc', 'val_loss']), - (0, ['train_some_val']), - (1, ['test_acc', 'test_loss'])] + assert log_metric_names == [(0, ['epoch', 'val_acc', 'val_loss']), + (0, ['epoch', 'train_some_val']), + (1, ['epoch', 'test_acc', 'test_loss'])] @pytest.mark.parametrize("logger_class", [