Search code examples
pythontensorflowtensorboard

Why tensorboard does not show the graph?


This is a simple code which creates a single node in the computational graph using tensorflow:

import tensorflow as tf
tf.constant(5)
writer = tf.summary.FileWriter('./path', tf.Session().graph)
writer.close()

When I try to visualize this graph using tensorboard, no graph is shown. This is my terminal code:

tensorboard --logdir=[![enter image description here][1]][1]path --port 6006

What is wrong with my codes?


Solution

  • There is no computational graph in your code. There is just alone vertex that does nothing. Create a graph with at least one op:

    import tensorflow as tf
    a = tf.constant(5)
    b = tf.constant(5)
    c = a + b
    
    with tf.Session() as sess:
        writer = tf.summary.FileWriter('path', sess.graph)
        writer.close()
    

    and you will see it