Skip to content

Instantly share code, notes, and snippets.

@Natural209X
Natural209X / hidden_state_lstm.py
Created May 9, 2017 14:03 — forked from mbollmann/hidden_state_lstm.py
Keras LSTM that inputs/outputs its internal states, e.g. for hidden state transfer
from keras import backend as K
from keras.layers.recurrent import LSTM
class HiddenStateLSTM(LSTM):
"""LSTM with input/output capabilities for its hidden state.
This layer behaves just like an LSTM, except that it accepts further inputs
to be used as its initial states, and returns additional outputs,
representing the layer's final states.