Keras implementation of Phased LSTM [https://arxiv.org/abs/1610.09513], from NIPS 2016.
This is an extension to the fferroni/PhasedLSTM-Keras original contribution, to allow switching off the training of the timegate and enable it to work on fixed weights for the shift, period and ratio parameters.
- Creating an initializer for the timegate:
# Opening the gate every 8 timesteps def timegate_init(shape, dtype=None): return K.constant(np.vstack(( np.zeros(shape[1]) + 0.8, # period np.zeros(shape[1]) + 0.01, # shift np.zeros(shape[1]) + 0.05)), dtype=dtype) # ratio
- Setting the
timegate_initializer
and marking thetrainable_timegame
asFalse
:PhasedLSTM(150, return_sequences=True, timegate_initializer=timegate_init, trainable_timegate=False)