tensorflow 利用TensorBoard查看计算图
原创
©著作权归作者所有:来自51CTO博客作者liuyunshengsir的原创作品,请联系作者获取转载授权,否则将追究法律责任
使用TensorFlow的基本步骤一般为:定义计算图,执行计算图,查看计算图
import tensorflow as tf
#定义计算图
g = tf.Graph()
with g.as_default():
hello = tf.constant('hello',name = 'hello')
world = tf.constant('world',name = 'world')
helloworld = tf.string_join([hello,world],name = 'join',separator=' ')
#执行计算图
with tf.Session(graph = g) as sess:
print(sess.run(fetches = helloworld,feed_dict={}))
#查看计算图
with tf.summary.FileWriter('F:\lys\my_graph') as writer:
writer.add_graph(g)
#1,在命令行中切换到 F:\lys\my_graph
#2,运行 tensorboard --logdir=my_graph
#3, 打开浏览器输入地址http://localhost:6006
或者
writer = tf.summary.FileWriter('F:\lys\my_graph', tf.get_default_graph())
writer.close()
查看
![在这里插入图片描述 tensorflow 利用TensorBoard查看计算图_Graph](https://s2.51cto.com/images/blog/202301/09171111_63bbda2f5436e10877.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=/resize,m_fixed,w_1184)