tensorflow结果可视化tensorboard

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import tensorflow as tf
from skimage import io

a = tf.placeholder(tf.int32, shape=[])
b = tf.constant(1, dtype=tf.int32)
y = a+b
sess=tf.Session()
sess.run(tf.global_variables_initializer())



# 1 创建文件夹,写入图
summary_writer = tf.summary.FileWriter("./logs",sess.graph)

# 2 写入数据
#图片
img = io.imread("data.png")
img = tf.reshape(img,[1,28,28,1])#(batch,28,28,ch)
tf.summary.image('img',img)
#数组
tf.summary.scalar("a", a)
tf.summary.scalar("b", b)
#总结
summarry = tf.summary.merge_all()
for i in range(10):
eval_summary = sess.run(summarry, feed_dict={a: i})
#写入
summary_writer.add_summary( eval_summary , global_step=i)

转载请注明来源 https://tianweiye.github.io