何时在Tensorboard中使用writer.flush()

时间:2016-10-11 13:26:02

标签: tensorflow tensorboard

在这个最小的例子中,Tensorboard在执行期间不显示我的摘要,除非我使用writer.flush()

from time import sleep
import tensorflow as tf
import numpy as np


x = tf.placeholder("float", [None, 2])

mean = tf.reduce_mean(x)
tf.scalar_summary("mean", mean)

init = tf.initialize_all_variables()

merged = tf.merge_all_summaries()

with tf.Session() as sess:
    sess.run(init)

    summary_writer = tf.train.SummaryWriter('/var/tmp/tf_log', graph=sess.graph)

    x_iter = np.random.rand(2,2)
    for ind in range(30):
        merged_summary = sess.run(merged, feed_dict={x: x_iter})
        summary_writer.add_summary(merged_summary, ind)
        summary_writer.flush()

        x_iter += 1.0
        sleep(1)

当跑步结束时,标量显示得很好 mnist_with_summaries示例在执行期间显示摘要就好了 我什么时候需要使用flush()?这是由于缓冲区没有填充吗?

1 个答案:

答案 0 :(得分:3)

看起来确实是缓冲区 当我添加其他一些巨大的摘要(例如tf.audio_summary("x", x, 1))时,不需要flush()