In a recurrent neural network, what is a "gate", and how does a number between 0 and 1 act like a tap that controls how much information passes through?

Sequence models and transformers, Recurrent networks
Level L1 Beginner. Length Short. Nature Th Theoretical.

What's being asked

Whether you understand a gate as a learned multiplier between 0 and 1, the basic idea behind LSTMs and GRUs.

Key idea

A gate is a number between 0 (closed) and 1 (fully open) that is multiplied with some information to decide how much of it passes. The network computes the gate from its inputs and learns when to open or close it.

Steps

  1. Think of a water tap. Fully closed lets nothing through, fully open lets everything through, and half open lets half through. A gate is such a tap for information.
  2. How the number is made: the network computes a score and passes it through the sigmoid function, which squashes any number into the range 0 to 1. Because the score depends on the current input, the gate can open or close depending on the situation.
  3. Tiny calculation: the memory holds the value 0.8 and the gate is 0.5. The amount passed is 0.8×0.5=0.4. A gate of 0 gives 0 (forget it), and a gate of 1 gives 0.8 (keep it all).
  4. Why it helps: a plain recurrent network rewrites its memory at every step. Gates let it keep something important for a long time, or ignore a useless word.
  5. LSTM and GRU are the two well-known gated networks. How they differ is the next question, `gru-gates-vs-lstm-overview`.

Common mistakes

How long your answer should be

Under 2 minutes, 4–6 sentences.

Read this

Previous in Sequence models and transformers: What is a recurrent neural network, and how does its hidden state act as a memory of the sequence so far? What is meant by 'unrolling' the network through time?
Next in Sequence models and transformers: When we train a model to write a sentence one word at a time, what does it mean to feed it the correct previous words during training, and why might that cause trouble later?