16
Sep
2019
/
Annirudh Prasad, Software Engineer

Anonymous Mode

As an engineer at W&B, nothing would make me happier than supporting the open source ML community with useful tools, which is why our product is and always will be free for open source projects. One of the reasons I joined W&B was the opportunity to contribute back to the community, so I would love for our product to provide value to the innovative projects out there pushing the field forward.

So to all the open source projects out there, I have some good news: you no longer need an account to submit runs to W&B! In the next sections, I’ll walk you through how to instrument a training script in a Jupyter notebook and then go over how to instrument a Python codebase. At the end of each section you’ll have training scripts logging to W&B, giving you access to our product’s experiment tracking and data visualization functionality — all without an account!

Jupyter Notebook

Let’s instrument a script that trains an MNIST classifier written using Keras. We’ll be using this notebook as a reference. Feel free to make a copy of the notebook by selecting File → Save a copy in Drive.

  1. To start, let’s install the requirements by executing the first code cell titled Install Requirements. Once the install finishes, you should see a Restart Runtime button in the output as demonstrated in the picture below. Let’s go ahead and click that button.
  1. Now let’s take a moment to familiarize ourselves with the training script, which can be found under the second code cell, titled Train a Classifier. The most important line here is line 9: run = wandb.init(anonymous="allow"). This line hooks the script up to W&B, and the anonymous="allow" parameter instructs W&B to enable anonymous logging. The rest of the script sets up a CNN classifier that trains on MNIST.
  2. Alright, now we’re ready to start training! Go ahead and execute the code cell with the training script. The training itself will take some time, but you should see a link like the following show up immediately:
  1. Let’s click the ‘open’ link to visit the run page for the training script we just kicked off. On that page, you’ll see charts tracking your model’s accuracy and loss for both the training and validation set that update in real time as your training script progresses.

That’s it! Your training script is set up with W&B, so now any new training jobs you run in your notebook will be automatically tracked.

Python Codebase

If you have a project that uses TensorFlow, PyTorch, Keras, XGBoost or Fast.ai then this is a perfect opportunity to instrument it with W&B. In just a few easy steps, you’ll be able to track every experiment you launch and monitor your models as they train.

  1. To start, we need to add wandb to your project’s requirements: echo "wandb" >> requirements.txt.
  2. Next, we need to add a couple of lines of code to integrate W&B with your framework. Though the details vary from framework to framework, the main idea is the same for each. We need to first import wandb and then invoke wandb.init() to set up W&B. Lastly, we’ll need to plug W&B into your framework of choice as follows:

Keras

import wandb
from wandb.keras import WandbCallback

wandb.init()

model.fit(X_train, y_train,  validation_data=(X_test, y_test),
         callbacks=[WandbCallback()])


PyTorch

import wandb
wandb.init()

# Magic
wandb.watch(model)


TensorFlow

import tensorflow as tf
import wandb

wandb.init()

estimator.train(hooks=[wandb.tensorflow.WandbHook(steps_per_log=1000)])


XGBoost

import wandb
import xgboost as xgb

wandb.init(config=param_list)

bst = xgb.train(param_list, d_train, callbacks=[wandb_callback()])


Fast.ai

import wandb
from wandb.fastai import WandbCallback

wandb.init()

learn = cnn_learner(data,
                   model,
                   callback_fns=WandbCallback)
learn.fit(epochs)


Now you can launch your training script just as you normally would. The first time you run your script after integrating with W&B, you’ll get a prompt like the following:

Once you select the first option your training script will proceed, and W&B will track the run execution for you in the background. Click the run link included in the output and you can monitor the performance of your model in real time.

That’s it! W&B will now automatically track all of your experiments, so you can just focus on building groundbreaking new models.

If you have any questions, please feel free to ask them in our community slack or email us.

Weights & Biases

We're building lightweight, flexible experiment tracking tools for deep learning. Add a couple of lines to your python script, and we'll keep track of your hyperparameters and output metrics, making it easy to compare runs and see the whole history of your progress. Think of us like GitHub for deep learning.

Partner Program

We are building our library of deep learning articles, and we're delighted to feature the work of community members. Contact Carey to learn about opportunities to share your research and insights.

Try our free tools for experiment tracking →