Python SDK
2 minute read
The W&B Python SDK, accessible at wandb
, enables you to train and fine-tune models, and manage models from experimentation to production.
After performing your training and fine-tuning operations with this SDK, you can use the Public API to query and analyze the data that was logged, and the Reports and Workspaces API to generate a web-publishable report summarizing your work.
Installation and setup
Sign up and create an API key
To authenticate your machine with W&B, you must first generate an API key at https://wandb.ai/authorize.
Install and import packages
Install the W&B library.
pip install wandb
Import W&B Python SDK:
import wandb
# Specify your team entity
entity = "<team_entity>"
# Project that the run is recorded to
project = "my-awesome-project"
with wandb.init(entity=entity, project=project) as run:
run.log({"accuracy": .90, "loss": .10})
Optional extras
The wandb
package supports optional extras for specific features. To install these, use square brackets with the package name.
In zsh (default on macOS), you need to escape the brackets or use quotes, e.g.
pip install "wandb[media]"
Available extras:
wandb[media]
- Media logging support (installs bokeh, moviepy, pillow, plotly)wandb[workspaces]
- Workspaces functionality (installs wandb-workspaces)wandb[sweeps]
- Hyperparameter sweeps supportwandb[launch]
- W&B Launch supportwandb[models]
- Model management featureswandb[aws]
- AWS integrationswandb[azure]
- Azure integrationswandb[gcp]
- Google Cloud Platform integrationswandb[kubeflow]
- Kubeflow integrationswandb[importers]
- Data importerswandb[perf]
- Performance monitoring tools
Installation examples:
# Using quotes (works in all shells)
pip install "wandb[media]"
pip install "wandb[workspaces,media]"
# Escaping brackets (for zsh/bash)
pip install wandb\[media\]
# Install all common extras
pip install "wandb[media,workspaces,sweeps,launch]"
For detailed documentation on each extra, see the Optional Extras Reference.
System Metrics Reference
Metrics automatically logged by W&B.
Feedback
Was this page helpful?
Glad to hear it! If you have more to say, please let us know.
Sorry to hear that. Please tell us how we can improve.