ゲート付き回帰型ユニット
ゲート付き回帰型ユニット(ゲートつきかいきがたユニット、英: Gated recurrent unit、略称: GRU)は、回帰型ニューラルネットワーク(RNN)におけるゲート機構である[1] 。2014年にKyunghyun Cho(조 경현)らによって発表された[2] 。GRUは忘却ゲートを持つ長・短期記憶(long short-term memory、LSTM)に似ているが[3] 、出力ゲートを欠くためLSTMよりもパラメータが少ない[4] 。多声音楽モデリングおよび音声シグナルモデリングの特定の課題におけるGRUの性能は、LSTMの性能と類似していることが明らかにされている。GRUは特定のより小さなデータセットではもっと良い性能を示すことが明らかにされている[5] 。
しかしながら、Gail Weiss、Yoav Goldberg、およびEran Yahavによって示されているように、LSTMは無制限の計数を容易に実行できるがGRUはできないため、LSTMはGRUよりも「厳密に強力」である[6] 。これが、LSTMによって学習可能な単純な言語の学習をGRUが失敗する理由である[6] 。
同様に、Google BrainのDenny Britz、Anna Goldie、Minh-Thang Luong、およびQuoc Leによって示されているように、LSTMセルは「ニューラル機械翻訳のためのアーキテクチャ変法の初の大規模分析」においてGRUセルを一貫して上回った[7] 。
アイデア
[編集 ]GRUのアイデアは次の式で表される(実際の演算とは異なる)。
{\displaystyle h_{t}=(1-z)\cdot h_{t-1}+z\cdot f(x_{t}+r\cdot h_{t-1})}
すなわち隠れ状態 {\displaystyle h_{t}} は以下の2要素の重み付け和で更新される。
- 1ステップ前の隠れ状態 {\displaystyle h_{t-1}}
- 「入力 {\displaystyle x_{t}} 」と「重み付けられた隠れ状態 {\displaystyle r\cdot h_{t-1}} 」の {\displaystyle f} による非線形変換
例えば {\displaystyle z=1} であれば入力は無視され隠れ状態がそのまま保持される。逆に {\displaystyle z=0} であれば入力と隠れ状態の非線形変換により新たな隠れ状態が計算される。{\displaystyle r} は新たな隠れ状態の計算に影響を与える。{\displaystyle r=0} であれば入力のみから新な隠れ状態が計算され[8] 、{\displaystyle r=1} であれば入力・隠れ状態の両方が利用される。これら {\displaystyle z} と {\displaystyle r} もまた {\displaystyle x_{t}} と {\displaystyle h_{t-1}} から計算される。
単純なRNNと比較して、GRUは更新ゲート {\displaystyle z} による隠れ状態の保持[9] とそれによる長期記憶[10] が可能になる。また初期化ゲート {\displaystyle r} による隠れ状態の削除[11] が可能になることでよりコンパクトな隠れ表現を得られる[12] 。
隠れ状態のサイズが1以上であれば複数の {\displaystyle z} と {\displaystyle r} ({\displaystyle z_{t}^{j}} と {\displaystyle r_{t}^{j}}) を持つことになる。それぞれの {\displaystyle j} は独立して学習されるため、ある {\displaystyle j} は更新ゲート {\displaystyle z} が長期間1に近いすなわち長期記憶を保持し、ほかの {\displaystyle j} は初期化ゲート {\displaystyle r} が頻繁に切り替わりながら入力のフィルタリングをおこなうように振る舞う、といったことが可能になっている。すなわちそれぞれの隠れ状態が異なる時間スケールの表現を学習しうる[13] 。
アーキテクチャ
[編集 ]様々な組合せで以前の隠れ状態とバイアスを使ってゲーティングを行う完全ゲート付きユニットや最小ゲート付きユニット(minimal gated unit)と呼ばれる単純形など複数の変種が存在する。
以下の式において、演算子{\displaystyle \circ }はアダマール積を示す。
完全ゲート付きユニット
[編集 ]最初、{\displaystyle t=0}に対して、出力ベクトルは{\displaystyle h_{0}=0}である。
- {\displaystyle {\begin{aligned}z_{t}&=\sigma _{g}(W_{z}x_{t}+U_{z}h_{t-1}+b_{z})\\r_{t}&=\sigma _{g}(W_{r}x_{t}+U_{r}h_{t-1}+b_{r})\\h_{t}&=(1-z_{t})\circ h_{t-1}+z_{t}\circ \sigma _{h}(W_{h}x_{t}+U_{h}(r_{t}\circ h_{t-1})+b_{h})\end{aligned}}}
変数
- {\displaystyle x_{t}}: 入力ベクトル
- {\displaystyle h_{t}}: 出力ベクトル
- {\displaystyle z_{t}}: 更新ゲートベクトル
- {\displaystyle r_{t}}: 初期化ゲートベクトル
- {\displaystyle W}、{\displaystyle U}、および{\displaystyle b}: パラメータ行列およびベクトル
{\displaystyle \sigma _{g}(x)\in [0,1]}という条件で、別の活性化関数も利用可能である。
{\displaystyle z_{t}}および{\displaystyle r_{t}}を変更することによって代替形式を作ることができる[14] 。
- タイプ1、それぞれのゲートが以前の隠れ状態およびバイアスにのみ依存する。
- {\displaystyle {\begin{aligned}z_{t}&=\sigma _{g}(U_{z}h_{t-1}+b_{z})\\r_{t}&=\sigma _{g}(U_{r}h_{t-1}+b_{r})\\\end{aligned}}}
- タイプ2、それぞれのゲートが以前の隠れ状態にのみ依存する。
- {\displaystyle {\begin{aligned}z_{t}&=\sigma _{g}(U_{z}h_{t-1})\\r_{t}&=\sigma _{g}(U_{r}h_{t-1})\\\end{aligned}}}
- タイプ3、それぞれのゲートはバイアスのみを使って計算される。
- {\displaystyle {\begin{aligned}z_{t}&=\sigma _{g}(b_{z})\\r_{t}&=\sigma _{g}(b_{r})\\\end{aligned}}}
最小ゲート付きユニット
[編集 ]最小ゲート付きユニットは、更新ゲートベクトルおよび初期化ゲートベクトルが忘却ゲートへと統合されたことを除いて、完全ゲート付きユニットと類似している。これは、出力ベクトルに対する方程式が変更されなければならないこと になる[15] 。
- {\displaystyle {\begin{aligned}f_{t}&=\sigma _{g}(W_{f}x_{t}+U_{f}h_{t-1}+b_{f})\\h_{t}&=f_{t}\circ h_{t-1}+(1-f_{t})\circ \sigma _{h}(W_{h}x_{t}+U_{h}(f_{t}\circ h_{t-1})+b_{h})\end{aligned}}}
変数
- {\displaystyle x_{t}}: 入力ベクトル
- {\displaystyle h_{t}}: 出力ベクトル
- {\displaystyle f_{t}}: 忘却ベクトル
- {\displaystyle W}、{\displaystyle U}、および{\displaystyle b}: パラメータ行列およびベクトル
出典
[編集 ]- ^ "we refer as a gated recurrent unit (GRU), was proposed by Cho et al. [2014]" Junyoung Chung, et al. (2014). Empirical Evaluation of Gated Recurrent Neural Networks on Sequence Modeling. Arxiv 1412.3555
- ^ Cho, Kyunghyun; van Merrienboer, Bart; Gulcehre, Caglar; Bahdanau, Dzmitry; Bougares, Fethi; Schwenk, Holger; Bengio, Yoshua (2014). "Learning Phrase Representations using RNN Encoder-Decoder for Statistical Machine Translation". arXiv:1406.1078 [cs.CL]。
- ^ Felix Gers; Jürgen Schmidhuber; Fred Cummins (1999). "Learning to Forget: Continual Prediction with LSTM". Proc. ICANN'99, IEE, London: 850-855. https://ieeexplore.ieee.org/document/818041 .
- ^ "Recurrent Neural Network Tutorial, Part 4 – Implementing a GRU/LSTM RNN with Python and Theano – WildML". May 18, 2016閲覧。
- ^ Chung, Junyoung; Gulcehre, Caglar; Cho, KyungHyun; Bengio, Yoshua (2014). "Empirical Evaluation of Gated Recurrent Neural Networks on Sequence Modeling". arXiv:1412.3555 [cs.NE]。
- ^ a b Weiss, Gail; Goldberg, Yoav; Yahav, Eran (2018). "On the Practical Computational Power of Finite Precision RNNs for Language Recognition". arXiv:1805.04908 [cs.NE]。
- ^ Britz, Denny; Goldie, Anna; Luong, Minh-Thang; Le, Quoc (2018). "Massive Exploration of Neural Machine Translation Architectures". arXiv:1703.03906 [cs.NE]。
- ^ "when the reset gate is close to 0, the hidden state is forced to ignore the previous hidden state and reset with the current input only." Cho, et al. (2014).
- ^ "the update gate controls how much information from the previous hidden state will carry over to the current hidden state" Cho, et al. (2014).
- ^ "acts similarly to the memory cell in the LSTM network and helps the RNN to remember longterm information" Cho, et al. (2014).
- ^ "allows the hidden state to drop any information that is found to be irrelevant later in the future, thus, allowing a more compact representation" Cho, et al. (2014).
- ^ "allowing a more compact representation" Cho, et al. (2014).
- ^ "As each hidden unit has separate reset and update gates, each hidden unit will learn to capture dependencies over different time scales" Cho, et al. (2014).
- ^ Dey, Rahul; Salem, Fathi M. (20 January 2017). "Gate-Variants of Gated Recurrent Unit (GRU) Neural Networks". arXiv:1701.05923 [cs.NE]。
- ^ Heck, Joel; Salem, Fathi M. (12 January 2017). "Simplified Minimal Gated Unit Variations for Recurrent Neural Networks". arXiv:1701.03452 [cs.NE]。