If you're using fastai to train your models, W&B has an easy integration using the WandbCallback. Explore the details in interactive docs with examples →

Start Logging with W&B

First install Weights & Biases and log in:

Command Line
!pip install wandb
import wandb
Command Line
pip install wandb
wandb login

Then add the callback to the learner or fit method:

import wandb
from fastai.callback.wandb import *
# start logging a wandb run
# To log only during one training phase, cbs=WandbCallback())
# To log continuously for all training phases
learn = learner(..., cbs=WandbCallback())

If you use version 1 of Fastai, refer to the Fastai v1 docs.

WandbCallback Arguments

WandbCallback accepts the following arguments:




"gradients" (default), "parameters", "all" or None. Losses & metrics are always logged.


whether we want to log prediction samples (default to True).


whether we want to log our model (default to True). This also requires SaveModelCallback.


  • False (default)

  • True will log folder referenced by learn.dls.path.

  • a path can be defined explicitly to reference which folder to log.

Note: subfolder "models" is always ignored.


name of logged dataset (default to folder name).


DataLoaders containing items used for prediction samples (default to random items from learn.dls.valid.


number of logged predictions (default to 36).


used for defining random samples.

For custom workflows, you can manually log your datasets and models:

  • log_dataset(path, name=None, medata={})

  • log_model(path, name=None, metadata={})

Note: any subfolder "models" will be ignored.

Data Visualization with W&B Tables

Use W&B Tables to log, query, and analyze your data. You can think of a W&B Table as a DataFrame that you can interact with inside W&B. Tables support rich media types, primitive and numeric types, as well as nested lists and dictionaries.

This pseudo-code shows you how to log images, along with their ground truth and predicted class, to W&B Tables:

# Create a new W&B Run
# Create a W&B Table
my_table = wandb.Table(columns=["id", "image", "labels", "prediction"])
# Get your image data and make predictions
image_tensors, labels = get_mnist_data()
predictions = model(image_tensors)
# Add your image data and predictions to the W&B Table
for idx, im in enumerate(image_tensors):
my_table.add_data(idx, wandb.Image(im), labels[idx], predictions[id])
# Log your Table to W&B
wandb.log({"mnist_predictions": my_table})

This is will produce a Table like this:

For more examples of data visualization with W&B Tables, please see the documentation.