
After the forget gate has scaled the previous memory and the input gate has added new content, the cell state is complete: it holds everything the network has chosen to remember at time . The output gate answers the last remaining question: which parts of that memory should be exposed as the hidden state ?
This is the only gate whose target is not the cell state itself. Its job is to decide what the cell says to the rest of the world, while the cell state stays free to hold information that may not be needed right now but will be later.
Definition
The output gate is again a sigmoid layer of width :
The hidden state is then read out from the cell state through a tanh and a pointwise product:
Dimensions used in this note
symbol role single example mini-batch () current input previous hidden state current cell state new hidden state output gate input-to-hidden weights idem hidden-to-hidden weights idem bias (broadcast across columns) The product acts on operands of identical shape: no broadcasting is involved in the .
Two things deserve attention.
- A tanh is applied to before gating. The cell state lives in an unbounded space (its components are sums of bounded increments, but they can accumulate over many steps); the hidden state must be bounded, because it is fed back into the gates at the next step and into any downstream prediction head. The tanh is the bounding step. Importantly, it acts only on the read-out, not on the cell state itself, so the long-term memory remains in its native unbounded range.
- The output gate then selects, coordinate by coordinate, how much of each bounded slot to expose. A value of exposes the slot in full; a value of hides it from view.
The Jacobian of the read-out
Differentiating with respect to (with held fixed, since it depends on and only) gives, component by component,
using and the coordinate independence of . Stacked into a matrix,
This Jacobian is again diagonal: the read-out couples each slot of to the same slot of , never to a different one. The coordinate independence that the cell state enjoys (see Cell state and Input gate) is therefore preserved by the read-out as well. Cross-coordinate mixing reappears only in the next step, when is consumed by the four affine maps to produce the next round of gates.
Cell state stores, hidden state speaks
The pair implements a clean separation of concerns that no single-state recurrence can express:
- is the archive: large, unbounded, persistent, and not directly observed by downstream layers. The network can use it to hold information that will only become relevant many steps later.
- is the dispatch: a bounded, selected projection of the archive, customized at every step to the current task. It is what the next-step gates see and what any prediction head consumes.
The output gate is the interface between the two. It is what lets the LSTM remember privately and report selectively.
Why this separation matters
A vanilla RNN, and any single-state recurrence, must pack everything into one vector: features it currently needs to output, features it will need later but not now, and features it must condition future gating decisions on. These three roles place incompatible demands on the same representation:
- Outputs benefit from being bounded (to keep prediction heads well-behaved).
- Long-term memory benefits from being unbounded (to let gradient flow without saturation, as derived in Cell state).
- Future gating decisions benefit from being selectively visible, not from seeing everything at once.
The output gate resolves all three. The cell state stays unbounded, so its gradient flows freely; the hidden state is bounded by tanh and selected by , so prediction heads and downstream gates see a clean, focused signal; and the network can choose, at every step, to keep some information dark by setting the corresponding component of near zero.
is a compressed view of
In information-theoretic terms, is a lossy projection of the cell state. Setting some components of to zero discards that information from the externally visible signal, even though it remains intact inside . The next step still has access to it through the cell-state line, but no other component of the network does.
This anticipates the design philosophy of modern attention-based architectures: maintain a rich internal state, and emit at each step only the selected summary that downstream computation needs.
A language-model example, continued
Continuing the example from the input gate note: by the time the model has finished reading “Alice was walking and”, the cell state contains, among other things, the gender of the subject in slot . While processing the next, uninformative tokens (“walking”, “and”), that gender information is not yet needed for any prediction; it must be kept alive in but does not need to be exposed in .
The output gate accomplishes this by setting at those steps: the gender slot stays in the archive, invisible to the next-step gates and to the prediction head. When the model reaches the position immediately before “she”, where the pronoun must be predicted, the output gate fires on the same slot: the gender becomes visible to the head, and the correct pronoun is generated. Throughout, the value in slot of has not changed; only its visibility has.
This is the kind of behaviour that no single-state recurrence can implement: the value and the visibility are entirely separate quantities, controlled by different parameters.
Why a sigmoid, again
The output gate uses the same sigmoid as the forget and input gates, for the same three reasons given in Forget gate: bounded range , smooth differentiability, and monotonicity. The output gate is a mask, not a content, so a output is the right range. Critically, multiplies pointwise, exactly as multiplied : same mathematical structure, different operand, different role.
Mini-batch form
The vectorized form for a mini-batch of examples is, as always, obtained by replacing the per-example vectors by matrices whose columns are the per-example values:
with . The bias broadcasts across the columns of the affine result; the element-wise product acts on matrices of identical shape, with no broadcasting.
All four gate operations are now defined. Putting all together assembles them into the complete forward pass of one LSTM cell.