0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

時系列予測のためのLSTM(1)(初心者向け)

Posted at

今回は、LSTMについて。
時系列などの規則性がある現象についての予測問題はアプローチとして有効かもしれない。
自分の理解のためのアウトプットなので、一旦は参考サイトをほぼトレースしている。

LSTM(Long Short-Term Memory)

ひとことでいうと、短期記憶で長期期間で活用して学習を進める。特徴がある。
LSTMの部分を図式化すると、以下になる。
スクリーンショット 2020-03-01 19.57.58.png
htでの計算で、前の出力結果ht-1とXtを使い求める。htはht+1を求めるために使われるイメージ。
それぞれ、
・OutputGate
・Forget Gate
・Input Gate
・活性化関数部分
・Memory Cell
で成り立っている

OutputGate

以下の矢印赤い部分。
Xtに対しての線形変換Wo、htに対しての線形変換Ro、バイアスBoを使い
Ot=σ(WoXt+Roht−1+Bo)
という計算が行われる。
ニューラルネットワークと同様の計算式。
スクリーンショット 2020-03-01 20.22.56.png

Forget Gate

OutputGateと同様、
Wf、Rf、Bfのパラメータがあり
ft=σ(WfXt+Rfht−1+Bf)
という計算が行われる。
スクリーンショット 2020-03-01 20.30.57.png

Input Gate

同様に、
it=σ(WiXt+Riht−1+Bi)
という計算が行われる。
スクリーンショット 2020-03-01 20.33.26.png

活性化関数部分

Zt=tanh(WzXt+Rzht−1+Bz)
活性化関数部分の計算式。
スクリーンショット 2020-03-01 20.39.47.png

Memory Cell付近の計算

①Forget Gate側

ft=σ(WfXt+Rfht−1+Bf)とセル点線からのアウトプットCt-1により
Ct−1 ⊗ ft というアウトプット。
⊗ は要素ごとの積
スクリーンショット 2020-03-01 20.43.05.png

②Input Gate側

it=σ(WiXt+Riht−1+Bi)とZt=tanh(WzXt+Rzht−1+Bz)により、
it ⊗ Zt というアウトプット。
スクリーンショット 2020-03-01 20.44.28.png

③Cellの手前

①でのCt−1 ⊗ ft と②での it ⊗ Zt により
Ct = Ct−1 ⊗ ft + it ⊗ Zt
という計算が行われる。
スクリーンショット 2020-03-01 20.45.04.png

④出力付近

Memory Cell部分 Ct = it ⊗ Zt + Ct−1 ⊗ ft
OutputGate部分 Ot = σ(WoXt+Roht−1+Bo)
を使い
ht = Ot ⊗ tanh(Ct)
が行われる。
スクリーンショット 2020-03-01 20.45.28.png

LSTMのポイント

Ct = Ct−1 ⊗ ft + it ⊗ Zt
Ct−1 ⊗ ft Forget Gate部分で、Ct-1は過去の情報のパラメータをどれくらい反映するかを調整している。
it ⊗ Zt Input部分で、得られた入力値 it をどれだけ反映するか、を Zt 活性化関数により調整している。

参考

[今更聞けないLSTMの基本]
(https://www.hellocybernetics.tech/entry/2017/05/06/182757)

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?