LSTM Gradient Flow › Peephole Connections
Language AI HandbookAll chapters LSTM Gradient Flow › Peephole ConnectionsOne section · Sections in this chapter10 / 17 ↓
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
In the standard LSTM, the gates (forget, input, output) are computed using only the previous hidden state and the current input . They cannot directly observe the cell state or . Gers and Schmidhuber (2000) proposed peephole connections as an extension that gives gates direct access to the cell state.
The Peephole Equations
With peephole connections, the forget, input, and output gate equations become:
where:
- : peephole weight vectors for forget and input gates (connected to )
- : peephole weight vector for output gate (connected to )
- All represent element-wise multiplication, making these diagonal weight connections
Note that the forget and input gates see (the previous cell state), while the output gate sees (the current cell state, available after the cell state update). This asymmetry is intentional.
Effect on Gradient Flow
Peephole connections change the gradient calculation because now the gate values depend on the cell state. The full partial derivative (which was approximately in the standard LSTM) now includes additional terms from the peephole connections. The peephole terms add complexity but also allow the network to make gating decisions based on cell state values, potentially enabling more precise control over memory retention. Greff et al. (2017) conducted an extensive ablation study and found that peephole connections provide modest improvements on some tasks but are not always worth the additional complexity.
When Peepholes Help
Peephole connections are most useful for tasks that require precise timing. Consider counting the exact number of steps between two events, or generating periodic patterns at exact intervals. In these cases, the cell state encodes timing information (e.g., a counter), and the gates need to make decisions based on the counter value. Peepholes allow the gate to directly read the counter rather than reading it indirectly through the hidden state.
The distinction matters because the hidden state is a lossy transformation of the cell state: it applies a tanh nonlinearity that compresses values into , and then multiplies by the output gate, which may attenuate the signal further. Reading the cell state directly through peepholes gives access to the uncompressed, unattenuated value.
For most NLP tasks, standard LSTMs without peepholes perform comparably, which is why peephole connections are rarely used in practice today.