TensorBoard is part of the TensorFlow suite. Yes, TensorFlow is actually a suite: it has TensorFlow (the module), TensorBoard and TensorServing.

TensorBoard is the tool that comes with TensorFlow. It reads files your training writes and shows them in your browser: the graph, the loss over time, histograms of the weights and even sample images.

Without it you are training blind.

TensorBoard is graph vizualization software. You can make nice visualizations with this.

If tensorflow runs some operations, it creates event files. TensorBoard can convert these event files to graphs.

install tensorboard run

TensorBoard comes with TensorFlow by default. But it may be that it doesn’t run automatically.
To show its location:

pip3 show tensorboard
pip show tensorboard

If the command tensorboard doesn’t do anything, setup an alias in the shell

alias tensorboard='python3 PATH/tensorboard/main.py'

Where PATH is the location shown by ‘pip show tensorboard’.
In my case:

/home/linux/.local/lib/python3.5/site-packages/

tensorboard

TensorBoard can create nice graphs from event files. You can create an event file from within your existing code. Add one line of code to the program you made before:

import tensorflow as tf

a = tf.add(2, 6)

with tf.Session() as ses:
writer = tf.summary.FileWriter('./graphs', ses.graph)
print(ses.run(a))

Save as tensor2.py

Then run the commands:

python tensor2.py
tensorboard --logdir="./graphs"

It will then bootup a server:

TensorBoard 1.9.0 at http://linux:6006 (Press CTRL+C to quit)

In any case that’s localhost, so http://127.0.0.1:6006

It will look something like this:

tensorboard

The TensorBoard screen should show up in your browser. Open your browser, it won’t popup automatically.

Writing and reading

  • Open a file with tf.summary.create_file_writer('logs').
  • Use with writer.as_default(): so you do not have to pass the writer around.
  • tf.summary.scalar('loss', loss, step=i) writes one number over time.
  • tf.summary.histogram('weights', w) writes the distribution of a tensor.
  • tf.summary.image('input', image, step=i) writes a picture.
  • tf.summary.graph(tf.compat.v1.get_default_graph()) writes the graph.

Then start TensorBoard and open the logs folder:

tensorboard --logdir logs

It prints a link like http://localhost:6006. Open it and pick Scalars or Graph from the menu.

Reading helps, writing fixes it. PyChallenge has exercises on this and you can try them right now.