9 查看图形化的模型

用TensorBoard查看数据流图

9.1 graph1
程序:

import tensorflow as tf

x = tf.placeholder(shape=[1, 3], dtype=tf.float32)

w = tf.Variable(tf.ones([3, 3]), dtype=tf.float32)
b = tf.Variable(1, dtype=tf.float32)

y = tf.matmul(x, w) + b

sess = tf.Session()
sess.run(tf.global_variables_initializer())

sess.run(y, feed_dict={x: [[1, 2, 3]]})

writer = tf.summary.FileWriter("graph", sess.graph)

cmd命令行输入:

tensorboard --logdir=E:\PycharmProjects\test20190712\graph

结果:
在这里插入图片描述
浏览器输入:

http://DESKTOP-6J6UU6I:6006/

控制TensorBoard图中对象的名称

7.2 graph2
程序:

import tensorflow as tf

x = tf.placeholder(shape=[1, 3], dtype=tf.float32, name="x")

w = tf.Variable(tf.ones([3, 3]), dtype=tf.float32, name="w")
b = tf.Variable(1, dtype=tf.float32, name="b")

y = tf.matmul(x, w, name="MatMul") + b

sess = tf.Session()
sess.run(tf.global_variables_initializer())

sess.run(y, feed_dict={x: [[1, 2, 3]]})

writer = tf.summary.FileWriter("graph", sess.graph)

结果:

9.3 graph3
程序:

import tensorflow as tf

x = tf.placeholder(shape=[1, 3], dtype=tf.float32, name="x")

w = tf.Variable(tf.ones([3, 3]), dtype=tf.float32, name="w")
b = tf.Variable(1, dtype=tf.float32, name="b")

y = tf.add(tf.matmul(x, w, name="MatMul"), b, name="y-Add")

sess = tf.Session()
sess.run(tf.global_variables_initializer())

sess.run(y, feed_dict={x: [[1, 2, 3]]})

writer = tf.summary.FileWriter("graph", sess.graph)

结果:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值