Use Tensorboard in Google Colab

Tommy Tao
2 min readJun 24, 2018

Google Colab provides free GPU acceleration for Machine Learning. During neural network training, we wanna see training progress and result. Using Tensorboard is convenient way to visualize the progress. This tutorial will show you how to do so in the most simplest way.

Progress of neural network training

Principle

Run Tensorboard in the background of Google Colab, use ngrok to tunnel traffic to localhost, so that it can be accessed outside Google Colab. Detail of code can be found in this stackoverflow. Credit to Joope 🙏🏻

Feel little bit complicated? Here is a library to do it easier

Installation

pip install tensorboardcolab

Initialization

tbc=TensorBoardColab()

After initialization, TensorBoard link will be shown in Colab Google Juyter output.

Colab Google Juyter output

Done! One line of code can start up TensorBoard in Google Colab, easy, right? :) But how to use it? Read below …

Add to Keras callback

model.fit(x,y,epochs=100000,callbacks=[TensorBoardColabCallback(tbc)])

That is all! Now you can read the progress graph

Oh! Wait, you want more control? Easy, read below …

Save picture to TensorBoard

tbc.save_image(title=”test_title”, image=image)

Save a value to graph of TensorBoard

tbc.save_value(“graph_name”, “line_name”, epoch, value)tbc.save_value(“graph_name2”, “line_name2”, epoch, value2)
.
.
.
tbc.flush_line(line_name)

tbc.flush_line(line_name2)
.
.
tbc.close()

Hope you enjoyed!

Reference

About Me

LinkedIn: https://www.linkedin.com/in/tommy-tao-a5961156/

Twitter: https://twitter.com/tommytao

--

--