How to create wandb reports
Quick answer
Use the
wandb Python package to log metrics and artifacts during training, then create reports by organizing runs and visualizations in the wandb web app. Programmatically, you can log data with wandb.log() and generate reports via the dashboard or export data for custom reports.PREREQUISITES
Python 3.8+pip install wandbWeights & Biases account (free tier available)wandb API key configured via <code>wandb login</code> or environment variable
Setup
Install the wandb package and authenticate your account to enable logging and report creation.
pip install wandb
wandb login output
wandb: Currently logged in as: your_username (use `wandb login --relogin` to force relogin)
Step by step
Log metrics and artifacts during your ML experiment, then create a report in the wandb web interface by grouping runs and adding visualizations.
import wandb
# Initialize a new run
wandb.init(project="my-project", entity="my-entity")
# Log metrics in a loop or training step
for epoch in range(3):
loss = 0.1 * (3 - epoch) # example loss
accuracy = 0.8 + 0.05 * epoch
wandb.log({"epoch": epoch, "loss": loss, "accuracy": accuracy})
# Finish the run
wandb.finish() output
wandb: Tracking run with wandb version 0.15.0 wandb: Run URL: https://wandb.ai/your_entity/my-project/runs/run_id Logging metrics for epochs 0 to 2...
Common variations
You can create reports directly in the wandb web app by selecting runs and adding panels like line charts, tables, and media. For automation, use the wandb.Api() to fetch run data and generate custom reports programmatically.
import wandb
api = wandb.Api()
runs = api.runs("your_entity/my-project")
for run in runs:
print(f"Run: {run.name}, Accuracy: {run.summary.get('accuracy')}") output
Run: run-20260401_1234, Accuracy: 0.9 Run: run-20260402_5678, Accuracy: 0.85
Troubleshooting
- If you see
wandb: ERROR API key not found, runwandb loginor setWANDB_API_KEYenvironment variable. - If runs do not appear in the dashboard, check your internet connection and project name spelling.
- For slow logging, reduce logging frequency or batch metrics.
Key Takeaways
- Use
wandb.init()andwandb.log()to track experiment metrics. - Create and customize reports in the
wandbweb app by grouping runs and adding visualizations. - Automate report generation by accessing run data with
wandb.Api(). - Always authenticate with
wandb loginor environment variables before logging. - Troubleshoot common issues by verifying API keys and project configuration.