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 LSTM
layer is easy to add. One can easily specify aBidirectionalWrapper
on LSTM and this gives rise to two layers, one the original layer and other a reversed layer.- One can specify the
merge
mode inkeras
and the options are( default is concat)- sum
- mul
- concat
- ave
- Although
BidirectionalLSTMs
were developed for speech recognition applications, they have been found to be very useful in other areas including Finance - The need for using
TimeDistributed
wrapper in the context ofcumsum
prediction has given me a good understanding of this wrapper