liveBook · Manning

Gating

As explained in Natural Language Processing in Action, Second Edition

A logic gate in a gated recurrent network is a learned signal-control mechanism that regulates how information passes into or out of the recurrent state.

Gating gives recurrent networks a learned version of an if statement. Instead of letting early tokens fade from memory, gates regulate which signals enter, remain in, or leave the recurrent state. Backpropagation learns the relevant thresholds by adjusting weights and biases, producing signals near 0, 1, or intermediate values. section 8.4.2

Gates are useful because their placement creates deliberate internal memory structure rather than merely adding another activation function.

  • GRUs add reset gates to block hidden-layer information that is no longer relevant and update gates to control what should matter to the current output. section 8.4.2
  • LSTMs use four internal gates: forgetting, input or update, relevance or cell, and output. Their cell state stores longer-term patterns, while the hidden state represents more recently processed tokens. section 8.4.3

Gate calculations

A GRU computes reset and update signals with sigmoid functions from the current input and previous hidden state, then uses the reset signal when forming a candidate state with tanh. An LSTM extends this pattern with forgetting, input, cell, and output calculations before updating its cell and hidden states.

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Works from an if-statement analogy through learned thresholds and gate equations, while omitting full training procedures.
Examples
Uses long-text token memory, GRU gate equations, LSTM state-update equations, and architecture figures as concrete examples.
What it assumes
Assumes recurrent hidden vectors and nonlinear activations, while explaining gate roles and cell-state memory incrementally.
What you can do after
Build GRU and LSTM gate calculations using sigmoid, tanh, learned weights, biases, and recurrent states.
How it connects
Connects gating to recurrent neural networks, GRUs, LSTMs, activation functions, backpropagation, hidden states, and cell states.

Also explained in

Compare how 4 books explain gating →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Natural Language Processing in Action, Second Edition. The section links point to the parts of the book it draws on.