TensorBoard使用

1.计算图可视化

 1 import tensorflow as tf
 2 
 3 path = "D:\Path"
 4 
 5 # 定义一个简单的计算图,实现向量加法的操作。
 6 input1 = tf.constant([1.0, 2.0, 3.0], name="input1")
 7 input2 = tf.Variable(tf.random_uniform([3]), name="input2")
 8 output = tf.add_n([input1, input2], name="add")
 9 
10 # 将当前的TensorFlow计算图写入日志
11 writer = tf.summary.FileWriter(path,tf.get_default_graph())
12 writer.close()

  运行后会在指定目录创建日志文件。

  通过命令行启动TensorBoard。

tensorboard --logdir=D:\Path

  浏览器打开命令行返回的地址即可。

 

2.添加命名空间

  命名空间可以将计算图的细节部分隐藏,保留关键部分。

 1 import tensorflow as tf
 2 
 3 path = "D:\Path"
 4 
 5 # 将输入定义放入各自的命名空间中,从而使得TensorBoard可以根据命名空间来整理可视化效果图上的节点。
 6 with tf.name_scope("namespace_1"):
 7     inputl = tf.constant([1.0, 2.0, 3.0], name="input1")
 8 
 9 with tf.name_scope("namespace_2"):
10     input2 = tf.Variable(tf.random_uniform([3]), name="input2")
11 
12 output = tf.add_n([inputl, input2], name="add")
13 
14 # 将当前的TensorFlow计算图写入日志
15 writer = tf.summary.FileWriter(path, tf.get_default_graph())
16 writer.close()

 

转载于:https://www.cnblogs.com/wangconnor/p/11207628.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值