tensorbosrd出现No graph definition files were found,补充内容 以下内容转载自https://blog.csdn.net/u014165082/article/details/79556366 tensorflow入门:新版本语法改动以及tensorbosrd出现No graph definition files were found问题

tensorbosrd出现No graph definition files were found,补充内容

在writer=tf.summary.FileWriter('./my_graph',sess.graph) 一句中,

./my_graph的绝对路径不允许出现汉语,否则就会出现No graph definition files were found

更多问题参考下面的博客:

以下内容转载自https://blog.csdn.net/u014165082/article/details/79556366

tensorflow入门:新版本语法改动以及tensorbosrd出现No graph definition files were found问题

 
   
一.使用的tensorflow版本为1.6
[python]  view plain  copy
  1. import tensorflow as tf  
  2.   
  3. a=tf.constant(5,name="input_a")  
  4. b=tf.constant(3,name="input_b")  
  5. c=tf.multiply(a,b,name="mul_c")  
  6. d=tf.add(a,b,name="add_d")  
  7. e=tf.add(c,d,name="add_e")  
  8.   
  9. sess=tf.Session()  
  10. output=sess.run(e)  
  11. writer=tf.summary.FileWriter('./my_graph',sess.graph)  
  12.   
  13. sess.close()  
  14. writer.close()  

1.AttributeError: module 'tensorflow' has no attribute 'mul'

遇到的第一个问题提示为tensorflow库中没有mul这个参数,百度后发现书本上的语法有错,应改mul为multiply:

[python]  view plain  copy
  1. c=tf.multiply(a,b,name="mul_c")  

2.AttributeError: module 'tensorflow.python.training.training' has no attribute 'SummaryWriter'

这是因为在1.0版本中,tf.train.SummaryWriter已经改为tf.summary.FileWriter;因此,代码必须改为:

[python]  view plain  copy
  1. writer=tf.summary.FileWriter('./my_graph',sess.graph)  
 
   

二.tensorbosrd出现No graph definition files were found问题

这个坑的关键在于:

在cmd命令行中一定要先cd到存数据流图日志文件的文件夹的上一级文件夹,

然后再输入命令tensorboard --logdir=存数据流图日志文件的文件夹名


例如:我的数据流图文件所在的文件夹名为my_graph,与py文件为同一级目录,均在目录E:\python3.5\tensorflow的下面

所以运行了py文件之后,先在cmd命令行中cd到目录E:\python3.5\tensorflow下,

然后输入命令:tensorboard --logdir=my_graph


得到如图信息,然后复制网址http://DESKTOP-CTPK05M:6006到浏览器打开即可查看数据流图。

我开始直接在pycharm的终端或者cmd到my_graph下执行tensorboard --logdir="my_graph"也可以得到一个含6006的网址,但是没有如图的一大串执行信息,所以在浏览器中打开能显示tensorboard界面但是出现No graph definition files were found,不能显示数据流图。

按照正确方法运行后得到



另外可以参考如下链接博客:

参考一

参考二

猜你喜欢

转载自blog.csdn.net/stt12345678/article/details/79813520