KansaiRobot
KansaiRobot

Reputation: 9912

there is no graph with tensorboard

I am reading a book on Tensorflow and I find this code:

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import tensorflow as tf

const1 = tf.constant(2)
const2 = tf.constant(3)
add_opp = tf.add(const1,const2)
mul_opp = tf.mul(add_opp, const2)

with tf.Session() as sess:
    result, result2 = sess.run([mul_opp,add_opp])
    print(result)
    print(result2)

    tf.train.SummaryWriter('./',sess.graph)

so it is very simple, nothing fancy and it is supposed to produce some output that can be visualized with tensorboard.

So I run the script, it prints the results but apparently SummaryWriter produces nothing.

I run tensorboard -logdir='./' and of course there is no graph. What could I be doing wrong?

And also how do you terminate tensorboard? I tried ctrl-C and ctrl-Z and it does not work. (also I am in a japanese keyboard so there is no backslash just in case)

Upvotes: 4

Views: 6757

Answers (2)

Gaurab Panthee
Gaurab Panthee

Reputation: 19

A very wierd thing happened to me I am learning to work with tensorflow

import tensorflow as tf

a = tf.constant(3)
b = tf.constant(4)

c = a+b

with tf.Session() as sess:
    File_Writer = tf.summary.FileWriter('/home/theredcap/Documents/CS/Personal/Projects/Test/tensorflow/tensorboard/' , sess.graph )
    print(sess.run(c))

Inorder to see the graph on tensorboard I typed

tensorboard --logdir = "the above mentioned path"

But nothing was displayed on the tensorboard Then I went to the github README page https://github.com/tensorflow/tensorboard/blob/master/README.md

And it said to run the command in this manner

tensorboard --logdir path/to/logs

I did the same, and finally I was able to view my graph

Upvotes: 1

mrry
mrry

Reputation: 126154

The tf.train.SummaryWriter must be closed (or flushed) in order to ensure that data, including the graph, have been written to it. The following modification to your program should work:

writer = tf.train.SummaryWriter('./', sess.graph)
writer.close()

Upvotes: 5

Related Questions