01
Remembering a sequence
A later decision may depend on an earlier event. A recurrent state carries something forward.
The cue is no longer in front of you
Imagine six events: a cue, two quiet gaps, a counter-cue, another gap, and a request to read the state. At the last step, the current event says only “read.” To respond to the earlier cue, a system needs a state that survives between steps.
We will use this invented sequence throughout. Its event names are a teaching story, not text being encoded by a trained model. Later, we will prescribe one numerical coordinate and inspect exactly what survives, changes, and becomes visible.
Invented signal story, not trained behavior. The signed stems mark the two candidate writes used later in the lab; their time positions stay fixed. Whether either cue survives depends on the state updates.
The question is not just whether the first cue can persist. What should happen when the counter-cue arrives? And can stored state remain present even when the system exposes nothing?
One update, used repeatedly
A recurrent neural network, or RNN, updates a state using the current input and a previous state. The same learned parameters are reused at successive positions; the inputs and states change. The state is a numerical representation, not a literal archive of every earlier event. See the recurrent update and unrolled computation in Pascanu, Mikolov, and Bengio, §1.1.
Write the current input vector as and the hidden state as . The subscript counts sequence steps. An update takes and and produces , which becomes available to the next step.
A plain tanh RNN, in one equation
One common baseline mixes the input and previous hidden state, then applies , a function that squashes each value between −1 and 1:
The matrices and bias are learned parameters. They have no time subscript because this update reuses them. This is a plain tanh RNN, not the definition of every recurrent architecture. The PyTorch RNN equations use the same idea, with the bias written in two parts.
Separate carrying from exposing
An LSTM—Long Short-Term Memory—is itself an RNN architecture. Its update separates a carried cell state from an exposed hidden state, using learned multipliers called gates. We will study the standard form shown in the LSTM equations, without peephole connections or an output projection.
Start with what one step computes. Once the distinction between storage and exposure is clear, the sequence—and the reason this structure can help learning—will be easier to follow.