FPGAX2016 ドキュンなFPGA
- 6. AIにおけるDeep Neural Network
(DNN)
6
J. Park, “Deep Neural Network SoC: Bringing deep learning to mobile
devices,” Deep Neural Network SoC Workshop, 2016.
Brain Inspired
AI
Machine
Learning
Deep
Learning
DNN RNN
Silicon retina
Neuromorphic
Attention
based processing
Electronic
cochlea
Bio‐mimic
Fuzzy logic
Knowledge
representation
Natural lang.
proc.
Genetic
algorithm
SVM
Decision Tree
K‐nearest
neighbor
Bayesian
- 7. Artificial Neuron (AN)
+
x0=1
x1
x2
xN
... w0 (Bias)
w1
w2
wN
f(u)
u y
xi: Input signal
wi: Weight
u: Internal state
f(u): Activation function
(Sigmoid, ReLU, etc.)
y: Output signal
y f (u)
u wi xi
i0
N
7
- 9. DNNの歴史
9
58 69 74 95 98 06 12
Perceptron
XOR問題
Back‐
propagation
SVM
Convolutional
Neural Network
Restricted
Boltzmann
Machine
Google
Brain Project
AlexNet
が世界⼀に
- 12. Google I/O 2015講演より
• わずか1年で⾳声認識の誤認識率が23%から
8%に下がった
• ⾃動写真整理とインテリジェント写真検索によって、
まさに探していたイメージを⾒つけることができる
• ⽂脈を理解し、⾃然⾔語処理・⾔語翻訳によって、
ユーザーに即座に返事ができる
by スンダル・ピチャイ (Google 副社⻑)
12
- 15. FPGAとDeep Neural Network
• Microsoft Open Computer Server (写真C)
• Xeon@2.1GHz x 2
• 64GB DRAM
• 4×HDDs@2TB, 2×SSDs@512GB
• Catapult FPGA accelerator card (写真B)
• Altera Stratix V D5
• PCIe Gen 3×8
• 8GB DDR3@1333
• Torus network
• GPUよりも電⼒効率に優る
• ラックが⼩さい(省スペース)こともメリット
• 短期間開発(短TAT)
• CNNの学習(!)も開発中
15
- 17. Artificial Neuron (AN)
+
x0=1
x1
x2
xN
... w0 (Bias)
w1
w2
wN
f(u)
u y
xi: Input signal
wi: Weight
u: Internal state
f(u): Activation function
(Sigmoid, ReLU, etc.)
y: Output signal
y f (u)
u wi xi
i0
N
17
- 19. 要求スペック
• サーバーにおけるディープラーニングでは20億回の積和
(MAC)演算が必要︕︕
19
J. Park, “Deep Neural Network SoC: Bringing deep learning to mobile
devices,” Deep Neural Network SoC Workshop, 2016.
J. Cong and B. Xiao, “Minimizing computation in convolutional
neural networks,” Artificial Neural Networks and Machine Learning
(ICANN2014), 2014, pp. 281-290.
- 24. Convolution Operation
24
1 2 1
2 4 2
1 2 1
• ⼊⼒画像に対してカーネルをずらしながら畳み込む
• 例︓ぼかしフィルタ
J. Anderson (トロント⼤, RegUpの作者), “Synthesizing Circuits from
Software with LegUp High-Level Synthesis,” 2016.
- 27. Parallel Multiplication
剰余数系による乗算器の削減
• Moduli set〈3,4,5〉, X=8, Y=2
• Z=X×Y=16=(1,0,1)
• X=(2,0,3), Y=(2,2,2)
Z=(4 mod 3,0 mod 4,6 mod 5)
=(1,0,1)=16
27
Binary2RNS Conversion
RNS2Binary Conversion
➔ ➔
- 28. DCNN Architecture using
the Nested RNS
28
...
16 parallel modulo mi
2D convolutional units
...
...
. . .
BRAM BRAM BRAM...
BRAM BRAM BRAM...
BRAM BRAM BRAM...
. . .
Parallel Bin2NRNS
Converters
Tree‐based NRNS2Bin
Converters
Sequencer
External DDR3SODIMM
DDR3 Ctrl.
On‐chip
Memory
RNS
2
Bin
RNS
2
Bin
RNS
2
Bin
RNS
2
Bin
RNS
2
Bin
.........
...
H. Nakahara et al., “A deep convolutional neural network based on nested residue number system,” FPL2015.
- 31. Binarized DCNN
• Treats only binarized (+1/-1) values (weights and inouts)
• Except for the first and the last layers
+
x0=1
x1
x2
xN
...
w0 (Bias)
w1
w2
wN
sign(u)
u s
X: Input (8bit for the layer 1)
si: Output
wi: Weight
U: Internal state (integer)
Sign(U): Sign bit for U
+1 or ‐1
M. Courbariaux, I. Hubara, D. Soudry, R.E.Yaniv, Y. Bengio, “Binarized neural networks: Training deep neural networks
with weights and activations constrained to +1 or -1,” Computer Research Repository (CoRR), Mar., 2016,
http://arxiv.org/pdf/1602.02830v3.pdf
31
- 35. Deep Convolutional
Neural NetworkのHLS実装
• 依存性のない7重ループの最適化
→⾼位合成でも最適化しやすい
...
...
120 nodes
10 nodes
16 F. maps
5x5
16 F. maps
10x10
6 F. maps
14x14
6 Feature maps
28x28
Gray scale
image
32x32
5x5
2x2
5x5
2x2 5x5
1 2 1
2 4 2
1 2 1
①
②
③
④
⑤
⑥
⑦
- 37. DNN Design with HLS
37
C/C++
HDL
High‐Level
Synthesis
Logic Synthesis
DatasetParameter set
DNN Software on GPUs
(Tensolflow, Theano, Caffe, Chainer)
- 38. DNN Design Time の短縮
38
C/C++
HDL
High‐Level
Synthesis
Logic Synthesis
DatasetParameter set
DNN Software on GPUs
(Tensolflow, Theano, Caffe, Chainer)
数週間
数⽇
‐‐‐
- 42. Deep Q-learning Network
• 全部の⼿を試すのは不可能
• 報酬を最⼤にする⾏動をDeep Neural
Networkで予測
Deep Neural Network
+
Q-learning
↓
Deep Q-learning Network (DQN)
42
- 48. 設計してみて
• 学習: Python on GPU
• 認識: Python→C++→HDL→動作
• ⾼位合成ツールでもそれなりの性能
• DQNだときちんとリアルタイム動作しました
• DQNの設計に1週間, FPGA化に1⽇(!)
(ただしHLSの最適化はほとんどしていませんが)
• エラーを⾒つけるのが⼤変
• ごくまれにオーバーフローするんです…
• 学習に失敗した時のロスがでかい
→学習時間が数⽇ってのがまた
• とにかくDNNの学習時間速くしてくださいおながしいます
たのみますよろしく
48
- 49. まとめ
• Deep Neural Networkを簡単に紹介
• まだまだ研究開発途上
• 学習時間の短縮がカギに
• 電⼒性能効率・短TATなFPGAにチャンス
• 既存のフレームワークとの連携による短期間開発
• 応⽤事例としてDQNを動かしてみた
• GPUより低消費電⼒・コンパクト
• CPUよりも⾼速
49