Home / Natural Language Processing

What is a Recurrent Cell?

A recurrent cell is a neuron with memory: it reads one token at a time and carries a hidden state forward. Step through a sentence and watch the memory change.

Input Sequence

The Update Rule

hₜ = tanh(W·xₜ + U·hₜ₋₁ + b)

xₜ — embedding of the current token

hₜ₋₁ — memory carried from the previous step

W, U, b — the same weights, reused at every step

The Cell

t = 0
RNN Cell tanh(Wx + Uh + b) xₜ (input) hₜ (output) hₜ₋₁ loops back (memory)

Hidden state hₜ — the network's memory (4 dims)

Memory Timeline

tTokenHidden state after step
Memory starts at h₀ = [0, 0, 0, 0]. Feed the first token.

The Recurrent Cell: A Neuron That Remembers

How a single loop turns a stateless network into a sequence processor.

One Loop Changes Everything

A feed-forward layer computes its output from the current input and forgets it immediately. A recurrent cell adds a single wire: its own previous output, hₜ₋₁, feeds back in alongside the new input. That loop gives the network a hidden state — a running summary of everything it has seen so far.

Reading the Update Rule

hₜ = tanh(W·xₜ + U·hₜ₋₁ + b)

  • W·xₜ — what the new token contributes.
  • U·hₜ₋₁ — what the past contributes. This term is the memory.
  • tanh — squashes the result into [-1, 1], keeping the state bounded step after step.
  • Same W, U, b at every step — the cell handles a 5-word or a 500-word sentence with the identical parameters. Variable-length input solved.

Interactive Exploration Guide

  1. Feed the first token. The hidden state jumps from all zeros to its first values — the cell has formed its first memory.
  2. Keep stepping. Each new token blends into the existing state rather than replacing it — compare consecutive rows in the timeline and notice values shifting, not resetting.
  3. Reset, then type two sentences that share a last word (e.g. "dogs chase cats" vs "people love cats"). Step both to the end: the final states differ even though the last token is identical — proof the state carries history, not just the present.

Key Takeaway

The recurrent cell fixes all three ANN limitations at once: it consumes sequences of any length (one token at a time), it respects order (each step builds on the last), and it has memory (the hidden state). Training it, however, requires backpropagating through that loop — the subject of the next module.

Cheat sheet

What is a Recurrent Cell?

A recurrent cell is a neuron with memory: it reads one token at a time and carries a hidden state forward. Step through a sentence and watch the memory change.

NLP · vizlearn.in/natural_language_processing/what_is_a_recurrent_cell.html