Shortcuts

mmcv.runner.hooks.logger.clearml 源代码

# Copyright (c) OpenMMLab. All rights reserved.

from typing import Dict, Optional

from ...dist_utils import master_only
from ..hook import HOOKS
from .base import LoggerHook


[文档]@HOOKS.register_module() class ClearMLLoggerHook(LoggerHook): """Class to log metrics with clearml. It requires `clearml`_ to be installed. Args: init_kwargs (dict): A dict contains the `clearml.Task.init` initialization keys. See `taskinit`_ for more details. interval (int): Logging interval (every k iterations). Default 10. ignore_last (bool): Ignore the log of last iterations in each epoch if less than `interval`. Default: True. reset_flag (bool): Whether to clear the output buffer after logging. Default: False. by_epoch (bool): Whether EpochBasedRunner is used. Default: True. .. _clearml: https://clear.ml/docs/latest/docs/ .. _taskinit: https://clear.ml/docs/latest/docs/references/sdk/task/#taskinit """ def __init__(self, init_kwargs: Optional[Dict] = None, interval: int = 10, ignore_last: bool = True, reset_flag: bool = False, by_epoch: bool = True): super().__init__(interval, ignore_last, reset_flag, by_epoch) self.import_clearml() self.init_kwargs = init_kwargs def import_clearml(self): try: import clearml except ImportError: raise ImportError( 'Please run "pip install clearml" to install clearml') self.clearml = clearml @master_only def before_run(self, runner) -> None: super().before_run(runner) task_kwargs = self.init_kwargs if self.init_kwargs else {} self.task = self.clearml.Task.init(**task_kwargs) self.task_logger = self.task.get_logger() @master_only def log(self, runner) -> None: tags = self.get_loggable_tags(runner) for tag, val in tags.items(): self.task_logger.report_scalar(tag, tag, val, self.get_iter(runner))
Read the Docs v: v1.6.2
Versions
latest
stable
2.x
v1.6.2
v1.6.1
v1.6.0
v1.5.3
v1.5.2_a
v1.5.1
v1.5.0
v1.4.8
v1.4.7
v1.4.6
v1.4.5
v1.4.4
v1.4.3
v1.4.2
v1.4.1
v1.4.0
v1.3.18
v1.3.17
v1.3.16
v1.3.15
v1.3.14
v1.3.13
dev-2.x
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.