Setting up a bidirectional RNN model
Recurrent Neural Networks focus on capturing the sequential information at time t by using historical states only. However, bidirectional RNN train the model from both directions using two RNN layers with one moving forwards from start to end and another RNN layer moving backwards from end to start of sequence.
Thus, the model is dependent on historical and future data. The bidirectional RNN models are useful where causal structure exists such as in text and speech. The unfolded structure of bidirectional RNN is shown in the following figure:
Unfolded bidirectional RNN architecture
Getting ready
Install and set up TensorFlow:
- Load required packages:
library(tensorflow)
- Load
MNIST
dataset. - The image from
MNIST
dataset is reduced to 16 x 16 pixels and normalized (Details are discussed in the Setting-up RNN model section).
How to do it...
This section covers the steps to set-up a bidirectional RNN model.
- Reset the graph and start an interactive session:
# Reset the...