I run the following code to see the graph generated.
import tensorflow as tf
logs_dir = "/home/sukriti/Desktop/GIS/new_code"
a = tf.constant(2)
b = tf.constant(3)
x = tf.add(a, b)
with tf.Session() as sess:
writer = tf.summary.FileWriter(logs_dir, sess.graph)
print sess.run(x)
writer.close()
I ran the following command
$ python demo.py
$ tensorboard --logdir="logs_dir"
Starting TensorBoard 54 at http://drsbhattac:6006 (Press CTRL+C to
quit)
Now clicking on the above link (Graph tab)I found the following message:
No graph definition files were found
Can you please help me what I am missing here?
Thanks in advance!!
Related
I am a newbie and I have had some trouble in using tensorboard.
I stared Spyder in Anaconda prompt by
conda activate D:\Software\Anaconda\envs\tf
spyder
And this is my simple code in file trial.py
import tensorflow as tf
a = 2
b = 3
x = tf.add(a, b)
writer = tf.summary.create_file_writer('./graphs')
print(writer)
Then I ran this code in spyder. I opened another Anaconda prompt and added this line
conda activate D:\Software\Anaconda\envs\tf
tensorboard --logdir=D:\Dung\Maytinh\Python\graphs --port 6006
I opened my Chrome and typed: http://localhost:6006/. The result was below:
I have tried many times and I could not understand where the error was. Some guides in the internet belong to tensorflow 1 and can not suit to handle. Please help me!
This is based on the documentation
import tensorflow as tf
a = 2
b = 3
#tf.function
def func(x, y):
return tf.add(a, b)
writer = tf.summary.create_file_writer('./graphs')
tf.summary.trace_on(graph=True, profiler=True)
z = func(a, b)
with writer.as_default():
tf.summary.trace_export(
name="trace",
step=0,
profiler_outdir='./graphs')
tensorboard --logdir ./graphs
Am doing this
# eager on
tf.summary.trace_on(graph=True, profiler=True)
tf.summary.trace_export('stuff', step=1, profiler_outdir='output')
# ... call train operation
tf.summary.trace_off()
Profile section shows up in tensorboard but no graph yet.
Please find the github gist here where I have created a graph using Tf2.0 and visualized it in tensorboard. Also for more information, please go through the following link.
Code for the same is mentioned below:
!pip install tensorflow==2.0.0-beta1
import tensorflow as tf
# The function to be traced.
#tf.function
def my_func(x, y):
# A simple hand-rolled layer.
return tf.nn.relu(tf.matmul(x, y))
# Set up logging.
logdir = './logs/func'
writer = tf.summary.create_file_writer(logdir)
# Sample data for your function.
x = tf.random.uniform((3, 3))
y = tf.random.uniform((3, 3))
# Bracket the function call with
# tf.summary.trace_on() and tf.summary.trace_export().
tf.summary.trace_on(graph=True, profiler=True)
# Call only one tf.function when tracing.
z = my_func(x, y)
with writer.as_default():
tf.summary.trace_export(
name="my_func_trace",
step=0,
profiler_outdir=logdir)
%load_ext tensorboard
%tensorboard --logdir ./logs/func
If the answer was helpful, please upvote it. Thanks!
I'm trying to profile a Tensorflow graph in Tensorboard, but despite recording runtime metadata, the "Compute time" colour option is greyed out. A simple example as follows:
import tensorflow as tf
sess = tf.Session()
x = tf.constant(1.0)
y = tf.constant(2.0)
z = x + y
writer = tf.summary.Filewriter('logs', sess.graph)
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_meta = tf.RunMetadata()
res = sess.run(z, options=run_options, run_metadata=run_meta)
writer.add_run_metadata(run_meta, "metadata")
writer.close()
I then run Tensorboard from the terminal:
$ tensorboard --logdir logs
I then navigate to http://localhost:6006 in Chrome, and can see the TF graph visualisation, but no performance stats. Am I missing something obvious?
Thanks,
Chris
Specs: OSX Mojave, Anaconda Python 3.6.8, Tensorflow 1.14.
Question answered! The piece I was missing was the dropdown "Tag" menu in the Tensorboard navigation panel on the left hand side of the brower window. I clicked it, and hey presto, I have "Compute Time" available to me.
Thanks all,
Chris
Here's the code I've written in python3.6. When I try to plot using tensorboard I see two graphs namely main and auxilary but they do not seem to correspond to my code:
import tensorflow as tf
a = tf.constant(1.0)
b = tf.constant(2.0)
c=a*b
sess=tf.Session()
writer=tf.summary.FileWriter("E:/python_prog",sess.graph)
print(sess.run(c))
writer.close()
sess.close().
I run the code in anaconda(Windows) prompt:
(tfp3.6) E:\python_prog>tensorboard --logdir="E:\python_prog"
Starting TensorBoard b'54' at http://DESKTOP-31KSN08:6006
(Press CTRL+C to quit)
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)
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()
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