A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Gated Recurrent Units (GRU)

Graduate Depth 106 in the knowledge graph ☐ I know this ☆ Set as goal
3topics build on this
776prerequisites beneath it
See this on the map →
LSTM and Gated Recurrent UnitsRecurrent Neural Networks→→Sequence-to-Sequence Models
gru gated-recurrent-unit rnn

Core Idea

Gated Recurrent Units (GRU) simplify LSTMs by combining forget and input gates into a single update gate, reducing parameters while maintaining gradient flow. GRUs have 3 gates vs. LSTMs' 4, making them faster to train with comparable performance. GRUs are preferred when computational efficiency matters.

Explainer

From your study of recurrent neural networks and LSTMs, you know the fundamental problem: vanilla RNNs struggle to learn long-range dependencies because gradients either vanish or explode as they are backpropagated through many time steps. LSTMs solved this with a gating mechanism — separate gates control what information to forget, what new information to store, and what to output, all protecting a cell state that can carry information across long sequences without degradation. Gated Recurrent Units (GRUs) achieve the same goal with a simpler architecture, reducing the gate count from four operations to three by merging the forget and input gates into a single update gate.

The GRU has two gates: the update gate z and the reset gate r. The update gate decides how much of the previous hidden state to keep versus how much to replace with new candidate information — it simultaneously handles what the LSTM splits into separate forget and input gates. When z is close to 1, the unit preserves the old hidden state almost entirely (like an LSTM keeping its cell state unchanged). When z is close to 0, the unit mostly adopts the new candidate state. The reset gate controls how much of the previous hidden state flows into the computation of the candidate state. When r is close to 0, the unit acts as if it is reading the first element of a sequence — it ignores history and computes a candidate based primarily on the current input. When r is close to 1, the candidate state incorporates the full previous hidden state, behaving more like a standard RNN.

The mathematical formulation makes the simplification clear. At each time step, the GRU computes: z = σ(W_z·[h_{t-1}, x_t]), r = σ(W_r·[h_{t-1}, x_t]), h̃ = tanh(W·[r⊙h_{t-1}, x_t]), and finally h_t = (1−z)⊙h_{t-1} + z⊙h̃. That last equation is the key insight: the new hidden state is a linear interpolation between the old hidden state and the candidate, controlled by the update gate. This linear interpolation creates a direct pathway for gradients to flow backward through time (similar to the LSTM's cell state highway), which is what prevents the vanishing gradient problem. Notice there is no separate cell state — the GRU maintains only the hidden state h, whereas the LSTM maintains both a cell state c and a hidden state h.

In practice, GRUs and LSTMs perform comparably on most sequence tasks. The GRU's advantage is computational: with fewer parameters (roughly 75% of an LSTM's parameter count for the same hidden size), GRUs train faster and require less memory. This makes them attractive for applications with limited compute budgets, real-time requirements, or smaller datasets where the extra LSTM parameters might lead to overfitting. The LSTM's advantage tends to emerge on tasks requiring very precise, independent control over what to store versus what to output — the separate output gate gives LSTMs slightly more expressive control. Neither architecture dominates universally; the choice is often made empirically by trying both on the specific task at hand. Both have largely been supplanted by transformer-based attention mechanisms for many sequence tasks, though GRUs remain popular in settings where sequence lengths are moderate and computational efficiency is paramount.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Dividing Integers → Unit Rates → Proportions → Percent Concept → Converting Between Fractions, Decimals, and Percents → Operations with Rational Numbers → Two-Step Equations → Solving Multi-Step Equations → Equations with Variables on Both Sides → Angle Pairs: Complementary, Supplementary, and Vertical → Parallel Lines and Transversals → Corresponding Angles → Alternate Interior Angles → Triangle Angle Sum Theorem → Exterior Angle Theorem → Triangle Inequality Theorem → Similar Triangles: AA Similarity → Similar Triangles: SSS and SAS Similarity → Proportions in Similar Triangles → Right Triangle Trigonometry Introduction → Sine, Cosine, and Tangent Ratios → Trigonometric Ratios Review → Radian Measure → Converting Between Degrees and Radians → The Unit Circle → Graphing Sine and Cosine → Graphing Tangent and Reciprocal Trigonometric Functions → Derivatives of Trigonometric Functions → Antiderivatives → Indefinite Integrals → Basic Integration Rules → Riemann Sums → Definite Integral Definition → Probability Density Functions and Continuous Distributions → Cumulative Distribution Functions → Continuous Random Variables → Probability Density Functions → Expected Value → Weak Law of Large Numbers → Probability Axioms and Rules → Conditional Probability → Conditional Distributions → Conditional Expectation → Markov Chains → Markov Decision Processes → Introduction to Reinforcement Learning → Policy Gradient Methods → Policy Networks and Policy Gradients → Actor-Critic Methods → Temporal Difference Learning → Q-Learning Algorithm → Deep Q-Networks (DQN) → Recurrent Neural Networks → LSTM and Gated Recurrent Units → Gated Recurrent Units (GRU)

Longest path: 107 steps · 776 total prerequisite topics

Prerequisites (2)

Leads To (1)