Stacked RNNs › Dropout Between RNN Layers
Language AI HandbookAll chapters Stacked RNNs › Dropout Between RNN LayersOne section · Sections in this chapter6 / 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
Deeper models are more expressive but also more prone to overfitting. The standard solution in feedforward networks is dropout, which randomly zeroes out a fraction of activations during training. Applying dropout naively to recurrent networks requires more care.
Standard Dropout on Non-Recurrent Connections
The original approach, used in early stacked RNNs, applies standard dropout only between layers (on the vertical connections), not on the recurrent connections within a layer. Concretely, the input to layer at timestep is:
where zeroes each element of independently with probability and scales by to preserve expected values.
The key constraint is that dropout is applied independently at each timestep. This means the dropout mask changes at every timestep. Applying a different mask at each timestep destroys the ability of the network to retain information over time, because any bit of memory that gets dropped at one step is lost permanently for the recurrent path through that step.
Variational Dropout (Fixed Mask Across Time)
Gal and Ghahramani (2016) showed that the correct Bayesian interpretation of dropout for recurrent networks requires using the same dropout mask at every timestep within a single forward pass. This is called variational dropout.
Instead of sampling a new mask at every , you sample once per forward pass:
and apply these fixed masks consistently:
where is element-wise multiplication. Using a fixed mask across timesteps means the same units are always dropped within a sequence, which preserves gradient flow through time while still regularizing.
Variational dropout applies the same random dropout mask to all timesteps within a single training sequence. This preserves the recurrent gradient flow while regularizing the network, unlike standard dropout which applies a different mask at each step and disrupts memory.
The practical effect is significant. With standard timestep-varying dropout, a model trained with high dropout rates struggles to retain information across many steps because the dropout noise accumulates over the recurrence. With variational dropout, a consistent mask prevents specific units from participating, but the units that do participate are always the same, so gradients flow cleanly through those units across all timesteps.
In PyTorch's built-in nn.LSTM with dropout=p, the dropout is applied between layers (inter-layer) using standard dropout. For variational dropout, you need a custom implementation or a library like torchnlp or WeightDrop from Merity et al.
Dropout Rate Selection
Typical dropout rates for stacked RNNs:
- 0.1–0.2: Light regularization, suitable for large datasets
- 0.3–0.5: Standard regularization, good for medium datasets
- 0.5: Strong regularization, often used for small datasets or highly expressive models
The optimal dropout rate usually increases with depth and decreases with dataset size. For a 3-layer stacked LSTM on a medium-sized language modeling task, rates of 0.3–0.5 between layers are common.

The divergence between training and validation loss without dropout illustrates classic overfitting. Standard dropout closes the gap somewhat, while variational dropout achieves the lowest validation loss because it preserves coherent gradient flow while still regularizing.