Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ゼロから作るDeep Learning 2 3章 word2vec 3.1〜3.2
Search
ota42y
May 29, 2019
Programming
1
450
ゼロから作るDeep Learning 2 3章 word2vec 3.1〜3.2
ゼロから作るDeep Learning 2 自然言語編 読書会 第5回
の資料です!
https://retrieva.connpass.com/event/131746/
ota42y
May 29, 2019
Tweet
Share
More Decks by ota42y
See All by ota42y
バックログを導入し やっぱやめた話
ota42y
0
230
PFNにある2つのKubernetes
ota42y
10
5.3k
Q&A for How to use OpenAPI3 for API developer
ota42y
0
2.5k
How to use OpenAPI3 for API developer (RubyKaigi 2019)
ota42y
5
20k
How should we face with microservices (我々はマイクロサービスとどう向き合うべきか)
ota42y
20
4.7k
DeepLearningの本番環境にSageMakerを利用してる話
ota42y
1
6.2k
検索結果の良さを計測して定量的に改善していく
ota42y
3
2.4k
Flutterを広めるために技術同人誌を作った話
ota42y
1
1.6k
何も考えずにCIや継続的デリバリーしたら辛くなった話.pdf
ota42y
0
2.9k
Other Decks in Programming
See All in Programming
Synchronizationを支える技術
s_shimotori
1
150
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
110
Kubernetes for Data Engineers: Building Scalable, Reliable Data Pipelines
sucitw
1
200
C#/.NETのこれまでのふりかえり
tomokusaba
1
160
GitHub Actionsのキャッシュと手を挙げることの大切さとそれに必要なこと
satoshi256kbyte
5
390
Identifying User Idenity
moro
6
7.9k
推し活としてのrails new/oshikatsu_ha_iizo
sakahukamaki
3
1.7k
gopls を改造したら開発生産性が高まった
satorunooshie
8
240
讓數據說話:用 Python、Prometheus 和 Grafana 講故事
eddie
0
350
現場で役立つモデリング 超入門
masuda220
PRO
13
2.9k
Why Spring Matters to Jakarta EE - and Vice Versa
ivargrimstad
0
980
CSC305 Lecture 13
javiergs
PRO
0
130
Featured
See All Featured
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
167
49k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Git: the NoSQL Database
bkeepers
PRO
425
64k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
290
Making Projects Easy
brettharned
115
5.9k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Agile that works and the tools we love
rasmusluckow
327
21k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Imperfection Machines: The Place of Print at Facebook
scottboms
264
13k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
A Philosophy of Restraint
colly
203
16k
Transcript
θϩ͔Β࡞ΔDeep Learning 2 ̏ষ word2vec 3.1ʙ3.2 ota42y θϩ͔Β࡞ΔDeep Learning
2 ࣗવݴޠฤ ಡॻձ ୈ5ճ
͜ͷষͰΔ͜ͱ • word2vecΛ࣮͢Δ • ਪϕʔεͰ୯ޠΛϕΫτϧͰද͢ํ๏ • γϯϓϧ͕ͩແବଟ͍࣮ • ࣍ͷষͰରԠ
3.1 ਪϕʔεͷख๏ͱ χϡʔϥϧωοτϫʔΫ
ਪϕʔεͷϕΫτϧԽ • ୯ޠΛϕΫτϧʹ͢Δ̎ͭͷख๏ • Χϯτϕʔεʢ̎ষʣ • ਪϕʔεʢ̏ষʣ • ͲͪΒԾઃΛϕʔεʹͯ͠Δ͕Ξϓϩʔνશ͘ผ •
Ծઃɿ୯ޠͷҙຯपғͷ୯ޠ͔Βܗ͞ΕΔ (p.67)
3.1.1ɹΧϯτϕʔεͷख๏ͷ • Χϯτϕʔεपғͷ୯ޠͷසΛܭࢉ͢Δ • ޠኮ͕nͩͱn*nͷڊେͳڞىߦྻ͕ඞཁʹͳΔ • ࣍ݩݮͷͨΊͷSVDO(n^3)ͷܭࢉྔɺ͍
ਪϕʔεͷར • Χϯτϕʔείʔύεશମͷ౷ܭσʔλΛҰؾʹར༻͢Δ • ਪϕʔε(χϡʔϥϧωοτ)ίʔύεͷҰ෦Ͱֶश͢Δ • GPUͷฒྻܭࢉฉ͘ • খ͚ʹͰ͖ɺߴʹฒྻॲཧͰ͖ΔͷͰڊେσʔλͰରԠͰ͖Δ •
ଞʹັྗతͳ͕͋Δ(Β͍͠ɺৄ͘͠3.5.3)
3.1.2ɹਪϕʔεͷख๏ͷ֓ཁ
पғͷ୯ޠ͔Β୯ޠΛʮਪʯ͢Δ • `?`ʹԿ͕ೖΔ͔Λલޙ͔Βਪ • ίϯςΩετ͔ΒλʔήοτΛਪ • ίϯςΩετɿपғͷ୯ޠ(you, goodby) • λʔήοτɿରͷ୯ޠ(`?`)
ਪ݁Ռ • ֤୯ޠ͕ͦ͜ʹݱΕΔ֬Λग़ྗ • ίϯςΩετΛϞσϧʹ༩͑Δͱ୯ޠͷ͕֬ಘΒΕΔ
3.1.3 χϡʔϥϧωοτϫʔΫʹ͓͚Δ୯ ޠͷॲཧํ๏ • χϡʔϥϧωοτϫʔΫ(NN)ͷೖྗݻఆϕΫτϧ • ୯ޠΛͦͷ··ೖΕΔͷ͍͠ • ୯ޠΛone-hotදݱ(one-hotϕΫτϧ)ʹม͢Δ
one-hotදݱ • ޠኮͷ͞Λ࣋ͪɺ୯ޠIDͱ֘͢Δ෦͕1ɺͦΕҎ֎͕0 ͷϕΫτϧ • ͯ͢ͷ୯ޠΛಉ͡͞ͷϕΫτϧͱͯ͠දݱ
one-hotදݱ • શ݁߹Ͱม͢ΔͳΒ؆୯(ྫதؒ=3)
αϯϓϧίʔυ(p.99) • np.dot(c, W)୯ޠʹରԠ͢ΔॏΈΛऔΓग़ͯ͠Δ͚ͩ • W[0]ͷσʔλΛऔΓग़ͯ͠Δ͚ͩ • ແବͬΆ͍͕࣍ͷষͰ࣏͢Β͍͠
ϨΠϠදݱ • MatMulϨΠϠ(p.30)Ͱಉ͜͡ͱ͕Ͱ͖Δ • np.dot͢Δ͚ͩͷϨΠϠͳͷͰ
3.2ɹγϯϓϧͳword2vec
word2vecΛ࣮͢Δ • word2vecͰΘΕΔϞσϧCROWϞσϧͱskip-gramϞσϧ • "word2vec"͕͜ΕΒͷϞσϧΛࢦ͢߹͋Δ • ຊདྷͷҙຯͱζϨͯΔ
3.2.1 CBOWϞσϧͷਪॲཧ • ίϯςΩετ͔ΒλʔήοτΛਪଌ͢ΔNN • ίϯςΩετʹपғͷ୯ޠ • λʔήοτʹରͷ୯ޠ
୯ޠͷࢄදݱ • CBOWϞσϧΛ܇࿅͢Δ͜ͱͰ୯ޠͷࢄදݱΛಘΒΕΔ • Ϟσϧͷύϥϝʔλ͕ࢄදݱʹରԠ͢Δ
CBOWϞσϧͷશମ૾ • ίϯςΩετʹ̎ɺӅΕʹ̏ͷ߹
CBOWϞσϧͷશମ૾ • ೖྗෳݸͷone-hotදݱͷ୯ޠ • ग़ྗ֤୯ޠͷείΞ • softmaxΛ͏ͱ͕֬ಘΒΕΔ • தؒೖྗ͔Βͷͷฏۉ
• ࢄදݱͷਖ਼ମ • [$ W_{in}]7*3ͷॏΈ • ͜Ε͕୯ޠͷࢄදݱ • ֶशʹΑͬͯྑ͍ࢄදݱʹ͍ͯ͘͠
CBOWϞσϧͷϨΠϠදݱ
CBOWϞσϧͷϨΠϠදݱ • ̎ͭͷMatMulϨΠϠ • ୯ޠʹରԠ͢ΔॏΈΛऔΓग़ͭ͢(P.99) • ̎ͭͷฏۉΛऔΔ(=ͯ͠0.5Λ͔͚Δ) • scoreͷશ݁߹ •
׆ੑԽؔແ͍ͷͰΘΓͱγϯϓϧ
3.2.2 CBOWϞσϧͷֶश • χϡʔϥϧωοτϫʔΫͷηΦϦʔ௨Γ • CBOWଞΫϥεྨΛ͢ΔNN • Ϋϥεʹone-hotͰද͞Εͨ୯ޠ • είΞ͔Β֬ΛٻΊͯɺਖ਼ղͱͷࠩΛֶश͢Δ
• Softmaxؔʹ͔͚ͯ֬ʹ͢Δ • ڭࢣϥϕϧ͔ΒަࠩΤϯτϩϐʔޡࠩΛٻΊΔ
ϨΠϠදݱ • Softmax with lossΛ͚Ճ͑Δ
ίʔυϦʔσΟϯά • ch03/cbow_predict.py • https://github.com/oreilly-japan/deep-learning-from- scratch-2/blob/master/ch03/cbow_predict.py
3.2.3 word2vecͷॏΈͱࢄදݱ • ͱɹɹͷҧ͍ • ྆ํͱ୯ޠͷҙຯ͕Τϯίʔυ͞Ε͍ͯΔ • ܗঢ়͕ҧ͏ • ɹɹ7x3
• ɹɹ3x7 Win Wout Win Wout
ࢄදݱɹɹΛ͏ • ɹɹ શ͘Θͳ͍ɹ • ɹɹʹର͢Δskip-ngramͰͷ༗༻ੑ࣮ݧ • https://arxiv.org/abs/1611.01462 • ɹɹ͏͜ͱͰΑ͍݁Ռ͕ಘΒΕΔͱ͍͏ใࠂ
• https://nlp.stanford.edu/projects/glove/ • word2vecͱࣅ͍ͯΔͭͷख๏ Win Win Wout Wout