【问题标题】:How to show numerical values into tensorboard如何在张量板上显示数值
【发布时间】:2019-10-10 21:17:40
【问题描述】:

我已经实现了一个非常简单的计算图,并且我能够在 tensorboard 上正确地对其进行可视化。

但是,当我运行图表时,我无法看到变量的数值

import tensorflow as tf
a = tf.constant(5, name = 'a')
b = tf.constant(5, name = 'b')
c = a + b
print(a)
print(b)
print(c)

sess = tf.Session()
print(sess.run(c))


with tf.Session() as sess:
    writer = tf.summary.FileWriter('c:/users/gpapari/documents/python', sess.graph)
    writer.close()

也许我错过了什么?

【问题讨论】:

    标签: tensorboard


    【解决方案1】:

    首先,您要创建两个单独的会话。 其次,您需要将要跟踪的值添加到文件写入器。 为此,您必须创建标量。 在示例中,我合并了所有标量,因此如果您想添加更多标量,则不必逐个添加标量

    import tensorflow as tf
    tf.reset_default_graph()
    a = tf.constant(5, name = 'a')
    b = tf.constant(5, name = 'b')
    c = a + b
    
    tf.summary.scalar("c", c)
    merged = tf.summary.merge_all()
    writer = tf.summary.FileWriter('log', tf.get_default_graph())
    with tf.Session() as sess:
        merged_value , _ =sess.run([merged,c])
        writer.add_summary(merged_value, 1)
    
    writer.close()
    

    您也不必为文件写入器定义整个路径。您可以使用相对路径。

    【讨论】:

      猜你喜欢
      • 2021-09-17
      • 2017-08-21
      • 2019-07-26
      • 2018-01-27
      • 2018-05-28
      • 1970-01-01
      • 2018-06-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多