Search code examples
tensorboard

Why does this code not produce a log that is readable by tensorboard?


Using Python (3.6) / Jupyter (5.7.8) on WIndows 10 .. I have tried many simple examples of trying to generate log files for tensorboard including this:

logs_base_dir = "C:/tensorlogs"
%load_ext tensorboard.notebook
# %tensorboard --port=6006 --logdir {logs_base_dir}

os.makedirs(logs_base_dir, exist_ok=True)
%tensorboard --port=6008 --logdir {logs_base_dir}

a = tf.constant([10])
b = tf.constant([20])
c = tf.add(a,b)

with tf.Session() as sess:
    # or creating the writer inside the session
    writer = tf.summary.FileWriter(logs_base_dir, sess.graph)
    print(sess.run(c))

writer.close()
sess.close()

I see a logfile created in the 'C:/tensorlogs' folder called: 'events.out.tfevents.1563219145.DESKTOP-5HG12IB'

I can also see tensorboard running in a separate browser window. On the 'scaler' page it lists the correct source folder 'C:/tensorflow'.

But tensorboard indicate that no session is running.

What am I doing wrong? Is there any way of checking that log file to see if it is legitimate?

Browser window showing tensorboard running - but not finding log file

(Also shows nothing on graph window)

Update: I tried to run tensorboard from the command line using:

tensorboard --logdir='c:/tensorlogs' --port=6006

It has the same behaviour .. page shows in browser with no data. Terminal displays the following messages:

TensorBoard 1.13.1 at http://DESKTOP-5HG12IB:6006 (Press CTRL+C to quit) I0716 06:56:05.074265 3780 _internal.py:122] ::1 - - [16/Jul/2019 06:56:05] "[37mGET /data/experiments HTTP/1.1[0m" 200 - I0716 06:56:05.086722 8400 _internal.py:122] ::1 - - [16/Jul/2019 06:56:05] "[37mGET /data/environment HTTP/1.1[0m" 200 - I0716 06:56:05.088708 3780 _internal.py:122] ::1 - - [16/Jul/2019 06:56:05] "[37mGET /data/plugins_listing HTTP/1.1[0m" 200 - I0716 06:56:05.090195 8400 _internal.py:122] ::1 - - [16/Jul/2019 06:56:05] "[37mGET /data/runs HTTP/1.1[0m" 200 - I0716 06:56:05.099200 3780 _internal.py:122] ::1 - - [16/Jul/2019 06:56:05] "[37mGET /data/plugin/scalars/tags HTTP/1.1[0m" 200 - I0716 06:56:13.198990 3780 _internal.py:122] ::1 - - [16/Jul/2019 06:56:13] "[37mGET / HTTP/1.1[0m" 200 - I0716 06:56:14.169489 3780 _internal.py:122] ::1 - - [16/Jul/2019 06:56:14] "[37mGET /tf-interactive-inference-dashboard/editedexample.png HTTP/1.1[0m" 200 - I0716 06:56:14.170989 8400 _internal.py:122] ::1 - - [16/Jul/2019 06:56:14] "[37mGET /tf-interactive-inference-dashboard/distance.png HTTP/1.1[0m" 200 - I0716 06:56:14.174491 3780 _internal.py:122] ::1 - - [16/Jul/2019 06:56:14] "[37mGET /tf-interactive-inference-dashboard/pdplots.png HTTP/1.1[0m" 200 - I0716 06:56:14.176498 12340 _internal.py:122] ::1 - - [16/Jul/2019 06:56:14] "[37mGET /tf-interactive-inference-dashboard/explorecounterfactuals.png HTTP/1.1[0m" 200 - I0716 06:56:14.281985 12876 _internal.py:122] ::1 - - [16/Jul/2019 06:56:14] "[37mGET /data/experiments HTTP/1.1[0m" 200 - I0716 06:56:14.282483 8400 _internal.py:122] ::1 - - [16/Jul/2019 06:56:14] "[37mGET /data/runs HTTP/1.1[0m" 200 - I0716 06:56:14.282483 12340 _internal.py:122] ::1 - - [16/Jul/2019 06:56:14] "[37mGET /data/environment HTTP/1.1[0m" 200 - .. and lots more ...


Solution

  • You might not have the basics about tensorboard so let me explain a bit. You created a graph, and logged it to a file. The only thing your log file will contain is a graph with a single operator (Add) and two inputs.

    Logging scalars is often done to track your loss function when training neural networks, this seems like a decent guide.

    EDIT

    1) Are you sure tensorboard is getting your path correctly? Can you go to your log folder in the terminal and run tensorboard --logdir ./ from there?

    2) try using "", I tried using the following commands:

    tensorboard --logdir ./
    tensorboard --logdir="./"
    tensorboard --logdir='./'
    

    The bottom one gave an error in browser displaying nothing, other 2 worked fine. The ./ should be replacable with any folder, I just prefer to go into my folder in terminal on windows, to prevent any path from breaking

    3) Have you played around with tensorflow installations, is your tensorboard perhaps not fully compatible with your tensorflow? Have you tried uninstalling every tensorboard / tensorflow package, and installing them again? These are my versions:

    tensorboard==1.13.1
    tensorflow==1.13.1