LoggerHook — mmengine 0.10.7 documentation (original) (raw)

class mmengine.hooks.LoggerHook(interval=10, ignore_last=True, interval_exp_name=1000, out_dir=None, out_suffix=('.json', '.log', '.py', 'yaml'), keep_local=True, file_client_args=None, log_metric_by_epoch=True, backend_args=None)[source]

Collect logs from different components of Runner and write them to terminal, JSON file, tensorboard and wandb .etc.

LoggerHook is used to record logs formatted by LogProcessor during training/validation/testing phase. It is used to control following behaviors:

Parameters:

Examples

The simplest LoggerHook config.

logger_hook_cfg = dict(interval=20)

after_run(runner)[source]

Copy logs to self.out_dir if self.out_dir is not None

Parameters:

runner (Runner) – The runner of the training/testing/validation process.

Return type:

None

after_test_epoch(runner, metrics=None)[source]

All subclasses should override this method, if they need any operations after each test epoch.

Parameters:

Return type:

None

after_test_iter(runner, batch_idx, data_batch=None, outputs=None)[source]

Record logs after testing iteration.

Parameters:

Return type:

None

after_train_iter(runner, batch_idx, data_batch=None, outputs=None)[source]

Record logs after training iteration.

Parameters:

Return type:

None

after_val_epoch(runner, metrics=None)[source]

All subclasses should override this method, if they need any operations after each validation epoch.

Parameters:

Return type:

None

after_val_iter(runner, batch_idx, data_batch=None, outputs=None)[source]

Record logs after validation iteration.

Parameters:

Return type:

None

before_run(runner)[source]

Infer self.file_client from self.out_dir. Initialize theself.start_iter and record the meta information.

Parameters:

runner (Runner) – The runner of the training process.

Return type:

None