Worked examples — Gated Recurrent Units (GRU)
Before anything else, let me re-list the four rules so this page stands on its own. Read them once; we will refer to them by number.
The heart of every example below is rule (4). Picture it as a slider between two memories.

Look at the slider: the left end is the fresh candidate , the right end is the old memory . The update gate is the knob position. pins the knob to "keep old"; pins it to "take new"; anything between blends the two.
The scenario matrix
Every GRU cell you will ever hand-compute falls into one of these cells. Each worked example below is tagged with the cell it covers.
| # | Cell (scenario class) | What makes it special | Example |
|---|---|---|---|
| A | , | fully overwrite, keep past for candidate | Ex 1 |
| B | (degenerate =1), any | freeze memory — perfect carry | Ex 2 |
| C | , (degenerate) | full reset + full overwrite — "start fresh" | Ex 3 |
| D | , | genuine blend (the everyday case) | Ex 4 |
| E | Negative components / sign flip | candidate goes negative | Ex 5 |
| F | Limiting behaviour over steps | gradient highway | Ex 6 |
| G | Real-world word problem | sentiment pivot at "but" | Ex 7 |
| H | Exam twist: vs mix-up | which term multiplies which memory | Ex 8 |
I will keep the numbers small (1- or 2-dimensional hidden states) so you can check every arithmetic step in your head.
- Rule (2) already gave the candidate. With , the candidate saw the full old memory, so went into the . We are told the result is . Why this step? means "the past is relevant while proposing the new memory" — reset does not erase; it only scales the past inside the candidate.
- Apply rule (4): . Why this step? Rule (4) is the only equation that produces the output memory.
- Arithmetic: . Why this step? zeroes the "keep old" term entirely.
Verify: exactly, and indeed . The old vanished — matches the forecast: knob at "take new".
- Rule (4): . Why this step? We test the upper degenerate corner of the slider.
- Arithmetic: . Why this step? The factor is , so the loud candidate is multiplied away completely.
- Repeat 100 times with each step: unchanged. Why this step? This is the "gradient highway": if always, , so information (and gradient) passes 100 steps with no decay.
Verify: identically, independent of . A gate of exactly is a perfect memory lock. Matches forecast: the candidate stays out.
- Rule (2) with reset zero: , so the candidate sees no history: . Why this step? literally deletes from inside the candidate — "start fresh from only."
- Compute the tanh: . Why this step? turns the raw score into a bounded content value in .
- Rule (4): . Why this step? Update gate is low, so mostly the fresh candidate flows through.
- Arithmetic: . Why this step? Final blend.
Verify: the survivor of old memory is only the chunk (about of the answer). Reset () killed the past inside the candidate; update () let only a sliver of raw leak into the final blend. Two independent knobs, two independent jobs — exactly as the matrix demands.
- Coordinate 1, rule (4): . Why this step? Rule (4) runs element-wise; each dimension has its own gate value.
- (coordinate 1).
- Coordinate 2, rule (4): . Why this step? Same rule, second slot.
- (coordinate 2).
- Assemble: .

The figure shows both sliders. Coordinate 2 (low ) swung far from its old up to ; coordinate 1 (high ) barely moved from to .
Verify: coordinate 1 stayed near old (, high ); coordinate 2 leapt toward candidate (, low ). Bigger change where is smaller — matches the forecast and the slider picture.
- Candidate via rule (2): . Why this step? is odd: , so a negative score gives a negative content value — this is exactly why we use and not sigmoid for content: memory must be able to point down.
- Rule (4): . Why this step? Standard blend.
- Arithmetic: .
Verify: result is negative because the negative candidate () outweighs the positive old memory (). If instead , : the sign of is genuinely controlled by the gate, not fixed. Matches forecast.
- Rule (4) with : . Why this step? No new content, so each step just scales the old memory by .
- Iterate 5 times: . Why this step? Multiplying by once per step compounds.
- Compute: . So of the original signal survives.
- Plain RNN comparison: , i.e. survives. Why this step? A vanilla RNN multiplies by every step (see 3.5.02-Vanishing-and-Exploding-Gradients), so it decays exponentially fast.
Verify: vs — GRU keeps ~75× more signal. Because , the gradient scales as , near , not near . This is the whole point of gating over the 3.5.01-Basic-RNN-Architecture. Forecast confirmed.
- Reset acts first (rule 2 input): — the positive past is damped before entering the candidate. Why this step? Low says "the contrast word means old sentiment is less trustworthy for proposing new sentiment."
- Candidate: . Why this step? The pivot pushes the score negative; yields a mildly negative candidate.
- Update blend (rule 4): . Why this step? Low lets most of the new (negative-leaning) candidate through.
- Arithmetic: .
Verify: memory dropped from all the way to — it crossed through zero at "but", poised to go fully negative once "boring plot" arrives. Units: sentiment stays in as required ( ✓). The two gates cooperated: reset distrusted the past, update accepted the pivot. This mirrors the LSTM behaviour in 3.5.03-Long-Short-Term-Memory-(LSTM) but with one fewer gate.
- Student's (wrong) formula: . Why this step? Show the consequence of the swap explicitly.
- Correct rule (4): . Why this step? multiplies the candidate, multiplies the old state — memorise this ordering.
- Arithmetic: .
Verify: correct answer keeps the old positive memory (high ⇒ protect past); the swapped version gives , wrongly discarding it. The sign flips! In the true GRU, means "remember", so must sit on . Forecast: high protects the old .
Recall Self-test
With , , , what is ? ::: Reset gate means the candidate ignores what? ::: the old hidden state (it is multiplied by ) Over 5 steps with and no new content, what fraction of a signal survives? ::: High behaves like which two LSTM gates combined? ::: high forget + low input (keep old, reject new)
Where to go next: 3.5.06-Bidirectional-RNNs runs a GRU forwards and backwards; 3.6.01-Attention-Mechanism later removes the single-state bottleneck entirely.