---
title: 【ゼロから作るDeep Learning】3.1~3.2
tags: 
author: [京都大学人工知能研究会KaiRA](https://www.docswell.com/user/kyoto-kaira)
site: [Docswell](https://www.docswell.com/)
thumbnail: https://bcdn.docswell.com/page/8EDYKPX6EG.jpg?width=480
description: 【ゼロから作るDeep Learning】3.1~3.2 by 京都大学人工知能研究会KaiRA
published: May 09, 24
canonical: https://www.docswell.com/s/kyoto-kaira/58GJL1-2024-05-09-230138
---
# Page. 1

![Page Image](https://bcdn.docswell.com/page/8EDYKPX6EG.jpg)

ニューラルネットワーク
ゼロから作るDeep Learning
3.1-3.2
ALAWIK Abdourrahman
ゼロから作るDeep Learning章3.1-3.2
1
Hello World!
1


# Page. 2

![Page Image](https://bcdn.docswell.com/page/V7P6KNKZJ8.jpg)

パーセプトロンの復習（3.1.2章）
• 複数の入力信号を受け取り、一つの信号を出力する。
• 一般的に、入力x1,x2,…,xn、重みw1,w2,…,wn、バイアスbがあった
とき、出力yは次のように計算できる。
𝑦=
0
1
𝑏 + ∑𝑤 𝑥 ≤ 0
𝑏 + ∑𝑤 𝑥 &gt; 0
ゼロから作るDeep Learning章3.1-3.2
2
1が入力扱いされたが、実際は入力ではなく定数なので、暗い色のノードに入
れて表す。
2


# Page. 3

![Page Image](https://bcdn.docswell.com/page/2JV3VKVMEQ.jpg)

3.1.3 活性化関数の登場
• 先ほどの式から、出力は入力の線型結合である 𝑏 + ∑ 𝑤 𝑥 の関
数として書ける：y=h(𝑏 + ∑ 𝑤 𝑥 )。
• パーセプトロンのとき、hはステップ関数である
y=h(x) =
0
𝑥≤0
1
𝑥&gt;0
ゼロから作るDeep Learning章3.1-3.2
3
(x=&gt; 𝑏 + ∑ 𝑤 𝑥 )
3


# Page. 4

![Page Image](https://bcdn.docswell.com/page/5EG3LQLX7L.jpg)

3.2 活性化関数
• 一般に、出力が入力の線型結合 𝑏 + ∑ 𝑤 𝑥 の関数として表され
たとき、その関数は活性化関数と呼ばれる。
• ステップ関数を用いたとき：ニューラルネットワーク
ゼロから作るDeep Learning章3.1-3.2
4
それぞれの円はノード＝ニューロンと呼ばれる。全体のグラフはニューラル
ネットワーク。
4


# Page. 5

![Page Image](https://bcdn.docswell.com/page/4JQ5YKY57P.jpg)

3.2.1-3.2.5 シグモイド関数
h x =
1
1+𝑒
ステップ
シグモイド
不連続
滑らか
出力は０か１
出力は０と１の間の実数
lim ℎ 𝑥 = 1
→
lim ℎ 𝑥 = 0
→
ゼロから作るDeep Learning章3.1-3.2
5
5


# Page. 6

![Page Image](https://bcdn.docswell.com/page/K749WPWVE1.jpg)

3.2.6 非線形関数
• 線型関数とは：h(x)=cx c：定数
• 線型関数は隠れ層で何個も使ったとしても、一つに変えられる
ので、意味がない。
• よって、シグモイドのような非線形関数を使う。
ゼロから作るDeep Learning章3.1-3.2
6
例 h1(x) = c1x、 h2(x) = c2x、 h3(x) = c3x のとき、
h1(h2(x)+ h3(x))=c1(c2+c3) x
線型関数を使う代わりに、重みを利用
6


# Page. 7

![Page Image](https://bcdn.docswell.com/page/LJ1KY9Y47G.jpg)

3.2.7 ReLU 関数
ニューラルネットワークの歴史において、古くから利用される。
本書の後半は主にReLU関数を使う。
h(x) =
0
𝑥≤0
𝑥
𝑥&gt;0
ゼロから作るDeep Learning章3.1-3.2
7
7


# Page. 8

![Page Image](https://bcdn.docswell.com/page/GJWDGQGZ72.jpg)

実装（Python）
ステップ関数、引数が実数のとき
def step_function(x) :
if x &gt; 0 :
return 1
else :
return 0
ゼロから作るDeep Learning章3.1-3.2
8
8


# Page. 9

![Page Image](https://bcdn.docswell.com/page/4EZGLWLLJ3.jpg)

実装（Python）
ステップ関数、引数が実数のとき（別解）
def step_function(x) :
return((int)(x&gt;0))
ゼロから作るDeep Learning章3.1-3.2
9
True -&gt; 1
False -&gt; 0
9


# Page. 10

![Page Image](https://bcdn.docswell.com/page/Y76YWGWMEV.jpg)

実装（Python）
ステップ関数、引数がNumPy配列のとき
def step_function(x) :
return (x &gt; 0).astype(np.int)
ゼロから作るDeep Learning章3.1-3.2
10
[-1,3,2,0.-3] -&gt; [0,1,1,0,0]
10


# Page. 11

![Page Image](https://bcdn.docswell.com/page/G75GMVMQ74.jpg)

実装（Python）
シグモイド関数
def sigmoid(x) :
return 1/(1+np.exp(-x))
ゼロから作るDeep Learning章3.1-3.2
11
[a,b,c…]-&gt;[1/(1+exp(-a)), 1/(1+exp(-b)), 1/(1+exp(-c))…]
11


# Page. 12

![Page Image](https://bcdn.docswell.com/page/9J2Y939WJR.jpg)

実装（Python）
ReLU関数
def relu(x) :
return np.maximum(0, x)
ゼロから作るDeep Learning章3.1-3.2
12
12


# Page. 13

![Page Image](https://bcdn.docswell.com/page/DEYG4149EM.jpg)

実装（Python）
グラフ
import numpy as np
import matplotlib.pylab as plt
x=np.arrange(-5.0,5.0,0.1)
y=h(x)
plt.plot(x,y)
plt.ylim(-0.1,1.1)
plt.show()
ゼロから作るDeep Learning章3.1-3.2
13
x=[-5.0,-4.9,-4.8,…,4.8,4.9,5.0]
ylim:yの範囲
13


