TensorBoard is a suite of visualization tools for training deep learning-based models with TensorFlow. The following data can be visualized in TensorBoard:
- Graphs: Computation graphs, device placements, and tensor details
- Scalars: Metrics such as loss, accuracy over iterations
- Images: Used to see the images with corresponding labels
- Audio: Used to listen to audio from training or a generated one
- Distribution: Used to see the distribution of some scalar
- Histograms: Includes histogram of weights and biases
- Projector: Helps visualize the data in 3-dimensional space
- Text: Prints the training text data
- Profile: Sees the hardware resources utilized for training
Tensorboard is installed along with TensorFlow. Go to the python3 prompt and type the following command, similar to the previous example, to start using Tensorboard:
x = tf.placeholder(tf.float32, name='x')
y = tf.placeholder(tf.float32, name='y')
z = tf.add(x, y, name='sum')
Note that an argument name has been provided as an extra parameter to placeholders and operations. These are names that can be seen when we visualize the graph. Now we can write the graph to a specific folder with the following command in TensorBoard:
session = tf.Session()
summary_writer = tf.summary.FileWriter('/tmp/1', session.graph)
This command writes the graph to disk to a particular folder given in the argument. Now Tensorboard can be invoked with the following command:
tensorboard --logdir=/tmp/1
Any directory can be passed as an argument for the logdir option where the files are stored. Go to a browser and paste the following URL to start the visualization to access the TensorBoard:
http://localhost:6006/
The browser should display something like this:
The TensorBoard visualization in the browser window
The graph of addition is displayed with the names given for the placeholders. When we click on them, we can see all the particulars of the tensor for that operation on the right side. Make yourself familiar with the tabs and options. There are several parts in this window. We will learn about them in different chapters. TensorBoard is one the best distinguishing tools in TensorFlow, which makes it better than any other deep learning framework.