Keras: Getting Cell States out of a LSTM Layer for each timestep

Created on 27 Jan 2018  路  4Comments  路  Source: keras-team/keras

Hi there,

I have a problem with LSTMs. I need to get the cell states out of a LSTM for each time step. Unfortunaly it is only possible to get the output for each time step with return_sequences=True. return_state=True only gives me the cell state for the last time step...

Is there any hack/modification to get the cell states for each time step?

Greetings

Most helpful comment

Yes, this is the cell state I am looking for, but not only. This parameter allows me to get the cell-state of the last time step, but not over all time steps like the output with return_sequences=True.

All 4 comments

This would be very helpful. We could (in combination with the LSTMVis project) visualize hidden state values in a reasonable manner.

Is it the hidden cell-state you are looking for? Example on how to get it:
lstm1, state_h, state_c = LSTM(1, return_state=True)
Deeper guide: https://machinelearningmastery.com/return-sequences-and-return-states-for-lstms-in-keras/

Yes, this is the cell state I am looking for, but not only. This parameter allows me to get the cell-state of the last time step, but not over all time steps like the output with return_sequences=True.

9351

Was this page helpful?
0 / 5 - 0 ratings