Phase 6 ยท Deep Learning Algorithm 23 / 30

Recurrent Neural Network

Networks that remember โ€” built for sequences

RNN hand-drawn sketchnote infographic

๐Ÿง  Core Concept

An RNN is a neural network with a loop. At each step it reads one element of a sequence and blends it with a hidden state โ€” a running memory of everything seen so far. That memory is what lets it model order and context, so word 5 can depend on word 1.

๐Ÿงฉ Key Components

๐Ÿ’พ

Hidden State

A vector carried forward each step โ€” the network's short-term memory of the sequence so far.

โฉ

Unrolling Through Time

The single looped cell is "unfolded" into a chain, one copy per time step, sharing the same weights.

๐Ÿ”

BPTT

Backpropagation Through Time: gradients flow backward across every unrolled step to update weights.

๐Ÿ“‰

Vanishing Gradients

Repeated multiplication shrinks (or blows up) gradients over long sequences, erasing long-range memory.

โš™๏ธ How It Works

1

Start with an initial hidden state hโ‚€ (usually zeros).

2

At each step t, combine the new input xโ‚œ with the previous memory hโ‚œโ‚‹โ‚ and squash through an activation.

3

The result becomes the new hidden state hโ‚œ โ€” and can produce an output yโ‚œ.

4

Repeat down the whole sequence, then train with BPTT to nudge the shared weights.

hโ‚œ = f( Wₓ ยท xโ‚œ  +  Wₕ ยท hโ‚œโ‚‹โ‚  +  b )

๐ŸŒ Real-World Applications

๐Ÿ“ Text & language modeling ๐Ÿ“ˆ Time-series forecasting ๐ŸŽ™๏ธ Speech recognition ๐ŸŽต Music generation ๐ŸŒก๏ธ Sensor / IoT sequences

โœ… Checkpoint Questions

Q1. Why do we need recurrence for sequential data โ€” what does a plain feed-forward network fail to capture?
Q2. What exactly is the hidden state, and how does it carry information across time steps?
Q3. What causes the vanishing/exploding gradient problem in RNNs, and why does it hurt long-range dependencies?