This page shows how to use the Weights & Biases handler with PyTorch Ignite to automatically log training and validation metrics, model and optimizer parameters, gradients, and model checkpoints during your experiments.
Ignite supports a Weights & Biases handler to log metrics, model and optimizer parameters, and gradients during training and validation. You can also use it to log model checkpoints to the Weights & Biases cloud. This class wraps the W&B Python SDK (wandb), so you can call any wandb function using this wrapper. See examples on how to save model parameters and gradients.
For additional context, see the following resources:
Basic setup
The following example defines a simple convolutional model and data loaders for MNIST. The logging examples that follow use these pieces.
Using WandBLogger in Ignite is a modular process. First, create a WandBLogger object. Next, attach it to a trainer or evaluator to automatically log the metrics. This example shows:
- Logs training loss, attached to the trainer object.
- Logs validation loss, attached to the evaluator.
- Logs optional parameters, such as learning rate.
- Watches the model.
With the logger attached, Ignite streams training and validation metrics, optimizer parameters, and model gradients to your Weights & Biases project automatically.
You can optionally use Ignite EVENTS to log the metrics directly to the terminal.
This code generates these visualizations:
Refer to the Ignite Docs for more details. Last modified on September 30, 2026