Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use writer.flush() in Tensorboard

In this minimal example, Tensorboard doesn't display my summaries during execution unless I use 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)

When the run is finished the scalar is displayed just fine.
The mnist_with_summaries example displays summaries during execution just fine.
When do I need to use flush()? Is this due to buffers not filling?

like image 355
ohad Avatar asked Oct 11 '16 13:10

ohad


1 Answers

Looks like it's indeed buffers.
When I add some other huge summary (e.g. tf.audio_summary("x", x, 1)) there's no need to flush().

like image 56
ohad Avatar answered Nov 03 '22 07:11

ohad