Stacked RNNs › Depth vs. Width Tradeoffs

Michael BrenndoerferMay 13, 20253 min read
Language AI HandbookAll chapters
Part 11 of 67Recurrent Neural Networks
Chapter 82Stacked RNNs › Depth vs. Width Tradeoffs
Reading section 5 of 16 · Depth vs. Width Tradeoffs · 3 minSection 5 of 16 · 3 min

Book contents

Section 5 of 16 · 3 min read

Stacked RNNs › Depth vs. Width TradeoffsOne section · Sections in this chapter5 / 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

Given a fixed parameter budget, you face a choice: use a single wide layer with hidden size dd, or use multiple narrower layers with hidden size d′<dd' < d. This depth-vs-width tradeoff is one of the fundamental design questions in deep learning, and recurrent networks are no exception.

Counting Parameters

For a single LSTM layer with hidden size dd and input size mm, the parameter count is approximately:

Psingle=4×(d2+d⋅m+d)P_{\text{single}} = 4 \times (d^2 + d \cdot m + d)

The factor of 4 comes from the four gates. For a 2-layer stacked LSTM where the second layer receives the first layer's hidden state as input:

Pstacked=4(d′2+d′⋅m+d′)+4(d′2+d′⋅d′+d′)=4(d′⋅m+2d′2+2d′)P_{\text{stacked}} = 4(d'^2 + d' \cdot m + d') + 4(d'^2 + d' \cdot d' + d') = 4(d' \cdot m + 2d'^2 + 2d')

where d′d' is the hidden size used in each layer. If we halve the hidden size (d′=d/2d' = d/2) to keep the parameter count similar, the stacked model has roughly equal parameters but much less capacity because d′2=d2/4d'^2 = d^2/4, which means the recurrent connections shrink quadratically.

What Width Buys

Width gives each timestep's hidden state a larger representational capacity. A wider hidden state can store more information about the current input and the recent history. Width helps when the bottleneck is insufficient local representational capacity.

What Depth Buys

Depth adds the ability to compose representations across levels. A deep network can learn features that are functions of other features in a way that a wide network cannot easily replicate. Depth helps when the bottleneck is insufficient compositional structure.

Empirical Guidance

For sequence tasks:

  • Shallow but wide models (1 layer, large dd) tend to work well on classification tasks where you need rich representations of individual timesteps but not compositional hierarchies.
  • Deep but narrower models (2–4 layers, moderate dd) tend to work better on generation and transduction tasks where multi-level structure matters.
  • For equal parameter counts, depth generally wins on tasks with strong compositional structure, but width wins on tasks with limited data.
Out[4]:
Visualization
Line chart comparing validation perplexity across layer counts from 1 to 5 with different hidden sizes.
Validation perplexity for language modeling as a function of layer count and hidden size, with total parameter count held approximately constant. Deeper networks with narrower hidden states consistently outperform wide single-layer networks on this task, with optimal performance around 2-3 layers.

The plot illustrates a consistent pattern: at equal parameter budgets, 2 to 3 layers with a moderate hidden size outperform a single wide layer for language modeling, but going beyond 3 to 4 layers without residual connections begins to hurt performance.