Skip to main content

Using W&B with training jobs

Modelbit integrates with Weights & Biases using your W&B API key to enable you to log model training progress to your W&B projects.

To add your W&B API key to Modelbit, go to the Integrations tab of Settings, click the Weights & Biases tile, and add your WANDB_API_KEY. This key will be available in your training jobs' environments as an environment variable so you can automatically authenticate with W&B.

Calling W&B from a training job‚Äč

When creating a training job, call wandb.init(...) as you normally would to start a session, and then call wandb.log(...) to record your training results.

For example:

import wandb, random
from sklearn import linear_model

def example_train_with_wandb():
# initialize W&B
"learning_rate": 0.02,
"architecture": "CNN",

# Do your training and log the results to W&B
lm = linear_model.LinearRegression()[[random.random()], [random.random()]], [random.random(), random.random()])
wandb.log({"acc": 0.5, "loss": 0.2})
return lm

# And run the code to make sure it works

Then deploy your training job to Modelbit:

mb.add_job(example_train_with_wandb, deployment_name="my_deployment")

Running the job will call your wandb.init and authenticate with your WANDB_API_KEY, enabling you to train in Modelbit and analyze training progress in W&B.