Weights & Biases Fundamentals
What you'll learn: How to initialize W&B, log metrics during training, and view your experiments in an organized dashboard.
The Core Idea
After understanding why experiment tracking matters and what to track, you need a practical tool to do it. Weights & Biases (W&B) is a platform that captures your training metrics, hyperparameters, and system information automatically, then presents everything in an interactive dashboard. Think of it as a laboratory notebook that writes itself while you focus on model development.
The workflow has three simple steps:
1. Initialize W&B
Before training starts, you initialize W&B with your project name and experiment configuration:
import wandb
wandb.init(
project="my-ml-project",
config={
"learning_rate": 0.001,
"batch_size": 32,
"epochs": 10
}
)
This creates a new experiment run and captures your hyperparameters.
2. Log Metrics During Training
Inside your training loop, log whatever matters—loss, accuracy, gradients:
for epoch in range(epochs):
# ... training code ...
train_loss = compute_loss()
wandb.log({
"epoch": epoch,
"train_loss": train_loss,
"learning_rate": optimizer.param_groups[0]['lr']
})
W&B timestamps each log entry automatically, building a complete history.
3. View in Dashboard
Navigate to your W&B dashboard in a browser. You'll see live-updating charts, compare multiple runs side-by-side, and filter by hyperparameters—all without writing visualization code.
Key Takeaway: W&B turns experiment tracking from a manual chore into three lines of code: wandb.init() to start, wandb.log() during training, and automatic dashboard visualization—giving you reproducible, comparable experiments instantly.