Tensorboard: No graph definition files were found.

≯℡__Kan透↙ 提交于 2019-12-06 16:29:37

The problem might be the parameter --logdir. make sure you have type the correct

example:

in the code: writer = tf.summary.FileWriter('./log/', s.graph)

open powershell

cd to your work directory and type tensorboard --logdir=log

you can also use --debug to see if there is a problem in finding the log file. if you see: TensorBoard path_to_run is: {'C:\\Users\\example\\log': None} that means it can not find the file.

I had similar issue. The issue occurred when I specified 'logdir' folder inside single quotes instead of double quotes. Hope this may be helpful to you.

egs: tensorboard --logdir='my_graph' -> Tensorboard didn't detect the graph

 tensorboard --logdir="my_graph"  -> Tensorboard detected the graph

In Tensorflows dealing with graphs, there are three parts: 1) creating the graph 2) Writing the graph to event file 3) Visualizing the graph in tensorboard

Example: Creating graph in tensorflow

a = tf.constant(5, name="input_a")
b = tf.constant(3, name="input_b")

c = tf.multiply(a,b, name="mul_c")
d = tf.add(a,b, name="add_d")

e = tf.add(c,d, name="add_e")

sess = tf.Session() 

sess.run(c) <--check, value should be 15
sess.run(d) <--check, value should be 8
sess.run(e) <--check, value should be 23

Writing graph in event file

 writer = tf.summary.FileWriter('./tensorflow_examples', sess.graph)

It is very important to specify a directory(in this case, the directory is tensorflow_examples), where the event file will be written to. writer = tf.summary.FileWriter('./', sess.graph) didnt work for me, because the shell command => tensorboard --logdir expects a directory name.

After executing this step, verify if event file has been created in specified directory.

Visualizing graph in Tensorboard

Open terminal(bash), under working directory type: tensorboard --logdir='tensorflow_examples' --host=127.0.0.1

Then open a new browser in http://127.0.0.1:6006/ or http://localhost/6006 and now tensorboard shows the graph successfully.

You may need to change the powershell directory to your log file. And the logdir need not the single quotation marks.(Double quotation marks or without the quotes will be both OK)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!