WandbLogger¶
- class pytorch_lightning.loggers.WandbLogger(name=None, save_dir=None, offline=False, id=None, anonymous=None, version=None, project=None, log_model=False, experiment=None, prefix='', sync_step=None, **kwargs)[source]¶
Bases:
pytorch_lightning.loggers.base.LightningLoggerBase
Log using Weights and Biases.
Install it with pip:
pip install wandb
- Parameters
save_dir¶ (
Optional
[str
]) – Path where data is saved (wandb dir by default).offline¶ (
Optional
[bool
]) – Run offline (data can be streamed later to wandb servers).id¶ (
Optional
[str
]) – Sets the version, mainly used to resume a previous run.anonymous¶ (
Optional
[bool
]) – Enables or explicitly disables anonymous logging.project¶ (
Optional
[str
]) – The name of the project to which this run will belong.Log checkpoints created by
ModelCheckpoint
as W&B artifacts.if
log_model == 'all'
, checkpoints are logged during training.if
log_model == True
, checkpoints are logged at the end of training, except whensave_top_k
== -1
which also logs every checkpoint during training.if
log_model == False
(default), no checkpoint is logged.
prefix¶ (
Optional
[str
]) – A string to put at the beginning of metric keys.experiment¶ – WandB experiment object. Automatically set when creating a run.
**kwargs¶ – Arguments passed to
wandb.init()
like entity, group, tags, etc.
- Raises
ImportError – If required WandB package is not installed on the device.
MisconfigurationException – If both
log_model
andoffline``is set to ``True
.
Example:
from pytorch_lightning.loggers import WandbLogger from pytorch_lightning import Trainer # instrument experiment with W&B wandb_logger = WandbLogger(project='MNIST', log_model='all') trainer = Trainer(logger=wandb_logger) # log gradients and model topology wandb_logger.watch(model)
See also
Demo in Google Colab with model logging
- after_save_checkpoint(checkpoint_callback)[source]¶
Called after model checkpoint callback saves a new checkpoint
- Parameters
checkpoint_callback¶ – the model checkpoint callback instance
- log_metrics(metrics, step=None)[source]¶
Records metrics. This method logs metrics as as soon as it received them. If you want to aggregate metrics for one specific step, use the
agg_and_log_metrics()
method.
- property experiment: wandb.wandb_run.Run¶
Actual wandb object. To use wandb features in your
LightningModule
do the following.Example:
self.logger.experiment.some_wandb_function()
- property name: Optional[str]¶
Return the experiment name.
- property save_dir: Optional[str]¶
Return the root directory where experiment logs get saved, or None if the logger does not save data locally.
- property version: Optional[str]¶
Return the experiment version.