LoginSignup
2
6

More than 5 years have passed since last update.

LSTMの簡易まとめ

Last updated at Posted at 2017-12-30

TensorFlowのBasicLSTMCellで実装されているLSTMについてのまとめ。詳細は論文https://arxiv.org/abs/1409.2329

変数

小文字はn次元ベクトル
大文字はn*n次元行列
$x_t$ : 前の層からの入力
$z_t$ : 今から出す自分の層の出力
$z_{t-1}$ : 1ステップ前の自分の層の出力
$c_t$ : このステップで計算するメモリ
$c_{t-1}$ : 1ステップ前のメモリ
$i$ : input ゲート
$f$ : forget ゲート
$o$ : output ゲート
$g$ : input modulation ゲート

わかりやすいように論文とは若干notationが違います.

計算

4つあるゲート$i, f, o, g$は全て$x_t, z_{t-1}$をつなげてからアフィン変換したもの. 例えば$i$は以下の式で計算する. $W_i, V_i, b_i$が学習するべきパラメータ.
$$ i = sigm(W_i x_t + V_i z_{t-1} + b_i) $$
$f, o$は添字を変えるだけで、$g$は添字を変えて、さらに$sigm$を$tanh$にする.

メモリは以下の式で計算する. $ \odot $は要素ごとの積
$$ c_t = f \odot c_{t-1} + i \odot g $$

出力は以下の式で計算する.
$$ z_t = o \odot tanh(c_t)$$

図にするとこんな感じ

IMG_20171231_083724.jpg

論文呼んだだけで、コードの中身は見てないのでほんとにあってるかは謎です。

2
6
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
2
6