Skip to content

Commit

Permalink
[Fix] Fix there is no space between data_time and metric (open-mmlab#…
Browse files Browse the repository at this point in the history
  • Loading branch information
HAOCHENYE authored Mar 28, 2023
1 parent f356b3c commit d174952
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions mmengine/runner/log_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ def get_log_after_epoch(self,
tag[key] = value
# Log other messages.
log_items = []
for name, val in chain(tag.items(), non_scalar_tag.items()):
for name, val in chain(tag.items(), non_scalar_tag.items(),
time_tag.items()):
if isinstance(val, float):
val = f'{val:.{self.num_digits}f}'
if isinstance(val, (torch.Tensor, np.ndarray)):
Expand All @@ -316,9 +317,6 @@ def get_log_after_epoch(self,
log_items.append(f'{name}: {val}')
log_str += ' '.join(log_items)

for name, val in time_tag.items():
log_str += f'{name}: {val:.{self.num_digits}f} '

if with_non_scalar:
tag.update(non_scalar_tag)
tag.update(time_tag)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_runner/test_log_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def test_log_val(self, by_epoch, mode, log_with_hierarchy):
return_value=non_scalar_logs)
_, out = log_processor.get_log_after_epoch(self.runner, 2, mode)
expect_metric_str = ("accuracy: 0.9000 recall: {'cat': 1, 'dog': 0} "
'cm: \ntensor([1, 2, 3])\ndata_time: 1.0000 ')
'cm: \ntensor([1, 2, 3])\n data_time: 1.0000')
if by_epoch:
if mode == 'test':
assert out == 'Epoch(test) [5/5] ' + expect_metric_str
Expand Down

0 comments on commit d174952

Please sign in to comment.