Unverified Commit 83df7c4b authored by Jiazhen Wang's avatar Jiazhen Wang Committed by GitHub
Browse files

[Fix] Fix LoggerHooks docstring (#1664)

* [Fix] fix loggerhooks docstring

* [Fix] fix some details

* [Fix] fix docstring

* [Fix] fix docstring

* [Fix] fix docstring

* [Fix] add docstring
parent 37121bf4
......@@ -12,11 +12,12 @@ class LoggerHook(Hook):
"""Base class for logger hooks.
Args:
interval (int): Logging interval (every k iterations).
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`.
if less than `interval`. Default True.
reset_flag (bool): Whether to clear the output buffer after logging.
by_epoch (bool): Whether EpochBasedRunner is used.
Default False.
by_epoch (bool): Whether EpochBasedRunner is used. Default True.
"""
__metaclass__ = ABCMeta
......
......@@ -13,21 +13,15 @@ class DvcliveLoggerHook(LoggerHook):
It requires `dvclive`_ to be installed.
Args:
model_file (str):
Default None.
If not None, after each epoch the model will
be saved to {model_file}.
interval (int): Logging interval (every k iterations).
Default 10.
model_file (str): Default None. If not None, after each epoch the
model will be saved to {model_file}.
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.
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.
kwargs:
Arguments for instantiating `Live`_
by_epoch (bool): Whether EpochBasedRunner is used. Default: True.
kwargs: Arguments for instantiating `Live`_.
.. _dvclive:
https://dvc.org/doc/dvclive
......
......@@ -6,6 +6,30 @@ from .base import LoggerHook
@HOOKS.register_module()
class MlflowLoggerHook(LoggerHook):
"""Class to log metrics and (optionally) a trained model to MLflow.
It requires `MLflow`_ to be installed.
Args:
exp_name (str, optional): Name of the experiment to be used.
Default None. If not None, set the active experiment.
If experiment does not exist, an experiment with provided name
will be created.
tags (Dict[str], optional): Tags for the current run.
Default None. If not None, set tags for the current run.
log_model (bool, optional): Whether to log an MLflow artifact.
Default True. If True, log runner.model as an MLflow artifact
for the current run.
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.
.. _MLflow:
https://www.mlflow.org/docs/latest/index.html
"""
def __init__(self,
exp_name=None,
......@@ -15,32 +39,6 @@ class MlflowLoggerHook(LoggerHook):
ignore_last=True,
reset_flag=False,
by_epoch=True):
"""Class to log metrics and (optionally) a trained model to MLflow.
It requires `MLflow`_ to be installed.
Args:
exp_name (str, optional): Name of the experiment to be used.
Default None.
If not None, set the active experiment.
If experiment does not exist, an experiment with provided name
will be created.
tags (dict of str: str, optional): Tags for the current run.
Default None.
If not None, set tags for the current run.
log_model (bool, optional): Whether to log an MLflow artifact.
Default True.
If True, log runner.model as an MLflow artifact
for the current run.
interval (int): Logging interval (every k iterations).
ignore_last (bool): Ignore the log of last iterations in each epoch
if less than `interval`.
reset_flag (bool): Whether to clear the output buffer after logging
by_epoch (bool): Whether EpochBasedRunner is used.
.. _MLflow:
https://www.mlflow.org/docs/latest/index.html
"""
super(MlflowLoggerHook, self).__init__(interval, ignore_last,
reset_flag, by_epoch)
self.import_mlflow()
......
......@@ -8,7 +8,7 @@ from .base import LoggerHook
class NeptuneLoggerHook(LoggerHook):
"""Class to log metrics to NeptuneAI.
It requires `neptune-client` to be installed.
It requires `Neptune`_ to be installed.
Args:
init_kwargs (dict): a dict contains the initialization keys as below:
......@@ -27,14 +27,18 @@ class NeptuneLoggerHook(LoggerHook):
Check https://docs.neptune.ai/api-reference/neptune#init for more
init arguments.
interval (int): Logging interval (every k iterations).
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`.
reset_flag (bool): Whether to clear the output buffer after logging
by_epoch (bool): Whether EpochBasedRunner is used.
if less than ``interval``. Default: True.
reset_flag (bool): Whether to clear the output buffer after logging.
Default: True.
with_step (bool): If True, the step will be logged from
``self.get_iters``. Otherwise, step will not be logged.
Default: True.
by_epoch (bool): Whether EpochBasedRunner is used. Default: True.
.. _NeptuneAI:
https://docs.neptune.ai/you-should-know/logging-metadata
.. _Neptune:
https://docs.neptune.ai
"""
def __init__(self,
......
......@@ -15,6 +15,21 @@ from .base import LoggerHook
@HOOKS.register_module()
class PaviLoggerHook(LoggerHook):
"""Class to visual model, log metrics (for internal use).
Args:
init_kwargs (dict): A dict contains the initialization keys.
add_graph (bool): Whether to visual model. Default: False.
add_last_ckpt (bool): Whether to save checkpoint after run.
Default: False.
interval (int): Logging interval (every k iterations). Default: True.
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.
img_key (string): Get image data from Dataset. Default: 'img_info'.
"""
def __init__(self,
init_kwargs=None,
......
......@@ -9,6 +9,18 @@ from .base import LoggerHook
@HOOKS.register_module()
class TensorboardLoggerHook(LoggerHook):
"""Class to log metrics to Tensorboard.
Args:
log_dir (string): Save directory location. Default: None. If default
values are used, directory location is ``runner.work_dir``/tf_logs.
interval (int): Logging interval (every k iterations). Default: True.
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.
"""
def __init__(self,
log_dir=None,
......
......@@ -11,10 +11,12 @@ from .base import LoggerHook
class WandbLoggerHook(LoggerHook):
"""Class to log metrics with wandb.
It requires `wandb` to be installed.
It requires `wandb`_ to be installed.
Args:
init_kwargs (dict): A dict contains the initialization keys. Check
https://docs.wandb.ai/ref/python/init for more init arguments.
interval (int): Logging interval (every k iterations).
Default 10.
ignore_last (bool): Ignore the log of last iterations in each epoch
......@@ -22,6 +24,11 @@ class WandbLoggerHook(LoggerHook):
Default: True.
reset_flag (bool): Whether to clear the output buffer after logging.
Default: False.
commit (bool): Save the metrics dict to the wandb server and increment
the step. If false ``wandb.log`` just updates the current metrics
dict with the row argument and metrics won't be saved until
``wandb.log`` is called with ``commit=True``.
Default: True.
by_epoch (bool): Whether EpochBasedRunner is used.
Default: True.
with_step (bool): If True, the step will be logged from
......@@ -35,6 +42,9 @@ class WandbLoggerHook(LoggerHook):
``out_suffix`` will be uploaded to wandb.
Default: ('.log.json', '.log', '.py').
`New in version 1.4.3.`
.. _wandb:
https://docs.wandb.ai
"""
def __init__(self,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment