LogProcessor — mmengine 0.11.0rc0 documentation (original) (raw)

class mmengine.runner.LogProcessor(window_size=10, by_epoch=True, custom_cfg=None, num_digits=4, log_with_hierarchy=False, mean_pattern='.*(loss|time|data_time|grad_norm).*')[source]

A log processor used to format log information collected fromrunner.message_hub.log_scalars.

LogProcessor instance is built by runner and will formatrunner.message_hub.log_scalars to tag and log_str, which can directly used by LoggerHook and MMLogger. Besides, the argumentcustom_cfg of constructor can control the statistics method of logs.

Parameters:

Examples

log_name is defined, loss_large_window will be an additional

record.

log_processor = dict( window_size=10, by_epoch=True, custom_cfg=[dict(data_src='loss', log_name='loss_large_window', method_name='mean', window_size=100)])

log_name is not defined. loss will be overwritten.

log_processor = dict( window_size=10, by_epoch=True, custom_cfg=[dict(data_src='loss', method_name='mean', window_size=100)])

Record loss with different statistics methods.

log_processor = dict( window_size=10, by_epoch=True, custom_cfg=[dict(data_src='loss', log_name='loss_large_window', method_name='mean', window_size=100), dict(data_src='loss', method_name='mean', window_size=100)])

Overwrite loss item twice will raise an error.

log_processor = dict( window_size=10, by_epoch=True, custom_cfg=[dict(data_src='loss', method_name='mean', window_size=100), dict(data_src='loss', method_name='max', window_size=100)]) AssertionError

get_log_after_epoch(runner, batch_idx, mode, with_non_scalar=False)[source]

Format log string after validation or testing epoch.

Parameters:

Returns:

Formatted log dict/string which will be recorded by runner.message_hub and runner.visualizer.

Return type:

Tuple[dict, str]

get_log_after_iter(runner, batch_idx, mode)[source]

Format log string after training, validation or testing iteration.

Parameters:

Returns:

Formatted log dict/string which will be recorded by runner.message_hub and runner.visualizer.

Return type:

Tuple[dict, str]