Home Knowledge Base The core idea is a hidden state carried forward and updated at every step.

A recurrent neural network is the architecture that assumes its input is a sequence — words, audio samples, sensor readings — and that order and recency matter. It encodes that assumption in the simplest possible way: it walks through the sequence one element at a time, and after each step it updates a single hidden state vector that is meant to summarize everything seen so far. That hidden state is the RNN's memory, and the entire architecture is really just one question asked repeatedly — given what I remember and the next input, what should I remember now? Understanding an RNN means understanding that loop and the reason it eventually gave way to attention.\n\nThe core idea is a hidden state carried forward and updated at every step. At each time step the network takes the current input and the previous hidden state, mixes them through the same shared weights, and produces a new hidden state and optionally an output. Because the weights are reused at every step, an RNN can process a sequence of any length with a fixed number of parameters — the temporal analogue of the CNN's weight sharing across space. When you "unroll" the loop across time it looks like a very deep network, one layer per time step, all tied to the same weights, with information flowing left to right through the hidden state.\n\nTraining happens by backpropagation through time, and that is where the trouble starts. To learn, you unroll the network across the whole sequence and backpropagate the error from the end all the way to the beginning — backpropagation through time. But sending a gradient back through many steps means repeatedly multiplying by the same recurrent weight matrix, and repeated multiplication either shrinks the signal toward zero (vanishing gradients) or blows it up (exploding gradients). Exploding gradients can be clipped, but vanishing gradients are the deeper problem: they mean a plain RNN struggles to connect events that are far apart in the sequence, which is exactly the long-range dependence that language and speech are full of.\n\nGating was the fix, and parallelism was the reason RNNs were ultimately replaced. The LSTM and its lighter cousin the GRU add a gated cell state — a protected memory highway with learned gates that decide what to keep, forget, and expose — so gradients can flow across hundreds of steps without vanishing. Gated RNNs were the workhorse of sequence modeling from the mid-2010s until 2017. Their fatal limitation was not accuracy but speed: because each step depends on the previous one, an RNN cannot be parallelized across the sequence, so it cannot exploit modern hardware the way a transformer can. The transformer threw out recurrence entirely, replaced it with attention over all positions at once, and won on both long-range modeling and training throughput.\n\n| Aspect | Plain RNN | LSTM / GRU | Transformer |\n|---|---|---|---|\n| Memory mechanism | Single hidden state | Gated cell state | Attention over all positions |\n| Long-range dependencies | Weak (vanishing gradient) | Strong (gated highway) | Strong (direct) |\n| Parallel over sequence | No | No | Yes |\n| Era | 1980s-2014 | 2014-2017 | 2017-present |\n\n``svg\n\n \n The RNN: one loop, unrolled through time\n Same weights at every step; a hidden state carries a running summary forward. Its weakness is reaching far back.\n\n \n Unrolled: the hidden state h passes left to right\n \n \n \n \n \n \n \n \n RNNRNNRNNRNN\n \n \n \n \n \n \n h1h2h3\n \n \n \n \n \n "the""cat""sat""down"\n \n \n \n \n \n output per step (optional)\n Weights are shared across all steps -> any sequence length, fixed parameters.\n\n \n \n The weakness: gradients vanish across long gaps\n Backprop through time multiplies by the same matrix over and over — the signal to distant steps fades toward zero.\n \n \n \n \n \n \n \n \n \n recent step (strong gradient)\n distant step (gradient ~ 0)\n \n \n The fix: LSTM / GRU gates\n A gated cell state is a protected memory\n highway that keeps gradients alive far back.\n\n``\n\nThe tempting way to see an RNN is as an outdated model you can safely skip now that transformers have won. But the RNN is worth understanding precisely because it makes the sequential assumption in its purest form — one shared cell, one running memory, marched step by step through time — and because its two defining limits, the vanishing gradient and the inability to parallelize, are exactly what the next two architectures were built to solve. Read an RNN through a carries-a-running-summary-through-time lens rather than a list-of-layers lens, and both the elegance and the eventual obsolescence make sense: gating rescued its memory, and attention rescued its speed, and the RNN's clean statement of the problem is what let you see why each fix was needed.

recurrent neural network lstm gruvanishing gradient rnnlong short term memory gatesgru gated recurrent unitsequence modeling rnn

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.