是否可以在没有训练操作的情况下可视化张量流图?
Is it possible to visualize a tensorflow graph without a training op?
我知道如何在使用 tensorboard 训练后可视化张量流图。现在,是否可以仅可视化图形的前部,即没有定义训练运算符?
我问这个问题的原因是我遇到了这个错误:
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).
我想检查图表以找出梯度张量流(双关语意)被破坏的地方。
是的,您可以可视化任何 图表。试试这个简单的脚本:
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
,而不做任何其他事情。
我知道如何在使用 tensorboard 训练后可视化张量流图。现在,是否可以仅可视化图形的前部,即没有定义训练运算符?
我问这个问题的原因是我遇到了这个错误:
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).
我想检查图表以找出梯度张量流(双关语意)被破坏的地方。
是的,您可以可视化任何 图表。试试这个简单的脚本:
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
,而不做任何其他事情。