[Fix] fix loss smooth when loss name doesn't start with `loss` (#539)

* fix loss mean

* update
pull/655/head
Yanyi Liu 2022-10-08 19:53:05 +08:00 committed by GitHub
parent da38b4113d
commit ccb32c7e31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions

View File

@ -153,7 +153,7 @@ class LogProcessor:
log_str = (f'Iter({mode}) '
f'[{cur_iter}/{runner.max_iters}] ')
else:
log_str = (f'Iter({mode}) [{batch_idx+1}'
log_str = (f'Iter({mode}) [{batch_idx + 1}'
f'/{len(current_loop.dataloader)}] ')
# Concatenate lr, momentum string with log header.
log_str += f'{lr_str} '
@ -266,8 +266,7 @@ class LogProcessor:
mode_history_scalars[key] = log_buffer
for key in mode_history_scalars:
# Update the latest learning rate and smoothed time logs.
if key.startswith('loss') or key in ('time', 'data_time',
'grad_norm'):
if 'loss' in key or key in ('time', 'data_time', 'grad_norm'):
tag[key] = mode_history_scalars[key].mean(self.window_size)
else:
# Default statistic method is current.