长短记忆神经网络(LSTM,Long Short-Term Memory)

长短记忆神经网络定义

长短记忆神经网络(Long-short term memory, LSTM)是一种特殊的RNN结构。该神经网络可以有效保留历史信息,实现对文本的长期依赖信息进行学习。

关键问题:控制长期状态信息

解决方法:门控开关
  1. 门的定义:使用门(Gate)实现对图1中开关的控制。所谓的门,即全连接层的一个神经元,如图2所示。门的激活有两种形式: s i g m o d sigmod sigmod t a n h tanh tanh

  1. 门控实现:LSTM网络由输入门 ( i n p u t   g a t e ) (input \ gate) (input gate)、遗忘门 ( f o r g e t   g a t e ) (forget \ gate) (forget gate)、输出门 ( o u t p u t   g a t e ) (output \ gate) (output gate)和一个记忆单元 ( c e l l ) (cell) (cell)来实现历史信息的更新和保留,如图3所示。

  • 门限开关控制
    遗忘门 f t f_t ft:决定保留多少上一时刻单元状态信息 c t − 1 c_{t - 1} ct1到当前时刻的记忆单元 c t c_{t} ct中。
    f t = s i g m o i d ( W f ⋅ [ a t − 1 , x t ] + b f ) . {f_t} = sigmoid\left( {{W_f} \cdot \left[ {{a_{t - 1}},{x_t}} \right] + {b_f}} \right). ft=sigmoid(Wf[at1,xt]+bf).
    输入门 i t i_t it:决定保留多少当前时刻的输入信息 x t x_t xt到当前时刻的记忆单元 c t c_{t} ct中。
    i t = s i g m o i d ( W i ⋅ [ a t − 1 , x t ] + b i ) . {i_t} = sigmoid\left( {{W_i} \cdot \left[ {{a_{t - 1}},{x_t}} \right] + {b_i}} \right). it=sigmoid(Wi[at1,xt]+bi).
    输出门 o t {o_{t}} ot:决定控制多少当前时刻的记忆单元 c t c_{t} ct的输出值 o t {o_t} ot
    o t = s i g m o i d ( W o ⋅ [ a t − 1 , x t ] + b o ) . {o_t} = sigmoid\left( {{W_o} \cdot \left[ {{a_{t - 1}},{x_t}} \right] + {b_o}} \right). ot=sigmoid(Wo[at1,xt]+bo).

  • 状态更新
    当前时刻 c e l l cell cell候选状态值 c i n {c_{in}} cin(中间状态):
    c i n = tanh ⁡ ( W c ⋅ [ a t − 1 , x t ] + b c ) . {c_{in}} = \tanh \left( {{W_c} \cdot \left[ {{a_{t - 1}},{x_t}} \right] + {b_c}} \right). cin=tanh(Wc[at1,xt]+bc).
    当前时刻长期状态值 c t {c_t} ct更新:
    c t = f t ⋅ c t − 1 + i t ⋅ c i n . {c_t} = {f_t} \cdot {c_{t-1}} + {i_t} \cdot {c_{in}}. ct=ftct1+itcin.

  • 当前时刻输出值
    当前时刻LSTM单元的输出值 a t {a_{t}} at
    a t = o t ⋅ tanh ⁡ ( c t ) . {a_t} = {o_t} \cdot \tanh \left( {{c_t}} \right). at=ottanh(ct).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值