TensorBoard

Next, let's use TensorBoard to visualize the graph. Let's update the program of addition to include the instructions for TensorBoard. Any node can be assigned with a name, so that the node can be rendered with a corresponding name in TensorBoard:

  1. In the following snippet, the names 'a', 'b', and 'c' are assigned to the placeholders:
a = tf.Placeholder(tf.int32, name='a')
b = tf.Placeholder(tf.int32, name='b')
c = tf.add(a, b, name='add')
values = {a: 5, b: 3}
sess = tf.Session()
  1. The values are created and the session is started, as usual. Then, the summary writer is created, with a file path as an argument. The details needed for the summary will be stored in that file, and can be used to display TensorBoard:
summary_writer = tf.summary.FileWriter('/tmp/1', sess.graph)
  1. Run the session, as described in the previous section:
sess.run([c], values)
  1. Once the program has been run, you can go to the Command Prompt and type the following command, with the path of the summary file as an argument, as shown here:
tensorboard --logdir=/tmp/1
  1. Go to the following link:
http://localhost:6006/

You will see the following view:

In subsequent chapters, you will learn about other uses of TensorBoard.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset