SlideShare une entreprise Scribd logo
1  sur  16
「深層学習による自然言語処
理」読書会
第2章2.1~2.5
白土 慧
株式会社レトリバ
© 2017 Retrieva, Inc.
自己紹介
• 名前:白土 慧
• 年齢:33歳
• 所属:株式会社レトリバ(2016年4月〜)
• 職業:エンジニア
• 自然言語処理:大学の授業レベル。
• 深層学習:入社してから少しだけ案件で。
© 2017 Retrieva, Inc. 2
範囲
• 2. ニューラルネットの基礎
• 2.1 教師あり学習
• 2.2 順伝搬型ニューラルネット
• 2.3 活性化関数
• 2.4 勾配法
• 2.5 誤差逆伝搬法
© 2017 Retrieva, Inc. 3
2. ニューラルネットの基礎
• この章で紹介すること
• 機械学習とは何か
• 誤差逆伝搬法
• 広く使われているニューラルネットの構造(次回)
© 2017 Retrieva, Inc. 4
2.1 教師あり学習
• 深層学習は、ニューラルネットを関数近似に使う手法
• ニューラルネットはあくまでもデータから関数を学習するため
のモデル
© 2017 Retrieva, Inc. 5
2.1.1 教師あり学習の定義
• 教師あり学習では、訓練データを使って所望の予測モデルを学
習する。
• 訓練データ:正解事例の集合
• 式(2.1):入力変数x(n)と出力変数y(n)について、損失を最小化す
るようなパラメータθを求める手続き
• 損失: x(n), y(n) を損失関数にかけた結果の平均値
• つまり学習とは、最適化アルゴリズムを使って、ある関数を最
小化するパラメータ値を求める、最適化問題である
© 2017 Retrieva, Inc. 6
2.1.2 損失関数
• 損失関数を何にするかも設計要素
• fθ(x,y) は予測モデル。本書ではニューラルネットとする
• 交差エントロピー損失関数
• 真の分布とモデルとの距離を表す交差エントロピーを、訓練データで
近似する
• ヒンジ損失関数
• 正解y(n)と、正解を除いた中で最もスコアが大きい 𝑦だけを使って損失
を定義する
• これを用いて学習するアルゴリズムをサポートベクトルマシンと呼ぶ
© 2017 Retrieva, Inc. 7
2.1.3 教師あり学習に用いるデータ
• 訓練データに対してだけ正しく予測できても意味がない
• 本当は世の中全てのデータを訓練データとしたいが、不可能
• 最適化問題と違い、教師あり学習は訓練データに最適化できれば良い
わけではない
• 評価データと開発データを用意する
• 評価データ:学習の最後に、モデルを評価するための正解事例
• 開発データ:学習の過程で使う正解事例
© 2017 Retrieva, Inc. 8
2.2.2 順伝搬型ニューラルネット、モデル
• 最も単純な構造である順伝搬型ニューラ
ルネット(FFNN)
• 行列Wをかけてベクトルbを足す、という
作業を層ごとに繰り返す
• 活性化関数a(l)を通す
• パラメータθは、{W(1),…W(l),b(1)…b(l)}と
なる
• 隠れ状態ベクトルの次元数、または層の
数が多いと、入力データを細かく分類で
きる
• つまり深いニューラルネットは表現力が高
いと言われる
© 2017 Retrieva, Inc. 9
o
h(2)
h(1)
h(0) = x
h(1) = a(1)(W(1)x +b(1))
h(2) = a(2)( W(2)h(1) +b(2))
o = W(3)h(2) +b(3)
2.3 活性化関数
• 活性化関数として非線形関数を適用する
• sigmoid
• tanh
• ReLU
• 勾配法と組み合わせるため、微分可能な関数を選ぶ
• 活性化関数と性能の関係は明確になっていないので、実験的に選ぶことが多
い
• 非線形関数を通さない2層のFFNNは、等価な1層のFFNNで構成でき
てしまう
• 深い構造を有効活用するため、非線形な活性化関数を適用する必要がある
© 2017 Retrieva, Inc. 10
2.4.1 勾配法、勾配法による関数最小化
• 2.1節の通り、学習はL(θ)の最小化
• ニューラルネットでは勾配法による最適化がよく使われる
• パラメータθを下記の式で更新していく
• θ(k+1)=θ(k)-η∂L(θ(k))
• 関数Lをθ(k)において偏微分を取り線形近似し、最も減る方向(最急降
下方向)に向かって、ηぶんパラメータを動かす
© 2017 Retrieva, Inc. 11
2.4.2 ミニバッチ化による確率的勾配法
• 式(2.1)では訓練データのすべての事例を利用している。バッチ法と呼ぶ
• 一回の評価に時間がかかりすぎる
• 最急降下方向は局所的な性質なので、雑に早く計算してパラメータ更新回数を増や
した方が、早く良い解にたどり着ける
• 事例からランダムに選んで勾配法を実行する確率的勾配法がよく使われる
• 1事例だけ使う(オンライン法)だとパラメータ更新回数は多くできるが、
偏微分のバラツキが大きい
• いいとこ取りをして、事例からランダムに複数選ぶ、ミニバッチ法を用い
る
• 選ぶ個数:バッチサイズ
• 全データ数/バッチサイズ:1エポック
© 2017 Retrieva, Inc. 12
2.5.1 誤差逆伝搬法、ニューラルネットの微分
• 誤差逆伝搬法:ニューラルネットにおいて目的関数の偏微分を
計算するアルゴリズム
• 自分で実装する必要はあまりない
• ニューラルネットを合成関数と捉え微分の連鎖律を使うと、
ニューラルネットの微分はそれぞれの導関数の積で表せる
© 2017 Retrieva, Inc. 13
2.5.2 深いニューラルネットの難しさ
• 隠れ層1層を持つニューラルネットをスコア関数 f とすると、
f(x,y) = f(o)(f(1)(x), y)=wy
(o)w(1)x
• 損失関数にかけた l(f(o)(f(1)(x), y)) を目的関数とすると、f(1)のパラ
メータw(1)における微分は(式2.31)、
𝜕𝑙 𝑜 𝑦
𝜕𝑜 𝑦
𝑤 𝑦
(𝑜)
𝑥
• これは関数評価とは逆方向に誤差(損失関数の入力による微分)が
かけられている
• 誤差が関数評価とは逆方向に伝達されることになるので誤差逆伝搬法
© 2017 Retrieva, Inc. 14
2.5.2 深いニューラルネットの難しさ
• 偏微分の計算は、目的関数の計算グラフを逆に辿っていく
© 2017 Retrieva, Inc. 15
入
力
(
訓
練
デ
ー
タ
)
行
列
活
性
化
関
数
行
列
活
性
化
関
数
行
列
損
失
関
数
順伝搬の計算
偏微分の計算
2.5.2 深いニューラルネットの難しさ
• 隠れ層を2つに増やすと(式2.33)、
𝜕𝑙 𝑜 𝑦
𝜕𝑜 𝑦
𝑤 𝑦
𝑜
𝑤(3) 𝑤(2) 𝑥
• 層が増えると積の回数が増える
• パラメータが大きいと、微分の値が非常に大きくなる:勾配爆発
• パラメータが小さいと、微分の値が非常に小さくなる:勾配消失
• 層を増やすと表現力は大きくなるが、学習が困難になる
• ResNetのような手法を用いると、1000層も可能になる
© 2017 Retrieva, Inc. 16

Contenu connexe

En vedette

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

深層学習による自然言語処理勉強会2章前半