Skip to main content
Try in Colab

What this notebook covers

  • Easy integration of W&B with your TensorFlow pipeline for experiment tracking.
  • Computing metrics with keras.metrics
  • Using wandb.log to log those metrics in your custom training loop.
dashboard
Note: Sections starting with Step are all you need to integrate W&B into existing code. The rest is just a standard MNIST example.

Install, Import, Login

Install W&B

Import W&B and login

Side note: If this is your first time using W&B or you are not logged in, the link that appears after running wandb.login() will take you to sign-up/login page. Signing up is as easy as one click.

Prepare Dataset

Define the Model and the Training Loop

Add wandb.log to your training loop

Run Training

Call wandb.init() to start a run

This lets us know you’re launching an experiment, so we can give it a unique ID and a dashboard. Check out the official documentation

Visualize Results

Click on the run page link above to see your live results.

Sweep 101

Use W&B Sweeps to automate hyperparameter optimization and explore the space of possible models. Check out a Colab notebook demonstrating hyperparameter optimization using W&B Sweeps

Benefits of using W&B Sweeps

  • Quick setup: With just a few lines of code you can run W&B Sweeps.
  • Transparent: We cite all the algorithms we’re using, and our code is open source.
  • Powerful: Our sweeps are completely customizable and configurable. You can launch a sweep across dozens of machines, and it’s just as easy as starting a sweep on your laptop.
Sweep result
Explore examples of projects tracked and visualized with W&B in our gallery of examples, Fully Connected →.

Best Practices

  1. Projects: Log multiple runs to a project to compare them. wandb.init(project="project-name")
  2. Groups: For multiple processes or cross validation folds, log each process as a runs and group them together. wandb.init(group="experiment-1")
  3. Tags: Add tags to track your current baseline or production model.
  4. Notes: Type notes in the table to track the changes between runs.
  5. Reports: Take quick notes on progress to share with colleagues and make dashboards and snapshots of your ML projects.

Advanced Setup

  1. Environment variables: Set API keys in environment variables so you can run training on a managed cluster.
  2. Offline mode
  3. On-prem: Install W&B in a private cloud or air-gapped servers in your own infrastructure. We have local installations for everyone from academics to enterprise teams.
  4. Artifacts: Track and version models and datasets in a streamlined way that automatically picks up your pipeline steps as you train models.