The same Wh, Wx and Wy are used in every box. Only h, the state, changes from step to step. It's the network's entire memory of everything it has read so far.
A 1-number RNN, . Two runs are identical except for the first input (x₁ = +1 vs −1), followed by 29 steps of the same random noise. If the gap between the two runs closes, the network has forgotten x₁.
σ squashes to 0–1, so each gate is a learned dial (0 = closed, 1 = open), set separately for each memory slot at each step.
The last line is linear interpolation: ht lies on the line between the old state and the candidate. (1 − z) acts as the LSTM's forget gate and z as its input gate, linked so they always add up to 1.
The filter is a pattern detector, and each output is a dot product between the filter and one patch (the same operation as Q·K). The same 9 weights are reused at every position, which is weight sharing over space, just as an RNN shares weights over time. A CNN learns many filters per layer. Early layers learn edges, and later layers combine them into shapes and objects.
For text, CNNs slide along the sequence. Their view is a fixed window that grows with depth, which makes them a learned cousin of n-grams. They run fully in parallel, which RNNs can't, but they can't see past their window.
| What it sees | Memory | Parallel? | Main weakness | |
|---|---|---|---|---|
| n-gram | last n−1 words | count tables | yes | no generalization; fixed window |
| CNN | window that grows with depth | none beyond the window | yes | can't see beyond its window |
| RNN | all past, in theory | one fixed vector, overwritten every step | no (sequential) | vanishing/exploding gradients |
| LSTM / GRU | all past, with gates | gated fixed vector; additive path | no | still sequential; still one bottleneck vector |
| Transformer | all past, directly | every past token kept (KV cache) | yes (in training) | cost grows with length² (every token vs. every token) |