## TensorBoard计算图的可视化实现

2020年02月18日 编程语言 ⁄ 共 1717字 ⁄ 字号 评论关闭

tensorflow 配套的可视化工具, 将你的计算图画出来.

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

tensorflow.python.summary.writer.writer.FileWriter(SummaryToEventTransformer)

__init__(self, logdir, graph=None,...)

tensorflow.python.summary.summary

scalar(name, tensor, ..） Outputs a Summary protocol buffer containing a single scalar value.

histogram(name, values, collections=None, family=None) Adding a histogram summary makes it possible to visualize your data's distribution in TensorBoard.

image

api, 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.

tensor为float: 此时, tf会内部作正规化处理, 转换到[0,255](解析 tf_events 即可验证), float通常对应于 softm 之后的概率, 值域为[0,1].

tensor为uint8, 保持不变, tf 不作任何内部转换.

attention 可视化, attention 的权重会作 soft-max 处理, 通常img显示的效果是, 一行看下来有深有浅, 颜色越白weight越大. 但有时后tf内部正规化不符合预期, 出现一行全白的情况, 稳妥起见自己转unit类型.

figure 3-3 计算图的可视化