Facebook introduced PyTorch 1.1 with TensorBoard support. Let’s try it out really quickly on Colab’s Jupyter Notebook.
Not need to install anything locally on your development machine. Google’s Colab cames in handy free of charge even with its upgraded Tesla T4 GPU.
Type in the first cell to check the version of PyTorch is at minimal 1.1.0
Then you are going to install the cutting edge TensorBoard build like this.
!pip install -q tb-nightly
The output might remind you to restart the runtime to make the new TensorBoard take effect. You can click through
Runtime -> Restart runtime...
Next, load the TensorBoard notebook extension with this magic line.
After which you can start by exploring the TORCH.UTILS.TENSORBOARD API, these utilities let you log PyTorch models and metrics into a directory for visualization within the TensorBoard UI. Scalars, images, histograms, graphs, and embedding visualizations are all supported for PyTorch models and tensors.
SummaryWriter class is your main entry to log data for consumption and visualization by TensorBoard. Let’s run this official demo for MNIST dataset and ResNet50 model.
You just wrote an image and the model graph data to TensorBoard summary. The writer wrote the output file to “./runs” directory by default.
Let’s run the TensorBoard to visualize them
That’s it, you have it!
Summary and Further reading
This really short tutorial gets you to start with running TensorBoard with latest Pytorch 1.1.0 in a Jupyter Notebook. Keep playing around with other features supported with PyTorch TensorBoard.
Read the official API document here — TORCH.UTILS.TENSORBOARD