RNN, LSTM 图文详解

往期文章链接目录

Sequence Data

There are many sequence data in applications. Here are some examples

  • Machine translation

    • from text sequence to text sequence.
  • Text Summarization

    • from text sequence to text sequence.
  • Sentiment classification

    • from text sequence to categories.
  • Music Generation

    • from nothing or some simple stuff (character, integer, etc) to wave sequence.
  • Name entity recognition (NER)

    • From text sequence to label sequence.

Why not use a standard neural network for sequence tasks

  • Inputs, outputs can be different lengths in different examples. This can be solved by standard neural network by paddings with the maximum lengths but it’s not a good solution since there would be too many parameters.

  • Doesn’t share features learned across different positions of text/sequence. Note that Convolutional Neural Network (CNN) is a good example of parameter sharing, so we should have a similar model for sequence data.

RNN

A Recurrent Neural Network (RNN) can be thought of as multiple copies of the same network, each passing a message to a successor. This chain-like nature reveals that recurrent neural networks are intimately related to sequences. Therefore, they’re the natural architecture of neural network to use for sequence data. Note that it also allows previous outputs to be used as inputs.

For each time step t t t, the activation a < t > a^{<t>} a<t> and the output y < t > y^{<t>} y<t> are expressed as follows:

  • a < t > = g 1 ( W a a a < t − 1 > + W a x x < t > + b a ) a^{<t>}=g_{1}\left(W_{a a} a^{<t-1>}+W_{a x} x^{<t>}+b_{a}\right) a<t>=g1(Waaa<t1>+Waxx<t>+ba)

  • y < t > = g 2 ( W y a a < t > + b y ) y^{<t>}=g_{2}\left(W_{y a} a^{<t>}+b_{y}\right) y<t>=g2(Wyaa<t>+by)

These calculation could be visualized in the following figure

Note:

  • dimension of W a a W_{a a} Waa: (number of hidden neurons, number of hidden neurons)

  • dimension of W a x W_{a x} Wax: (number of hidden neurons, length of x x x)

  • dimension of W y a W_{y a} Wya: (length of y y y, number of hidden neurons)

  • The weight matrix W a a W_{a a} Waa is the memory the RNN is trying to maintain from the previous layers.

  • dimension of b a b_a ba: (number of hidden neurons, 1)

  • dimension of b y b_y by: (length of y

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值