LSTM Gate Equations › The Forget Gate
Language AI HandbookAll chapters LSTM Gate Equations › The Forget GateOne section · Sections in this chapter3 / 17 ↓
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
Imagine you're reading a novel and encounter a new chapter. Some details from previous chapters remain important: the protagonist's name, the central conflict, key relationships. Other details have served their purpose and can fade: the color of a minor character's shirt, the exact wording of a throwaway line. Your brain naturally performs this filtering, retaining what matters while letting irrelevant details slip away.
The forget gate gives an LSTM this same capability. At each time step, it examines the current input and the network's recent processing history, then decides, for each piece of stored information, how much to retain. This isn't a binary keep-or-discard decision but a continuous scaling: some memories are preserved almost entirely, others are dimmed, and some are nearly erased.
The forget gate computes a forgetting coefficient for each dimension of the cell state, determining how much of the previous memory to retain at the current time step.
The Core Mechanism
The forget gate needs to make its retention decisions based on context. What should be forgotten depends entirely on what the network is currently seeing and what it has recently processed. To capture this context-dependence, the gate combines two sources of information:
- The current input : What new information is arriving right now?
- The previous hidden state : What was the network's recent output, summarizing its processing up to this point?
These two vectors are transformed through learned weight matrices and combined:
where:
- : the forget gate activation vector, one value per cell state dimension
- : weight matrix that learns which input features signal "time to forget"
- : weight matrix that learns which hidden state patterns signal "time to forget"
- : bias vector that sets the default forgetting behavior
- : the sigmoid activation function
Why Sigmoid?
The sigmoid function is the mathematical heart of gating. It converts any real number into a value between 0 and 1, perfect for representing "how much to keep":
where:
- : the input value (can be any real number)
- : the exponential function, which ensures the output is always positive
- The denominator normalizes the result to fall between 0 and 1
The sigmoid has a characteristic S-shape that makes it ideal for soft decisions. When the pre-activation is large and positive, approaches 0, so , meaning "keep this memory." When is large and negative, becomes very large, so , meaning "forget this." For intermediate values, the sigmoid produces intermediate retention levels, allowing the network to partially dim memories rather than making hard binary choices.

Understanding the Dimensions
Let's trace through the matrix dimensions carefully. Suppose we have an input dimension (e.g., 100-dimensional word embeddings) and hidden dimension .
The input transformation multiplies a matrix by a vector, producing a vector. The hidden state transformation multiplies a matrix by a vector, also producing a vector. These two vectors are added element-wise along with the bias, then sigmoid is applied element-wise to produce the final forget gate vector.
Initialization Matters
The forget gate bias is often initialized to a positive value (commonly 1 or 2) rather than zero. This ensures that early in training, the forget gate outputs values close to 1, meaning the network starts by remembering everything. Without this initialization trick, the network might learn to forget too aggressively before it has learned what information is worth keeping.