The LSTM — short for Long Short-Term Memory — fixed vanishing gradients with three gates and a separate cell state running alongside the hidden state. What if you could get the same fix with one gate fewer, and no second state to keep track of at all?
The same fixed input every step, an update gate biased almost shut. Watch the hidden state creep upward, a little more each step, never resetting and never exploding — the signature of a gate that's mostly saying "keep what you already have."
A GRU — short for Gated Recurrent Unit — cell has two gates instead of the LSTM's three, and only one state instead of two:
- — the update gate: how much of the new candidate state to blend in versus keeping the old hidden state.
- — the reset gate: how much of the previous hidden state the candidate is allowed to see.
- — the input at time step .
- — the hidden state carried over from the previous time step.
- — the candidate hidden state: a fresh proposal for the new state, computed from the current input and the (possibly reset) previous state.
- — the new hidden state: a blend of the old state and the candidate, weighted by the update gate.
- The update gate merges two LSTM jobs into one
plays the LSTM's forget gate and input gate at once: it's a single dial between "keep exactly" () and "replace it with the new candidate" ().
- The reset gate controls what the candidate sees
controls how much of the old state the candidate itself is allowed to see before being blended in.
The same 10-step gradient comparison from the LSTM chapter, with the GRU added: a plain RNN's gradient has collapsed to essentially zero, the LSTM's typical forget gate of holds onto a modest fraction, and this GRU's update gate — biased hard toward "remember" — preserves more gradient than either, using one fewer gate to do it.
Fixed input every step, weights biasing toward and toward :
- Both gates settle to the same value every step
With , , :
- at every timestep, regardless of the hidden state.
- — the reset gate stays wide open, barely touching the candidate.
- The hidden state creeps forward
With and fixed every step, the recurrence becomes (since , , and ). Starting from :
Each step keeps about of the old state and blends in only a shrinking sliver of the (slowly rising) candidate. Continuing the same recurrence for 7 more steps reaches — small, steadily increasing, never overshooting.
- The same gate that shapes memory shapes the gradient
The dominant path for is a product of at each step: . The LSTM's typical forget gate of gives over the same span — this GRU's bias toward remembering preserves gradient even more aggressively, with no separate cell state required.
Find a step count, among the three candidates, where the GRU's surviving gradient is still bigger than the LSTM's.
The GRU isn't a different fix from the LSTM's — it's a cheaper one. Fold the forget and input decisions into a single update gate, drop the separate cell state, and the same memory highway falls out for free. Fewer parameters, fewer states to track, and — as this chapter's numbers show — no real cost in how well gradient survives across time. The next chapter builds on this same gated hidden state to solve a problem no single-sequence chapter has faced yet: turning one sequence into another of a different length entirely.