32
coursera e-learning “machine-learning” week4:”Neural Networks”

Coursera "Neural Networks"

Embed Size (px)

Citation preview

coursera e-learning“machine-learning”

week4:”Neural Networks”

Agenda

1. Motivations

2. Neural Networks

3. Applications

1.Motivations:Non-linear Hypotheses

1.Motivations:Non-linear Hypotheses

• What’s This?

– 例えば「車」

• 「車」と判断する基準は何ですか?

– 色

– 形

– タイヤの数

– …

1.Motivations:Non-linear Hypotheses

• PCだと?(画像認識の例)

– 識別できそうな情報:色、座標、…

1.Motivations:Non-linear Hypotheses

• PCだと?(画像認識の例)

– 識別できそうな情報:色、座標、…

• 要素としてみると非常に多い

• 例:50x50pixelの画像

– 50×50=2500pixel分の情報を持つ

• RGBなら7500、α入りなら10000

– トレーニングセットとして入力すると…?

普通に二次式で当てはめたりを考えると、非常にコストがかかる

1.Motivations:Neurons and the Brain

1.Motivations:Neurons and the Brain

• ニューラルネットワーク

– 初出:1943 (多分)• Warren S. McCulloch; Walter Pitts (1943).

– 古くからある

– 当時は再現しきれなかった

– コンピュータの性能向上

• 大量のデータを高速で処理できるように

thus far

Now

1.Motivations:Neurons and the Brain

• ニューラルネットワーク

– ノード間の密な高次の結合

– 複雑な問題への適用が可能(非線形分類等)

– 並列処理が基本

– コンピュータと好相性

• マルチプロセッサ等

– 入出力は単純

– ハードウェアとしての実装も可能

1.Motivations:Neurons and the Brain

• ニューラルネットワーク

– 「脳は最高の学習・認識能力を持つ」

– 「学習システムを作ろう」

• 何を手本とするべきか?

– 「目の前にある、最高の学習装置」

– つまり脳

2.Neural Networks:Model Representation Ⅰ

2.Neural Networks:Model Representation Ⅰ

• ニューラルネットワークを機械学習に

x1

x2

x3

x0

hθ(x)

𝑥 =

𝑥0𝑥1𝑥2𝑥3

, 𝜃 =

𝜃0𝜃1𝜃2𝜃3

計算

input

bias unit

output

weights

input:入力

2.Neural Networks:Model Representation Ⅰ

• ニューラルネットワークを機械学習に

x1

x2

x3

x0

hθ(x)

𝑥 =

𝑥0𝑥1𝑥2𝑥3

, 𝜃 =

𝜃0𝜃1𝜃2𝜃3

計算

input

bias unit

output

weights

bias unit:前提条件

2.Neural Networks:Model Representation Ⅰ

• バイアスは人間にもある

– なぜ「車」だと思うのか?

• サーキットだし

• 走ってる

• タイヤついてる

• 二輪じゃない

• 車の流れだったし

• その他もろもろの思い込みモデルにおいても設定するべき

2.Neural Networks:Model Representation Ⅰ

• ニューラルネットワークは階層的

x1

x2

x3

x0

a2 hθ(x)

a0

a1

a3

Layer1 Layer2 Layer3

「3層ニューラルネット」

2.Neural Networks:Model Representation Ⅰ

• ニューラルネットワークは階層的• 単純なアルゴリズムだけで複雑な計算を実現

x1

x2

x3

x0

a2 hθ(x)

a0

a1

a3

Layer1 Layer2 Layer3

bias unit

hidden layer

output layer

input layer

2.Neural Networks:Model Representation Ⅰ

• 数式で表現してみると…

𝑎1(2)

= 𝑔(𝜃101𝑥0 + 𝜃11

1𝑥1 + 𝜃12

1𝑥2 + 𝜃13

(1)𝑥3)

𝑎2(2)

= 𝑔(𝜃201𝑥0 + 𝜃21

1𝑥1 + 𝜃22

1𝑥2 + 𝜃23

(1)𝑥3)

𝑎3(2)

= 𝑔(𝜃301𝑥0 + 𝜃31

1𝑥1 + 𝜃32

1𝑥2 + 𝜃33

(1)𝑥3)

h𝜃 𝑥 = 𝑎1(3)

= 𝑔(𝜃102𝑎0(2)

+ 𝜃112𝑎1(2)

+ 𝜃122𝑎2(2)

+ 𝜃13(2)𝑎3(2))

𝑥 =

𝑥0𝑥1𝑥2𝑥3

, 𝜃 =

𝜃0𝜃1𝜃2𝜃3

2.Neural Networks:Model Representation Ⅱ

2.Neural Networks:Model Representation Ⅱ

• より単純に(ベクトル表現)

• まとめて

𝑧1(2)

= 𝜃101𝑥0 + 𝜃11

1𝑥1 + 𝜃12

1𝑥2 + 𝜃13

(1)𝑥3

𝑎1(2)

= 𝑔(𝑧1(2))

x =

𝑥0𝑥1𝑥2𝑥3

, 𝑧(2) =

𝑧12

𝑧22

𝑧32

𝑧(2) = 𝜃(1)𝑎(1), 𝑎(2) = 𝑔(𝑧(2))

Add 𝑎0(2)

= 1, 𝑧(3) = 𝜃(2)𝑎(2)

ℎ𝜃 𝑥 = 𝑎(3) = 𝑔(𝑧(3))

bias unit追加

3.Applications:Examples and Intuitions Ⅰ

3.Applications:Examples and Intuitions Ⅰ

• 論理演算 AND

– 要素とパラメータをシグモイド関数に入れる

+1

x1

x2

hθ(x)

x1 x2 hθ0 0 g(-30)0 1 g(-10)1 0 g(-10)1 1 g(10)

-30

+20

+20

ℎ𝜃 𝑥 =g z = g(−30 + 20𝑥1 + 20𝑥2)

x1 x2 hθ0 0 00 1 01 0 01 1 1

3.Applications:Examples and Intuitions Ⅰ

• 論理演算 AND

– 要素とパラメータをシグモイド関数に入れる

+1

x1

x2

hθ(x)

-30

+20

+20

ℎ𝜃 𝑥 =g z = g(−30 + 20𝑥1 + 20𝑥2)

AND

x1 x2 hθ0 0 g(-10)0 1 g(10)1 0 g(10)1 1 g(30)

3.Applications:Examples and Intuitions Ⅰ

• 論理演算 OR

– 要素とパラメータをシグモイド関数に入れる

+1

x1

x2

hθ(x)

-10

+20

+20

ℎ𝜃 𝑥 =g z = g(−10 + 20𝑥1 + 20𝑥2)

x1 x2 hθ0 0 00 1 11 0 11 1 1

3.Applications:Examples and Intuitions Ⅰ

• 論理演算 OR

– 要素とパラメータをシグモイド関数に入れる

+1

x1

x2

hθ(x)

-10

+20

+20

ℎ𝜃 𝑥 =g z = g(−10 + 20𝑥1 + 20𝑥2)

OR

3.Applications:Examples and Intuitions Ⅱ

3.Applications:Examples and Intuitions Ⅱ

• ここまでの例

0

0.2

0.4

0.6

0.8

1

1.2

0 0.2 0.4 0.6 0.8 1 1.2

AND

0

0.2

0.4

0.6

0.8

1

1.2

0 0.2 0.4 0.6 0.8 1 1.2

OR

どちらも線形 = ニューラルネットワークでなくても分類可能

面倒な分類 = 非線形分類への適用を考える

3.Applications:Examples and Intuitions Ⅱ

• 非線形分類への適用-XNOR

0

0.2

0.4

0.6

0.8

1

1.2

0 0.2 0.4 0.6 0.8 1 1.2

x1 x2 a1 a2 hθ0 0 0 1 10 1 0 0 01 0 0 0 01 1 1 0 1

3.Applications:Examples and Intuitions Ⅱ

• 非線形分類への適用-XNOR

+1

x1

x2

a1

hθ(x)

-30+20

+20

a2

10

-20

-20

+1 x1 AND x2

(NOT x1) AND (NOT x2)

x1 OR x2

-10

20

20

x1 x2 a1 a2 hθ0 0 0 1 10 1 0 0 01 0 0 0 01 1 1 0 1

3.Applications:Examples and Intuitions Ⅱ

• 非線形分類への適用-XNOR

+1

x1

x2

a1

hθ(x)

-30+20

+20

a2

10

-20

-20

+1 x1 AND x2

(NOT x1) AND (NOT x2)

x1 OR x2

-10

20

20

線形分類の積み重ねで非線形分類が可能に!

3.Applications:Multiclass Classification

3.Applications:Multiclass Classification

• 多クラス分類に適用するには?One-vs-allを利用

3.Applications:Multiclass Classification

• 4クラス分類の例

+1

x1

x2

input layer layer 2 layer 3 output layer

分類結果を行列表現

ℎ𝜃 𝑥 ≈

1000

, ℎ𝜃 𝑥 ≈

0100

,

ℎ𝜃 𝑥 ≈

0010

, ℎ𝜃 𝑥 ≈

0001