TensorLayer官方中文文档1.7.4:API – 可视化
API - 可视化¶
TensorFlow 提供了可视化模型和激活输出等的工具 TensorBoard。
在这里,我们进一步提供一些可视化模型参数和数据的函数。
read_image(image[, path]) |
Read one image. |
read_images(img_list[, path, n_threads, ...]) |
Returns all images in list by given path and name of each image file. |
save_image(image[, image_path]) |
Save one image. |
save_images(images, size[, image_path]) |
Save mutiple images into one single image. |
draw_boxes_and_labels_to_image(image[, ...]) |
Draw bboxes and class labels on image. |
W([W, second, saveable, shape, name, fig_idx]) |
Visualize every columns of the weight matrix to a group of Greyscale img. |
CNN2d([CNN, second, saveable, name, fig_idx]) |
Display a group of RGB or Greyscale CNN masks. |
frame([I, second, saveable, name, cmap, fig_idx]) |
Display a frame(image). |
images2d([images, second, saveable, name, ...]) |
Display a group of RGB or Greyscale images. |
tsne_embedding(embeddings, reverse_dictionary) |
Visualize the embeddings by using t-SNE. |
读取与保存图片¶
读取单个图片¶
-
tensorlayer.visualize.read_image(image, path='')[源代码]¶ -
Read one image.
Parameters: images : string, file name.
path : string, path.
读取多个图片¶
-
tensorlayer.visualize.read_images(img_list, path='', n_threads=10, printable=True)[源代码]¶ -
Returns all images in list by given path and name of each image file.
Parameters: img_list : list of string, the image file names.
path : string, image folder path.
n_threads : int, number of thread to read image.
printable : bool, print infomation when reading images, default is True.
保存单个图片¶
-
tensorlayer.visualize.save_image(image, image_path='')[源代码]¶ -
Save one image.
Parameters: images : numpy array [w, h, c]
image_path : string.
保存多个图片¶
-
tensorlayer.visualize.save_images(images, size, image_path='')[源代码]¶ -
Save mutiple images into one single image.
Parameters: images : numpy array [batch, w, h, c]
size : list of two int, row and column number.
number of images should be equal or less than size[0] * size[1]
image_path : string.
Examples
>>> images = np.random.rand(64, 100, 100, 3)
>>> tl.visualize.save_images(images, [8, 8], 'temp.png')
保存目标检测图片¶
tensorlayer.visualize.draw_boxes_and_labels_to_image(image, classes=[], coords=[], scores=[], classes_list=[], is_center=True, is_rescale=True, save_name=None)[源代码]¶-
Draw bboxes and class labels on image. Return or save the image with bboxes, example in the docs of
tl.prepro.Parameters: image : RGB image in numpy.array, [height, width, channel].
classes : a list of class ID (int).
coords : a list of list for coordinates.
- Should be [x, y, x2, y2] (up-left and botton-right format)
- If [x_center, y_center, w, h] (set is_center to True).
scores : a list of score (float). (Optional)
classes_list : list of string, for converting ID to string on image.
is_center : boolean, defalt is True.
If coords is [x_center, y_center, w, h], set it to True for converting [x_center, y_center, w, h] to [x, y, x2, y2] (up-left and botton-right).
If coords is [x1, x2, y1, y2], set it to False.is_rescale : boolean, defalt is True.
If True, the input coordinates are the portion of width and high, this API will scale the coordinates to pixel unit internally.
If False, feed the coordinates with pixel unit format.save_name : None or string
The name of image file (i.e. image.png), if None, not to save image.
References
- OpenCV rectangle and putText.
- scikit-image.
可视化模型参数¶
可视化Weight Matrix¶
-
tensorlayer.visualize.W(W=None, second=10, saveable=True, shape=[28, 28], name='mnist', fig_idx=2396512)[源代码]¶ -
Visualize every columns of the weight matrix to a group of Greyscale img.
Parameters: W : numpy.array
The weight matrix
second : int
The display second(s) for the image(s), if saveable is False.
saveable : boolean
Save or plot the figure.
shape : a list with 2 int
The shape of feature image, MNIST is [28, 80].
name : a string
A name to save the image, if saveable is True.
fig_idx : int
matplotlib figure index.
Examples
>>> tl.visualize.W(network.all_params[0].eval(), second=10, saveable=True, name='weight_of_1st_layer', fig_idx=2012)
可视化CNN 2d filter¶
tensorlayer.visualize.CNN2d(CNN=None, second=10, saveable=True, name='cnn', fig_idx=3119362)[源代码]¶-
Display a group of RGB or Greyscale CNN masks.
Parameters: CNN : numpy.array
The image. e.g: 64 5x5 RGB images can be (5, 5, 3, 64).
second : int
The display second(s) for the image(s), if saveable is False.
saveable : boolean
Save or plot the figure.
name : a string
A name to save the image, if saveable is True.
fig_idx : int
matplotlib figure index.
Examples
>>> tl.visualize.CNN2d(network.all_params[0].eval(), second=10, saveable=True, name='cnn1_mnist', fig_idx=2012)
可视化图像¶
matplotlib显示单图¶
tensorlayer.visualize.frame(I=None, second=5, saveable=True, name='frame', cmap=None, fig_idx=12836)[源代码]¶-
Display a frame(image). Make sure OpenAI Gym render() is disable before using it.
Parameters: I : numpy.array
The image
second : int
The display second(s) for the image(s), if saveable is False.
saveable : boolean
Save or plot the figure.
name : a string
A name to save the image, if saveable is True.
cmap : None or string
'gray' for greyscale, None for default, etc.
fig_idx : int
matplotlib figure index.
Examples
>>> env = gym.make("Pong-v0")
>>> observation = env.reset()
>>> tl.visualize.frame(observation)
matplotlib显示多图¶
tensorlayer.visualize.images2d(images=None, second=10, saveable=True, name='images', dtype=None, fig_idx=3119362)[源代码]¶-
Display a group of RGB or Greyscale images.
Parameters: images : numpy.array
The images.
second : int
The display second(s) for the image(s), if saveable is False.
saveable : boolean
Save or plot the figure.
name : a string
A name to save the image, if saveable is True.
dtype : None or numpy data type
The data type for displaying the images.
fig_idx : int
matplotlib figure index.
Examples
>>> X_train, y_train, X_test, y_test = tl.files.load_cifar10_dataset(shape=(-1, 32, 32, 3), plotable=False)
>>> tl.visualize.images2d(X_train[0:100,:,:,:], second=10, saveable=False, name='cifar10', dtype=np.uint8, fig_idx=20212)
可视化词嵌入矩阵¶
tensorlayer.visualize.tsne_embedding(embeddings, reverse_dictionary, plot_only=500, second=5, saveable=False, name='tsne', fig_idx=9862)[源代码]¶-
Visualize the embeddings by using t-SNE.
Parameters: embeddings : a matrix
The images.
reverse_dictionary : a dictionary
id_to_word, mapping id to unique word.
plot_only : int
The number of examples to plot, choice the most common words.
second : int
The display second(s) for the image(s), if saveable is False.
saveable : boolean
Save or plot the figure.
name : a string
A name to save the image, if saveable is True.
fig_idx : int
matplotlib figure index.
Examples
>>> see 'tutorial_word2vec_basic.py'
>>> final_embeddings = normalized_embeddings.eval()
>>> tl.visualize.tsne_embedding(final_embeddings, labels, reverse_dictionary,
... plot_only=500, second=5, saveable=False, name='tsne')
艾伯特(http://www.aibbt.com/)国内第一家人工智能门户
TensorLayer官方中文文档1.7.4:API – 可视化的更多相关文章
- TensorLayer官方中文文档1.7.4:API – 数据预处理
所属分类:TensorLayer API - 数据预处理¶ 我们提供大量的数据增强及处理方法,使用 Numpy, Scipy, Threading 和 Queue. 不过,我们建议你直接使用 Tens ...
- TensorLayer官方中文文档1.7.4:API – 强化学习
API - 强化学习¶ 强化学习(增强学习)相关函数. discount_episode_rewards([rewards, gamma, mode]) Take 1D float array of ...
- Keras官方中文文档:函数式模型API
\ 函数式模型接口 为什么叫"函数式模型",请查看"Keras新手指南"的相关部分 Keras的函数式模型为Model,即广义的拥有输入和输出的模型,我们使用M ...
- ReactNative官方中文文档0.21
整理了一份ReactNative0.21中文文档,提供给需要的reactnative爱好者.ReactNative0.21中文文档.chm 百度盘下载:ReactNative0.21中文文档 来源: ...
- PyTorch官方中文文档:torch.nn
torch.nn Parameters class torch.nn.Parameter() 艾伯特(http://www.aibbt.com/)国内第一家人工智能门户,微信公众号:aibbtcom ...
- 学习Python 新去处:Python 官方中文文档
Python 作为世界上最好用的语言,官方支持的文档一直没有中文.小伙伴们已经习惯了原汁原味的英文文档,但如果有官方中文文档,那么查阅或理解速度都会大大提升.本文将介绍隐藏在 Python 官网的中文 ...
- django2.0 官方中文文档地址
django2.0 官方开始发布中文文档了,之前还想着一直翻译完成所有有必要的内容,想着可以省事一些了,打开以后看了一下,发现官方的中文文档还没翻译完成, 现在(2018-7-10)最新章节是是 编 ...
- mysql 新手入门 官方文档+官方中文文档附地址
点评: 官方文档地址 官方中文文档地址 sql语句扩展
- PyTorch官方中文文档:torch.optim 优化器参数
内容预览: step(closure) 进行单次优化 (参数更新). 参数: closure (callable) –...~ 参数: params (iterable) – 待优化参数的iterab ...
随机推荐
- 蛋疼的_after_insert
这两天在做一个素材类的网站,用的依旧是TP3.2,在做到发布话题这部分的时候,发现了一个问题,我在添加话题的时候在模型里写了个钩子函数_after_insert(),希望在新增话题数据之后同时将话题的 ...
- css居中方法与双飞翼布局
居中 类型 方法 对应属性 水平 垂直 水平&垂直 1.父元素使用外边距自动 2.子元素显示行内块级元素,写入内容,父元素设置文本居中 3.给父元素开启非绝对和固定定位作为子元素开启绝对定位的 ...
- JS声明对象时属性名加引号与不加引号的问题
般情况下属性名加引号和不加引号是都可以的,效果是一样的. var obj = { name : '你好', 'age' : 1, }; document.write( obj['name'] + '& ...
- 使用Docker link搭建PHP开发环境
一般我们会把nginx.php都安装在同一个容器,为了扩展方便,我们希望nginx和php分开.那么就可以使用docker link命令实现这一目的. 需要的镜像: nginx 1.12.2 php( ...
- 记录一则fsck的简单案例
环境:RHEL 6.5 + ext4文件系统 我个人实验环境的一个虚拟机,开机时在Checking filesystems时,有报错: /dev/mapper/vg_linuxbase-lv_root ...
- WinForm中ClickOnce发布至广域网
ClickOnce智能客户端,是微软提供比较早的一项技术,用于实现WinForm开发的应用程序能够自动更新,省去给每台客户端升级带来的困扰. 从网上的贴子里看,有的说好用,有的说不好用.客观的说,微软 ...
- nyoj222 整数中的1 数位DP
从a枚举到b是一定会超时的.此题应该考虑数位dp,也可以理解为递推,假设给定数n,就能在O(32)复杂度算出所有小于等于n的数中1出现的次数,那么给定区间[a, b],solve(b) - solve ...
- Fabric单节点安装备忘
安装文档:http://www.cnblogs.com/studyzy/p/7437157.html 安装上面的文档安装成功,但是过程中遇到一些问题. 一.go的源码包可能下载不下来,因为被墙,go官 ...
- flask中jinjia2模板引擎详解3
接上文 模板继承 Jinji2中的模板继承是jinjia2比较强大的功能之一. 模板继承可以定义一个父级公共的模板,把同一类的模板框架定义出来共享. 这样做一方面可以提取共享代码,减少代码冗余和重复的 ...
- vim编辑器——常用操作整理
注意:以下的操作都是在命令状态下进行的,不要进入插入状态了.参考这里 1.删除 dd 删除一行 ndd 删除以当前行开始的n行dw 删除以当前字符开始的一个字符ndw 删除 ...