在session中加入
# Launch the graph in a session.
sess = tf.Session()
# Create a summary writer, add the 'graph' to the event file.
writer = tf.summary.FileWriter(<some-directory>, sess.graph)
展示别的变量
tf.summary.histogram(
name,
values,
collections=None,
family=None
)
在文档中还可以找到一些别的summary
可以参考https://www.tensorflow.org/api_docs/python/tf/summary
在模型中添加完后,必须在
# 在model中添加
self.merged = tf.summary.merge_all()
# 在sess.run中
....., summary = sess.run(a, b, c, self.merged)
writer.add_summary(summary, i) # i 指的是每次运行一个batch
运行完程序之后,在命令行中输入
tensorboard --logdir 文件夹名字(和上面保存的地方同个地址)
之后,在浏览器中打开地址。在Windows中打开 http://localhost:6006