Is it possible to visualize a tensorflow graph without a training op?

后端 未结 1 1183
被撕碎了的回忆
被撕碎了的回忆 2020-12-30 08:05

I know how to visualize a tensorflow graph after training with tensorboard. Now, is it possible to visualize just the forward part of the graph, i.e., with no training opera

相关标签:
1条回答
  • 2020-12-30 08:53

    Yes, you can visualize any graph. Try this simple script:

    import tensorflow as tf
    
    a = tf.add(1, 2, name="Add_these_numbers")
    b = tf.multiply(a, 3)
    c = tf.add(4, 5, name="And_These_ones")
    d = tf.multiply(c, 6, name="Multiply_these_numbers")
    e = tf.multiply(4, 5, name="B_add")
    f = tf.div(c, 6, name="B_mul")
    g = tf.add(b, d)
    h = tf.multiply(g, f)
    
    with tf.Session() as sess:
        writer = tf.summary.FileWriter("output", sess.graph)
        print(sess.run(h))
        writer.close()
    

    Then run...

    tensorboard --logdir=output
    

    ... and you'll see:

    So you can simply create a session just to write the graph to the FileWriter and not do anything else.

    0 讨论(0)
提交回复
热议问题