LSTM Gate Equations › Summary

Michael BrenndoerferUpdated May 11, 20252 min read
Language AI HandbookAll chapters
Part 11 of 67Recurrent Neural Networks
Chapter 78LSTM Gate Equations › Summary
Reading section 16 of 17 · Summary · 2 minSection 16 of 17 · 2 min

Book contents

Section 16 of 17 · 2 min read

LSTM Gate Equations › SummaryOne section · Sections in this chapter16 / 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

This chapter translated the intuition of LSTM gates into precise mathematics and working code. The key equations form a system where three gates control information flow through a memory cell.

The Gate Equations:

  • Forget gate: ft=σ(Wfxt+Ufht−1+bf)\mathbf{f}_t = \sigma(\mathbf{W}_f \mathbf{x}_t + \mathbf{U}_f \mathbf{h}_{t-1} + \mathbf{b}_f) decides what to discard from memory
  • Input gate: it=σ(Wixt+Uiht−1+bi)\mathbf{i}_t = \sigma(\mathbf{W}_i \mathbf{x}_t + \mathbf{U}_i \mathbf{h}_{t-1} + \mathbf{b}_i) decides how much new information to write
  • Candidate: c~t=tanh⁡(Wcxt+Ucht−1+bc)\tilde{\mathbf{c}}_t = \tanh(\mathbf{W}_c \mathbf{x}_t + \mathbf{U}_c \mathbf{h}_{t-1} + \mathbf{b}_c) proposes new values to store
  • Output gate: ot=σ(Woxt+Uoht−1+bo)\mathbf{o}_t = \sigma(\mathbf{W}_o \mathbf{x}_t + \mathbf{U}_o \mathbf{h}_{t-1} + \mathbf{b}_o) decides what to expose as output

The State Updates:

  • Cell state: ct=ft⊙ct−1+it⊙c~t\mathbf{c}_t = \mathbf{f}_t \odot \mathbf{c}_{t-1} + \mathbf{i}_t \odot \tilde{\mathbf{c}}_t combines filtered memory with gated new information
  • Hidden state: ht=ot⊙tanh⁡(ct)\mathbf{h}_t = \mathbf{o}_t \odot \tanh(\mathbf{c}_t) exposes filtered cell state as output

Parameter Count:

An LSTM cell has 4h(d+h+1)4h(d + h + 1) parameters, where dd is the input dimension (e.g., word embedding size), hh is the hidden dimension, and the factor of 4 accounts for the four components (forget gate, input gate, candidate, output gate). This is four times the parameters of a vanilla RNN. This reflects the four separate learnable transformations.

Implementation Insights:

  • Initializing the forget gate bias to 1 improves training by starting with full memory retention
  • Combining weight matrices into single operations improves computational efficiency
  • The cell state can grow unbounded, so applying tanh before the output gate maintains numerical stability

With these equations internalized, you can now trace exactly how information flows through an LSTM, debug unexpected behaviors, and make informed decisions about when to use this architecture. The next chapter examines how these equations enable better gradient flow compared to vanilla RNNs.