Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a Tensorflow Tensorboard Empty Graph

launch tensorboard with tensorboard --logdir=/home/vagrant/notebook

at tensorboard:6006 > graph, it says No graph definition files were found.

To store a graph, create a tf.python.training.summary_io.SummaryWriter and pass the graph either via the constructor, or by calling its add_graph() method.

import tensorflow as tf

sess = tf.Session()
writer = tf.python.training.summary_io.SummaryWriter("/home/vagrant/notebook", sess.graph_def)

However the page is still empty, how can I start playing with tensorboard?

current tensorboard

Current Tensorboard

result wanted

An empty graph that can add nodes, editable.

update

Seems like tensorboard is unable to create a graph to add nodes, drag and edit etc ( I am confused by the official video ).

running https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/tutorials/mnist/fully_connected_feed.py and then tensorboard --logdir=/home/vagrant/notebook/data is able to view the graph

However seems like tensorflow only provide ability to view summary, nothing much different to make it standout

like image 316
Anonymous Avatar asked Nov 12 '15 01:11

Anonymous


People also ask

How do you show a TensorFlow graph?

Select the Graphs dashboard by tapping “Graphs” at the top. You can also optionally use TensorBoard. dev to create a hosted, shareable experiment. By default, TensorBoard displays the op-level graph.

Does TensorBoard work with TensorFlow 1?

TensorBoard is a built-in tool for providing measurements and visualizations in TensorFlow. Common machine learning experiment metrics, such as accuracy and loss, can be tracked and displayed in TensorBoard. TensorBoard is compatible with TensorFlow 1 and 2 code.

Is TensorBoard included in TensorFlow?

To make it easier to understand, debug, and optimize TensorFlow programs, we've included a suite of visualization tools called TensorBoard.” TensorFlow programs can range from very simple to super complex problems (using thousands of computations), and they all have two basic components, Operations and Tensors.


2 Answers

TensorBoard is a tool for visualizing the TensorFlow graph and analyzing recorded metrics during training and inference. The graph is created using the Python API, then written out using the tf.train.SummaryWriter.add_graph() method. When you load the file written by the SummaryWriter into TensorBoard, you can see the graph that was saved, and interactively explore it.

However, TensorBoard is not a tool for building the graph itself. It does not have any support for adding nodes to the graph.

like image 139
mrry Avatar answered Nov 15 '22 14:11

mrry


Starting from the following Code Example, I can add one line as shown below:

import tensorflow as tf
import numpy as np
sess = tf.InteractiveSession()  #define a session
# Create 100 phony x, y data points in NumPy, y = x * 0.1 + 0.3
x_data = np.random.rand(100).astype("float32")
y_data = x_data * 0.1 + 0.3

# Try to find values for W and b that compute y_data = W * x_data + b
# (We know that W should be 0.1 and b 0.3, but Tensorflow will
# figure that out for us.)
W = tf.Variable(tf.random_uniform([1], -1.0, 1.0))
b = tf.Variable(tf.zeros([1]))
y = W * x_data + b

# Minimize the mean squared errors.
loss = tf.reduce_mean(tf.square(y - y_data))
optimizer = tf.train.GradientDescentOptimizer(0.5)
train = optimizer.minimize(loss)

# Before starting, initialize the variables.  We will 'run' this first.
init = tf.initialize_all_variables()

# Launch the graph.
sess = tf.Session()
sess.run(init)

#### ----> ADD THIS LINE <---- ####
writer = tf.train.SummaryWriter("/tmp/test", sess.graph)

# Fit the line.
for step in xrange(201):
    sess.run(train)
    if step % 20 == 0:
        print(step, sess.run(W), sess.run(b))

# Learns best fit is W: [0.1], b: [0.3]

And then run tensorboard from the command line, pointing to the appropriate directory. This shows a complete call for the SummaryWriter. It is important to note the following things:

  1. SummaryWriter is passed a Session, and so must happen after the Session (or InteractiveSession) is created
  2. That Session may be created early in the program, but when the Session is passed to the SummaryWriter, the graph as it exists at that point is written to the file that the TensorBoard will use.
like image 44
Novak Avatar answered Nov 15 '22 14:11

Novak