Is there any way to use TensorBoard when training a TensorFlow model on Google Colab?
Here's an easier way to do the same ngrok tunneling method on Google Colab.
!pip install tensorboardcolab
then,
from tensorboardcolab import TensorBoardColab, TensorBoardColabCallback
tbc=TensorBoardColab()
Assuming you are using Keras:
model.fit(......,callbacks=[TensorBoardColabCallback(tbc)])
You can read the original post here.
To join @solver149 answer, here is a simple example how to use TensorBoard in google colab
a = tf.constant(3.0, dtype=tf.float32)
b = tf.constant(4.0)
total = a + b
!pip install tensorboardcolab # to install tensorboeadcolab if it does not it not exist
==> Result in my case :
Requirement already satisfied: tensorboardcolab in /usr/local/lib/python3.6/dist-packages (0.0.22)
Fist of all import TensorBoard from tensorboaedcolab (you can use import*
to import everything at once), then create your tensorboeardcolab after that attach a writer to it like this :
from tensorboardcolab import *
tbc = TensorBoardColab() # To create a tensorboardcolab object it will automatically creat a link
writer = tbc.get_writer() # To create a FileWriter
writer.add_graph(tf.get_default_graph()) # add the graph
writer.flush()
==> Result
Using TensorFlow backend.
Wait for 8 seconds...
TensorBoard link:
http://cf426c39.ngrok.io
This example was token from TF guide : TensorBoard.
TensorBoard works with Google Colab and TensorFlow 2.0
!pip install tensorflow==2.0.0-alpha0
%load_ext tensorboard.notebook
Many of the answers here are now obsolete. So will be mine I'm sure in a few weeks. But at the time of this writing all I had to do is run these lines of code from colab. And tensorboard opened up just fine.
%load_ext tensorboard
%tensorboard --logdir logs
I am using tensorflow==1.15.
%load_ext tensorboard
%tensorboard --logdir /content/logs
works for me.
/content/logs
is the path of my logs in google drive.
According to the documentation all you need to do is this:
%load_ext tensorboard
!rm -rf ./logs/ #to delete previous runs
%tensorboard --logdir logs/
tensorboard = TensorBoard(log_dir="./logs")
And just call it in the fit method:
model.fit(X_train, y_train, epochs = 1000,
callbacks=[tensorboard], validation_data=(X_test, y_test))
And that should give you something like this: