经典LSTM和LSTMP

 

传统的LSTM

在原来学习的LSTM中,通常都是使用的一个比较简单版本的LSTM,参考理解LSTM

 然而在最近的学习中,阅读论文发现一种经典LSTM,而之前介绍学习的LSTM通常都是简单LSTM,因此写篇随笔总结一下,几种LSTM的变体。

经典LSTM

where the W terms denote weight matrices (e.g. Wix is the matrix of weights from the input gate to the input), Wic, Wf c, Woc are diagonal weight matrices for peephole connections, the b terms denote bias vectors (bi is the input gate bias vector), σ is the logistic sigmoid function, and i, f, o and c are respectively the input gate, forget gate, output gate and cell activation vectors, all of which are the same size as the cell output activation vector m,  is the element-wise product of the vectors, g and h are the cell input and cell output activation functions, generally and in this paper tanh, and φ is the network output activation function, softmax in this paper

——Long Short-Term Memory Recurrent Neural Network Architectures For Large Scale Acoustic Modeling

 相比简单LSTM结构,这个经典LSTM在计算中多出了Wic,Wfc, Wcm的计算,引入了一种叫做peephole connections的结构。我们通过图示来对两种结构进行比较,可以看到他们的不同

 

 

 

 

 

 可以看到两者相比,后者比前者多了几条红色数据流,Ct-1加入到遗忘门,输入门和输出门的计算之中,这种LSTM变种的调控方式就叫做peephole connection,将上一次的ht-1,ct-1,和本次的xt都考虑进去,来产生门的输出。

LSTMP与Projection layer

Projection lay而有什么好处呢?Projection layer可以减少计算量,它的作用和全连接layer很像,就是对输出向量做一下压缩,从而能把高纬度的信息降维,减小cell unit的维度,从而减小相关参数矩阵的参数数目!

传统的LSTM

 

 

 最后的yt是输出,式中的mt-1就是前面图片中的ht-1表达的是同一个参数,只是写法不同。

如果不计算其中的bias,那么传统LSTM中需要计算的参数就为:

W = nc*nc*4 + nc* n* 4 + nc* no+ nc* 3

其中,nc表示隐藏层cell units的大小,即隐藏层的维度,ni表示输入数据的维度,no表示最终输出的向量维度。

nc * nc * 4表示的是Wim,Wfm,Wom,Wcm中参数数目

nc* n* 4 表示的是Wix,Wfx,Wox,Wcx中参数数目

nc* n表示的是Wym中参数数目

nc* 3 表示的是Wic,Wfc,Woc中参数数目,这三个参数为对角矩阵

LSTMP

加入Projection layer之后,LSTMP的计算如下:

 

 此时的参数个数就发生了变化:

W = nc*nr*4 + nc* n* 4 + nc* nr+ n* n+ nc* 3

其中,

 nc * nr * 4表示的是Wir,Wfr,Wor,Wcr中参数数目

nc* n* 4 表示的是Wix,Wfx,Wox,Wcx中参数数目

nc* nr * 4 表示的是Wrm中参数数目

nr* n表示的是Wym中参数数目

nc* 3 表示的是Wic,Wfc,Woc中参数数目,这三个参数为对角矩阵

 

两者的对比计算可以举个例子将其带入,很容易的就发现参数数目有了显著的减少。

 

posted @ 2020-03-30 20:37  风风风风风掠  阅读(1990)  评论(0)    收藏  举报