RubyでChainerつくってます!!

C582b722e015633f7900083f8ea75732?s=47 hatappi
March 30, 2019

 RubyでChainerつくってます!!

Chainer Meetup #09
#chug_jp

C582b722e015633f7900083f8ea75732?s=128

hatappi

March 30, 2019
Tweet

Transcript

  1. RubyͰChainerͭͬͯ͘·͢!! @Chainer Meetup #9

  2. 2 • Yusaku Hatanaka • Merpay Inc. • Backend Engineer

    • GoΛॻ͍͍ͯΔ͜ͱ͕ଟ͍ • ϓϥΠϕʔτ • RubyΛॻ͍͍ͯΔ͜ͱ͕ଟ͍ • Anket: RailsΛ࢖ͬͨSlackͷΞϯέʔταʔϏε • Red Chainer: ʁʁʁʁ
 ↑ࠓ೔͸͜ͷ࿩Λ͠·͢
 self introduction @hatappi
  3. 3 Red Chainer??

  4. 4 + Chainer

  5. 5 Red Chainer

  6. 6 • Rubyのための深層学習フレームワーク • GitHub: red-data-tools/red-chainer • PythonでかかれたChainerをRubyへポーティング Red Chainer

    ͱ͸? Chainer Red Chainer NumPy Numo::NArray
 (ruby-numo/numo-narray) CuPy cumo (sonots/cumo)
  7. 7 ✓ Activation
 Relu, Sigmoid, LeakyReLU, LogSoftmax, Tanh ✓ loss


    SoftMaxEntropy, MeanSquaredError ✓ noise
 Dropout ✓ Normalization
 BatchNormalization ✓ Pooling
 AveragePooling2D, MaxPooling2D ✓ etc
 Chainerͷఏڙ͢ΔVariable΍TrainerͳͲ ͷ֤छAPIΛ༻ҙ͍ͯ͠·͢ ݱঢ়Կ͕Ͱ͖Δͷ͔ ֤छAPIͷఏڙ αϯϓϧ ✓ MNIST ✓ CIFAR 10, 100 ✓ Iris
  8. 8 ͳͥRed Chainer Λ࡞Γ͸͡Ίͨͷ͔

  9. ある⽇ Red Data Tools という プロジェクトに出会う

  10. 10 Red Data Tools • Ruby⽤のデータ処理ツールを提供するプロジェクト • 2017年2⽉に発⾜ • 活動例

    • Apache Arrow本体への開発の参加やRubyのbinding • Charty, Red Datasets, Red Chainer, etc • 毎⽉1回のオフラインMeetupをやっている • 次回は4/9!! • https://speee.connpass.com/event/124079/ https://red-data-tools.github.io/ja/
  11. 11 Red Data Tools Policy 1. Collaborate across the Ruby

    community 2. Acting rather than blaming 3. Continuous, iterative progress rather than a short, big project 4. The current lack of knowledge doesn't matter 5. Ignore criticism from outsiders 6. Fun!
  12. 参加するのは良いけど ⾃分は何をしよう

  13. Rubyで深層学習ができたら ⾯⽩いのでは

  14. ただそれだけですw

  15. 15 Ͳ͏΍ͬͯ ϙʔςΟϯάͨ͠ͷ͔

  16. 16 2017/08 2017/10 2018/05 2019/03 Red Chainer ͷྺ࢙

  17. 17 2017/08 First Commit 2017/10 2018/05 2019/03 Red Chainer ͷྺ࢙

  18. 18 First Commit 2017/08

  19. 19 First Commit • Chainer v2ͷίʔυΛͻͨ͢ΒಡΉ • Python΄ͱΜͲॻ͍ͨ͜ͱͳ͍ͷͰPythonͷυΩϡϝϯτಡ Έͳ͕Βͻͨ͢ΒϙʔςΟϯά •

    ྫ͑͹࠷ॳ͸ˣ͕ͲΜͳڍಈʹͳΔ͔෼͔ΒͣυΩϡϝϯτ ΛಡΉͳͲ͢ΔͨΊ͕͔͔࣌ؒΔ • ͳΕͯ͘Δͱ಄ͷதͰม׵Ͱ͖ΔΑ͏ʹͳΔ
  20. 20 2017/08 First Commit 2017/10 2018/05 2019/03 Red Chainer ͷྺ࢙

  21. 21 2017/08 First Commit 2017/10 First release 2018/05 2019/03 Red

    Chainer ͷྺ࢙
  22. 22 First Release • Multi Layer Perceptron(MLP)ʹඞཁͳ࠷௿ݶͷAPIΛαϙʔτ • ಈ͘΋ͷ͕Ͱ͖ͨʂʂ

  23. DEMO

  24. 24

  25. 25 2017/08 First Commit 2017/10 First release 2018/05 2019/03 Red

    Chainer ͷྺ࢙
  26. 26 2017/08 First Commit 2017/10 First release 2018/05 ৞ΈࠐΈԋࢉΛαϙʔτ 2019/03

    Red Chainer ͷྺ࢙
  27. 27 ৞ΈࠐΈԋࢉͷαϙʔτ • ը૾ࣝผ͍ͨ͠ʂʂʂ • BatchNormalization, Pooling, etc.. ͳͲͷAPIΛ௥Ճ •

    CIFAR-10, 100ͷαϯϓϧͷ௥Ճ • Ϟσϧ͸VGG, ResNet18 • ՄࢹԽͨ͘͠ͳΔ • ྫ͑͹ը૾ࣝผΛRed ChainerͰߦͬͯepoch͝ͱͷਫ਼౓ΛՄ ࢹԽ͍ͨ͠
  28. DEMO

  29. 29 1epoch 45epoch

  30. 30 2017/08 First Commit 2017/10 First release 2018/05 ৞ΈࠐΈԋࢉΛαϙʔτ 2019/03

    Red Chainer ͷྺ࢙
  31. 31 2017/08 First Commit 2017/10 First release 2018/05 ৞ΈࠐΈԋࢉΛαϙʔτ 2019/03

    Chainer 3ܥ΁ͷରԠ Red Chainer ͷྺ࢙
  32. 32 Chainer 3ܥ΁ͷରԠ • Chainer3ܥͰऔΓࠐ·ΕͨPRΛͬ͟ͱݟͯͲΜ ͳରԠ͕ඞཁ͔Λ೺Ѳ͢Δ • ChainerͷGithub releasesݟ΍ͯ͘͢ॿ͔Γ ·ͨ͠

    • 1೔1࣌ؒ͘Β͍͔͕࣌ؒ͠ͱΕͳ͍ͷͰ Trello Ͱ؅ཧͭͭ͠๨Εͳ͍Α͏ʹ͠ͳ͕Βਐḿͤ͞ Δ
  33. 33 ͿͬͪΌ͚࢖͑Δͷʁ

  34. 34 ͿͬͪΌ͚࢖͑Δͷʁ MNIST (epoch: 20, unit: 1000, batchsize: 100) શepochʹ͔͔ͬͨඵ਺

    0 2000 4000 6000 8000 Numo::NArray Numo::NArray with OpenBLAS numpy 408.025 s 784.824 s 7415.42 s
  35. 35 ଎౓໘ͷ՝୊ • ಺෦ͷॲཧͰແବͳ෦෼͕ͳ͍͔͸ௐ͕ࠪඞཁ • NumPyʹ͸͋ͬͯNumo::NArrayʹ͸ͳ͍ϝιουΛҰ෦Ruby ͷੈքʹ΋͖͍ͬͯͯΔ(Arrayʹม׵ͯ͠ॲཧ͍ͯ͠Δ)ͷͰ Numo::NArrayͰ׬݁Ͱ͖ΔΑ͏ʹ͢Δ • ͳͲͳͲվળͰ͖Δͱ͜Ζ͸͋Γͦ͏

    • ͡ɺ͔͡Μ͕ɻɻɻ
  36. 36 ࠓޙʹ͍ͭͯ • 4ܥରԠ΋͍͖ͯ͠·͢$ • ONNX͕࢖͑ΔΑ͏ʹͳΓ͍ͨ <= ࠓணख͠͸͡Ίͯ·͢ • ONNX

    • open neural network exchange format • ྫ͑͹ChainerͰֶशͨ͠ϞσϧΛMXNetͰऔΓࠐΜͰ࢖ ͏͜ͱ͕ग़དྷΔ • Red ChainerͰ΋࢖͑ΔΑ͏ʹͳΕ͹طଘͷࢿ࢈Λ࢖͏͜ͱ ͕Ͱ͖ΔͷͰخ͍͠͸ͣ
  37. 37 ·ͱΊ

  38. 38 ·ͱΊ • RubyͰChainerΛ࡞ͬͯ·͢ • v2͔ΒϙʔςΟϯάͯ͠࠷ۙv3ʹରԠ͠·ͨ͠ • ଎౓໘ͷ՝୊͸͋ΔͷͰվળ͍ͨ͠ • ONNX໘നͦ͏ͳͷͰ΍Γ͍ͨ

    • ࠓޙ΋։ൃ͸ଓ͚Δ༧ఆͳͷͰஆ͔͍໨Ͱݟक͍͚ͬͯͨͩΔ ͱخ͍͠Ͱ͢