Configure Lightning Loggers
Under the framework of PyTorch Lightning, metrics collected by Lightning Trainer are delivered to Lightning Logger objects to produce output, as shown in the Output Results (CL) section. The metrics can include training loss, validation loss, accuracy, etc. If you are not familiar with the metrics involved in continual learning, feel free to get some knowledge from my article A Summary of Continual Learning Metrics.
Each type of logger is designed for one type of output, such as CSV files (by CSVLogger
), TensorBoard logs (by TensorBoardLogger
). We can apply multiple loggers to produce different forms of output at the same time. There are 6 types of built-in loggers in Lightning: CSVLogger
, TensorBoardLogger
, WandbLogger
, NeptuneLogger
, MLFlowLogger
, and CometLogger
.
Lightning loggers is a sub-config under the experiment index config (CL Main). To configure custom loggers, you need to create a YAML file in lightning_loggers/
folder. Unlike optimizer, there is no point to assign distinct loggers to each task. We use uniform loggers setting across all tasks instead. Below shows examples of the Lightning loggers config.
Example
configs
βββ __init__.py
βββ entrance.yaml
βββ experiment
β βββ example_clmain_train.yaml
β βββ ...
βββ lightning_loggers
β βββ default.yaml
β βββ csv
β β βββ default.yaml
β βββ tensorboard
β β βββ default.yaml
...
configs/experiment/example_clmain_train.yaml
defaults:
...
- /lightning_loggers: default.yaml
...
The Lightning loggers config maintain a βmaster panelβ that controls which loggers are applied and which are not. When a logger is not applied, its corresponding field in the master panel is set to null
, or simply remove this field:
configs/lightning_loggers/default.yaml
defaults:
- csv: default.yaml
- tensorboard: default.yaml
- comet: null # or simply remove this field
- wandb: null # or simply remove this field
- neptune: null # or simply remove this field
- mlflow: null # or simply remove this field
Each logger is defined in its own sub-config:
configs/lightning_loggers/csv/default.yaml
_target_: lightning.pytorch.loggers.CSVLogger
save_dir: ${output_dir}
Supported Lightning Loggers & Required Config Fields
All Lightning built-in loggers are supported, including:
- CSV Logger:
CSVLogger
- TensorBoard Logger:
TensorBoardLogger
- WandB Logger:
WandbLogger
- Neptune Logger:
NeptuneLogger
- MLFlow Logger:
MLFlowLogger
- Comet Logger:
CometLogger
The _target_
field of each logger must be assigned to the corresponding class name, such as lightning.pytorch.loggers.CSVLogger
for CSVLogger
. Each logger has its own required fields, which are the same as the arguments of the class specified by _target_
. The arguments of each logger class can be found in PyTorch Lightning documentation.
Note that some loggers also need additional setup, such as installing softwares, setting API keys. Please follow the instructions in the PyTorch Lightning documentation for each logger.