mirror of
https://github.com/open-mmlab/mmengine.git
synced 2025-06-03 21:54:44 +08:00
[Docs] Fix typos (#1348)
This commit is contained in:
parent
00df73cf43
commit
c5274ba326
@ -13,7 +13,7 @@ from mmengine.device import get_max_cuda_memory, is_cuda_available
|
|||||||
from mmengine.registry import LOG_PROCESSORS
|
from mmengine.registry import LOG_PROCESSORS
|
||||||
|
|
||||||
|
|
||||||
@LOG_PROCESSORS.register_module() # type: ignore
|
@LOG_PROCESSORS.register_module()
|
||||||
class LogProcessor:
|
class LogProcessor:
|
||||||
"""A log processor used to format log information collected from
|
"""A log processor used to format log information collected from
|
||||||
``runner.message_hub.log_scalars``.
|
``runner.message_hub.log_scalars``.
|
||||||
@ -24,7 +24,7 @@ class LogProcessor:
|
|||||||
``custom_cfg`` of constructor can control the statistics method of logs.
|
``custom_cfg`` of constructor can control the statistics method of logs.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
window_size (int): default smooth interval Defaults to 10.
|
window_size (int): default smooth interval. Defaults to 10.
|
||||||
by_epoch (bool): Whether to format logs with epoch stype. Defaults to
|
by_epoch (bool): Whether to format logs with epoch stype. Defaults to
|
||||||
True.
|
True.
|
||||||
custom_cfg (list[dict], optional): Contains multiple log config dict,
|
custom_cfg (list[dict], optional): Contains multiple log config dict,
|
||||||
@ -35,7 +35,7 @@ class LogProcessor:
|
|||||||
- If custom_cfg is None, all logs will be formatted via default
|
- If custom_cfg is None, all logs will be formatted via default
|
||||||
methods, such as smoothing loss by default window_size. If
|
methods, such as smoothing loss by default window_size. If
|
||||||
custom_cfg is defined as a list of config dict, for example:
|
custom_cfg is defined as a list of config dict, for example:
|
||||||
[dict(data_src=loss, method='mean', log_name='global_loss',
|
[dict(data_src='loss', method='mean', log_name='global_loss',
|
||||||
window_size='global')]. It means the log item ``loss`` will be
|
window_size='global')]. It means the log item ``loss`` will be
|
||||||
counted as global mean and additionally logged as ``global_loss``
|
counted as global mean and additionally logged as ``global_loss``
|
||||||
(defined by ``log_name``). If ``log_name`` is not defined in
|
(defined by ``log_name``). If ``log_name`` is not defined in
|
||||||
@ -43,8 +43,8 @@ class LogProcessor:
|
|||||||
|
|
||||||
- The original log item cannot be overwritten twice. Here is
|
- The original log item cannot be overwritten twice. Here is
|
||||||
an error example:
|
an error example:
|
||||||
[dict(data_src=loss, method='mean', window_size='global'),
|
[dict(data_src='loss', method='mean', window_size='global'),
|
||||||
dict(data_src=loss, method='mean', window_size='epoch')].
|
dict(data_src='loss', method='mean', window_size='epoch')].
|
||||||
Both log config dict in custom_cfg do not have ``log_name`` key,
|
Both log config dict in custom_cfg do not have ``log_name`` key,
|
||||||
which means the loss item will be overwritten twice.
|
which means the loss item will be overwritten twice.
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ class LogProcessor:
|
|||||||
if ``by_epoch`` is set to False, ``windows_size`` should not be
|
if ``by_epoch`` is set to False, ``windows_size`` should not be
|
||||||
`epoch` to statistics log value by epoch.
|
`epoch` to statistics log value by epoch.
|
||||||
num_digits (int): The number of significant digit shown in the
|
num_digits (int): The number of significant digit shown in the
|
||||||
logging message.
|
logging message. Defaults to 4.
|
||||||
log_with_hierarchy (bool): Whether to log with hierarchy. If it is
|
log_with_hierarchy (bool): Whether to log with hierarchy. If it is
|
||||||
True, the information is written to visualizer backend such as
|
True, the information is written to visualizer backend such as
|
||||||
:obj:`LocalVisBackend` and :obj:`TensorboardBackend`
|
:obj:`LocalVisBackend` and :obj:`TensorboardBackend`
|
||||||
@ -122,7 +122,7 @@ class LogProcessor:
|
|||||||
|
|
||||||
def get_log_after_iter(self, runner, batch_idx: int,
|
def get_log_after_iter(self, runner, batch_idx: int,
|
||||||
mode: str) -> Tuple[dict, str]:
|
mode: str) -> Tuple[dict, str]:
|
||||||
"""Format log string after training, validation or testing epoch.
|
"""Format log string after training, validation or testing iteration.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
runner (Runner): The runner of training phase.
|
runner (Runner): The runner of training phase.
|
||||||
@ -131,7 +131,7 @@ class LogProcessor:
|
|||||||
mode (str): Current mode of runner, train, test or val.
|
mode (str): Current mode of runner, train, test or val.
|
||||||
|
|
||||||
Return:
|
Return:
|
||||||
Tuple(dict, str): Formatted log dict/string which will be
|
Tuple[dict, str]: Formatted log dict/string which will be
|
||||||
recorded by :obj:`runner.message_hub` and :obj:`runner.visualizer`.
|
recorded by :obj:`runner.message_hub` and :obj:`runner.visualizer`.
|
||||||
"""
|
"""
|
||||||
assert mode in ['train', 'test', 'val']
|
assert mode in ['train', 'test', 'val']
|
||||||
@ -139,11 +139,11 @@ class LogProcessor:
|
|||||||
parsed_cfg = self._parse_windows_size(runner, batch_idx,
|
parsed_cfg = self._parse_windows_size(runner, batch_idx,
|
||||||
self.custom_cfg)
|
self.custom_cfg)
|
||||||
# log_tag is used to write log information to terminal
|
# log_tag is used to write log information to terminal
|
||||||
|
log_tag = self._collect_scalars(parsed_cfg, runner, mode)
|
||||||
|
|
||||||
# If `self.log_with_hierarchy` is False, the tag is the same as
|
# If `self.log_with_hierarchy` is False, the tag is the same as
|
||||||
# log_tag. Otherwise, each key in tag starts with prefix `train`,
|
# log_tag. Otherwise, each key in tag starts with prefix `train`,
|
||||||
# `test` or `val`
|
# `test` or `val`
|
||||||
log_tag = self._collect_scalars(parsed_cfg, runner, mode)
|
|
||||||
|
|
||||||
if not self.log_with_hierarchy:
|
if not self.log_with_hierarchy:
|
||||||
tag = copy.deepcopy(log_tag)
|
tag = copy.deepcopy(log_tag)
|
||||||
else:
|
else:
|
||||||
@ -259,7 +259,7 @@ class LogProcessor:
|
|||||||
returned tag. Defaults to False.
|
returned tag. Defaults to False.
|
||||||
|
|
||||||
Return:
|
Return:
|
||||||
Tuple(dict, str): Formatted log dict/string which will be
|
Tuple[dict, str]: Formatted log dict/string which will be
|
||||||
recorded by :obj:`runner.message_hub` and :obj:`runner.visualizer`.
|
recorded by :obj:`runner.message_hub` and :obj:`runner.visualizer`.
|
||||||
"""
|
"""
|
||||||
assert mode in [
|
assert mode in [
|
||||||
|
@ -519,7 +519,7 @@ def get_object_from_string(obj_name: str):
|
|||||||
try:
|
try:
|
||||||
module = import_module(module_name)
|
module = import_module(module_name)
|
||||||
part = next(parts)
|
part = next(parts)
|
||||||
# mmcv.ops has nms.py has nms function at the same time. So the
|
# mmcv.ops has nms.py and nms function at the same time. So the
|
||||||
# function will have a higher priority
|
# function will have a higher priority
|
||||||
obj = getattr(module, part, None)
|
obj = getattr(module, part, None)
|
||||||
if obj is not None and not ismodule(obj):
|
if obj is not None and not ismodule(obj):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user