Deep Sequence Modelling (RNN)
Lesson 1Foundations of deep sequence modeling
Why sequences require a different kind of network
Why sequence modeling? A motivating example
Let's begin with an intuitive motivation. Imagine a ball moving in 2D space. You're asked to predict its next location.
Case 1
You only have access to the ball's current position. Any prediction you make will essentially be a guess the problem is underdetermined.
Case 2
You're also given the ball's prior trajectory and its historical positions. With this sequence of past states, you can now model its motion and reasonably estimate its future position.
This illustrates the crux of sequence modeling: incorporating historical context to improve predictive accuracy.
Sequence data in the real world
While the example above is simple, the relevance of sequence modeling extends across diverse domains:
| Domain | How it shows up as a sequence |
|---|---|
| Speech and Audio | Voice signals can be decomposed into sequences of sound wave chunks over time. |
| Natural Language | Sentences are sequences of words or characters. |
| Finance | Stock prices and market indicators evolve as time-series data. |
| Biology | DNA and protein sequences are naturally sequential. |
In each case, the temporal or positional ordering of data points is essential. Ignoring that order risks discarding key patterns.
Types of sequence modeling problems
Unlike traditional classification tasks where inputs and outputs are fixed-length and often tabular, sequence modeling introduces structured and variable-length data. Let's look at some canonical problem types:
Sequence Classification
Input: A sequence of tokens (e.g., words in a sentence)
Output: A fixed label (e.g., sentiment classification: positive vs negative)
Example: Text classification, intent recognition.
Sequence-to-Sequence (Seq2Seq) Generation
Input: A sequence
Output: Another sequence
Examples
Translation: English → French
Speech Recognition: Audio → Text
Image Captioning: Visual features → Sentence
Many-to-One
Input: A sequence
Output: A single label
Example: Predicting stock trend direction based on previous N time steps.
One-to-Many
Input: A single state
Output: A sequence
Example: Image → Description (caption generation).
Many-to-Many
Input: Sequence A
Output: Sequence B
Example: Video frame → Text transcript; or language translation tasks.
These problem types are foundational to real-world applications of NLP, speech, vision, and decision modeling systems.
Core challenge: capturing temporal dependencies
A feedforward neural network as discussed in the previous lecture assumes that all input features are independent and identically distributed (i.i.d.). This assumption breaks down in sequential settings.
In sequence modeling:
Inputs are ordered.
Future predictions must respect and leverage past observations.
The same model must be applied across time steps or positions.
To handle this, we need architectures that are designed to process sequences, capable of learning representations where current predictions are functions of both present and past information.
See the difference live. A ball moves around a circle. A feedforward predictor that sees only the current point can't tell which way it's headed; a time-aware predictor with hidden state tracks the trajectory:
Why memory matters
A ball traces a circular trajectory. Two predictors try to guess where it goes next. The memoryless FFN sees only the current point — no idea which way the ball is heading. The time-aware RNN carries a hidden state that remembers direction.
Memoryless FFN
Input is just (x_t, y_t). With no temporal context, predictions scatter across the canvas — the model has no way to recover direction.
Time-aware RNN
Input is (x_t, y_t) + hidden state h_t. The hidden state encodes which way the ball is moving — predictions snap to the circle.
This sets the stage for understanding Recurrent Neural Networks (RNNs), Long Short-Term Memory (LSTM) networks, and eventually, Transformers.
Check your understanding
1 / 7What distinguishes sequence data from i.i.d. tabular data?
Practice it yourself
Use history, not just the present — predict from a trajectory, name the task, and slice a series into training pairs. Real Python, hidden tests, no setup.