LSTM 用于情感分析

浏览: 2733


本文讨论基于 Long Short Term Memory (LSTM) 结构的 Recurrent Neural Network (RNN) 示例。具体问题是情感分析,数据集来自

http://ai.stanford.edu/~amaas/data/sentiment/, 即  IMDB 数据集。

具体来讲,本文针对的问题是给定一条电影评论,如何判定它是正性评论还是负性评论。也就是一个二分类问题。

模型

LSTM

在传统回归神经网络中,梯度反向反馈阶段中,梯度会通过多次跟连接矩阵相乘来反馈信息,其中的连接矩阵是回归隐含层之间的连接权重构成的矩阵,所以这些连接权重的大小对学习过程影响是比较大的。

如果连接权重比较小,则学习过程会比较慢,也不容易学到数据之间的长依赖关系。相反,如果权重比较大,则学习过程就会呈现发散现象,不易收敛。

为了解决如上问题,LSTM 中引入了记忆单元,如下图所示。




如上图所示,一个LSTM的记忆单元有四个主要组件:输入门限,自回归连接的神经元(自己跟自己相连),遗忘门限,输出门限。自回归连接权重为1,这样可以保证记忆单元能够阻拦外部推理,从而保证该记忆单元从一个时间步长到另一个时间步长时保持不变。输入门限用来接收信号,进而改变记忆单元的状态或者用来组织信号。输出门限可以促使或者阻止记忆单元对其他记忆单元造成印象。遗忘门限用来调节自回归连接,进而使得某个单元记住或者遗忘之前的状态。

下面的等式给出了时间步长 t 中如何更新某层的记忆单元,一些符号说明如下:

  •  is the input to the memory cell layer at time 

  • ,  and  are weight matrices

  •  and  are bias vectors

首先,计算 ,输入门限, 是时间 t 对应记忆单元状态的候选值:

Clipboard Image.png

其次,计算 ,即时刻 t 遗忘门限的激活值:

Clipboard Image.png

有了输入门限的激活值 ,遗忘门限  ,以及候选状态 ,可以由下式记忆单元时刻 t 的候选状态  :

Clipboard Image.png

有了记忆单元的新状态,可以计算门限,然后可以得到输出:

Clipboard Image.png


示例中所用模型

本例中的模型并不是标准的LSTM,而是一种变形。本例中,为了提高计算效率,记忆单元的输出门限不依赖于记忆单元的状态,即式(5)由下式代替:

Clipboard Image.png

图示如下:



注意:上面的(1) (2) (3) (7) 式可以并行实现。

相关论文:

Introduction of the LSTM model:

  • [pdf] Hochreiter, S., & Schmidhuber, J. (1997). Long short-term memory. Neural computation, 9(8), 1735-1780.

Addition of the forget gate to the LSTM model:

  • [pdf] Gers, F. A., Schmidhuber, J., & Cummins, F. (2000). Learning to forget: Continual prediction with LSTM. Neural computation, 12(10), 2451-2471.

More recent LSTM paper:

  • [pdf] Graves, Alex. Supervised sequence labelling with recurrent neural networks. Vol. 385. Springer, 2012.

  • Tai, K. S., Socher, R., & Manning, C. D. (2015). Improved semantic representations from tree-structured long short-term memory networks. arXiv preprint arXiv:1503.0007

  • Tang, D., Qin, B., & Liu, T. (2015). Document modeling with gated recurrent neural network for sentiment classification. In Proceedings of the 2015 Conference on Empirical Methods in Natural Language Processing (pp. 1422-1432).

  • Zhu, X., Sobhani, P., & Guo, H. (2015, July). Long short-term memory over recursive structures. In Proceedings of the 32nd International Conference on Machine Learning (pp. 1604-1612).

  • Le, P., & Zuidema, W. (2015). Compositional distributional semantics with long short term memory. arXiv preprint arXiv:1503.02510.

       

Papers related to Theano:

  • [pdf] Bastien, Frédéric, Lamblin, Pascal, Pascanu, Razvan, Bergstra, James, Goodfellow, Ian, Bergeron, Arnaud, Bouchard, Nicolas, and Bengio, Yoshua. Theano: new features and speed improvements. NIPS Workshop on Deep Learning and Unsupervised Feature Learning, 2012.

  • [pdf] Bergstra, James, Breuleux, Olivier, Bastien, Frédéric, Lamblin, Pascal, Pascanu, Razvan, Desjardins, Guillaume, Turian, Joseph, Warde-Farley, David, and Bengio, Yoshua. Theano: a CPU and GPU math expression compiler. In Proceedings of the Python for Scientific Computing Conference (SciPy), June 2010.

其他:

http://deeplearning.net/tutorial/lstm.html

推荐 0
本文由 深度学习 创作,采用 知识共享署名-相同方式共享 3.0 中国大陆许可协议 进行许可。
转载、引用前需联系作者,并署名作者且注明文章出处。
本站文章版权归原作者及原出处所有 。内容为作者个人观点, 并不代表本站赞同其观点和对其真实性负责。本站是一个个人学习交流的平台,并不用于任何商业目的,如果有任何问题,请及时联系我们,我们将根据著作权人的要求,立即更正或者删除有关内容。本站拥有对此声明的最终解释权。

0 个评论

要回复文章请先登录注册