๐Ÿ”ฅLimited Offer: Get 50% OFFon AI & Full Stack Courses๐Ÿ”ฅ
Back to Deep Learning Notes
Topic #230

GRU Update Gate

The update gate is GRU's merged replacement for LSTM's separate forget and input gates โ€” it controls, in a single decision, how much of the old hidden state to keep versus how much to replace with new candidate content.

Formula

\[ \mathbf{z}_t = \sigma(\mathbf{W}_z[\mathbf{h}_{t-1}, \mathbf{x}_t] + \mathbf{b}_z) \]

Structurally the same pattern as every gate seen so far โ€” a sigmoid-activated linear layer over the concatenated previous hidden state and current input.

How One Gate Does the Work of Two

Recall LSTM's cell-state update: \(\mathbf{C}_t = \mathbf{f}_t\odot\mathbf{C}_{t-1}+\mathbf{i}_t\odot\tilde{\mathbf{C}}_t\), with \(\mathbf{f}_t\) and \(\mathbf{i}_t\) as two independently learned gates. GRU's hidden-state update (full formula in GRU Equations) instead uses a single \(\mathbf{z}_t\) for both roles simultaneously:

\[ \mathbf{h}_t = (1-\mathbf{z}_t)\odot\mathbf{h}_{t-1} + \mathbf{z}_t \odot \tilde{\mathbf{h}}_t \]

Notice \((1-\mathbf{z}_t)\) and \(\mathbf{z}_t\) are exact complements โ€” if \(\mathbf{z}_t\) is close to 1, almost all of the new candidate is used and almost none of the old state is kept; if \(\mathbf{z}_t\) is close to 0, the old state is almost entirely preserved and almost none of the new candidate gets in. This couples the "how much to forget" and "how much to add" decisions into a single, complementary tradeoff โ€” a genuine simplification (fewer independent parameters) compared to LSTM's fully independent forget and input gates, at the cost of losing LSTM's ability to, say, forget a lot AND add only a little at the same time.

Numerical Example

\(z_t = 0.7\): 70% of the new candidate is used, 30% of the old hidden state is retained. With \(h_{t-1}=0.4\), \(\tilde h_t = -0.2\):

\[ h_t = (1-0.7)(0.4) + (0.7)(-0.2) = (0.3)(0.4)+(0.7)(-0.2) = 0.12-0.14 = -0.02 \]

Code

import torch

h_prev = torch.tensor(0.4)
z_t = torch.tensor(0.7)
h_candidate = torch.tensor(-0.2)

h_t = (1 - z_t) * h_prev + z_t * h_candidate
print(h_t)   # tensor(-0.0200) -- matches the hand-worked example

Common Mistakes

  • Assuming the update gate works identically to LSTM's input gate โ€” LSTM's input gate scales only the new candidate's contribution, independently of the forget gate; GRU's update gate scales both the old and new contributions simultaneously, as complementary fractions that always sum to 1.
  • Forgetting that this coupling is a genuine tradeoff, not a strict improvement โ€” it reduces GRU's parameter count and can simplify training, but it does remove one degree of freedom LSTM has (independently controlling forget and input amounts).

Interview Relevance

Q: "How does GRU's update gate relate to LSTM's forget and input gates?" It merges their roles into a single gate: \(\mathbf{z}_t\) directly determines both how much of the new candidate to incorporate (weighted by \(\mathbf{z}_t\)) and how much of the old hidden state to retain (weighted by the complement, \(1-\mathbf{z}_t\)) โ€” a coupled, complementary tradeoff rather than LSTM's two independently-learned gates.

Practice Question

If the update gate outputs exactly 0 for a specific dimension, what happens to that dimension of the hidden state at this time step?

Want to go beyond the notes?

Join CodingNow 2.0's Deep Learning course โ€” live mentorship, real projects, and 100% placement support.

Enroll Now โ€” Free Demo Available

GRU Update Gate โ€“ FAQs

Quick answers about learning GRU Update Gate in Deep Learning.

This free note from CodingNow 2.0 explains GRU Update Gate in Deep Learning โ€” concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Deep Learning topic on CodingNow 2.0, including GRU Update Gate, is 100% free with no signup required.
With focused practice, most students grasp GRU Update Gate in 1โ€“3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) โ€” expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now