lightning/docs/source-pytorch/visualize/supported_exp_managers.rst

199 lines
6.2 KiB
ReStructuredText
Raw Normal View History

docs refactor 3/n (#12795) * updated titles + css * updated titles + css * levels structure * levels structure * levels structure * adding level indexes * finished intro guide layout * finished intro guide layout * general titles * general titles * added movie * added movie * finished 15 mins * levels * added core levels * added core levels * fixed api reference on the left * gpu guides * gpu guides * gpu guides * gpu guides * precision * hpu guide * added ipu * added ipu * added ipu * added ckpt docs * finished basic logging * intermediate * intermediate * intermediate * fixed * fixed margins * fixed margins * fixed margins * fixed margins * fixed margins * fixed margins * fixed margins * fixed margins * fixed margins * added logger stuff * added logger stuff * added logger stuff * added logger stuff * added logger stuff * ic * added inconsolata * added inconsolata * added inconsolata * added inconsolata * added inconsolata * added inconsolata * added inconsolata * updated menu * added basic cloud docs * added basic cloud docs * added basic cloud docs * added basic cloud docs * ic * ic * ic * ic * ic * ic * ic * ic * ic * ic * ic * ic * added demos folder * added demos folder * added demos folder * added demos folder * added demos folder * added demos folder * twocolumns directive * twocols * twocols * registry * registry * registry * registry * registry * registry * registry * registry * registry * registry * registry * registry * registry * registry * registry * registry * registry * registry * registry * cleaning up * cleaning up * cleaning up * cleaning up * cleaning up * cleaning up * cleaning up * cleaning up * cleaning up * updated titles + css * levels structure * adding level indexes * finished intro guide layout * general titles * added movie * finished 15 mins * levels * added core levels * fixed api reference on the left * gpu guides * precision * hpu guide * added ipu * added ckpt docs * finished basic logging * intermediate * fixed margins * added logger stuff * ic * added inconsolata * updated menu * added basic cloud docs * ic * added demos folder * twocolumns directive * registry * cleaning up * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * deconflict * deconflict * deconflict * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add testsetup sections wherever needed; fix errors in building docs * pre-commit fixes * Fix duplicate label * minor nit with pre-commit * Fix labels * More changes... * require * debug & cli * prec & model & visu * fix references * fix references * fix refs * fix refs - model_parallel * fix references * prune testsetup with global * refs in index * Fix duplicate label errors * Update orphan docs * Update orphan docs * Update orphan docs * fix links * Fix genindex and search index * fix refs * fix refs * Fix index rst related issues * fix refs * inc to rst * Fix links ref * fix more references * fix refs * deconflict * errors * errors * errors * fix refs * fix refs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix warnings * Fix LightningCLI errors * Fix LightningCLI errors * Fix LightningCLI errors * Fix LightningCLI errors * fix doc build * Duplicate Label fix (docs) (#12800) Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com> * ignore typing in demo folder * Ignore demos for mypy Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Kushashwa Ravi Shrimali <kushashwaravishrimali@gmail.com> Co-authored-by: Jirka <jirka.borovec@seznam.cz> Co-authored-by: rohitgr7 <rohitgr1998@gmail.com> Co-authored-by: Kaushik B <kaushikbokka@gmail.com> Co-authored-by: otaj <ota@grid.ai>
2022-04-19 18:15:47 +00:00
Comet.ml
========
To use `Comet.ml <https://www.comet.ml/site/>`_ first install the comet package:
.. code-block:: bash
pip install comet-ml
Configure the logger and pass it to the :class:`~pytorch_lightning.trainer.trainer.Trainer`:
.. code-block:: python
from pytorch_lightning.loggers import CometLogger
comet_logger = CometLogger(api_key="YOUR_COMET_API_KEY")
trainer = Trainer(logger=comet_logger)
Access the comet logger from any function (except the LightningModule *init*) to use its API for tracking advanced artifacts
.. code-block:: python
class LitModel(LightningModule):
def any_lightning_module_function_or_hook(self):
comet = self.logger.experiment
fake_images = torch.Tensor(32, 3, 28, 28)
comet.add_image("generated_images", fake_images, 0)
Here's the full documentation for the :class:`~pytorch_lightning.loggers.CometLogger`.
----
MLflow
======
To use `MLflow <https://mlflow.org/>`_ first install the MLflow package:
.. code-block:: bash
pip install mlflow
Configure the logger and pass it to the :class:`~pytorch_lightning.trainer.trainer.Trainer`:
.. code-block:: python
from pytorch_lightning.loggers import MLFlowLogger
mlf_logger = MLFlowLogger(experiment_name="lightning_logs", tracking_uri="file:./ml-runs")
trainer = Trainer(logger=mlf_logger)
Access the comet logger from any function (except the LightningModule *init*) to use its API for tracking advanced artifacts
.. code-block:: python
class LitModel(LightningModule):
def any_lightning_module_function_or_hook(self):
mlf_logger = self.logger.experiment
fake_images = torch.Tensor(32, 3, 28, 28)
mlf_logger.add_image("generated_images", fake_images, 0)
Here's the full documentation for the :class:`~pytorch_lightning.loggers.MLFlowLogger`.
----
Neptune.ai
==========
To use `Neptune.ai <https://neptune.ai/>`_ first install the neptune package:
.. code-block:: bash
pip install neptune-client
or with conda:
.. code-block:: bash
conda install -c conda-forge neptune-client
Configure the logger and pass it to the :class:`~pytorch_lightning.trainer.trainer.Trainer`:
.. code-block:: python
from pytorch_lightning.loggers import NeptuneLogger
neptune_logger = NeptuneLogger(
api_key="ANONYMOUS", # replace with your own
project="common/pytorch-lightning-integration", # format "<WORKSPACE/PROJECT>"
)
trainer = Trainer(logger=neptune_logger)
Access the neptune logger from any function (except the LightningModule *init*) to use its API for tracking advanced artifacts
.. code-block:: python
class LitModel(LightningModule):
def any_lightning_module_function_or_hook(self):
neptune_logger = self.logger.experiment["your/metadata/structure"]
neptune_logger.log(metadata)
Here's the full documentation for the :class:`~pytorch_lightning.loggers.NeptuneLogger`.
----
Tensorboard
===========
`TensorBoard <https://pytorch.org/docs/stable/tensorboard.html>`_ already comes installed with Lightning. If you removed the install install the following package.
.. code-block:: bash
pip install tensorboard
Configure the logger and pass it to the :class:`~pytorch_lightning.trainer.trainer.Trainer`:
.. code-block:: python
from pytorch_lightning.loggers import TensorBoardLogger
logger = TensorBoardLogger()
trainer = Trainer(logger=logger)
Access the tensorboard logger from any function (except the LightningModule *init*) to use its API for tracking advanced artifacts
.. code-block:: python
class LitModel(LightningModule):
def any_lightning_module_function_or_hook(self):
tensorboard_logger = self.logger.experiment
fake_images = torch.Tensor(32, 3, 28, 28)
tensorboard_logger.add_image("generated_images", fake_images, 0)
Here's the full documentation for the :class:`~pytorch_lightning.loggers.TensorBoardLogger`.
----
Weights and Biases
==================
To use `Weights and Biases <https://docs.wandb.ai/integrations/lightning/>`_ (wandb) first install the wandb package:
.. code-block:: bash
pip install wandb
Configure the logger and pass it to the :class:`~pytorch_lightning.trainer.trainer.Trainer`:
.. code-block:: python
from pytorch_lightning.loggers import WandbLogger
wandb_logger = WandbLogger(project="MNIST", log_model="all")
trainer = Trainer(logger=wandb_logger)
# log gradients and model topology
wandb_logger.watch(model)
Access the wandb logger from any function (except the LightningModule *init*) to use its API for tracking advanced artifacts
.. code-block:: python
class MyModule(LightningModule):
def any_lightning_module_function_or_hook(self):
wandb_logger = self.logger.experiment
fake_images = torch.Tensor(32, 3, 28, 28)
# Option 1
wandb_logger.log({"generated_images": [wandb.Image(fake_images, caption="...")]})
# Option 2 for specifically logging images
wandb_logger.log_image(key="generated_images", images=[fake_images])
Here's the full documentation for the :class:`~pytorch_lightning.loggers.WandbLogger`.
`Demo in Google Colab <http://wandb.me/lightning>`__ with hyperparameter search and model logging.
----
Use multiple exp managers
=========================
To use multiple experiment managers at the same time, pass a list to the *logger* :class:`~pytorch_lightning.trainer.trainer.Trainer` argument.
.. code-block:: python
from pytorch_lightning.loggers import TensorBoardLogger, WandbLogger
logger1 = TensorBoardLogger()
logger2 = WandbLogger()
trainer = Trainer(logger=[logger1, logger2])
Access all loggers from any function (except the LightningModule *init*) to use their APIs for tracking advanced artifacts
.. code-block:: python
class MyModule(LightningModule):
def any_lightning_module_function_or_hook(self):
tensorboard_logger = self.logger.experiment[0]
wandb_logger = self.logger.experiment[1]
fake_images = torch.Tensor(32, 3, 28, 28)
tensorboard_logger.add_image("generated_images", fake_images, 0)
wandb_logger.add_image("generated_images", fake_images, 0)