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

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

by 斋藤康毅
July 2018
Intermediate to advanced
310 pages
8h 21m
Chinese
Posts & Telecom Press
Content preview from 深度学习入门 : 基于Python的理论与实现
5.5  激活函数层的实现 
139
这个实现稍微有一点长,但是每一条命令都很简单。首先,生成必要的
层,以合适的顺序调用正向传播的
forward()
方法。然后,用与正向传播相
反的顺序调用反向传播的
backward()
方法,就可以求出想要的导数。
综上,计算图中层的实现(这里是加法层和乘法层)非常简单,使用这
些层可以进行复杂的导数计算。下面,我们来实现神经网络中使用的层。
5.5
激活函数层的实现
现在,我们将计算图的思路应用到神经网络中。这里,我们把构成神经
网络的层实现为一个类。先来实现激活函数的
ReLU
层和
Sigmoid
层。
5.5.1
 ReLU层
激活函数
ReLU
Rectified Linear Unit
)由 式(5.7)表示。
5.7
通过式(5.7),可以求出y 关于x 的导数,如式(5.8)所示。
5.8
式(5.8)中,如果正向传播时的输入x 大于0,则反向传播会将上游的
值原封不动地传给下游。反过来,如果正向传播时的x 小于等于0,则反向
传播中传给下游的信号将停在此处。用计算图表示的话,如图5
-
18 所示。
现在我们来实现
ReLU
层。在神经网络的层的实现中,一般假定
forward()
backward()
的参数是
NumPy
数组。另外,实现
ReLU
层的源代码在
common/
layers.py
中。
5章 误差反向传播法
140
5-18 ReLU 层的计算图
relu relu
y yx
0
x
x > 0
x
0
class Relu:
def __init__(self): ...
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