惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 【当耐特】
Help Net Security
Help Net Security
P
Proofpoint News Feed
J
Java Code Geeks
爱范儿
爱范儿
Last Week in AI
Last Week in AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
F
Full Disclosure
Google DeepMind News
Google DeepMind News
H
Help Net Security
G
Google Developers Blog
Jina AI
Jina AI
Vercel News
Vercel News
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
Lohrmann on Cybersecurity
S
Schneier on Security
Microsoft Azure Blog
Microsoft Azure Blog
IT之家
IT之家
Security Archives - TechRepublic
Security Archives - TechRepublic
阮一峰的网络日志
阮一峰的网络日志
N
News and Events Feed by Topic
GbyAI
GbyAI
B
Blog
O
OpenAI News
博客园_首页
Cisco Talos Blog
Cisco Talos Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Hacker News: Ask HN
Hacker News: Ask HN
TaoSecurity Blog
TaoSecurity Blog
腾讯CDC
MongoDB | Blog
MongoDB | Blog
M
MIT News - Artificial intelligence
C
Cybersecurity and Infrastructure Security Agency CISA
Cyberwarzone
Cyberwarzone
Webroot Blog
Webroot Blog
Simon Willison's Weblog
Simon Willison's Weblog
Y
Y Combinator Blog
C
Cisco Blogs
A
Arctic Wolf
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Exploit Database - CXSecurity.com
Security Latest
Security Latest
AI
AI
W
WeLiveSecurity
aimingoo的专栏
aimingoo的专栏
The Register - Security
The Register - Security
Project Zero
Project Zero
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
Netflix TechBlog - Medium
Blog — PlanetScale
Blog — PlanetScale

博客园 - 星际浪子

如何让Ubuntu中virtualbox虚拟机用上USB设备 Deep Learning Stuffs(持续更新中……) 实例描述如何用python组件ctypes调用c的dll中的函数 放弃MATLAB!简述winpython为什么比MATLAB更方便 虚拟机Ubuntu10.04无法显示windows中文目录和文件 W: GPG 错误 用debugfs挂载硬盘,删除损坏的文件 数据资源 机器学习资源 镜头的参数指标 PCA和ICA GIT diff 命令 GIT 常用命令手册 opencv中snake的调用方法示例 偏最小二乘法回归(Partial Least Squares Regression) Linux常用几种shell Git详解-Git分支 网线连接并PPPOE拨号后无法扫描无线网络问题的解决办法 gdb 命令详细解释
In Theano, how to do Reverse-MaxPooling in the Convolutional MaxPooling Auto-Encoder
星际浪子 · 2015-03-07 · via 博客园 - 星际浪子

MaxPooling Layer always follows Convolutional Layer. But in the Convolutional MaxPooling Auto-Encoder, how to do reverse or Un-MaxPooling?

Here is the method:

 1 import numpy as np
 2 import theano
 3 import theano.tensor as T
 4 import theano.sandbox.neighbours as nbr
 5 
 6 poolsize = (2, 2)
 7 print 'neighbor box:'
 8 print poolsize
 9 # Defining batch images
10 images = T.tensor4('images')
11 #conver images to neighbors matrix
12 neibs = nbr.images2neibs(images, neib_shape=poolsize)
13 
14 # Constructing theano function 
15 window_function = theano.function([images], neibs)
16 
17 # Input tensor image width and height are 4
18 im_val = np.random.randint(0, 100, (2, 1, 4, 4))
19 im_val = im_val.astype(np.float32)
20 # Function application
21 neibs_val = window_function(im_val)
22 
23 print 'original images:'
24 print im_val
25 print 'neighbor flatten:'
26 print neibs_val
27 
28 
29 neibs0 = T.zeros_like(neibs)
30 #get maximum of neighbors
31 am = T.argmax(neibs, axis=1)
32 neibs1 = T.set_subtensor(neibs0[T.arange(neibs.shape[0]), am], 1)
33 neibs *= neibs1 #suppress the non-maximum
34 
35 #convert neighbors matrix to images
36 im_new = nbr.neibs2images(neibs, poolsize, im_val.shape)
37 # Theano function definition
38 inv_window = theano.function([images], im_new)
39 # Function application
40 im_new_val = inv_window(im_val)
41 
42 print 'non maximum suppression result:'
43 print im_new_val

View Code

The following is the output:

 1 neighbor box:
 2 (2, 2)
 3 original images:
 4 [[[[ 15.  46.  46.  37.]
 5    [ 73.  93.   2.  91.]
 6    [ 97.  93.  78.   7.]
 7    [  0.  24.  34.  26.]]]
 8 
 9 
10  [[[ 70.  46.   2.  93.]
11    [ 11.  54.  29.  83.]
12    [  0.  48.  69.  95.]
13    [ 49.  48.  10.  19.]]]]
14 neighbor flatten:
15 [[ 15.  46.  73.  93.]
16  [ 46.  37.   2.  91.]
17  [ 97.  93.   0.  24.]
18  [ 78.   7.  34.  26.]
19  [ 70.  46.  11.  54.]
20  [  2.  93.  29.  83.]
21  [  0.  48.  49.  48.]
22  [ 69.  95.  10.  19.]]
23 non maximum suppression result:
24 [[[[  0.   0.   0.   0.]
25    [  0.  93.   0.  91.]
26    [ 97.   0.  78.   0.]
27    [  0.   0.   0.   0.]]]
28 
29 
30  [[[ 70.   0.   0.  93.]
31    [  0.   0.   0.   0.]
32    [  0.   0.   0.  95.]
33    [ 49.   0.   0.   0.]]]]

View Code