Skip to Content
深度学习入门 : 基于Python的理论与实现
book

深度学习入门 : 基于Python的理论与实现

by 斋藤康毅
July 2018
Intermediate to advanced
310 pages
8h 21m
Chinese
Posts & Telecom Press
Content preview from 深度学习入门 : 基于Python的理论与实现
7.4  卷积层和池化层的实现 
217
>>> x[0].shape # (1, 28, 28)
>>> x[1].shape # (1, 28, 28)
如果要访问第1 个数据的第 1个通道的空间数据,可以写成下面这样。
>>> x[0, 0] #
或者
x[0][0]
像这样,
CNN
中处理的是4 维数据,因此卷积运算的实现看上去会很复
杂,但是通过使用下面要介绍的
im2col
这个技巧,问题就会变得很简单。
7.4.2
 基于im2col的展开
如果老老实实地实现卷积运算,估计要重复好几层的
for
语句。这样的
实现有点麻烦,而且,
NumPy
中存在使用
for
语句后处理变慢的缺点(
NumPy
中,访问元素时最好不要用
for
语句)。这里,我们不使用
for
语句,而是使
im2col
这个便利的函数进行简单的实现。
im2col
是一个函数,将输入数据展开以适合滤波器(权重)。如图 7
-
17 所示,
3 维的输入数据应用
im2col
后,数据转换为2 维矩阵(正确地讲,是把包含
批数量的4 维数据转换成了 2维数据)。
7-17 im2col 的示意图
im2col
输入数据
im2col
会把输入数据展开以适合滤波器(权重)。具体地说,如图 7
-
18 所示,
对于输入数据,将应用滤波器的区域(3 维方块)横向展开为1 列。
im2col
在所有应用滤波器的地方进行这个展开处理。
7章 卷积神经网络
218
7-18 将滤波器的应用区域从头开始依次横向展开为1
在图7
-
18 中,为了便于观察,将步幅设置得很大,以使滤波器的应用区 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

ルールズ・オブ・プログラミング ―より良いコードを書くための21のルール

ルールズ・オブ・プログラミング ―より良いコードを書くための21のルール

Chris Zimmerman, 久富木 隆一

Publisher Resources

ISBN: 9787115485588