34
Chainer で Deep Learning でででででででででで でででで でででで でででで 西

Dots nishitoba

Embed Size (px)

Citation preview

Page 1: Dots nishitoba

Chainer で Deep Learning を試す為に必要なこと

株式会社 レトリバ西鳥羽二郎

Page 2: Dots nishitoba

自己紹介• 西鳥羽二郎• ID: jnishi• 略歴• 東京大学情報理工学系研究科コンピュータ科学専攻 修士課程卒業• 2006 年 Preferred Infrastructure に創業メンバーとして参画

• プロトタイプ開発• プロフェッショナルサービス・サポートサービス• 研究開発

• 2016 年 レトリバ創業• 取締役・リサーチャーとして研究開発に従事• 主に音声認識や自然言語処理を担当

Page 3: Dots nishitoba

Deep Learning(DL) への取り組み• 2015 年 3 月頃に音声認識で DL が使えそうなことを知る• 2015 年 6 月から Chainer を用いて音声認識エンジンの開発開始• 最適化関数 NesterovAG• 活性化関数 ClippedReLU• 損失関数 Connectionist Temporal Classification

Torch7: Baiduが 2016 年 1 月に公開TensorFlow:

2016 年 2 月に搭載Chainer: 2015年 10 月に搭載

Page 4: Dots nishitoba

Deep Learning の手法をためそう !

Page 5: Dots nishitoba

Deep Learning の手法をためそう !

Page 6: Dots nishitoba

Deep Learning の手法をためそう !

Page 7: Dots nishitoba

Deep Learning の手法をためそう !

OK 実装だ !

Page 8: Dots nishitoba

Deep Learning の手法をためそう !

OK 実装だ !

Page 9: Dots nishitoba

見るべきところ• Baidu の Deep Specch2

Page 10: Dots nishitoba

見るべきところ• Google の音声認識

Page 11: Dots nishitoba

見るべきところ• Microsoft の画像認識

Page 12: Dots nishitoba

Deep Learning のシステムを実装する際• きちんと処理を理解するには数式を理解することが大事• 実際に処理を記述する際には構造を図示したグラフを見ることが多い

Page 13: Dots nishitoba

ニューラルネットワークの基本単位

x1x2

xn

n 個の入力 1 個の出力w1w2

wn

u = w1x1 + w2x2 + …+ wnxn

ユニット

Page 14: Dots nishitoba

ニューラルネットワークの基本

x1x2

xn

n 個の入力 m 個の出力

入力を同じとするユニットをたくさん並べる

Page 15: Dots nishitoba

ニューラルネットワーク ( 全結合 )

x1x2

xn

n 個の入力 m 個の入力

入力

Linear

Page 16: Dots nishitoba

活性化関数

x1x2

xn

… u

出力にスケーリングや制限をかける処理を行うことがある活性化関数の例• ReLU: 負の時は 0 にする• sigmoid: 大小関係を維したまま 0 〜 1 にする• tanh: 大小関係を維持したまま -1 〜 1 にする

Page 17: Dots nishitoba

活性化関数も同様に表せる

入力

Linear

ReLU

Page 18: Dots nishitoba

ネットワークとして示す• ニューラルネットワーク以下のものをコンポーネントとするネットワークで表すことができる• 入力• Linear• 活性化関数• 損失関数• Convolution 層• 正則化関数• etc.

Page 19: Dots nishitoba

ネットワークの読み方• Baidu の Deep Specch2

Page 20: Dots nishitoba

ネットワークの読み方• Baidu の Deep Specch2

入力

Page 21: Dots nishitoba

ネットワークの読み方• Baidu の Deep Specch2

Convolution 層を 3 段つなげる

Page 22: Dots nishitoba

ネットワークの読み方• Baidu の Deep Specch2

RNN を 7 層

Page 23: Dots nishitoba

ネットワークの読み方• Baidu の Deep Specch2

BatchNormalizationを正則化として用いる

Page 24: Dots nishitoba

ネットワークの読み方• Baidu の Deep Specch2

Linear を 1 層用いる

Page 25: Dots nishitoba

ネットワークの読み方• Baidu の Deep Specch2

CTC という損失関数を用いる

Page 26: Dots nishitoba

Deep Learning を行う際に必要なこと• forward 処理• back propagation• 行列計算• 微分計算

• 処理に用いる関数• 入出力の関係• 入力の大きさ• 出力の大きさ

フレームワークが実行 フレームワークを用いて実装する時に考えること

Page 27: Dots nishitoba

Chainer の example コードclass MLP(Chain): def __init__(self, n_units=100, n_out=10): super(MLP, self).__init__( l1=L.Linear(None, n_units), l2=L.Linear(None, n_units), l3=L.Linear(None, n_out), ) def __call__(self, x): h1 = F.relu(self.l1(x)) h2 = F.relu(self.l2(h1)) y = self.l3(h2) return y

Linear

MNIST 画像

Linear

Linear

784(28x28)

100

100

0 〜9の判定10

Page 28: Dots nishitoba

layer1class MLP(Chain): def __init__(self, n_units=100, n_out=10): super(MLP, self).__init__( l1=L.Linear(None, n_units), l2=L.Linear(None, n_units), l3=L.Linear(None, n_out), ) def __call__(self, x): h1 = F.relu(self.l1(x)) h2 = F.relu(self.l2(h1)) y = self.l3(h2) return y

Linear

MNIST 画像

Linear

Linear

784(28x28)

100

100

0 〜9の判定10

l1

Page 29: Dots nishitoba

layer2class MLP(Chain): def __init__(self, n_units=100, n_out=10): super(MLP, self).__init__( l1=L.Linear(None, n_units), l2=L.Linear(None, n_units), l3=L.Linear(None, n_out), ) def __call__(self, x): h1 = F.relu(self.l1(x)) h2 = F.relu(self.l2(h1)) y = self.l3(h2) return y

Linear

MNIST 画像

Linear

Linear

784(28x28)

100

100

0 〜9の判定10

l1

l2

Page 30: Dots nishitoba

layer3class MLP(Chain): def __init__(self, n_units=100, n_out=10): super(MLP, self).__init__( l1=L.Linear(None, n_units), l2=L.Linear(None, n_units), l3=L.Linear(None, n_out), ) def __call__(self, x): h1 = F.relu(self.l1(x)) h2 = F.relu(self.l2(h1)) y = self.l3(h2) return y

Linear

MNIST 画像

Linear

Linear

784(28x28)

100

100

0 〜9の判定10

l1

l2

l3

Page 31: Dots nishitoba

forward 処理class MLP(Chain): def __init__(self, n_units=100, n_out=10): super(MLP, self).__init__( l1=L.Linear(None, n_units), l2=L.Linear(None, n_units), l3=L.Linear(None, n_out), ) def __call__(self, x): h1 = F.relu(self.l1(x)) h2 = F.relu(self.l2(h1)) y = self.l3(h2) return y

Linear

MNIST 画像

Linear

Linear

x

h1

h2

0 〜9の判定y

l1

l2

l3

Page 32: Dots nishitoba

forward 処理class MLP(Chain): def __init__(self, n_units=100, n_out=10): super(MLP, self).__init__( l1=L.Linear(None, n_units), l2=L.Linear(None, n_units), l3=L.Linear(None, n_out), ) def __call__(self, x): h1 = F.relu(self.l1(x)) h2 = F.relu(self.l2(h1)) y = self.l3(h2) return y

Linear

MNIST 画像

Linear

Linear

x

h1

h2

0 〜9の判定y

l1

l2

l3

Page 33: Dots nishitoba

forward 処理class MLP(Chain): def __init__(self, n_units=100, n_out=10): super(MLP, self).__init__( l1=L.Linear(None, n_units), l2=L.Linear(None, n_units), l3=L.Linear(None, n_out), ) def __call__(self, x): h1 = F.relu(self.l1(x)) h2 = F.relu(self.l2(h1)) y = self.l3(h2) return y

Linear

MNIST 画像

Linear

Linear

x

h1

h2

0 〜9の判定y

l1

l2

l3

Page 34: Dots nishitoba

まとめ• Deep Learning を行う際にはネットワーク構造が大事• 構造が決まれば後はフレームワークが処理を行う• Chainer の場合、 MNIST の train_example.py の例がシンプル• Chainer に限らない