TensorBoard 计算图的可视化

时间:2023-02-03 17:34:12

1.简介

tf配套的可视化工具, 将你的张量图画出来.

当训练一个巨大的网络的时候, 计算图既复杂又令人困惑. TensorBoard 提供了一系列的组件, 可以看到 learning rate 的变化, 看到 objective function 的变化.

tfboard 读取 tf 运行时你记下的 events files, 来进行可视化. 这些 events files 包含了你记下的 summary data, 它是 protobuffer 格式, 并非文本文件.

1.1 参考

notebook
官方 tutorial
video

2.类与方法

  • tensorflow.python.summary.writer.writer.FileWriter(SummaryToEventTransformer)
    类.
    __init__(self, logdir, graph=None,...)
    构造函数, Creates a FileWriter and an event file.

  • tensorflow.python.summary.summary
    模块.

    • scalar(name, tensor, ..)
      Outputs a Summary protocol buffer containing a single scalar value.
    • image(name, tensor, max_outputs=3, collections=None, family=None)
      Outputs a Summary protocol buffer with images.
      images are built from tensor which must be 4-D with shape [batch_size, height, width, channels] and where channels can be:
      1. 1-tensor is interpreted as Grayscale.
      2. 3-tensor is interpreted as RGB.
      3. 4-tensor is interpreted as RGBA.
    • histogram(name, values, collections=None, family=None)
      Adding a histogram summary makes it possible to visualize your data’s distribution in TensorBoard.

3.效果截图

TensorBoard 计算图的可视化
图3-1 logdir中的文件

TensorBoard 计算图的可视化
图3-2 炫酷的可视化效果