TensorBoard 计算图的可视化实现


Posted in Python onFebruary 15, 2020

简介

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

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

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

推荐使用 Estimator 风格.

类与方法

在 tf.estimator 框架下, 可以直接用 tf.summary.scalar() 这样的方法, 不必显式地创建writer并调用writer.add_summary()

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.

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

image

作图, 对于grap-scale 图来讲, 0表示全黑, 255表示全白.

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类型.

打开web页面

在命令行中 敲tensorboard --logdir=D:\tf_models\iris, 根据提示打开URL即可.

比如我的为http://yichu-amd:6006/.

效果截图

TensorBoard 计算图的可视化实现

图3-1 logdir中的文件

TensorBoard 计算图的可视化实现

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

TensorBoard 计算图的可视化实现

figure 3-3 计算图的可视化

给出一些建议:

网络也是分模块,有结构的, 合理使用 scope 可以让计算图清晰优雅.

有些tensor来自dataset, 有些来自api中op操作的输出, 本身没有明确的名字, 此时用x=tf.identity(x,'name') 给tensor起名字, 便于计算图中定位. 图3-3 中的 memory 就是 encoder 的输出的tensor.

以上这篇TensorBoard 计算图的可视化实现就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持三水点靠木。

Python 相关文章推荐
Python中的对象,方法,类,实例,函数用法分析
Jan 15 Python
在Python中使用cookielib和urllib2配合PyQuery抓取网页信息
Apr 25 Python
python中实现迭代器(iterator)的方法示例
Jan 19 Python
疯狂上涨的Python 开发者应从2.x还是3.x着手?
Nov 16 Python
python的中异常处理机制
Aug 30 Python
Python3爬取英雄联盟英雄皮肤大图实例代码
Nov 14 Python
Python的高阶函数用法实例分析
Apr 11 Python
Pyqt5 实现跳转界面并关闭当前界面的方法
Jun 19 Python
Python使用Slider组件实现调整曲线参数功能示例
Sep 06 Python
python代码区分大小写吗
Jun 17 Python
python 使用递归的方式实现语义图片分割功能
Jul 16 Python
Python压缩模块zipfile实现原理及用法解析
Aug 14 Python
TensorBoard 计算图的查看方式
Feb 15 #Python
pycharm 更改创建文件默认路径的操作
Feb 15 #Python
PyCharm刷新项目(文件)目录的实现
Feb 14 #Python
浅谈Pycharm最有必要改的几个默认设置项
Feb 14 #Python
python图形开发GUI库pyqt5的详细使用方法及各控件的属性与方法
Feb 14 #Python
python图形开发GUI库pyqt5的基本使用方法详解
Feb 14 #Python
Python 写了个新型冠状病毒疫情传播模拟程序
Feb 14 #Python
You might like
php SQL Injection with MySQL
2011/02/27 PHP
一个简洁实用的PHP缓存类完整实例
2014/07/26 PHP
CodeIgniter集成smarty的方法详解
2016/05/26 PHP
php中array_slice和array_splice函数解析
2016/10/18 PHP
PHP7内核之Reference详解
2019/03/14 PHP
判断iframe是否加载完成的完美方法
2010/01/07 Javascript
jQuery.clean使用方法及思路分析
2013/01/07 Javascript
js浮点数精确计算(加、减、乘、除)
2013/12/26 Javascript
jquery基础教程之数组使用详解
2014/03/10 Javascript
在jquery中的ajax方法怎样通过JSONP进行远程调用
2014/04/04 Javascript
JavaScript实现存储HTML字符串示例
2014/04/21 Javascript
JavaScript判断变量是对象还是数组的方法
2014/08/28 Javascript
Angularjs全局变量被作用域监听的正确姿势
2016/02/06 Javascript
分享JS数组求和与求最大值的方法
2016/08/11 Javascript
jQuery图片切换动画特效
2016/11/02 Javascript
ajax异步请求详解
2017/01/06 Javascript
解决vue 格式化银行卡(信用卡)每4位一个符号隔断的问题
2018/09/14 Javascript
css配合JavaScript实现tab标签切换效果
2018/10/11 Javascript
傻瓜式vuex语法糖kiss-vuex整理
2018/12/21 Javascript
nodejs中使用archive压缩文件的实现代码
2019/11/26 NodeJs
python遍历文件夹并删除特定格式文件的示例
2014/03/05 Python
python实现可将字符转换成大写的tcp服务器实例
2015/04/29 Python
Python二分法搜索算法实例分析
2015/05/11 Python
Pyspider中给爬虫伪造随机请求头的实例
2018/05/07 Python
Pycharm取消py脚本中SQL识别的方法
2018/11/29 Python
selenium+python设置爬虫代理IP的方法
2018/11/29 Python
Appium Python自动化测试之环境搭建的步骤
2019/01/23 Python
python将print输出的信息保留到日志文件中
2019/09/27 Python
使用Html5多媒体实现微信语音功能
2019/07/26 HTML / CSS
AE美国鹰美国官方网站:American Eagle Outfitters
2016/08/22 全球购物
P D PAOLA意大利官网:西班牙著名的珠宝首饰品牌
2019/09/24 全球购物
馥蕾诗美国官网:Fresh美国
2019/10/09 全球购物
2014年医学生毕业自我鉴定
2014/03/26 职场文书
工程项目经理岗位职责
2015/02/02 职场文书
会计岗位工作总结
2015/08/12 职场文书
php 文件上传至OSS及删除远程阿里云OSS文件
2021/07/04 PHP