是否可以在无需培训的情况下可视化张量流图? [英] Is it possible to visualize a tensorflow graph without a training op?
问题描述
我知道在使用张量板训练后如何可视化张量流图.现在,是否可以只显示图形的前部,即没有定义训练运算符?
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.
推荐答案
是的,您可以可视化 any 图.试试这个简单的脚本:
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()
然后运行...
tensorboard --logdir=output
...,您会看到:
因此,您只需创建一个会话即可,只需将图形写入FileWriter
,而无需执行其他任何操作.
So you can simply create a session just to write the graph to the FileWriter
and not do anything else.
这篇关于是否可以在无需培训的情况下可视化张量流图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!