深度学习
  • 前言
  • 第一章:经典网络
    • ImageNet Classification with Deep Convolutional Neural Network
    • Very Deep Convolutional Networks for Large-Scale Image Recognition
    • Going Deeper with Convolutions
    • Deep Residual Learning for Image Recognition
    • PolyNet: A Pursuit of Structural Diversity in Very Deep Networks
    • Squeeze-and-Excitation Networks
    • Densely Connected Convolutional Networks
    • SQUEEZENET: ALEXNET-LEVEL ACCURACY WITH 50X FEWER PARAMETERS AND <0.5MB MODEL SIZE
    • MobileNet v1 and MobileNet v2
    • Xception: Deep Learning with Depthwise Separable Convolutions
    • Aggregated Residual Transformations for Deep Neural Networks
    • ShuffleNet v1 and ShuffleNet v2
    • CondenseNet: An Efficient DenseNet using Learned Group Convolution
    • Neural Architecture Search with Reinforecement Learning
    • Learning Transferable Architectures for Scalable Image Recognition
    • Progressive Neural Architecture Search
    • Regularized Evolution for Image Classifier Architecture Search
    • 实例解析:12306验证码破解
  • 第二章:自然语言处理
    • Recurrent Neural Network based Language Model
    • Learning Phrase Representations using RNN Encoder-Decoder for Statistical Machine Translation
    • Neural Machine Translation by Jointly Learning to Align and Translate
    • Hierarchical Attention Networks for Document Classification
    • Connectionist Temporal Classification : Labelling Unsegmented Sequence Data with Recurrent Neural Ne
    • About Long Short Term Memory
    • Attention Is All you Need
    • BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
  • 第三章:语音识别
    • Speech Recognition with Deep Recurrent Neural Network
  • 第四章:物体检测
    • Rich feature hierarchies for accurate object detection and semantic segmentation
    • Spatial Pyramid Pooling in Deep Convolutional Networks for Visual Recognition
    • Fast R-CNN
    • Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks
    • R-FCN: Object Detection via Region-based Fully Convolutuional Networks
    • Mask R-CNN
    • You Only Look Once: Unified, Real-Time Object Detection
    • SSD: Single Shot MultiBox Detector
    • YOLO9000: Better, Faster, Stronger
    • Focal Loss for Dense Object Detection
    • YOLOv3: An Incremental Improvement
    • Learning to Segment Every Thing
    • SNIPER: Efficient Multi-Scale Training
  • 第五章:光学字符识别
    • 场景文字检测
      • DeepText: A Unified Framework for Text Proposal Generation and Text Detection in Natural Images
      • Detecting Text in Natural Image with Connectionist Text Proposal Network
      • Scene Text Detection via Holistic, Multi-Channel Prediction
      • Arbitrary-Oriented Scene Text Detection via Rotation Proposals
      • PixelLink: Detecting Scene Text via Instance Segmentation
    • 文字识别
      • Spatial Transform Networks
      • Robust Scene Text Recognition with Automatic Rectification
      • Bidirectional Scene Text Recognition with a Single Decoder
      • multi-task learning for text recognition with joint CTC-attention
    • 端到端文字检测与识别
      • Reading Text in the Wild with Convolutional Neural Networks
      • Deep TextSpotter: An End-to-End Trainable Scene Text Localization and Recognition Framework
    • 实例解析:字符验证码破解
    • 二维信息识别
      • 基于Seq2Seq的公式识别引擎
      • Show and Tell: A Neural Image Caption Generator
      • Show, Attend and Tell: Neural Image Caption Generation with Visual Attention
  • 第六章:语义分割
    • U-Net: Convolutional Networks for Biomedical Image Segmentation
  • 第七章:人脸识别
    • 人脸检测
      • DenseBox: Unifying Landmark Localization with End to End Object Detection
      • UnitBox: An Advanced Object Detection Network
  • 第八章:网络优化
    • Batch Normalization
    • Layer Normalization
    • Weight Normalization
    • Instance Normalization
    • Group Normalization
    • Switchable Normalization
  • 第九章:生成对抗网络
    • Generative Adversarial Nets
  • 其它应用
    • Holistically-Nested Edge Detection
    • Image Style Transfer Using Convolutional Nerual Networks
    • Background Matting: The World is Your Green Screen
  • Tags
  • References
由 GitBook 提供支持
在本页
  • Learning Phrase Representations using RNN Encoder-Decoder for Statistical Machine Translation
  • 简介
  • 详解
  • 2. GRU
  • 3. 总结
  • 参考文献

这有帮助吗?

  1. 第二章:自然语言处理

Learning Phrase Representations using RNN Encoder-Decoder for Statistical Machine Translation

Learning Phrase Representations using RNN Encoder-Decoder for Statistical Machine Translation

简介

在很多时序分类(Temporal Classification)的应用中,输入数据X和输出数据Y的标签长度并不相等,而且不存在单调的映射关系,例如机器翻译,对话系统等等。为了解决这个问题,作者提出了RNN Encoder-Decoder模型,RNN Encoder-Decoder是由两个RNN模型级联而成的,通过Encoder将输入数据编码成特征向量,再通过Decoder将特征向量解码成输出数据。

这篇论文的第二个贡献就是GRU(Gated Recurrent Unit)的提出,GRU和LSTM均是采用门机制的思想改造RNN的神经元,和LSTM相比,GRU更加简单,高效,且不容易过拟合,但有时候在更加复杂的场景中效果不如LSTM,算是RNN和LSTM在速度和精度上的一个折中方案。

论文的实现是对SMT中短语表的rescore,即使用MOSES(SMT的一个开源工具)根据平行语料产生短语表,使用GRU的RNN Encoder-Decoder对短语表中的短语对进行重新打分。

详解

1. RNN Encoder-Decoder

给定训练集D=(X,Y)D=(X,Y)D=(X,Y),我们希望最大化输出标签的条件概率,即:

p(y1,y2,...,yT′∣x1,x2,...,XT)p(y_1, y_2, ..., y_T' | x_1, x_2, ..., X_T)p(y1​,y2​,...,yT′​∣x1​,x2​,...,XT​)

在上式中,T≠T′T \neq T'T=T′。

1.1 编码

RNN Encoder-Decoder的编码过程是先是通过一个RNN将变长的输入序列转换成固定长度的特征向量,再通过RNN将特征向量解码成需要的输出,如图1.

图1:RNN Encoder-Decoder by Cho K

输入序列是一个标准的RNN,在计算时间片ttt的输出h<t>h_{<t>}h<t>​时,将h<t−1>h_{<t-1>}h<t−1>​和x<t>x_{<t>}x<t>​输入激活函数中,表示为

h<t>=f(h<t−1>,x<t>)h_{<t>} = f(h_{<t-1>}, x_{<t>})h<t>​=f(h<t−1>​,x<t>​)

经过TTT个时间片后,得到一个h×1h\times1h×1的特征向量c\mathbf{c}c,其中hhh是隐层节点的节点数。f(.)f(.)f(.)是一个RNN单元,在这篇论文中,使用的是GRU,GRU的详细内容会在下面详细讲解。

1.2 解码

RNN Encoder-Decoder的解码过程是另外一个RNN,解码器的作用是将特征向量c\mathbf{c}c,前一个时间片的输出y<t−1>y_{<t-1>}y<t−1>​,以及前一个隐层节点h<t−1>h_{<t-1>}h<t−1>​作为输入,得到h<t>h_{<t>}h<t>​,表示为

h<t>=f(h<t−1>,y<t−1>,c)h_{<t>} = f(h_{<t-1>}, y_{<t-1>}, \mathbf{c})h<t>​=f(h<t−1>​,y<t−1>​,c)

其中,y<t>y_{<t>}y<t>​也是关于c\mathbf{c}c,y<t−1>y_{<t-1>}y<t−1>​以及h<t−1>h_{<t-1>}h<t−1>​的条件分布

y<t>=P(y<t>∣y<t−1>,y<t−2>,...,y<1>,c)=g(h<t>,y<t−1>,c)y_{<t>} = P(y_{<t>} | y_{<t-1>}, y_{<t-2>}, ..., y_{<1>}, \mathbf{c}) = g(h_{<t>}, y_{<t-1>}, \mathbf{c})y<t>​=P(y<t>​∣y<t−1>​,y<t−2>​,...,y<1>​,c)=g(h<t>​,y<t−1>​,c)

RNN Encoder-Decoder的优化便是最大化p(y∣x)p(y|x)p(y∣x)的log条件似然

max⁡θ1N∑n=1Nlogpθ(yn∣xn)\mathop{\max}_\mathbf{\theta} \frac{1}{N} \sum^{N}_{n=1}logp_\mathbf{\theta} (\mathbf{y}_n|\mathbf{x}_n)maxθ​N1​n=1∑N​logpθ​(yn​∣xn​)

其中θ\mathbf{\theta}θ是编码解码器的所有参数。

RNN Encoder-Decoder不仅可以用于产生输出数据,根据训练好的模型,使用条件概率模型pθ(yn∣xn)p_\mathbf{\theta} (\mathbf{y}_n|\mathbf{x}_n)pθ​(yn​∣xn​),也可以对现有的的标签进行评分。在这篇论文的实验中,作者便是对SMT中的短语表进行了重新打分。

另外一篇著名的Seq2Seq的论文 几乎和这篇论文同时发表,在Seq2Seq中,编码器得到的特征向量仅用于作为解码器的第一个时间片的输入,结构如图2

图2:RNN Encoder-Decoder by Sutskever I

2. GRU

对于短语rescore这个任务,作者最先使用的是RNN模型,遗憾的是RNN表现并不是非常理想。究其原因,在时间序列数据中,h<t>\mathbf{h}_{<t>}h<t>​怎样更新,使用多少比例更新值,这些是可以仔细设计的,或者可以通过数据学习到的。根据LSTM中提出的门机制的思想,作者提出了一种更简单,更高效且更不容易过拟合的GRU,图3便是GRU的结构。

图3:GRU的结构

在上图中,有两个门:重置门(reset gate)以及更新门(update gate),两个门的计算均是通过当前时间片的输入数据xt\mathbf{x}_txt​以及上一个时间片的隐节点h<t−1>\mathbf{h}_{<t-1>}h<t−1>​计算而来:

重置门rjr_jrj​:

rj=σ([Wrx]j+[Urh<t−1>]j)r_j = \sigma([\mathbf{W}_r \mathbf{x}]_j + [\mathbf{U}_r\mathbf{h}_{<t-1>}]_j)rj​=σ([Wr​x]j​+[Ur​h<t−1>​]j​)

更新门zj:z_j:zj​:

zj=σ([Wzx]j+[Uzh<t−1>]j)z_j = \sigma([\mathbf{W}_z \mathbf{x}]_j + [\mathbf{U}_z\mathbf{h}_{<t-1>}]_j)zj​=σ([Wz​x]j​+[Uz​h<t−1>​]j​)

其中,[.]j[.]_j[.]j​表示向量的第j个元素,σ\sigmaσ是sigmoid激活函数。

重置们rjr_jrj​用于控制前一时刻的状态h<t−1>\mathbf{h}_{<t-1>}h<t−1>​对更新值的影响,当前一时刻的状态对当前状态的影响并不大时rj=0r_j = 0rj​=0,则更新值只受该时刻的输入数据xtx_{t}xt​的影响:

h^j<t>=ϕ([WX]j+[U(r⊙h<t−1>)]j)\hat{h}_j^{<t>} = \phi([\mathbf{W}\mathbf{X}]_j + [\mathbf{U}(\mathbf{r}\odot\mathbf{h}_{<t-1>})]_j)h^j<t>​=ϕ([WX]j​+[U(r⊙h<t−1>​)]j​)

其中ϕ\phiϕ是tanh激活函数,⊙\odot⊙是向量的按元素相乘。

而ztz_tzt​用于控制该时间片的隐节点使用多少比例的上个状态,多少比例的更新值,当zt=1z_t = 1zt​=1时,则完全使用上个状态,即h<t>=h<t−1>\mathbf{h}_{<t>} = \mathbf{h}_{<t-1>}h<t>​=h<t−1>​,相当于残差网络的short-cut。

hj<t>=zjhj<t−1>+(1−zj)h^j<t−1>h_j^{<t>} = z_jh_j^{<t-1>} + (1-z_j)\hat{h}_j^{<t-1>}hj<t>​=zj​hj<t−1>​+(1−zj​)h^j<t−1>​

GRU的两个门机制是可以通过SGD和整个网络的参数共同调整的。

3. 总结

RNN Encoder-Decoder模型的提出和RNN门机制的隐层单元(LSTM/GRU)在解决长期依赖问题得到非常好的效果是分不开的。因为解码器使用的是编码器最后一个时间片的输出,加入我们使用的是经典RNN结构,则编码器得到的特征向量将包含大量的最后一个时间片的特征,而早期时间片的特征会在大量的计算过程中被抹掉。

参考文献

上一页Recurrent Neural Network based Language Model下一页Neural Machine Translation by Jointly Learning to Align and Translate

最后更新于4年前

这有帮助吗?

[1]

https://zhuanlan.zhihu.com/p/28297161