AI Glossary / Deep learning / Advanced
Recurrent neural network
Definition
A recurrent neural network, or RNN, is a neural-network architecture that processes sequential information using a state updated through repeated computations. Each update combines a current input with information carried from earlier steps. This allows outputs to depend on sequence context rather than only on isolated observations. Simple recurrent networks, LSTMs, and GRUs belong to this broad family.
What it means
Order can change meaning. A learner opening a lesson, attempting an exercise, and requesting help presents a different sequence from the same events in reverse. An RNN can represent that difference by updating its internal state as events arrive.
The state is a learned numerical representation. It is neither a complete database of prior events nor proof that the system understands them as a person would. An RNN is also distinct from a recursive neural network, which commonly combines representations according to a hierarchical structure such as a tree.
How it works
An input is encoded as numbers and combined with the previous hidden state. In a simple RNN, learned input and recurrent weights, a bias, and a nonlinear activation produce the next state. An output transformation converts that state into a prediction. The same parameters are reused across steps, so processing a longer sequence need not add parameters, although it adds computation.
A model may produce one result for a complete sequence, a result at every position, or a generated sequence. Training compares predictions with targets and typically propagates errors through the unfolded sequence of computations. Gradients can shrink or grow over many steps; gated architectures and other training choices help address these difficulties without guaranteeing perfect memory.
A forward-only model uses preceding context. Bidirectional processing also uses later context and therefore requires care when predictions must be made before future inputs exist.
Three practical examples
- A support platform classifies an incoming message from its word sequence. The model produces a category after processing the message, with performance checked on representative writing styles.
- A maintenance team models sequences of sensor readings to forecast a future measurement. Training and evaluation respect time order and exclude readings that would not yet exist at prediction time.
- A learning application proposes the next activity from a session's event history. Recommendations are evaluated for usefulness, rather than assuming that accurate next-click prediction establishes educational benefit.
Think of it this way
An RNN resembles a running briefing that is revised after each new event. The next briefing depends on both the new information and the previous briefing. This creates continuity, but an incomplete or poorly updated briefing can lose crucial context. The comparison illustrates the information flow, not human memory or reasoning.
Worked example
Consider a hand-built teaching RNN with a single state and update h(t) = ReLU(0.5 times h(t−1) + x(t)), starting at zero. Let each input indicate whether a fictional service reported an error during that interval: one for an error and zero otherwise. Define an illustrative alert score as sigmoid(h(t) minus 1).
For inputs [1, 0, 1], the states are 1, 0.5, and 1.25. The final score is sigmoid(0.25), approximately 0.562. For [1, 1, 0], the states are 1, 1.5, and 0.75, giving sigmoid(minus 0.25), approximately 0.438.
Both histories contain two errors, but their different order produces different scores. With a teaching threshold of 0.5, the first history triggers an alert and the second does not. These chosen weights and threshold demonstrate a mechanism; they do not establish sensible monitoring policy or calibrated failure probabilities. A real model would require training, representative testing, and an operationally justified decision rule.
Illustrative case study
Fictional Elm Academy compares an RNN with a baseline that uses only total session activity. The recurrent model appears more accurate at predicting a help request. During review, the team finds that its histories include events recorded after the request itself.
The team rebuilds each history using only events available at the decision time and repeats the comparison on later sessions. It also separates prediction quality from the effect of offering help. An intervention trial would answer that second question. This invented case shows why a sophisticated sequence model still needs a clearly defined information boundary.
Common misconceptions and mistakes
Recurrence does not guarantee that a network retains every earlier detail. More timesteps do not necessarily mean more learned parameters. An RNN is not simply a loop that repeatedly runs an unchanged independent prediction: its state connects successive computations.
Shuffling events within a sequence can destroy the intended signal. Accidentally carrying a state from one person to another mixes unrelated histories. Padding must be handled deliberately, and repeated users or overlapping windows can create misleading train-test splits. Finally, predicting a future event does not establish that a recommended action will prevent or cause that event.
Business use
RNNs can be useful when sequence order and context matter, including operational forecasting, language processing, and event-history analysis. The relevant question is whether a recurrent model improves the actual task enough to justify its complexity and operating cost.
Document sequence boundaries, input availability, prediction horizon, and state management. Compare against suitable simpler baselines and evaluate performance on realistic future or otherwise independent data. Include latency and failure handling in the assessment, since a model that performs well offline may still be unsuitable for a time-sensitive workflow.
People also ask
Is every RNN an LSTM?
No. LSTM is a particular gated recurrent architecture.
Can an RNN generate text?
Yes, by predicting and feeding successive tokens through a generation process, although architecture alone does not guarantee quality.
Does the hidden state change the learned weights during ordinary inference?
No. Updating state is different from updating model parameters through training.
Check your understanding
Why do equal error counts yield different example scores?
Answer: The recurrent state depends on event order, with older inputs reduced by the chosen recurrent weight.
What is wrong with using post-request events to predict a help request?
Answer: Those inputs would be unavailable when the prediction is needed.
Does successful prediction demonstrate that an intervention works?
Answer: No. That requires evidence about the intervention's effect.
Related terms
- Recurrent Layer
- Vanishing gradient
- Recursive Neural Network
- hidden state
- sequence modeling
- LSTM
- GRU
- backpropagation through time
- bidirectional network
Learn next
Compare the example with a model that uses only the total error count. Identify the information that total loses. Then examine how LSTM gates alter state updates and design an evaluation that preserves the intended prediction time.
More in Deep learning
- Random neural network - The random neural network is Erol Gelenbe's stochastic neural model in which units hold non-negative integer potentials and exchange excitatory or...
- Reactive layer - A reactive layer is the part of a robot or agent architecture that produces timely responses to current observations through relatively direct...
- Receptron - A receptron is a proposed nonlinear threshold computing unit that generalizes the perceptron by allowing effective input weights to depend on the input...
- Region Based Convolutional Neural Networks - Region-based convolutional neural networks are object-detection approaches that analyze candidate image regions using convolutional features to identify...
- Relation network - A relation network is a neural-network module designed to learn from relationships between pairs of represented objects.
- Reservoir computing - Reservoir computing is an approach to processing time-dependent information in which an input drives a dynamical system, called a reservoir, and a readout...
Sources
Dive into Deep Learning, recurrent neural networks, hidden-state updates, and parameter sharing: https://d2l.ai/chapter_recurrent-neural-networks/rnn.html TensorFlow, Working with RNNs, model configurations and state management: https://www.tensorflow.org/guide/keras/working_with_rnns
Previous: Recurrent Layer Next: Recurrent state space model