Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RubyでChainerつくってます!!

hatappi
March 30, 2019

 RubyでChainerつくってます!!

Chainer Meetup #09
#chug_jp

hatappi

March 30, 2019
Tweet

More Decks by hatappi

Other Decks in Technology

Transcript

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

    View full-size slide

  2. 2
    • Yusaku Hatanaka
    • Merpay Inc.
    • Backend Engineer
    • GoΛॻ͍͍ͯΔ͜ͱ͕ଟ͍
    • ϓϥΠϕʔτ
    • RubyΛॻ͍͍ͯΔ͜ͱ͕ଟ͍
    • Anket: RailsΛ࢖ͬͨSlackͷΞϯέʔταʔϏε
    • Red Chainer: ʁʁʁʁ

    ↑ࠓ೔͸͜ͷ࿩Λ͠·͢

    self introduction
    @hatappi

    View full-size slide

  3. 3
    Red Chainer??

    View full-size slide

  4. 5
    Red Chainer

    View full-size slide

  5. 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)

    View full-size slide

  6. 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

    View full-size slide

  7. 8
    ͳͥRed Chainer
    Λ࡞Γ͸͡Ίͨͷ͔

    View full-size slide

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

    View full-size slide

  9. 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/

    View full-size slide

  10. 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!

    View full-size slide

  11. 参加するのは良いけど
    ⾃分は何をしよう

    View full-size slide

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

    View full-size slide

  13. ただそれだけですw

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  17. 18
    First Commit
    2017/08

    View full-size slide

  18. 19
    First Commit
    • Chainer v2ͷίʔυΛͻͨ͢ΒಡΉ
    • Python΄ͱΜͲॻ͍ͨ͜ͱͳ͍ͷͰPythonͷυΩϡϝϯτಡ
    Έͳ͕Βͻͨ͢ΒϙʔςΟϯά
    • ྫ͑͹࠷ॳ͸ˣ͕ͲΜͳڍಈʹͳΔ͔෼͔ΒͣυΩϡϝϯτ
    ΛಡΉͳͲ͢ΔͨΊ͕͔͔࣌ؒΔ
    • ͳΕͯ͘Δͱ಄ͷதͰม׵Ͱ͖ΔΑ͏ʹͳΔ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  24. 27
    ৞ΈࠐΈԋࢉͷαϙʔτ
    • ը૾ࣝผ͍ͨ͠ʂʂʂ
    • BatchNormalization, Pooling, etc.. ͳͲͷAPIΛ௥Ճ
    • CIFAR-10, 100ͷαϯϓϧͷ௥Ճ
    • Ϟσϧ͸VGG, ResNet18
    • ՄࢹԽͨ͘͠ͳΔ
    • ྫ͑͹ը૾ࣝผΛRed ChainerͰߦͬͯepoch͝ͱͷਫ਼౓ΛՄ
    ࢹԽ͍ͨ͠

    View full-size slide

  25. 29
    1epoch 45epoch

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  28. 32
    Chainer 3ܥ΁ͷରԠ
    • Chainer3ܥͰऔΓࠐ·ΕͨPRΛͬ͟ͱݟͯͲΜ
    ͳରԠ͕ඞཁ͔Λ೺Ѳ͢Δ
    • ChainerͷGithub releasesݟ΍ͯ͘͢ॿ͔Γ
    ·ͨ͠
    • 1೔1࣌ؒ͘Β͍͔͕࣌ؒ͠ͱΕͳ͍ͷͰ Trello
    Ͱ؅ཧͭͭ͠๨Εͳ͍Α͏ʹ͠ͳ͕Βਐḿͤ͞
    Δ

    View full-size slide

  29. 33
    ͿͬͪΌ͚࢖͑Δͷʁ

    View full-size slide

  30. 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

    View full-size slide

  31. 35
    ଎౓໘ͷ՝୊
    • ಺෦ͷॲཧͰແବͳ෦෼͕ͳ͍͔͸ௐ͕ࠪඞཁ
    • NumPyʹ͸͋ͬͯNumo::NArrayʹ͸ͳ͍ϝιουΛҰ෦Ruby
    ͷੈքʹ΋͖͍ͬͯͯΔ(Arrayʹม׵ͯ͠ॲཧ͍ͯ͠Δ)ͷͰ
    Numo::NArrayͰ׬݁Ͱ͖ΔΑ͏ʹ͢Δ
    • ͳͲͳͲվળͰ͖Δͱ͜Ζ͸͋Γͦ͏
    • ͡ɺ͔͡Μ͕ɻɻɻ

    View full-size slide

  32. 36
    ࠓޙʹ͍ͭͯ
    • 4ܥରԠ΋͍͖ͯ͠·͢$
    • ONNX͕࢖͑ΔΑ͏ʹͳΓ͍ͨ <= ࠓணख͠͸͡Ίͯ·͢
    • ONNX
    • open neural network exchange format
    • ྫ͑͹ChainerͰֶशͨ͠ϞσϧΛMXNetͰऔΓࠐΜͰ࢖
    ͏͜ͱ͕ग़དྷΔ
    • Red ChainerͰ΋࢖͑ΔΑ͏ʹͳΕ͹طଘͷࢿ࢈Λ࢖͏͜ͱ
    ͕Ͱ͖ΔͷͰخ͍͠͸ͣ

    View full-size slide

  33. 38
    ·ͱΊ
    • RubyͰChainerΛ࡞ͬͯ·͢
    • v2͔ΒϙʔςΟϯάͯ͠࠷ۙv3ʹରԠ͠·ͨ͠
    • ଎౓໘ͷ՝୊͸͋ΔͷͰվળ͍ͨ͠
    • ONNX໘നͦ͏ͳͷͰ΍Γ͍ͨ
    • ࠓޙ΋։ൃ͸ଓ͚Δ༧ఆͳͷͰஆ͔͍໨Ͱݟक͍͚ͬͯͨͩΔ
    ͱخ͍͠Ͱ͢

    View full-size slide