Fast.ai

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 →

First install Weights & Biases and log in:

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
wandb.init(project='my_project')
# To log only during one training phase
learn.fit(..., 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 accepts the following arguments:

Args

Description

log

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

log_preds

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

log_model

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

log_dataset

  • 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.

dataset_name

name of logged dataset (default to folder name).

valid_dl

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

n_preds

number of logged predictions (default to 36).

seed

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.

Examples