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

偶尔善良 提交于 2019-11-29 18:54:30

问题


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 operator defined?

The reason I'm asking this is that I'm getting this error:

No gradients provided for any variable, check your graph for ops that do not support gradients, between variables [ ... list of model variables here ... ] and loss Tensor("Mean:0", dtype=float32).

I'd like to inspect the graph to find out where the gradient tensor flow (pun intended) is broken.


回答1:


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.



来源:https://stackoverflow.com/questions/48391075/is-it-possible-to-visualize-a-tensorflow-graph-without-a-training-op

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!