Configure Lightning Loggers
Under the PyTorch Lightning framework, metrics collected by the 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 learn more from my article: A Summary of Continual Learning Metrics.
Each logger type is designed for a specific output, such as CSV files (by CSVLogger
) or TensorBoard logs (by TensorBoardLogger
). We can apply multiple loggers to produce different forms of output at the same time. Lightning provides the following built-in loggers: CSVLogger
, TensorBoardLogger
, WandbLogger
, NeptuneLogger
, MLFlowLogger
, and CometLogger
.
Lightning loggers are a sub-config under the experiment index config (CL Main). To configure custom loggers, create a YAML file in the lightning_loggers/
folder. Unlike optimizers, there is no point in assigning distinct loggers to each task. We use a uniform logger setting across all tasks. Below is an example 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 maintains a βmaster panelβ that controls which loggers are applied. When a logger is not applied, set its corresponding field in the master panel to null
, or simply remove the 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
To choose a logger, assign the _target_
field to the corresponding class name, such as lightning.pytorch.loggers.CSVLogger
for CSVLogger
. Each logger has its own hyperparameters and configurations, which means it has its own required fields. The required fields are the same as the arguments of the class specified by _target_
. The arguments for each logger class can be found in the PyTorch Lightning documentation.
Note that some loggers require additional setup, such as installing software or setting API keys. Please follow the instructions in the PyTorch Lightning documentation for each logger.