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
.
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
import os
import modelbit
os.environ["WANDB_API_KEY"] = modelbit.get_secret("WANDB_API_KEY")
def example_train_with_wandb():
# initialize W&B
wandb.init(
project="my-awesome-project",
config={
"learning_rate": 0.02,
"architecture": "CNN",
}
)
# Do your training and log the results to W&B
lm = linear_model.LinearRegression()
lm.fit([[random.random()], [random.random()]], [random.random(), random.random()])
wandb.log({"acc": 0.5, "loss": 0.2})
wandb.finish()
return lm
# And run the code to make sure it works
example_train_with_wandb()
Run the training job
Send this training function to Modelbit with mb.add_job
or using Git.
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.