More Related Content Similar to Deep learning Libs @twm (20) More from Yuta Kashino (11) Deep learning Libs @twm4. 自己紹介
• バクフー株式会社 代表取締役 柏野 雄太 (かしの ゆうた)
• 大規模リアルタイムデータのデータプラットフォーム
• PPPP preprocess /process /persistence /providing
4
7. 自己紹介
• Zope3の開発
• Python
• いくつかの本
• PyCon JP 2015でのトーク
• バックグラウンドは宇宙物理学
• 大規模データ統計解析,科学計算
• 深層学習ウオッチャー: 2012年Hinton講義
https://goo.gl/GG4Bo8
https://www.coursera.org/course/neuralnets
7
14. 動画講義 (全力でオススメ)
• Deep Learning Summer School 2015
• Hugo Larochelle (Twitter/U of Sherbrooke)
• Nando de Freitas (Oxford)
• CS231n: CNN for Visual Recognition
• CS224d: DL for Natural Language Processing
http://videolectures.net/deeplearning2015_montreal/
http://cs231n.stanford.edu/
http://cs224d.stanford.edu/index.html
https://www.cs.ox.ac.uk/people/nando.defreitas/machinelearning/
https://goo.gl/UWtRWT
14
15. 書籍
• 古典: Bengio et.al. 2015 DLBook
• Theano Tutorial
• Neural Networks and Deep Learning
• 岡谷貴之著 深層学習 (機械学習プロ)
• 神嶌敏弘編 深層学習: Deep Learning
http://www.iro.umontreal.ca/~bengioy/dlbook/
http://neuralnetworksanddeeplearning.com/
http://deeplearning.net/tutorial/deeplearning.pdf
15
17. 神経回路の数理表現
17
h(k)
(x) = g(a(k)
(x))
a(k)
(x) = b(k)
+ W (k)
h(k 1)
(x)
…
…
…
1
1
1
b(3)
b(2)
b(1)
W (1)
W (2)
W (3)
x1 x2 xd
a(3)
(x) = b(3)
+ W (3)
h(2)
(x)
= b(3)
+ W (3)
g(b(2)
+ W (2)
h(1)
(x))
= b(3)
+ W (3)
g(b(2)
+ W (2)
g(b(1)
+ W (1)
x))
h(0)
(x) = x
h(1)
(x) = g(a(1)
(x))
h(2)
(x) = g(a(2)
(x))
a(1)
(x) = b(1)
+ W (1)
h(0)
(x)
a(2)
(x) = b(2)
+ W (2)
h(1)
(x)
a(3)
(x) = b(3)
+ W (3)
h(2)
(x)
h(3)
(x) = o(a(3)
(x))
= f(x)
a(1)
(x)
a(2)
(x)
a(3)
(x)
h(2)
(x)
h(1)
(x)
f(x) = h(3)
(x)
g
g
o
b(1)
W (1)
b(3)
b(2)
W (2)
W (3)
x
18. マルチレイヤー神経回路
• L個の隠れ層の神経回路
• プレ活性
• 隠れ層活性
• 出力層活性
• レイヤーは関数適用に他ならない
18
h(k)
(x) = g(a(k)
(x))
a(k)
(x) = b(k)
+ W (k)
h(k 1)
(x)
h(L+1)
(x) = o(a(L+1)
(x))
= f(x)
a(1)
(x)
a(2)
(x)
a(3)
(x)
h(2)
(x)
h(1)
(x)
f(x) = h(3)
(x)
g
g
o
b(1)
W (1)
b(3)
b(2)
W (2)
W (3)
x
19. 機械学習と損失関数
• パラメータ・トレーニングセット
• 目的関数最小化
• 損失関数・正則関数
a(1)
(x)
a(2)
(x)
a(3)
(x)
h(2)
(x)
h(1)
(x)
f(x) = h(3)
(x)
g
g
o
b(1)
W (1)
b(3)
b(2)
W (2)
W (3)
x
l(f(x), y)
✓ = {W (1)
, b(1)
, ..., W (L+1)
, b(L+1)
}
(x(t)
, y(t)
)
⌦(✓)
l(f(x(t)
; ✓), y(t)
) = logf(x(t)
)y
L(✓) =
1
T
X
t
l(f(x(t)
; ✓), y(t)
) + ⌦(✓)
argmin✓L(✓)
19
21. 勾配の計算:誤差逆伝搬
• 目的関数を最小にするには勾配の計算が必要
• 勾配の計算=誤差逆伝搬 = r✓l(f(x(t)
; ✓), y(t)
)
✓ ✓ + ↵
a(1)
(x)
a(2)
(x)
a(3)
(x)
h(2)
(x)
h(1)
(x)
f(x) = h(3)
(x)
g
g
o
b(1)
W (1)
b(3)
b(2)
W (2)
W (3)
x
l(f(x), y)
a(1)
(x)
a(2)
(x)
a(3)
(x)
h(2)
(x)
h(1)
(x)
f(x) = h(3)
(x)
g
g
o
b(1)
W (1)
b(3)
b(2)
W (2)
W (3)
x
l(f(x), y)
rW (2) l(f(x), y) ra(2)(x)l(f(x), y)h(2)
(x)T
ra(2)(x)l(f(x), y) rh(2)(x)l(f(x), y) [..., g0
(a(2)
(x)), ...]
rh(2)(x)l(f(x), y) W(3)T
ra(3)(x)l(f(x), y)
21
22. 勾配の計算:誤差逆伝搬
• Hugo Larochelleの講義にGo https://goo.gl/UWtRWT
a(1)
(x)
a(2)
(x)
a(3)
(x)
h(2)
(x)
h(1)
(x)
f(x) = h(3)
(x)
g
g
o
b(1)
W (1)
b(3)
b(2)
W (2)
W (3)
x
l(f(x), y)
a(1)
(x)
a(2)
(x)
a(3)
(x)
h(2)
(x)
h(1)
(x)
f(x) = h(3)
(x)
g
g
o
b(1)
W (1)
b(3)
b(2)
W (2)
W (3)
x
l(f(x), y)
rW (2) l(f(x), y) ra(2)(x)l(f(x), y)h(2)
(x)T
ra(2)(x)l(f(x), y) rh(2)(x)l(f(x), y) [..., g0
(a(2)
(x)), ...]
rh(2)(x)l(f(x), y) W(3)T
ra(3)(x)l(f(x), y)
22
23. 勾配の計算:誤差逆伝搬
• 主要DLライブラリは勾配を自動に計算
• 実はあまり気にしないでいい
a(1)
(x)
a(2)
(x)
a(3)
(x)
h(2)
(x)
h(1)
(x)
f(x) = h(3)
(x)
g
g
o
b(1)
W (1)
b(3)
b(2)
W (2)
W (3)
x
l(f(x), y)
a(1)
(x)
a(2)
(x)
a(3)
(x)
h(2)
(x)
h(1)
(x)
f(x) = h(3)
(x)
g
g
o
b(1)
W (1)
b(3)
b(2)
W (2)
W (3)
x
l(f(x), y)
rW (2) l(f(x), y) ra(2)(x)l(f(x), y)h(2)
(x)T
ra(2)(x)l(f(x), y) rh(2)(x)l(f(x), y) [..., g0
(a(2)
(x)), ...]
rh(2)(x)l(f(x), y) W(3)T
ra(3)(x)l(f(x), y)
23
24. ライブラリ利用で必要なのは
• データを入れる場所:テンソル
• レイヤーの表現
• 活性化関数・出力関数
• 損失関数
• 最適化法
• 勾配計算(誤差伝搬)
• GPUへの対応
a(1)
(x)
a(2)
(x)
a(3)
(x)
h(2)
(x)
h(1)
(x)
f(x) = h(3)
(x)
g
g
o
b(1)
W (1)
b(3)
b(2)
W (2)
W (3)
x
l(f(x), y)
24
31. DLライブラリ世代論
• 第一世代: GPU対応
• Theano, Torch
• 第二世代: プレトレーニングモデル利用 DIY時代
• Caffe, PyLearn2
• 第三世代: より使いやすく,より速くmulti-GPU
• Keras, Lasagne, Chainer, Neon
31
34. Theano
• James Bergstra+ (montreal/Bengio)
• Python/Cython
• GPU:独自(CUDA/cuDNN)
• DLライブラリの草分け
• 強力な自動微分機能,NumPyとシームレス
• 独自のPython → C変換で高速
• 数々のDLライブラリのビルディングブロックに
• 益々開発が活発になっている
https://github.com/Theano/Theano
34
Licence multiGPU Binding Activity
BSD △ ◎
35. Torch7
• Ronan Collobert (FB AI), Koray Kavukcuoglu (G
DeepMind), Clement Farabet (Twitter)
• GPU: cutorch (CUDA/cuDNN/OpenMP)
• Model: Lua
• Matlab風のコーディングをLuaでする
• Lua.JITでCになるので高速
• 拡張性が高い →ライブラリが充実
• 全然現役
http://ronan.collobert.com/pub/matos/2011_torch7_nipsw.pdf
https://github.com/torch/torch7
35
Licence multiGPU Binding Activity
BSD ○ C/C++ ◎
36. Caffe
• Yangqing Jia (Google)
• GPU: 独自(CUDA/cuDNN)
• Model:Protocol Buffer
• モデルプログラムをさせない: ”DIY DL for Vision"
• Model Zoo, Reference models
• 最近元気がない…
https://github.com/BVLC/caffe/
36
Licence multiGPU Binding Activity
BSD - python/matlab △
37. Keras
• François Chollet (Google)
• GPU: Theano
• Model: Python
• クリーンでクリアなモデリング
• Theanoを隠 .Theanoの内部データはとれない:あ
る層の勾配
• 人気が急上昇中
https://github.com/fchollet/keras
37
Licence multiGPU Binding Activity
MIT △ O
38. Lasagne
• Sander Dieleman (G DeepMind)
• GPU: Theano
• Model: Python
• Theano + layer + activ./loss func + optimizer
• 最後には必ずTheanoを触る必要がある
• Theano好きには○,ただ最近元気がない
https://github.com/torch/torch7
38
Licence multiGPU Binding Activity
MIT △ △
39. Chainer
• 得居誠也 (PFI/PFN)
• GPU: cupy (CUDA, cuDNN) 以前はPyCUDA
• Model: Python
• 動的グラフなど設計思想が違う革命児
• ギリギリまでPythonオブジェクトなのでデバグが異常に楽
• PFI/PFNの主力兵器になる可能性
https://github.com/pfnet/chainer
http://www.ustream.tv/recorded/64082997
http://goo.gl/z2IjsY
39
Licence multiGPU Binding Activity
MIT ○ ◎
40. Neon
• Arjun Bansal+ (Nervana Systems) G/Fでない…
• GPU: PyCUDAベースの独自
• Model: Python
• 関数・レイヤーなど良く整備され準備されたAPI群を
装備
• シングルマシンにおいて汎用DLライブラリ最速
https://github.com/nervanasystems/neon
40
Licence multiGPU Binding Activity
Apache ○ ○
https://github.com/soumith/convnet-benchmarks
41. Reference Manual / Code
• ライブラリを使うには
• Exampleの後は,Reference Manual熟読し
ましょう.設計思想がわかります.
• そしてソースコードを読みましょう.
41
43. 実装するモデルの例
• MNISTデータ
• MLP(Multi Layer Perception) 隠れ層 2つ
43
http://deeplearning.net/tutorial/mlp.html
a(1)
(x)
a(2)
(x)
a(3)
(x)
h(2)
(x)
h(1)
(x)
f(x) = h(3)
(x)
b(1)
W (1)
b(3)
b(2)
W (2)
W (3)
x
o: softmax
g: ReLU
g: ReLU
68. パフォーマンス
• AlexNet (One Weird Trick paper) - Input 128x3x224x224
https://github.com/soumith/convnet-benchmarks
68