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
440
ゼロから作る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
210
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.6k
DeepLearningの本番環境にSageMakerを利用してる話
ota42y
1
6.1k
検索結果の良さを計測して定量的に改善していく
ota42y
3
2.4k
Flutterを広めるために技術同人誌を作った話
ota42y
1
1.6k
何も考えずにCIや継続的デリバリーしたら辛くなった話.pdf
ota42y
0
2.9k
Other Decks in Programming
See All in Programming
LangChainでWebサイトの内容取得やGitHubソースコード取得
shukob
0
160
unique パッケージから学ぶ interning と weak reference @ Asakusa.go#3
karamaru
2
810
Lessons by WebAssembly app in production on CDN Edge Computing Service
tetsuharuohzeki
0
210
Kotlin 2.0が与えるAndroid開発の進化
masayukisuda
1
370
Debugging: All you need to know (for simultaneous interpreting)
jmatsu
2
760
watsonx.ai Dojo #2 生成AIを使ったアプリ開発入門編
oniak3ibm
PRO
0
110
Architecture Decision Record (ADR)
nearme_tech
PRO
1
680
メモリ最適化を究める!iOSアプリ開発における5つの重要なポイント
yhirakawa333
0
410
connect-go で面倒くささと戦う / 2024-08-27 #newmo_layerx_go
izumin5210
2
640
rails_girls_is_my_gate_to_join_the_ruby_commuinty
maimux2x
0
200
実践 Advanced CallKit 〜快適な通話の実現に向けて〜
mot_techtalk
3
140
労務ドメインを快適に開発する方法 / How to Comfortably Develop in the Labor Domain
yuki21
1
250
Featured
See All Featured
Building a Scalable Design System with Sketch
lauravandoore
458
32k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
157
15k
Being A Developer After 40
akosma
84
590k
It's Worth the Effort
3n
182
27k
Pencils Down: Stop Designing & Start Developing
hursman
119
11k
Infographics Made Easy
chrislema
239
18k
WebSockets: Embracing the real-time Web
robhawkes
59
7.3k
Learning to Love Humans: Emotional Interface Design
aarron
270
40k
A Philosophy of Restraint
colly
202
16k
How STYLIGHT went responsive
nonsquared
93
5.1k
Bootstrapping a Software Product
garrettdimon
PRO
304
110k
Fashionably flexible responsive web design (full day workshop)
malarkey
401
65k
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