Altair + Jupyter Notebooks vs Tensorboard?¶

I am a heavy user of Tensorboard. However, there were many instances where I had to do custom visualizations. I used to visualize on notebooks with matplotlib.

Recently we came across Altair. It's a Python API to create Vega schema for visualizations, and Vega renders interactive charts with d3.

We are thinking of completely switching over to Altair + Notebooks. The two main questions are:

1. Which is better?
2. Which is easier?
In [1]:
from lab.analytics import Analyzer

# a = Analyzer('mnist_loop', '9070f0ba756511ea8c99acde48001122')
a = Analyzer('mnist_loop', '1d3f855874d811eabb9359457a24edc8')

Histograms, Scalars = a.get_indicators('Histogram', 'Scalar')

# print(dir(Scalars))
# print(dir(Histograms))


We can use EventAccumulator to extract data from Tensorboard.

In [2]:
a.tb.load()


I mostly use Tensorboard's Scalars and Distributions tabs.

Scalars can be easily replicated on a notebook.

In [3]:
a.tb.render_scalar_simple(Scalars.train_loss, points=None).interactive()

Out[3]:

Here's a smoothed out version, with variance bands, which I tend to prefer.

In [4]:
a.tb.render_scalar_simple(Scalars.train_loss).interactive()

Out[4]:

The one I use is smoothed out with a view finder. It is so much easier to zoom and go into details of a chart with it.

In [5]:
a.tb.render_scalar(Scalars.train_loss)

Out[5]:

Histograms can also be visualized on a notebook just like with Tensorboard. And you can zoom into them, which you can not do on Tensorboard. You can also have a view finder.

In [6]:
a.tb.render_histogram(Histograms.model_conv1_weight_grad)

Out[6]:

The best thing about visualizing on notebooks is that you can customize. For instance, here's two histograms laid on top of each other. Not a very useful visualization here, but you get the point.

In [7]:
a.tb.render_histogram_multiple([Histograms.model_fc1_weight_grad, Histograms.model_conv1_weight_grad])

Out[7]:

So the visualizations on notebooks are clearly better. What about the ease of use. Tensorboard is definety easier to use. But visualizing with a single line of code isn't so bad.

We haven't used this extensively yet. And we plan on have simple helper functions to create most of the frequently needed visualizations. Like may be a single function to render a collection of charts for all scalars.

Today, we open sourced the code on lab/analytics. And this notebook is available on lab/samples.

This notebook assumes your project was using 🧪 lab. However, you can directly connect to any Tensorboard log directory using AltairTensorBoardAnalytics found in lab/analytics/altair/tb.py.