Read a sequence one item at a time, carrying a hidden state — a running summary — from step to step.
A recurrent neural network reads a sequence one item at a time — word by word, character by character — and carries a hidden state from each step to the next. That hidden state is a *running summary* of everything seen so far, so earlier items can shape later predictions. The loop is what gives the network memory.
There is really just one small cell. At step t it takes the current input x_t and the previous hidden state h_{t-1}, mixes them, and produces the new hidden state h_t. The *same* weights are reused at every step — that's weight sharing, which is why a single cell can handle a sequence of any length.
# one step of a vanilla RNN cell
h_t = tanh(W_x @ x_t + W_h @ h_prev + b) # new running summary
y_t = W_y @ h_t # optional output at this step
# W_x, W_h, W_y, b are shared across ALL time stepsh_t flowing rightward. It now looks like a very deep feed-forward network whose depth equals the sequence length.h_0 = all zeros (no memory yet).x_1 ("the") → compute h_1 from x_1 and h_0.x_2 ("cat") → compute h_2 from x_2 and h_1 — now h_2 reflects *both* words.h_n summarizes the whole sequence, and per-step y_t can be read off as you go.Training uses backpropagation through time: the error signal flows backward through every step. Each step multiplies the gradient by roughly the same factor, so over many steps it shrinks toward zero (or blows up). This is the vanishing gradient problem — the earliest inputs barely get learned, so a plain RNN struggles to connect things that are far apart, like a pronoun to the noun it refers to twenty words earlier.