Simple TensorFlow Integration
W&B + TensorFlow 2.x
Use Weights & Biases for machine learning experiment tracking, dataset versioning, and project collaboration.
What this notebook covers
- Easy integration of Weights and Biases with your TensorFlow pipeline for experiment tracking.
- Computing metrics with
keras.metrics - Using
wandb.logto log those metrics in your custom training loop.
The interactive W&B dashboard will look like this:
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.
๐ 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
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.

๐จ Example Gallery
See examples of projects tracked and visualized with W&B in our gallery of examples, Fully Connected โ
๐ Best Practices
- Projects: Log multiple runs to a project to compare them.
wandb.init(project="project-name") - Groups: For multiple processes or cross validation folds, log each process as a runs and group them together.
wandb.init(group='experiment-1') - Tags: Add tags to track your current baseline or production model.
- Notes: Type notes in the table to track the changes between runs.
- Reports: Take quick notes on progress to share with colleagues and make dashboards and snapshots of your ML projects.
๐ค Advanced Setup
- Environment variables: Set API keys in environment variables so you can run training on a managed cluster.
- Offline mode: Use
dryrunmode to train offline and sync results later. - 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.
- Artifacts: Track and version models and datasets in a streamlined way that automatically picks up your pipeline steps as you train models.