Skip to content
Snippets Groups Projects
Unverified Commit 6bd548d8 authored by Mashiro's avatar Mashiro Committed by GitHub
Browse files

[FIx] Logging time in LoggerHook.after_val_epoch has no effect (#376)

parent 6b47035f
No related branches found
No related tags found
No related merge requests found
......@@ -214,10 +214,7 @@ class LoggerHook(Hook):
# by iter. At the same time, scalars related to time should
# still be logged by iter to avoid messy visualized result.
# see details in PR #278.
time_tags = {k: v for k, v in tag.items() if 'time' in k}
metric_tags = {k: v for k, v in tag.items() if 'time' not in k}
runner.visualizer.add_scalars(
time_tags, step=runner.iter, file_path=self.json_log_path)
runner.visualizer.add_scalars(
metric_tags, step=runner.epoch, file_path=self.json_log_path)
else:
......
......@@ -128,12 +128,7 @@ class TestLoggerHook:
logger_hook.after_val_epoch(runner)
args = {'step': ANY, 'file_path': ANY}
# expect visualizer log `time` and `metric` respectively
runner.visualizer.add_scalars.assert_any_call(
{
'time': 1,
'datatime': 1
}, **args)
runner.visualizer.add_scalars.assert_any_call({'acc': 0.8}, **args)
runner.visualizer.add_scalars.assert_called_with({'acc': 0.8}, **args)
# Test when `log_metric_by_epoch` is False
logger_hook = LoggerHook(log_metric_by_epoch=False)
......@@ -145,7 +140,7 @@ class TestLoggerHook:
}, 'string'))
logger_hook.after_val_epoch(runner)
# expect visualizer log `time` and `metric` jointly
runner.visualizer.add_scalars.assert_any_call(
runner.visualizer.add_scalars.assert_called_with(
{
'time': 5,
'datatime': 5,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment