How to use TensorBoard with Google Colab

Kuan Hoong, Ph.D
2 min readMay 2, 2019

--

With the recent interest in Artificial Intelligence, Machine Learning and Data Analytics, one of the biggest hurdles for Machine Learning Engineer, Data Scientist and Data Analyst is allocate the right hardware for model training. However, now it is possible for anyone to kick off model training with Google Colab.

Google Colab is a free to use Jupyter notebook, that allows you to use free Nvidia Tesla T4 GPUs and 12 GB of RAM which you can use it up to 12 hours in row.

With TensorFlow 2.0, it is possible to visualize your TensorFlow graph, plot quantitative metrics about the execution of your graph, and show additional data like images that pass through it using TensorBoard directly from within Google Colab.

Installation

#install TensorFlow 2.0 
!pip install tensorflow==2.0.0-alpha0

Initialization

# Load the TensorBoard notebook extension
%load_ext tensorboard.notebook

Add to tf.keras callback

tensorboard_callback = tf.keras.callbacks.TensorBoard(logdir, histogram_freq=1)

Start TensorBoard within the notebook using magics function

%tensorboard — logdir logs

Now you can view your TensorBoard from within Google Colab.

Full source code can be downloaded from here

Reference

--

--

Kuan Hoong, Ph.D

Google Developer Expert (GDE) in Machine Learning, Lead Data Scientist, Malaysia TensorFlow User Group, Malaysia R User Group