Notebooks
W
Weights and Biases
Simple TensorFlow Integration

Simple TensorFlow Integration

tensorflowwandb-examplescolabs

Open In Colab

Weights & Biases

W&B + TensorFlow 2.x

Use Weights & Biases for machine learning experiment tracking, dataset versioning, and project collaboration.

Weights & Biases

What this notebook covers

  • Easy integration of Weights and Biases with your TensorFlow pipeline for experiment tracking.
  • Computing metrics with keras.metrics
  • Using wandb.log to log those metrics in your custom training loop.

The interactive W&B dashboard will look like this:

Screenshot (9).png

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

Step 0๏ธโƒฃ: Install W&B

[ ]

Step 1๏ธโƒฃ: 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

[ ]
[ ]
[ ]

Step 2๏ธโƒฃ: Add wandb.log to your training loop

[ ]

๐Ÿ‘Ÿ Run Training

Step 3๏ธโƒฃ: 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 here โ†’\rightarrow

[ ]

๐Ÿ‘€ Visualize Results

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

Or run the cell below to see an example dashboard rendered inside this notebook using the %wandb magic:

[ ]

๐Ÿงน Sweep 101

Use Weights & Biases Sweeps to automate hyperparameter optimization and explore the space of possible models.

Check out Hyperparameter Optimization in TensorFlow using W&B Sweeps โ†’\rightarrow

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

๐ŸŽจ Example Gallery

See 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: Use dryrun mode to train offline and sync results later.
  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.