Bidirectional RNNs › Architecture: Forward and Backward Passes

Michael BrenndoerferMay 20, 20253 min read
Language AI HandbookAll chapters
Part 11 of 67Recurrent Neural Networks
Chapter 81Bidirectional RNNs › Architecture: Forward and Backward Passes
Reading section 3 of 16 · Architecture: Forward and Backward Passes · 3 minSection 3 of 16 · 3 min

Book contents

Section 3 of 16 · 3 min read

Bidirectional RNNs › Architecture: Forward and Backward PassesOne section · Sections in this chapter3 / 16 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

A bidirectional RNN runs two independent recurrent networks over the same input sequence.

The forward network processes tokens in the standard left-to-right order:

h→t=f(h→t−1,xt)\overrightarrow{h}_t = f(\overrightarrow{h}_{t-1}, x_t)

The backward network processes the same tokens in reverse order, from position TT down to position 11:

h←t=f(h←t+1,xt)\overleftarrow{h}_t = f(\overleftarrow{h}_{t+1}, x_t)

where:

  • h→t\overrightarrow{h}_t is the forward hidden state at position tt, summarizing context from the left (tokens 11 through tt)
  • h←t\overleftarrow{h}_t is the backward hidden state at position tt, summarizing context from the right (tokens TT down through tt)
  • ff is the same type of recurrent cell used in both directions, though the two networks have separate, independent parameters

At each position tt, the two hidden states are concatenated to form a combined representation:

ht=[h→t;h←t]h_t = [\overrightarrow{h}_t ; \overleftarrow{h}_t]

where:

  • [⋅;⋅][\cdot ; \cdot] denotes vector concatenation
  • If each directional hidden state has dimension dd, the combined state has dimension 2d2d

This combined representation at position tt encodes information from the entire sequence. The forward component carries context from tokens to the left of tt, and the backward component carries context from tokens to the right. Every position benefits from full sentence-level context.

Bidirectional RNN

A bidirectional RNN (BiRNN) consists of two recurrent networks processing the same sequence in opposite directions. Their hidden states are concatenated at each time step, giving each position access to both past and future context within the sequence. The two directional networks have separate weight matrices and are trained jointly.

Parameter Independence

A subtle but important point is that the two directional networks have completely independent parameters. The forward LSTM has its own input-to-hidden weights, hidden-to-hidden weights, and biases. The backward LSTM has a separate, unshared set of weights. They are trained jointly via backpropagation, but gradient updates to one set do not directly affect the other.

This independence is intentional and beneficial. The forward network is optimized to summarize left context effectively. The backward network is optimized to summarize right context effectively. These tasks differ: left context tends to encode the topic and the syntactic head of phrases that came before, while right context tends to encode the consequences and completions of the current phrase. Separate parameters let each direction specialize in what it does best. Sharing parameters would force both directions to use the same representational strategy, which would likely hurt both.

Initialization and Backpropagation

Both directional networks are initialized independently, typically with the same random initialization scheme applied separately. During training, gradients flow backward through each direction independently: gradients for the forward LSTM flow from right to left through time (from position TT back to position 11), and gradients for the backward LSTM flow from left to right through time (from position 11 up to position TT). Both sets of gradients are accumulated and applied to their respective parameters at each update step.

The combined representation at each position receives gradient contributions from both the output layer (through the classification head or whatever follows) and is passed back to both directional networks. This means the forward LSTM's weights are shaped by how well the combined forward-plus-backward representation classifies each position, not just by how well the forward representation alone would classify it. The two networks are coupled through the shared output loss, even though their parameters are independent.