Foundations — Long Short-Term Memory (LSTM) cells
Before you can read the parent note Long Short-Term Memory (LSTM) cells comfortably, you must own every symbol it throws at you. This page builds each one from nothing, in the order they depend on each other. Nothing here assumes you have seen an RNN or calculus before.
1. A vector: a bag of numbers with a fixed length
The parent note writes things like , , . Each of these is a vector.
The picture: think of a vector as a column of little boxes, each box holding one number. If someone says "", read it as: " is a column of boxes, each holding a real number."

Why the topic needs it: at each moment the LSTM sees an input (a word, a sensor reading) encoded as a list of numbers — a vector. Its memory and output are also lists of numbers. Everything is vectors of boxes.
- ::: the set of all real numbers (any number on the number line, e.g. , , ).
- ::: the set of all vectors with exactly real-number boxes.
2. The subscript : a clock, not a multiplication
The picture: lay the sequence out left-to-right like frames of a film. is the frame just before . The subscript never means "multiply by ".
Why the topic needs it: LSTMs process one tick at a time and pass memory forward from tick to tick . Without a clock symbol we could not talk about "before" and "after".
3. Hidden state and cell state : two kinds of memory
Two of the vectors have special names because they persist across ticks.
The picture: imagine a conveyor belt running left to right through every tick (that is ). At each tick a small window lets a controlled amount of the belt peek out — that peek is .

- and ::: the starting memories before any input; both are set to the all-zeros vector.
- Why two separate memories? ::: can grow large and carry raw memory; is kept bounded and controlled because it feeds the next computation and the final answer.
Why the topic needs it: the entire trick of the LSTM (see 3.5.03-Vanishing-and-Exploding-Gradientsin-RNNs) is keeping gently edited so that information — and the learning signal — survives across many ticks.
4. The sigmoid : a knob squeezed into
The parent writes for every gate. Here is what it is and why.
The picture: an S-shaped curve. Very negative input → output near (gate shut). Very positive input → output near (gate wide open). Input → output exactly (half open).
- ::: Euler's number, about ; shrinks fast as grows, which is what bends the S-curve.
- ::: .
- As , ::: .
- As , ::: .
5. The : a squasher into that allows negatives
The candidate memory and the exposed memory use , not sigmoid.
The picture: an S-curve like sigmoid, but shifted and stretched so it passes through and runs from (bottom) to (top).
- ::: .
- Why not use sigmoid for the candidate content? ::: content must be able to be negative; sigmoid can never output a negative number.
6. Element-wise product : box-by-box multiply
The cell update uses , the Hadamard (element-wise) product.
The picture: line up two columns of boxes side by side; multiply each pair straight across. No mixing between different positions.
- where ::: the zero vector — memory completely erased.
- Why must and have the same length? ::: because pairs boxes position-by-position; unequal lengths have unpaired boxes.
7. Concatenation : stack two columns into one
The picture: glue one column of boxes on top of the other to form a single, longer column.
Why the topic needs it: every gate looks at both the past hidden state and the current input together. Stacking them lets a single weight matrix mix all that information at once.
- Length of if , ::: .
8. Weight matrix and matrix–vector multiply: the learnable mixer
Every gate is . The is where learning lives.
The picture: think of as a mixing board. Each output box has a row of dials in that say how strongly it listens to each input box. Training turns these dials.
- If , it turns an input of length into an output of length ::: .
- What does "" mean in ? ::: matrix–vector multiplication (rows of dotted with the stacked column).
9. Loss and gradients : the "which way to nudge?" arrow
The parent note's gradient-highway argument uses .
The picture: stand on a hilly landscape where height = loss. The gradient is the arrow pointing uphill; training walks the opposite way (downhill).
- ::: "multiply these things together" (capital-pi = repeated product).
- tells us gradient through the belt is just ::: multiplied by the forget gate (near = signal survives).
10. How it all feeds the topic
Once these pieces click, the LSTM equations read as plain English, and the follow-ons — 3.5.05-Gated-Recurrent-Units-(GRU), 3.5.06-Bidirectional-RNNs, 3.6.01-Attention-Mechanisms, 4.2.01-Transformers — reuse the exact same vocabulary.
Equipment checklist
Test yourself — cover the right side and answer aloud.
- What is a vector and its dimension? ::: An ordered list of numbers; the dimension is how many numbers it holds.
- What does the subscript in mean? ::: The clock tick / time step — NOT multiplication.
- Difference between cell state and hidden state ? ::: is the lightly-edited long-term memory belt; is its filtered, squashed short-term output.
- Range and shape of , and why gates use it? ::: Output in , S-shaped; gates need a "fraction to let through" from none to all.
- Range of and why the candidate uses it? ::: ; memory content must be able to be negative.
- What does do? ::: Multiplies two same-length vectors box-by-box (element-wise).
- What is ? ::: The two vectors stacked into one taller vector of length .
- What does the weight matrix do and what is learned? ::: Mixes the stacked input into a new vector via weighted sums; and bias are the learned dials.
- What is the loss and the gradient ? ::: is a single wrongness score; the gradient says which way to nudge each box of to lower .
- Why is good news? ::: The backward signal through the belt is only scaled by (near ), so it survives across many ticks.
Recall Quick self-check answer
If and , then .