在没有训练操作的情况下,能可视化张量流图吗?

2024-10-02 06:32:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我知道如何在使用tensorboard训练后可视化tensorflow图。现在,是否可以仅可视化图形的前半部分,即不定义训练运算符?

我之所以这么问是因为我犯了个错误:

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).

我想检查这个图,找出梯度张量流(双关语)在哪里被破坏。


Tags: no图形for定义可视化tensorflow错误any
1条回答
网友
1楼 · 发布于 2024-10-02 06:32:16

是的,您可以可视化任何图形。试试这个简单的脚本:

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

。。。你会看到:

tensorboard

因此,您只需创建一个会话就可以将图形写入FileWriter,而不必执行任何其他操作。

相关问题 更多 >

    热门问题