Bidirectional LSTM
Contents
This post creates a Bidirectional LSTM and learns a simple pattern in the sequence.
Toy Dataset
The simulated dataset contains input sequences of length 10. The output sequence is one that contains a series of 0’s and 1’s based on whether the cumulative sum exceeds a particular level
Data Preparation
| |
Building Model
| |
Training the Model
| |
Testing the Model
| |
Takeaways
Bidirectional LSTMlayer is easy to add. One can easily specify aBidirectionalWrapperon LSTM and this gives rise to two layers, one the original layer and other a reversed layer.- One can specify the
mergemode inkerasand the options are( default is concat)- sum
- mul
- concat
- ave
- Although
BidirectionalLSTMswere developed for speech recognition applications, they have been found to be very useful in other areas including Finance - The need for using
TimeDistributedwrapper in the context ofcumsumprediction has given me a good understanding of this wrapper