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

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

by 斋藤康毅
July 2018
Intermediate to advanced
310 pages
8h 21m
Chinese
Posts & Telecom Press
Content preview from 深度学习入门 : 基于Python的理论与实现
3.2  激活函数 
43
信号被传送给下一个神经元。实际上,上一章介绍的感知机和接下来要介绍
的神经网络的主要区别就在于这个激活函数。其他方面,比如神经元的多层
连接的构造、信号的传递方法等,基本上和感知机是一样的。下面,让我们
通过和阶跃函数的比较来详细学习作为激活函数的
sigmoid
函数。
3.2.2
 阶跃函数的实现
这里我们试着用
Python
画出阶跃函数的图(从视觉上确认函数的形状对
理解函数而言很重要)。阶跃函数如式(3.3)所示,当输入超过0 时,输出 1
否则输出0。可以像下面这样简单地实现阶跃函数。
def step_function(x):
if x > 0:
return 1
else:
return 0
这个实现简单、易于理解,但是参数
x
只能接受实数(浮点数)。也就是
说,允许形如
step_function(3.0)
的调用,但不允许参数取
NumPy
数组,例
step_function(np.array([1.0, 2.0]))
。为了便于后面的操作,我们把它修
改为支持
NumPy
数组的实现。为此,可以考虑下述实现。
def step_function(x):
y = x > 0
return y.astype(np.int)
上述函数的内容只有两行。由于使用了
NumPy
中的“技巧”,可能会有
点难理解。下面我们通过
Python
解释器的例子来看一下这里用了什么技巧。
下面这个例子中准备了
NumPy
数组
x
,并对这个
NumPy
数组进行了不等号
运算。
>>> import numpy as np
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