算法工程师面试题十二之LSTM简析
前言
- 文章来源:LawsonAbs(CSDN)
- 望各位读者审慎阅读
1.模型单元结构
主要记住如下特征:
-
lstm 有三重门,分别是:输入门,输出门,遗忘门。
输入门:输入的数据有多大程度进入模型;
输出门:控制当前时刻的内部状态 c t c_t ct有多少信息需要输出给外部状态;
遗忘门:控制上一个时刻的内部状态 c t − 1 c_{t-1} ct−1需要遗忘多少信息 -
lstm 的三重门都是由输入向量 x t \bold{x_t} xt变换得到的,变换公式如下:
i t = σ ( W i x t + U i h t − 1 + b i ) o t = σ ( W o x t + U o h t − 1 + b o ) f t = σ ( W f x t + U f h t − 1 + b f ) \bold{i_t} = \sigma(\bold{W_i} \bold{x_t}+ \bold{U_i} \bold{h_{t-1}} + \bold{b_i})\\ \bold{o_t} = \sigma(\bold{W_o} \bold{x_t}+ \bold{U_o} \bold{h_{t-1}} + \bold{b_o})\\ \bold{f_t} = \sigma(\bold{W_f} \bold{x_t}+ \bold{U_f} \bold{h_{t-1}} + \bold{b_f})\\ it=σ(Wixt+Uiht−1+bi)ot=σ(Woxt+Uoht−1+bo)ft=σ(Wfxt+Ufht−1+bf) -
更新公式
c t = f t ⊙ c t − 1 + i t ⊙ c ~ t h t = o t ⊙ t a n h c t c_t=f_t \odot c_{t-1} + i_t \odot \widetilde{c}_{t}\\ h_t=o_t \odot tanh {c_t} ct=ft⊙ct−1+it⊙c tht=ot⊙tanhct -
其它标记
这里再解释一下其它的标记: 和内部状态 c t c_t ct相反, h t h_t ht 表示的是外部状态
2.学习笔记
3.常问题
- 为什么叫
Long Short Term Memory Network
?