Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
ChainerとAnnoyを使った 類似画像検索
takaaki shimbo
August 29, 2018
Technology
0
840
ChainerとAnnoyを使った 類似画像検索
Qiita:
https://qiita.com/ta7uwtaka/items/9301eef7dd74a249d5ea
takaaki shimbo
August 29, 2018
Tweet
Share
Other Decks in Technology
See All in Technology
Power AutomateでのAdaptive Cards-基本編
miyakemito
1
300
Custom GitHub Actions by Java
kazamori
0
290
モブに早く慣れたい人のためのガイド / A Guide to Getting Started Quickly with Mob Programming
cybozuinsideout
PRO
2
1.8k
Meet passkeys
satotakeshi
1
120
誰が正解を知っているのか / Who knows the right answer
takaking22
1
240
Target SDK Versionを上げない Notification runtime permission対応
napplecomputer
0
140
HoloLens2とMetaQuest2どちらも動くWebXRアプリをBabylon.jsで作る
iwaken71
0
190
リファインメントは楽しいかね?
kitamu_mu
1
430
Design for Humans: How to make better modernization decisions
indualagarsamy
2
120
現状のFedCMの動作解説と OIDCとの親和性について- OpenID TechNight vol.19
ritou
2
450
音のような言葉 〜ちゃちゃっとチャットで楽しむちょっとしたコツ〜 / words like sounds
satoryu
1
1.4k
The Fractal Geometry of Software Design
vladikk
0
870
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
9
1.3k
Building Better People: How to give real-time feedback that sticks.
wjessup
344
17k
Building an army of robots
kneath
299
40k
Clear Off the Table
cherdarchuk
79
280k
For a Future-Friendly Web
brad_frost
166
7.4k
Fireside Chat
paigeccino
12
1.3k
Teambox: Starting and Learning
jrom
123
7.7k
Adopting Sorbet at Scale
ufuk
63
7.6k
Faster Mobile Websites
deanohume
294
28k
Infographics Made Easy
chrislema
233
17k
Code Review Best Practice
trishagee
43
9.2k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
349
27k
Transcript
Chainer ͱAnnoyΛͬͨ ྨࣅը૾ݕࡧ ʙɹ͘͘Ռൃද + هɹʙ Shimbo Takaaki 2018 /
08 / 25 @Chainer mokumoku #2
ࣗݾհ • ໊લɿɹ৽อɹᠳཅ • 4݄͔Βࣾձਓ (ERPͷձࣾ ) • Twitter: @ta7uw
• GitHub: @takaaki82 • Qiita: https://qiita.com/ta7uwtaka
ྨࣅը૾ݕࡧͱ • ಛϕΫτϧ Ͱදݱ͞Εͨը૾ʹ͍ۙը૾Λ σʔλϕʔεͷத͔Β୳͢͜ͱ • σʔλϕʔεͷͯ͢ͷը૾ͱྨࣅΛൺֱ͠ ͍ͯΔͱେͳܭࢉྔʹͳΓ͕͔͔࣌ؒΔͷ ͰɺޮΑ͘ࣅ͍ͯΔը૾Λ୳ͩ͢͜͠ͱ͕ ٻΊΒΕΔɻ
Pinterest
Approach • ը૾ಛྔͷྨࣅܭࢉ ը૾͔ΒCNNͳͲͰಛྔΛநग़͠ɺίαΠϯྨࣅͳͲͷؔʹΑͬ ͯྨࣅܭࢉΛߦ͏͜ͱͰը૾ͷྨࣅΛٻΊΔ → ࠓճͪ͜ΒΛ࣮͢Δ • Deep LearningΛͬͨྨࣅֶश
ࣅ͍ͯΔը૾Ͱ͋Εɺྨࣅ͕େ͖ͳΔΑ͏ʹଛࣦΛઃఆֶͯ͠शΛ ߦ͏
ߏ ɾը૾ಛྔநग़ ֶशࡁΈը૾ೝࣝϞσϧͷதؒΛ͏ → Chainer ɾಛྔͷྨࣅܭࢉ ۙࣅ࠷ۙ୳ࡧ(ANN)Λ͏ → Annoy
ۙࣅ࠷ۙ୳ࡧϥΠϒϥϦ Annoy
Annoy • ࠷ۙ୳ࡧ(ANN)Λ࣮ͨ͠ϥΠϒϥϦ • Spotify͕։ൃ͢ΔOSS • ԻָͷϨίϝϯυػೳʹΘΕ͍ͯΔ • C++࣮ɹ-> PythonόΠϯσΟϯά
• PythonͰ؆୯ʹ͑Δ
MNISTͰྨࣅը૾Λ୳ͯ͠ΈΔ ݕࡧʹ ͬͨը૾
CIFAR-10ͷֶश • ࠓճσʔληοτʹCIFAR-10Λ༻͍Δ • ௨ৗͷը૾ྨͱಉ༷ʹChainerͰֶशΛߦ͏ • ֶशΛߦͬͨϞσϧΛಛྔநग़ʹ͏
ಛྔΛAnnoyʹՃ from annoy import AnnoyIndex train, test = chainer.datasets.get_cifar10() dim
= 1024 #தؒͷग़ྗͷཁૉ annoy_model = AnnoyIndex(dim) with chainer.using_config('train', False), chainer.using_config('enable_backprop', False): for i in range(len(train)): img, _ = train[i] # numpy -> cupy x = model.xp.asarray(img[None, ...]) # ֶशσʔλͷਪ݁Ռͷ͏ͪը૾ྨϞσϧͷ̍̌ͷग़ྗΛಘΔ x = get_hidden(model ,9 ,x=x).data x = x.reshape(-1) #cupy -> numpy x = chainer.cuda.to_cpu(x) annoy_model.add_item(i, x) # AnnoyϞσϧͷϏϧυ(ҎޙσʔλͷՃߦ͑ͳ͍) annoy_model.build(1000) annoy_model.save("cifar-10-1000tree.ann")
ۙࣅ࠷ۙ୳ࡧͷ࣮ߦ x = model.xp.asarray(x[None, …]) x = get_hidden(model ,9 ,x=
x).data x = x.reshape(-1) x = chainer.cuda.to_cpu(x) # ಛϕΫτϧxΛΘͨ͢ͱɺྨࣅܭࢉΛߦ͍ɺྨࣅͷେ͖͍ͷΛฦ͢ɹɹɹɹɹɹɹɹɹɹɹ predict_indexes = annoy_model.get_nns_by_vector(x, 5, search_k=-1)
݁Ռ ը૾ΫΤϦ
ը૾ΫΤϦ
·ͱΊ • Chainerͱۙࣅ࠷ۙ୳ࡧϥΠϒϥϦAnnoyΛ ͏ͱྨࣅը૾ݕࡧͰ͖Δ • ࣍Deep LearningͷྨࣅֶशΛͬͨྨ ࣅը૾ݕࡧΛ࣮ͯ͠ΈΔ
ࢀߟ • Start Today Technologies TECH BLOG (https://tech.starttoday-tech.com/entry/detection_and_retrieval) • ݪాୡ
(2017) , ը૾ೝࣝɹػցֶशϓϩϑΣογϣφϧ γϦʔζ • Deep metric learning using Triplet network (https://arxiv.org/pdf/1412.6622.pdf)
ৄࡉQiitaʹॻ͖·ͨ͠ɻ Α͔ͬͨΒͲ͏ͧ Qiita
͝ਗ਼ௌ ͋Γ͕ͱ͏͍͟͝·ͨ͠