Commit 621f49ad authored by Yuxin Wu's avatar Yuxin Wu

remote logging docs

parent 44076798
...@@ -69,6 +69,24 @@ As a result, tensorboard will show not only summaries in the graph, but also you ...@@ -69,6 +69,24 @@ As a result, tensorboard will show not only summaries in the graph, but also you
For example, a precise validation error often needs to be computed manually, outside the TensorFlow graph. For example, a precise validation error often needs to be computed manually, outside the TensorFlow graph.
With a uniform monitor backend, this number will show up in tensorboard as well. With a uniform monitor backend, this number will show up in tensorboard as well.
### Remote Logging
It is also easy to send data to online logging services
for experiment management and reproducibility.
For example, to send logging data to [comet.ml](https://www.comet.ml/), you can use
[CometMLMonitor](../modules/callbacks.html#tensorpack.callbacks.CometMLMonitor).
To send logging data to [WandB](https://www.wandb.com/),
it's even simpler -- you only need to do:
```python
import wandb; wandb.init(..., sync_tensorboard=True)
```
Refer to their documentation for more types of logging you can do by using
their APIs directly: [comet.ml](https://www.comet.ml/docs/python-sdk/Experiment/),
[WandB](https://docs.wandb.com/docs/init.html).
### Textual Logs ### Textual Logs
```python ```python
......
...@@ -550,33 +550,34 @@ class SendMonitorData(MonitorBase): ...@@ -550,33 +550,34 @@ class SendMonitorData(MonitorBase):
class CometMLMonitor(MonitorBase): class CometMLMonitor(MonitorBase):
""" """
Send data to https://www.comet.ml. Send scalar data and the graph to https://www.comet.ml.
Note: Note:
1. comet_ml requires you to `import comet_ml` before importing tensorflow or tensorpack. 1. comet_ml requires you to `import comet_ml` before importing tensorflow or tensorpack.
2. The "automatic output logging" feature of comet_ml will make the training progress bar appear to freeze. 2. The "automatic output logging" feature of comet_ml will make the training progress bar appear to freeze.
Therefore the feature is disabled by default. Therefore the feature is disabled by default.
""" """
def __init__(self, experiment=None, api_key=None, tags=None, **kwargs): def __init__(self, experiment=None, tags=None, **kwargs):
""" """
Args: Args:
experiment (comet_ml.Experiment): if provided, invalidate all other arguments experiment (comet_ml.Experiment): if provided, invalidate all other arguments
api_key (str): your comet.ml API key
tags (list[str]): experiment tags tags (list[str]): experiment tags
kwargs: other arguments passed to :class:`comet_ml.Experiment`. kwargs: arguments used to initialize :class:`comet_ml.Experiment`,
such as project name, API key, etc.
Refer to its documentation for details.
""" """
if experiment is not None: if experiment is not None:
self._exp = experiment self._exp = experiment
assert api_key is None and tags is None and len(kwargs) == 0 assert tags is None and len(kwargs) == 0
else: else:
from comet_ml import Experiment from comet_ml import Experiment
kwargs.setdefault('log_code', True) # though it's not functioning, git patch logging requires it kwargs.setdefault('log_code', True) # though it's not functioning, git patch logging requires it
kwargs.setdefault('auto_output_logging', None) kwargs.setdefault('auto_output_logging', None)
self._exp = Experiment(api_key=api_key, **kwargs) self._exp = Experiment(**kwargs)
if tags is not None: if tags is not None:
self._exp.add_tags(tags) self._exp.add_tags(tags)
self._exp.set_code("Code logging is impossible because there are too many files ...") self._exp.set_code("Code logging is impossible ...")
self._exp.log_dependency('tensorpack', __git_version__) self._exp.log_dependency('tensorpack', __git_version__)
@property @property
...@@ -593,6 +594,17 @@ class CometMLMonitor(MonitorBase): ...@@ -593,6 +594,17 @@ class CometMLMonitor(MonitorBase):
def process_scalar(self, name, val): def process_scalar(self, name, val):
self._exp.log_metric(name, val, step=self.global_step) self._exp.log_metric(name, val, step=self.global_step)
@HIDE_DOC
def process_image(self, name, val):
self._exp.set_step(self.global_step)
for idx, v in enumerate(val):
log_name = "{}_step{}{}".format(
name,
self.global_step,
"_" + str(idx) if len(val) > 1 else "")
self._exp.log_image(v, image_format="jpeg", name=log_name, image_minmax=(0, 255))
def _after_train(self): def _after_train(self):
self._exp.end() self._exp.end()
......
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