A bidirectional RNN processes a sequence in both directions: one recurrent layer reads left to right, while another reads right to left. Their outputs are combined at each time step, giving later layers access to information from both the past and the future. This can make learning long-range dependencies easier because information accumulates more evenly across the sequence. section 4.4.2
In PyTorch, enable the configuration with bidirectional=True. The representation from each direction is concatenated, so a hidden size of hidden_nodes produces 2 * hidden_nodes values. A classifier consuming the final state therefore needs nn.Linear(hidden_nodes * 2, classes). section 4.4.2 section 4.2.3
Implementing a bidirectional recurrent classifier typically requires these changes:
- Set bidirectional=True on nn.RNN, nn.GRU, or another recurrent layer. section 4.4.2
- Extract the final layer’s states for both directions, reshape them by layer and direction, then permute and concatenate them by batch. section 4.2.3 section 11.4.1
- Resize downstream layers to consume the doubled representation; a three-layer example uses LastTimeStep(rnn_layers=3, bidirectional=True) followed by nn.Linear(hidden_nodes*2, classes). section 4.4.2
Sequence-to-sequence encoder
A sequence-to-sequence model can use a bidirectional GRU encoder because the complete input sequence is available. With hidden_size//2 units per direction, concatenation restores the intended hidden_size for the encoder representation. The decoder remains one-directional: it generates output incrementally and cannot know future output tokens. section 11.4.1
Figure 4.16 Bidirectional RNN. The output of each step in time goes to two RNNs: one processing input from left to right (green) and the other from right to left (red). The output of the two RNNs is combined (via concatenation) to create one new item at each step. This item then goes to two outputs.
Shows the two recurrent passes, their per-step concatenation, and the combined outputs passed onward. section 4.4.2



