LSTM Gate Equations › The Cell State Update
Language AI HandbookAll chapters LSTM Gate Equations › The Cell State UpdateOne section · Sections in this chapter6 / 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
We've now assembled all the ingredients: a forget gate that knows what to discard, an input gate that knows how much to write, and a candidate that proposes what to write. The cell state update combines these three components into a single equation that forms the heart of the LSTM.
This is where the "information highway" metaphor becomes concrete. The cell state flows through time, modified at each step by two operations: selective forgetting and selective addition. The key insight is that information can flow unchanged for many time steps if the forget gate stays near 1 and the input gate stays near 0. This enables LSTMs to capture long-range dependencies.
The Update Equation
The new cell state is computed as:
where:
- : the new cell state
- : the previous cell state (the memory we're updating)
- : the forget gate activation (values between 0 and 1)
- : the input gate activation (values between 0 and 1)
- : the candidate cell state (values between -1 and 1)
- : the Hadamard (element-wise) product, where
Understanding the Two Terms
The equation has two terms, each serving a distinct purpose:
Term 1: Filtered Memory ()
This term takes the previous cell state and scales each dimension by the corresponding forget gate value. If for dimension , then 90% of that dimension's previous value is retained. If , only 10% survives. This element-wise multiplication allows the network to selectively preserve some memories while erasing others, all within the same time step.
Term 2: New Information ()
This term takes the candidate's proposal and scales it by the input gate. If for dimension , then 80% of the candidate's proposed value for that dimension gets written. If , the candidate's proposal is largely ignored. This gating prevents irrelevant information from contaminating the cell state.
The Sum: Combining Old and New
Adding these terms creates the new cell state. Each dimension independently combines its filtered old value with its gated new value. This additive structure gives gradients a direct path: during backpropagation, gradients can flow directly through the addition operation without being squashed by nonlinearities.
A Concrete Example: Tracing the Update Step by Step
Let's walk through a concrete example to see exactly how the gates interact. Suppose the cell state has dimension and at time we have:
- Previous cell state:
- Forget gate:
- Input gate:
- Candidate:
Step 1: Apply the forget gate to the previous cell state
Step 2: Apply the input gate to the candidate
Step 3: Sum to get the new cell state
Interpreting Each Dimension:
-
Dimension 1 (): The forget gate was high (0.9), preserving most of the old value. The input gate was low (0.2), adding little new information. Result: minimal change, memory preserved.
-
Dimension 2 (): The forget gate was low (0.1), nearly erasing the old value. The input gate was high (0.8), strongly writing the candidate's positive value. Result: dramatic reversal, old memory replaced with new information.
-
Dimension 3 (): Moderate forget gate (0.7) kept most of the old value. Low input gate (0.3) added a small negative candidate contribution. Result: gradual decrease.
-
Dimension 4 (): Balanced gates (0.5 and 0.6) created a blend of old and new. Result: moderate change incorporating both sources.
This example illustrates the LSTM's power: each dimension of the cell state can be updated independently, with different balances of remembering and writing, all controlled by the learned gate values.

