Skip to main content

Documentation Index

Fetch the complete documentation index at: https://wb-21fd5541-style-guide-models-integrations-20260527-015516.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

This documentation is for fastai v1. If you use the current version of fastai, see the fastai page.
For fastai v1 scripts, W&B provides a callback that automatically logs model topology, losses, metrics, weights, gradients, sample predictions, and the best trained model.
import wandb
from wandb.fastai import WandbCallback

wandb.init()

learn = cnn_learner(data, model, callback_fns=WandbCallback)
learn.fit(epochs)
You can configure what data to log through the callback constructor.
from functools import partial

learn = cnn_learner(
    data, model, callback_fns=partial(WandbCallback, input_type="images")
)
You can also use WandbCallback only when starting training. In this case, you must instantiate it.
learn.fit(epochs, callbacks=WandbCallback(learn))
You can also pass custom parameters at that stage.
learn.fit(epochs, callbacks=WandbCallback(learn, input_type="images"))

Example code

The following examples show how the integration works:

Options

The WandbCallback() class supports several options:
Keyword argumentDefaultDescription
learnN/AThe fast.ai learner to hook.
save_modelTrueSave the model if it’s improved at each step. It also loads the best model at the end of training.
modeautomin, max, or auto. How to compare the training metric specified in monitor between steps.
monitorNoneTraining metric used to measure performance for saving the best model. None defaults to validation loss.
loggradientsgradients, parameters, all, or None. Losses and metrics are always logged.
input_typeNoneimages or None. Used to display sample predictions.
validation_dataNoneData used for sample predictions if input_type is set.
predictions36Number of predictions to make if input_type is set and validation_data is None.
seed12345Initialize random generator for sample predictions if input_type is set and validation_data is None.