oneDNN icon indicating copy to clipboard operation
oneDNN copied to clipboard

Simple implementation for LSTM

Open RadjaHachilif opened this issue 7 years ago • 2 comments

Hello everyone, I'm trying to implement a simple LSTM block using mkl-dnn. The implementation is described here :

A cell consists of three gates (input, forget, output), and a cell unit. Gates use a sigmoid activation, while input and cell state is often transformed with tanh. LSTM cell can be defined with a following set of equations:

Gates: it=g(Wxixt+Whiht−1+bi) ft=g(Wxfxt+Whfht−1+bf) ot=g(Wxoxt+Whoht−1+bo)

Input transform: c_int=tanh(Wxcxt+Whcht−1+bc_in)

State update: ct=ft⋅ct−1+it⋅c_int ht=ot⋅tanh(ct)

Is this fucntion supported in mkldnn? if it is the case could you please provide an example? (In the examples, I could only find an implementation of Vanilla_lstm. )

Thank you.

RadjaHachilif avatar Feb 01 '19 15:02 RadjaHachilif

Hello @RadjaHachilif , What you describe is the exact definition of our vanilla_lstm cell. In our notations, we call c_int a gate too. You can find a few examples of how to create such an lstm cell here and here.

mgouicem avatar Feb 01 '19 16:02 mgouicem

Thank you so much for your clarifications.

RadjaHachilif avatar Feb 01 '19 18:02 RadjaHachilif