keras lstm architecture

201 views
Skip to first unread message

Vinayakumar R

unread,
Sep 21, 2016, 12:22:12 AM9/21/16
to Keras-users

model.add(LSTM(4, input_dim=look_back)) // 4 LSTM blocks

But how many cells it has in keras?

for example i assume 4 memory blocks and 2 cells. Please see the architecture below. is this right?

In stacked LSTM

model.add(LSTM(4, return_sequences=True))
model.add(LSTM(4, return_sequences=False))

for example i assume 4 memory blocks and 2 cells. Please see the architecture below. is this right?

in that case, in the attached image in the hidden layer i have 4 lstm blocks (layer1) these feedback to another lstm layer which has same 4 lstm blocks. Am i right?

I would like to know the LSTM architecture of imdb_lstm example. 

tom.g...@gmail.com

unread,
Sep 22, 2016, 6:31:33 AM9/22/16
to Keras-users
I am not exactly sure where you get the distinction between blocks and cells from. If you do:

model.add(LSTM(4, input_dim=look_back))

You simply create a layer with 4 LSTM cells. Every LSTM cell has an input, a input gate, a forget gate and an output gate. You could view this as 4 separate 'layers', which all have a direct connection with the input and interact in a special way. If you do:

model.add(LSTM(4, return_sequences=True))
model.add(LSTM(4, return_sequences=False))

You create 2 layers of 4 LSTM cells. The output of the LSTM cells in the first layer is used as the input of the LSTM cells in the next layer. return_sequences=False has no effect on the network architecture, this only means the network does not output a value at every timestep, but only outputs the activation value at the last timestep.

I recommend to read the following article which explains LSTMs very well: http://colah.github.io/posts/2015-08-Understanding-LSTMs/

Op woensdag 21 september 2016 06:22:12 UTC+2 schreef Vinayakumar R:

Vinayakumar R

unread,
Sep 22, 2016, 11:46:06 AM9/22/16
to Keras-users
we  cannot call it as cell. it is a block which inturn has one or more memory celss. But i would like to know the number of cells cerated in keras lstm

for model.add(latm(4))
Reply all
Reply to author
Forward
0 new messages