When we use trainer.test() on a fresh trainer, the call to self.log_metrics(log_metrics, {}, step) fails to produce logs.
Steps to reproduce the behavior:
model = ...
test_dl = ...
logger = ...
trainer = pl.Trainer(
logger=logger
)
trainer.test(model, test_dataloaders=test_dl)
Metrics are logged.
Because of the way aggregate_metrics is implemented, logs are only produced when we are leaving the current step. Because there is only one step in testing, the logs are stored in self._metrics_to_agg = [metrics] but never logged.
@ justusschock any ideas?
Btw, I was able to log my logs by adding self.logger.log_metrics(logs) at the end of test_epoch_end but I believe this should be the default.
@Varal7 would you be able to send a PR with the fix?
results = trainer.test()
results is a dict with the results
Most helpful comment
Btw, I was able to log my logs by adding
self.logger.log_metrics(logs)at the end oftest_epoch_endbut I believe this should be the default.