Search code examples
pythontensorflowtensorboard

Tensorboard on Windows reports "No scalar data was found"


Doing the tutorial off the TensorFlow community Git repository at https://github.com/BinRoot/TensorFlow-Book/blob/master/ch02_basics/Concept08_TensorBoard.ipynb

When running tensorboard --logdir=path/to/logs in the command panel I get, Starting TensorBoard b'47' at http://0.0.0.0:6006.

Then when I go to explorer and look at the board it brings up, No scalar data was found. I am not sure what I am missing.

Copy of the code as I have it in my Python script:

import tensorflow as tf
import numpy as np

raw_data = np.random.normal(10, 1, 100)

alpha = tf.constant(0.05)
curr_value = tf.placeholder(tf.float32)
prev_avg = tf.Variable(0.)

update_avg = alpha * curr_value + (1 - alpha) * prev_avg

avg_hist = tf.summary.scalar("running_average", update_avg)
value_hist = tf.summary.scalar("incoming_values", curr_value)

merged = tf.summary.merge_all()
writer = tf.summary.FileWriter("./logs")

init = tf.global_variables_initializer()

with tf.Session() as sess:
    sess.run(init)
    for i in range(len(raw_data)):
        summary_str, curr_avg = sess.run([merged, update_avg], feed_dict=
{curr_value: raw_data[i]})
        sess.run(tf.assign(prev_avg, curr_avg))
        print(raw_data[i], curr_avg)
        writer.add_summary(summary_str, i)

Solution

  • Tensorboard has a known issue with paths on windows.

    To summarize, tensorboard's --logdir can take a path, such as --logdir=/my/path, but the user can also specify a name to one or several comma separated paths, such as --logdir=foo:/my/path1,bar:/my/path2.

    The problem is that this naming system does not play nice with Windows' drive name. When specifying --logdir=C:\my\path, how does tensorboard knows C: is a drive name and not a path name? Well, it doesn't, and you end up with a nice tensorboard webpage showing no summaries at all.

    The solution is either to omit the drive letter and make sure you start from the correct drive, or somewhat more robustly, to always provide a path name, as in --logdir foo:"C:\My path\to my logs".

    UPDATE

    Since TF 1.5, tensorboard learned to recognize Windows drives and do not treat them as labels anymore.