2020-02-11 04:55:22 +00:00
|
|
|
Experiment Logging
|
|
|
|
===================
|
|
|
|
|
|
|
|
Comet.ml
|
2020-02-11 12:41:15 +00:00
|
|
|
^^^^^^^^
|
2020-02-11 04:55:22 +00:00
|
|
|
|
|
|
|
`Comet.ml <https://www.comet.ml/site/>`_ is a third-party logger.
|
|
|
|
To use CometLogger as your logger do the following.
|
|
|
|
|
2020-03-15 23:46:39 +00:00
|
|
|
.. seealso:: :ref:`comet` docs.
|
2020-02-11 04:55:22 +00:00
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
2020-03-06 09:21:45 +00:00
|
|
|
from pytorch_lightning.loggers import CometLogger
|
2020-02-11 04:55:22 +00:00
|
|
|
|
|
|
|
comet_logger = CometLogger(
|
|
|
|
api_key=os.environ["COMET_KEY"],
|
|
|
|
workspace=os.environ["COMET_WORKSPACE"], # Optional
|
|
|
|
project_name="default_project", # Optional
|
|
|
|
rest_api_key=os.environ["COMET_REST_KEY"], # Optional
|
|
|
|
experiment_name="default" # Optional
|
|
|
|
)
|
|
|
|
trainer = Trainer(logger=comet_logger)
|
|
|
|
|
2020-02-27 20:54:06 +00:00
|
|
|
The CometLogger is available anywhere except ``__init__`` in your LightningModule
|
2020-02-11 04:55:22 +00:00
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
class MyModule(pl.LightningModule):
|
|
|
|
|
2020-02-27 20:54:06 +00:00
|
|
|
def any_lightning_module_function_or_hook(self, ...):
|
2020-02-11 04:55:22 +00:00
|
|
|
some_img = fake_image()
|
|
|
|
self.logger.experiment.add_image('generated_images', some_img, 0)
|
|
|
|
|
|
|
|
Neptune.ai
|
|
|
|
^^^^^^^^^^
|
|
|
|
|
|
|
|
`Neptune.ai <https://neptune.ai/>`_ is a third-party logger.
|
|
|
|
To use Neptune.ai as your logger do the following.
|
|
|
|
|
2020-03-15 23:46:39 +00:00
|
|
|
.. seealso:: :ref:`neptune` docs.
|
2020-02-11 04:55:22 +00:00
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
from pytorch_lightning.loggers import NeptuneLogger
|
|
|
|
|
|
|
|
neptune_logger = NeptuneLogger(
|
|
|
|
project_name="USER_NAME/PROJECT_NAME",
|
|
|
|
experiment_name="default", # Optional,
|
|
|
|
params={"max_epochs": 10}, # Optional,
|
|
|
|
tags=["pytorch-lightning","mlp"] # Optional,
|
|
|
|
)
|
|
|
|
trainer = Trainer(logger=neptune_logger)
|
|
|
|
|
2020-02-27 20:54:06 +00:00
|
|
|
The Neptune.ai is available anywhere except ``__init__`` in your LightningModule
|
2020-02-11 04:55:22 +00:00
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
class MyModule(pl.LightningModule):
|
|
|
|
|
2020-02-27 20:54:06 +00:00
|
|
|
def any_lightning_module_function_or_hook(self, ...):
|
2020-02-11 04:55:22 +00:00
|
|
|
some_img = fake_image()
|
|
|
|
self.logger.experiment.add_image('generated_images', some_img, 0)
|
|
|
|
|
2020-03-14 17:02:14 +00:00
|
|
|
allegro.ai TRAINS
|
|
|
|
^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
`allegro.ai <https://github.com/allegroai/trains/>`_ is a third-party logger.
|
|
|
|
To use TRAINS as your logger do the following.
|
|
|
|
|
2020-03-15 23:46:39 +00:00
|
|
|
.. seealso:: :ref:`trains` docs.
|
2020-03-14 17:02:14 +00:00
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
from pytorch_lightning.loggers import TrainsLogger
|
|
|
|
|
|
|
|
trains_logger = TrainsLogger(
|
|
|
|
project_name="examples",
|
|
|
|
task_name="pytorch lightning test"
|
|
|
|
)
|
|
|
|
trainer = Trainer(logger=trains_logger)
|
|
|
|
|
|
|
|
The TrainsLogger is available anywhere in your LightningModule
|
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
class MyModule(pl.LightningModule):
|
|
|
|
|
|
|
|
def __init__(self, ...):
|
|
|
|
some_img = fake_image()
|
|
|
|
self.logger.log_image('debug', 'generated_image_0', some_img, 0)
|
|
|
|
|
2020-02-11 04:55:22 +00:00
|
|
|
Tensorboard
|
2020-02-11 12:41:15 +00:00
|
|
|
^^^^^^^^^^^
|
2020-02-11 04:55:22 +00:00
|
|
|
|
|
|
|
To use `Tensorboard <https://pytorch.org/docs/stable/tensorboard.html>`_ as your logger do the following.
|
|
|
|
|
2020-03-15 23:46:39 +00:00
|
|
|
.. seealso:: TensorBoardLogger :ref:`tf-logger`
|
2020-02-11 04:55:22 +00:00
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
from pytorch_lightning.loggers import TensorBoardLogger
|
|
|
|
|
|
|
|
logger = TensorBoardLogger("tb_logs", name="my_model")
|
|
|
|
trainer = Trainer(logger=logger)
|
|
|
|
|
2020-02-27 20:54:06 +00:00
|
|
|
The TensorBoardLogger is available anywhere except ``__init__`` in your LightningModule
|
2020-02-11 04:55:22 +00:00
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
class MyModule(pl.LightningModule):
|
|
|
|
|
2020-02-27 20:54:06 +00:00
|
|
|
def any_lightning_module_function_or_hook(self, ...):
|
2020-02-11 04:55:22 +00:00
|
|
|
some_img = fake_image()
|
|
|
|
self.logger.experiment.add_image('generated_images', some_img, 0)
|
|
|
|
|
|
|
|
|
|
|
|
Test Tube
|
2020-02-11 12:41:15 +00:00
|
|
|
^^^^^^^^^
|
2020-02-11 04:55:22 +00:00
|
|
|
|
|
|
|
`Test Tube <https://github.com/williamFalcon/test-tube>`_ is a tensorboard logger but with nicer file structure.
|
|
|
|
To use TestTube as your logger do the following.
|
|
|
|
|
2020-03-15 23:46:39 +00:00
|
|
|
.. seealso:: TestTube :ref:`testTube`
|
2020-02-11 04:55:22 +00:00
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
from pytorch_lightning.loggers import TestTubeLogger
|
|
|
|
|
|
|
|
logger = TestTubeLogger("tb_logs", name="my_model")
|
|
|
|
trainer = Trainer(logger=logger)
|
|
|
|
|
2020-02-27 20:54:06 +00:00
|
|
|
The TestTubeLogger is available anywhere except ``__init__`` in your LightningModule
|
2020-02-11 04:55:22 +00:00
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
class MyModule(pl.LightningModule):
|
|
|
|
|
2020-02-27 20:54:06 +00:00
|
|
|
def any_lightning_module_function_or_hook(self, ...):
|
2020-02-11 04:55:22 +00:00
|
|
|
some_img = fake_image()
|
|
|
|
self.logger.experiment.add_image('generated_images', some_img, 0)
|
|
|
|
|
|
|
|
Wandb
|
2020-02-11 12:41:15 +00:00
|
|
|
^^^^^
|
2020-02-11 04:55:22 +00:00
|
|
|
|
|
|
|
`Wandb <https://www.wandb.com/>`_ is a third-party logger.
|
|
|
|
To use Wandb as your logger do the following.
|
|
|
|
|
2020-03-15 23:46:39 +00:00
|
|
|
.. seealso:: :ref:`wandb` docs
|
2020-02-11 04:55:22 +00:00
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
from pytorch_lightning.loggers import WandbLogger
|
|
|
|
|
|
|
|
wandb_logger = WandbLogger()
|
|
|
|
trainer = Trainer(logger=wandb_logger)
|
|
|
|
|
2020-02-27 20:54:06 +00:00
|
|
|
The Wandb logger is available anywhere except ``__init__`` in your LightningModule
|
2020-02-11 04:55:22 +00:00
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
class MyModule(pl.LightningModule):
|
|
|
|
|
2020-02-27 20:54:06 +00:00
|
|
|
def any_lightning_module_function_or_hook(self, ...):
|
2020-02-11 04:55:22 +00:00
|
|
|
some_img = fake_image()
|
|
|
|
self.logger.experiment.add_image('generated_images', some_img, 0)
|
|
|
|
|
2020-02-25 19:52:39 +00:00
|
|
|
|
|
|
|
Multiple Loggers
|
|
|
|
^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
PyTorch-Lightning supports use of multiple loggers, just pass a list to the `Trainer`.
|
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
from pytorch_lightning.loggers import TensorBoardLogger, TestTubeLogger
|
|
|
|
|
|
|
|
logger1 = TensorBoardLogger("tb_logs", name="my_model")
|
|
|
|
logger2 = TestTubeLogger("tt_logs", name="my_model")
|
|
|
|
trainer = Trainer(logger=[logger1, logger2])
|
|
|
|
|
2020-02-27 20:54:06 +00:00
|
|
|
The loggers are available as a list anywhere except ``__init__`` in your LightningModule
|
2020-02-25 19:52:39 +00:00
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
class MyModule(pl.LightningModule):
|
|
|
|
|
2020-02-27 20:54:06 +00:00
|
|
|
def any_lightning_module_function_or_hook(self, ...):
|
2020-02-25 19:52:39 +00:00
|
|
|
some_img = fake_image()
|
2020-02-27 20:54:06 +00:00
|
|
|
|
|
|
|
# Option 1
|
2020-02-25 19:52:39 +00:00
|
|
|
self.logger.experiment[0].add_image('generated_images', some_img, 0)
|
2020-02-27 20:54:06 +00:00
|
|
|
|
|
|
|
# Option 2
|
|
|
|
self.logger[0].experiment.add_image('generated_images', some_img, 0)
|