GRU Architecture › The Candidate Hidden State

Michael BrenndoerferMay 14, 20254 min read
Language AI HandbookAll chapters
Part 11 of 67Recurrent Neural Networks
Chapter 80GRU Architecture › The Candidate Hidden State
Reading section 5 of 15 · The Candidate Hidden State · 4 minSection 5 of 15 · 4 min

Book contents

Section 5 of 15 · 4 min read

GRU Architecture › The Candidate Hidden StateOne section · Sections in this chapter5 / 15 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Before the update gate can blend old and new information, we need to compute the proposed "new" information. The candidate hidden state h~t\tilde{h}_t represents what the hidden state would become if we completely ignored the update gate's blending.

This is where the reset gate comes into play. The candidate computation uses the reset-gated version of the previous hidden state, not the raw hidden state:

h~t=tanh⁡(Wh⋅[rt⊙ht−1,xt]+bh)\tilde{h}_t = \tanh(W_h \cdot [r_t \odot h_{t-1}, x_t] + b_h)

where:

  • h~t\tilde{h}_t: the candidate hidden state, a vector of dimension hh with values in [−1,1][-1, 1]
  • rtr_t: the reset gate output from the previous computation
  • rt⊙ht−1r_t \odot h_{t-1}: the reset-gated previous hidden state, where ⊙\odot denotes element-wise multiplication
  • [rt⊙ht−1,xt][r_t \odot h_{t-1}, x_t]: concatenation of the reset-gated hidden state and current input
  • WhW_h: the candidate's weight matrix of shape (h,d+h)(h, d + h)
  • bhb_h: the candidate's bias vector of dimension hh
  • tanh⁡\tanh: hyperbolic tangent activation function, outputting values in [−1,1][-1, 1]

The tanh activation serves two important purposes. First, it bounds the candidate values to a reasonable range [−1,1][-1, 1], preventing any single dimension from growing unboundedly. Second, it centers the values around zero, which helps with gradient flow during training and allows the hidden state to both increase and decrease in value.

The reset gate's role is clearer now. By gating ht−1h_{t-1} before it enters the candidate computation, the reset gate controls how much the previous context influences the new candidate:

  • When rt≈0r_t \approx 0: the term rt⊙ht−1≈0r_t \odot h_{t-1} \approx \mathbf{0}, so the candidate depends primarily on the current input xtx_t
  • When rt≈1r_t \approx 1: the term rt⊙ht−1≈ht−1r_t \odot h_{t-1} \approx h_{t-1}, so the candidate incorporates the full previous context

This gives the GRU two distinct ways to control information flow: the reset gate decides how much past context influences the proposal for the new state, while the update gate decides how much of that proposal to accept.

Out[9]:
Visualization
Flow diagram showing reset gate modulating previous hidden state before candidate computation with tanh.
The candidate hidden state computation incorporates the reset-gated previous state and current input through a tanh activation. The reset gate modulates how much past context influences the candidate before the update gate decides how much of this candidate to actually use.