PCCMT503 · MOD 3 Recurrent Neural Networks (RNN)
0 / 9 Mastered

Module 3 — Recurrent Neural Networks (RNN)

Official Syllabus (PCCMT503): Model of a typical RNN, Computation Graph, Bidirectional RNNs, Encoder–decoder sequence to sequence architectures, BPTT for training RNN, Deep Recurrent Networks, Recursive Recurrent Networks, Long Short Term Memory Networks (LSTM), Gated Recurrent Networks (GRU).

Merged Sources: DEEP LEARNING CONCEPTS MODULE 3.pdf, M 3.1.pdf (82 slides), M 3.2.pdf (52 slides), M 3.pdf (76p CETKR notes).

Filter:

3.1 Model of a Typical Recurrent Neural Network (RNN)

🔥 HIGH YIELD 3M · 6M · 9M Sources: MODULE 3.pdf, M 3.1.pdf, M 3.pdf
Simple Intuition (ELI5) An MLP reads a book with amnesia — it forgets word 1 as soon as it looks at word 2! An RNN keeps a sticky-note memory scratchpad (ht) as it reads word-by-word: at every word, it reads the new word (x(t)), glances at its previous sticky-note (h(t−1)), updates the note, and uses the exact same reading rules (shared weights U, W, V) across every sentence length!

1. Why Standard Feedforward MLPs Fail on Sequences

  • Traditional MLPs require fixed-size input vectors and assume every input example is independent.
  • Sequential data (sentences, audio, stock prices, ECG, video) has variable length, order sensitivity ("Dog bites man" ≠ "Man bites dog"), and contextual dependence ("I grew up in India, so I speak ______").

2. Mathematical Equations of a Typical RNN

Given input sequence (x(1), x(2), …, x(τ)) and initial hidden state h(0) (typically zeros):

1. Pre-activation:   a(t) = b + W h(t−1) + U x(t)
2. Hidden State Update:   h(t) = tanh(a(t)) = tanh(b + W h(t−1) + U x(t))
3. Output Logits:   o(t) = c + V h(t)
4. Predicted Probability:   ŷ(t) = softmax(o(t))
5. Sequence Loss (Negative Log-Likelihood):   L = ∑t=1..τ L(t) = −∑t=1..τ log ŷ(t)y(t)
  • Shared Parameters Across Time: U (input → hidden), W (hidden → hidden), V (hidden → output), and biases b, c are identical at every time step t, giving huge generalization across variable lengths.
Exam Practice Numerical 3.1A: 2-Step Scalar RNN Forward Pass

Given: Initial state h(0) = 0, weights U = 0.8, W = 0.5, V = 1.2, b = 0, c = 0, activation tanh, inputs x(1) = 1.0, x(2) = 0.5.

  1. Step t = 1: a(1) = 0.5(0) + 0.8(1.0) = 0.8 ⇒ h(1) = tanh(0.8) = 0.664,  o(1) = 1.2(0.664) = 0.797.
  2. Step t = 2: a(2) = 0.5(0.664) + 0.8(0.5) = 0.332 + 0.40 = 0.732 ⇒ h(2) = tanh(0.732) = 0.624,  o(2) = 1.2(0.624) = 0.749.

3.2 Computation Graph & Unfolding Design Patterns

🔥 HIGH YIELD 3M · 6M · 9M Sources: M 3.1.pdf, M 3.pdf

1. Unfolding a Cyclic Computation Graph

  • A computation graph represents variables as nodes and operations as directed edges.
  • A classical dynamical system s(t) = f(s(t−1); θ) can be unrolled for τ=3 steps as s(3) = f(f(s(1); θ); θ).
  • For an RNN: h(t) = g(t)(x(t), …, x(1)) = f(h(t−1), x(t); θ). Unfolding (Unrolling) expands the compact cyclic graph (with a 1-step delay block ■) into a deep acyclic chain over time t = 1 … τ sharing the same parameters (U, W, V)!
A. FOLDED (Cyclic + Delay ■) x h o U V W B. UNFOLDED COMPUTATION GRAPH (t = 1, 2, …, τ) · Runtime O(τ) x⁽¹⁾ h⁽¹⁾ o⁽¹⁾ L⁽¹⁾ U V W x⁽²⁾ h⁽²⁾ o⁽²⁾ L⁽²⁾ U V W x⁽ᵗ⁾ h⁽ᵗ⁾ o⁽ᵗ⁾ L⁽ᵗ⁾ U V
Figure 3.1: Folded Cyclic RNN (Left) and Unfolded Time-Step Computation Graph (Right)

2. Core RNN Architectural Patterns (Goodfellow / M 3.1.pdf)

PatternRecurrent FlowExample Application
1. Hidden-to-Hidden (Seq → Seq aligned)h(t−1) → h(t), outputs o(t), L(t) at every stepPOS Tagging, frame-by-frame video labeling
2. Output-to-Hidden RecurrenceRecurrent loop only from o(t−1) → h(t) (weaker, allows parallel Teacher Forcing)Sequence generation with decoupled time steps
3. Sequence → Single Output (Many-to-One)Processes full sequence, outputs single prediction at τSentiment Analysis, Spam Classification
4. One-to-ManySingle fixed input generates sequence y(1)…(τ)Image Captioning ("A dog is running")

3.3 Backpropagation Through Time (BPTT) & Gradient Problems

🔥 VERY HIGH YIELD 6M · 9M Sources: MODULE 3.pdf, M 3.1.pdf

1. What is BPTT & 5-Step Execution

BPTT trains an RNN by applying standard backpropagation to the unrolled computation graph from the final time step t = τ backwards to t = 1, summing parameter gradients across all time steps:

  1. Feed sequence (x(1)…x(τ)) into the unrolled network.
  2. Forward Pass: Compute hidden states h(1)…h(τ) and predictions ŷ(1)…ŷ(τ) (must store all states in memory → O(τ) memory!).
  3. Loss Computation: Compute per-step losses L(t) and total loss L = ∑t=1..τ L(t).
  4. Backward Pass: Propagate error derivatives backwards in time via Chain Rule through repeated recurrent Jacobians ∏ (∂hj/∂hj−1).
  5. Shared Weight Update: Sum gradients across every time step because W, U, V are shared:
    ∂L∂W = ∑t=1..τ ∂L(t)∂W,     Wnew = Wold − η ∂L∂W

2. Vanishing vs. Exploding Gradients in BPTT

1. Vanishing Gradient Problem Repeated multiplication by recurrent weights & tanh′ ≤ 1 shrinks distant gradients exponentially toward zero (e.g., 0.5ⁿ → 0).
Consequence: Early time steps get near-zero updates → vanilla RNN forgets long-range context (e.g., "I grew up in France... I speak fluent French").
Solution: Use gated architectures — LSTM / GRU!
2. Exploding Gradient Problem When largest eigenvalue |λ(W)| > 1, repeated matrix powers blow gradients up exponentially toward ∞ / NaN.
Solution: Gradient Clipping (if ‖g‖ > threshold, rescale g ← (threshold/‖g‖) g), or Truncated BPTT (cap backprop window length k).

3.4 Bidirectional RNNs (BiRNN)

🔥 HIGH YIELD 3M · 6M Sources: MODULE 3.pdf, M 3.1.pdf
Simple Intuition (ELI5): Why Past Context Alone Fails Read: "The bank..." — is it a money bank or a river bank? You can't know until you read the END of the sentence: "...is near the river!" A BiRNN reads the sentence forward AND backward simultaneously so every word sees both left & right neighbors.
  • Two Independent Hidden Chains:
    Forward Pass (t = 1 → T):   h(t) = f(x(t), h(t−1))   (past/left context)
    Backward Pass (t = T → 1):   g(t) = f(x(t), g(t+1))   (future/right context)
    Combined Output:   hbi(t) = [h(t) ; g(t)],    o(t) = Wo hbi(t) + bo,    ŷ(t) = softmax(o(t))
  • Applications: Named Entity Recognition (NER), POS Tagging, Sentiment Analysis, Speech Recognition, Handwriting Recognition, Bioinformatics.
  • Key Limitation: Requires the entire sequence upfront before making predictions → unsuitable for real-time / online streaming.
BIDIRECTIONAL RNN (Forward h⁽ᵗ⁾ → + Backward g⁽ᵗ⁾ ← → Concatenated Output ŷ⁽ᵗ⁾) x₁ h⁽¹⁾→ ←g⁽¹⁾ ŷ₁ x₂ h⁽²⁾→ ←g⁽²⁾ ŷ₂ x₃ h⁽³⁾→ ←g⁽³⁾ ŷ₃
Figure 3.2: Bidirectional RNN Computing Output ŷ⁽ᵗ⁾ from Combined Past h⁽ᵗ⁾ & Future g⁽ᵗ⁾ States

3.5 Encoder–Decoder Sequence-to-Sequence (Seq2Seq) Architecture

🔥 HIGH YIELD 6M · 9M Sources: MODULE 3.pdf, M 3.1.pdf

Motivation: Maps an input sequence X = (x(1)…x(nₓ)) to an output sequence Y = (y(1)…y(nᵧ)) where lengths differ (nₓ ≠ nᵧ), e.g., translating "I love AI" (3 words) → French "J'aime l'IA", or 5-word English → variable Spanish.

  1. Encoder RNN / LSTM / GRU: Reads input tokens step-by-step (ht = f(W(hh)ht−1 + W(hx)xt)) and discards intermediate outputs.
  2. Context / Thought Vector (C): Final encoder hidden state C = h(nₓ) summarizing the entire meaning of the input sentence; passed to initialize the decoder.
  3. Decoder RNN / LSTM / GRU: Starts from <SOS> (Start of Sequence) and context C, autoregressively generating y(1), y(2), … until outputting <EOS>:
    s(t) = f(y(t−1), s(t−1), C),    P(Y | X) = ∏t=1..nᵧ P(y(t) | y(1),…,y(t−1), X)
ENCODER – DECODER SEQ2SEQ (nx ≠ ny): “I love AI” → “J'aime l'IA” Enc h₁ Enc h₂ Enc h₃ “I” “love” “AI” Context C (Bottleneck) Dec s₁ Dec s₂ Dec s₃ “J'aime” “l'IA” <EOS> <SOS> y₁ (“J'aime”) y₂ (“l'IA”)
Figure 3.3: Encoder–Decoder Seq2Seq Architecture with Fixed Context Vector C

Major Bottleneck & Attention Fix: Compressing long paragraphs into one fixed-size vector C causes information loss. The Attention mechanism removes this bottleneck by allowing the decoder to inspect all encoder hidden states dynamically at every decoding step.

Applications: Machine Translation, Text Summarization, Speech Recognition, Question Answering, Chatbots, Image Captioning.

3.6 Deep Recurrent Networks (Deep RNNs)

⭐ MEDIUM-HIGH YIELD 3M · 6M Sources: MODULE 3.pdf, M 3.1.pdf

A vanilla RNN applies only shallow single-matrix mappings between x → h, ht−1 → ht, and h → y. Deep RNNs introduce hierarchy using three depth strategies (Goodfellow / M 3.1.pdf Slide 63):

  1. Stacked Recurrent Hidden Layers: Stack multiple recurrent layers vertically so each layer l passes hidden states upward AND forward in time:
    ht(l) = f(W(l) ht(l−1) + U(l) ht−1(l) + b(l))
    Lower layers extract basic local word/audio patterns; higher layers represent abstract phrases & sentence meaning (e.g., "The students are studying deep learning").
  2. Deep Transitions (MLPs Inside Each Step): Insert additional non-recurrent MLP hidden layers inside x → h, h → h, or h → y transformations.
  3. Deep Hidden-to-Hidden Transition + Skip Connections: When h → h becomes deep, gradients struggle to travel across many time steps. Adding a skip connection from h(t−1) directly around the intermediate layers shortens the shortest gradient path and eases optimization.

Trade-offs: Captures complex multi-scale sequential abstractions, at the expense of higher parameter count, slower compute, and harder optimization without skip connections.

3.7 Recursive Recurrent / Recursive Neural Networks (RvNN)

🔥 HIGH YIELD 3M · 6M · 9M Sources: MODULE 3.pdf, M 3.1.pdf, M 3.pdf

Definition: A Recursive Neural Network generalizes an RNN from a flat 1D temporal chain to a hierarchical tree (DAG) structure, repeatedly applying the same neural composition weights bottom-up from leaf nodes (words/patches) → phrases → root (sentence/scene meaning).

Parent Composition:   hparent = p = f( W
hleft
hright
+ b )   (where f = tanh or σ)
Node Merge Score:   S = Wscore · p
  • Tree Structures Used: Balanced binary tree, external NLP syntax parse tree, or dynamically learned parse structure.
  • Crucial Computational Advantage: For a sequence of length T, a balanced binary Recursive NN reduces the maximum dependency path depth from O(T) (chain RNN) down to O(log T) (e.g., 8 → 4 → 2 → 1 = depth 3!), dramatically easing long-range optimization.
A. DEEP STACKED RNN (Chain Depth O(T)) x₁ x₂ x₃ h₁⁽¹⁾ h₂⁽¹⁾ h₃⁽¹⁾ h₁⁽²⁾ h₂⁽²⁾ h₃⁽²⁾ B. RECURSIVE TREE NN (Tree Depth O(log T)) w₁ w₂ w₃ w₄ p₁ p₂ Root Shared (W, b)
Figure 3.4: Deep Stacked RNN (Left) vs. Recursive Tree NN Reducing Path Length from O(T) to O(log T) (Right)

Three-Way Comparison: RNN vs. Recursive NN vs. Encoder–Decoder

ModelTopologyComplexity / DepthPrimary Use
Standard RNNLinear time chainO(T) stepsFrame/token labeling, time series
Recursive NNHierarchical parse treeO(log T) depthSyntax parsing, compositional sentiment, scene trees
Encoder–DecoderChained Encoder + Decoder RNNsTwo O(T) stages via Context CSeq2Seq variable length (Translation, Summarization)

3.8 Long Short-Term Memory Networks (LSTM) + Gate Numericals

🔥 #1 PART B QUESTION 🧮 FORGET-GATE VECTOR + 1-STEP NUMERICALS 6M · 9M Sources: MODULE 3.pdf, M 3.2.pdf
Simple Intuition (ELI5): The Notebook Conveyor Belt A Vanilla RNN rewrites its entire notebook completely at every word, quickly erasing old clues. An LSTM instead runs an unbroken horizontal conveyor belt (Ct — Long-Term Memory) across the top of the cell, guarded by three smart bouncers (Forget: erase outdated info; Input: write important new info; Output: reveal relevant facts into ht).

1. LSTM Equations (Hochreiter & Schmidhuber, 1997)

1. Forget Gate (what to discard from Ct−1):   ft = σ(Wf · [ht−1, xt] + bf)
2. Input Gate (which values to update):   it = σ(Wi · [ht−1, xt] + bi)
3. Candidate / Input Modulation Gate:   C̃t = g = tanh(WC · [ht−1, xt] + bC)
4. Cell State Update (Additive Highway):   Ct = ft ⊙ Ct−1 + it ⊙ C̃t
5. Output Gate & Hidden State:   ot = σ(Wo · [ht−1, xt] + bo),    ht = ot ⊙ tanh(Ct)

Why LSTM Solves the Vanishing Gradient Problem: Because the cell state updates additively (Ct = ft⊙Ct−1 + …) rather than passing through repeated nonlinear weight matrix multiplications, error gradients travel directly backwards along the conveyor belt (∂Ct/∂Ct−1 ≈ ft), preserving long-term dependencies when ft ≈ 1!

LSTM CELL ARCHITECTURE (3 Gates fₜ, iₜ, oₜ + Linear Cell Conveyor Belt Cₜ) Cₜ₋₁ Cₜ × + σ (fₜ) σ (iₜ) tanh C̃ₜ σ (oₜ) × tanh × hₜ₋₁ xₜ hₜ
Figure 3.5: LSTM Cell Architecture Showing Forget (fₜ), Input (iₜ, C̃ₜ), and Output (oₜ) Gates
Exam Sketch Tip: Draw the top horizontal line (Cₜ₋₁ → × → + → Cₜ) FIRST, then add 4 side-by-side gate boxes [σ, σ, tanh, σ] along the bottom bus!
Worked Numericals: Source Vector Example (M 3.2.pdf p. 25) + 1-Step LSTM Exam Problem

1. Element-Wise Forget-Gate Vector Control (M 3.2.pdf): Given Ct−1 = [2, 5, 3]T and forget gate ft = [1, 0, 0.5]T:
ft ⊙ Ct−1 = [1×2, 0×5, 0.5×3]T = [2, 0, 1.5]T (keeps 100% of feature 1, erases feature 2, halves feature 3!).

2. Exam Practice Numerical (1-Step Scalar LSTM): Given xt=1, ht−1=0.5, Ct−1=1.0, weights (all gates) wx=0.5, wh=0.5, b=0:
• Weighted sum = 0.5(0.5) + 0.5(1) = 0.75 ⇒ ft = it = ot = σ(0.75) = 0.679; C̃t = tanh(0.75) = 0.635.
• Ct = (0.679)(1.0) + (0.679)(0.635) = 0.679 + 0.431 = 1.110.
• ht = 0.679 × tanh(1.110) = 0.679 × 0.804 = 0.546.

3.9 Gated Recurrent Units / Networks (GRU) & LSTM vs. GRU

🔥 HIGH YIELD 3M · 6M · 9M Sources: MODULE 3.pdf, M 3.2.pdf, M 3.pdf

Design Goal: A streamlined, faster alternative to LSTM that retains long-term memory with fewer parameters: eliminates the separate cell state Ct (keeps only ht) and merges Forget + Input gates into just 2 gates:

1. Reset Gate (controls how much past state to forget):   rt = σ(Wr [ht−1, xt] + br)
2. Update Gate (acts as coupled forget + input gate):   zt = σ(Wz [ht−1, xt] + bz)
3. Candidate Hidden State:   h̃t = tanh(Wh [rt ⊙ ht−1, xt] + bh)
4. Final Hidden State Update:   ht = (1 − zt) ⊙ ht−1 + zt ⊙ h̃t
Notation Alert Across Uploaded Notes (M 3.2/MOD 3 vs M 3 p. 75) M 3.2.pdf & MODULE 3.pdf write ht = (1 − zt) ⊙ ht−1 + zt ⊙ h̃t (zt = write weight), whereas M 3.pdf p. 75 writes ht = zt ⊙ ht−1 + (1 − zt) ⊙ h̃t (zt = keep weight). Both are convex interpolations and mathematically equivalent — just label which gate fraction keeps vs updates!
GRU CELL (2 Gates rₜ, zₜ · Single State hₜ) hₜ₋₁ hₜ × + σ (rₜ) σ (zₜ) tanh h̃ₜ 1 − zₜ × xₜ
Figure 3.6: GRU Cell Diagram Showing Reset (rₜ) & Coupled Update (zₜ / 1−zₜ) Gates

Vanilla RNN vs. LSTM vs. GRU Comparison Table

FeatureVanilla RNNLSTMGRU
Memory States1 (ht)2 (Ct + ht)1 (ht only)
GatesNone3 (Forget, Input, Output)2 (Reset, Update)
Parameters / SpeedFewest / FastestMost (~4× RNN) / Slowest~3/4 of LSTM / Faster
Long-Term MemoryFails (Vanishing Gradient)Excellent on very long sequencesVery good; resists overfitting on smaller data
Exam Practice Numerical 3.9A: 1-Step Scalar GRU Calculation

Given: xt = 1.0, ht−1 = 0.5, zero biases; gate weights wr=0.5, ur=0.5, wz=0.5, uz=0.5, wh=0.8, uh=0.6.

  1. Reset & Update Gates: rt = zt = σ(0.5(1.0) + 0.5(0.5)) = σ(0.75) = 0.679.
  2. Candidate State: h̃t = tanh(0.8(1.0) + 0.6(0.679 × 0.5)) = tanh(0.8 + 0.2037) = tanh(1.0037) = 0.763.
  3. Final State: ht = (1 − 0.679)(0.5) + 0.679(0.763) = 0.1605 + 0.5181 = 0.679.

Module 3 Revision (A–D): Checklist, Definitions & Diagrams

A. Official Syllabus Coverage Checklist

  • ✅ Model of a Typical RNN (equations, shared parameters U/W/V, NLL loss, advantages/limitations)
  • ✅ Computation Graph (folded/unfolded dynamical system, 3 design patterns, O(τ) complexity)
  • ✅ Bidirectional RNNs (forward + backward states, concatenation, NER/POS/river bank example, offline limit)
  • ✅ Encoder–Decoder Seq2Seq (nₓ ≠ nᵧ, context vector C, <SOS>/<EOS>, bottleneck & Attention fix)
  • ✅ BPTT (5 steps, summed weight gradient, Vanishing & Exploding Gradients + Clipping)
  • ✅ Deep Recurrent Networks (3 depth approaches: stacked layers, deep MLP transitions, skip connections)
  • ✅ Recursive Neural Networks (tree structure, parent compose + merge score, O(log T) path reduction)
  • ✅ LSTM (3 gates + candidate g, additive cell state, worked forget-gate vector + scalar step)
  • ✅ GRU (2 gates, single state, sign convention note, LSTM vs GRU comparison)

B. Must-Know 3-Mark Definitions

Unfolding (Unrolling)

Expanding a cyclic recurrent computation graph over time steps t=1…τ into a deep acyclic chain whose layers share identical weights (U, W, V).

BPTT

Backpropagation Through Time applies gradient descent to the unrolled RNN graph from step τ back to 1, summing parameter gradients across all steps.

Context Vector Bottleneck

Encoding a long input sentence into a single fixed-length vector C = h(nₓ) drops early details; Attention fixes this by reading all encoder states.

Teacher Forcing

Feeding true ground-truth outputs y(t−1) (rather than model predictions) into output-to-hidden or decoder RNNs during training for speed and stability.

Module 3 Revision (E): Master Formula & Equation Sheet

1. Typical RNN: h(t) = tanh(b + W h(t−1) + U x(t)),    o(t) = c + V h(t),    ŷ(t) = softmax(o(t))
2. BPTT Gradient: ∂L/∂W = ∑t=1..τ ∂L(t)/∂W
3. BiRNN: hbi(t) = [h(t) ; g(t)],    o(t) = Wo hbi(t) + bo
4. Recursive NN: p = f(W [hleft; hright] + b),    S = Wscore p    (Tree depth: O(log T))
5. LSTM: ft = σ(Wf[ht−1,xt]+bf),   it = σ(…),   C̃t = tanh(…),   Ct = ft⊙Ct−1 + it⊙C̃t,   ot = σ(…),   ht = ot⊙tanh(Ct)
6. GRU: rt = σ(…),   zt = σ(…),   h̃t = tanh(Wh[rt⊙ht−1, xt]+bh),   ht = (1−zt)⊙ht−1 + zt⊙h̃t

Module 3 Revision (F): 3M / 6M / 9M Question Bank (With Answers)

Q1 [3M]: Distinguish between Vanishing and Exploding gradients in BPTT and state their remedies.3 Marks
Show Answer

Vanishing: Gradients decay exponentially (0.5ⁿ → 0) via repeated multiplication of small Jacobians/weights so early tokens aren't learned; fixed by LSTM / GRU. Exploding: Gradients blow up when eigenvalues exceed 1 causing NaNs; fixed by Gradient Clipping and Truncated BPTT.

Q2 [6M]: Differentiate Deep RNNs vs. Recursive Neural Networks, explaining how Recursive NNs cut path depth to O(log T).6 Marks
Show Answer

Explain 3 Deep RNN strategies (Stacked layers, Deep MLP transitions, Skip connections) vs Recursive Tree composition p = f(W[hleft; hright]+b), draw Figure 3.4, show 8→4→2→1 balanced tree reducing depth from O(T) to O(log T), and add the 3-way comparison table.

Q3 [9M]: Draw the internal cell diagram of an LSTM, write all 6 governing equations, and explain how it overcomes vanishing gradients (vs GRU).9 Marks
Show Answer

Sketch Figure 3.5 cleanly, define Cell State Ct, Hidden State ht, and all 3 gates + candidate C̃t with exact matrix formulas, explain additive gradient highway Ct = ft⊙Ct−1 + it⊙C̃t (1.5M), compute the forget-gate numerical [2,5,3]ᵀ ⊙ [1,0,0.5]ᵀ = [2,0,1.5]ᵀ, and compare LSTM vs GRU (2M).

Module 3 Revision (G): 10-Minute Last-Minute Cheat Sheet

  • RNN Shared Params: U (input), W (recurrent hidden), V (output). Cost: O(τ) sequential time & memory.
  • BiRNN: Past h(t) + Future g(t) concatenated → offline only!
  • Seq2Seq: Handles nₓ ≠ nᵧ via Encoder → fixed Context C → Decoder (<SOS>..<EOS>); bottleneck motivates Attention.
  • LSTM (F-I-O): 3 gates, 2 states (Ct, ht). Linear belt Ct stops vanishing gradients.
  • GRU (R-U): 2 gates (Reset rt, Update zt), 1 state (ht). Fewer params than LSTM!

Module 3 Revision (H): KTU 2024 Pattern Module 3 Mock Exam (15 Marks)

KTU PCCMT503 — MODULE 3 MOCK TEST (15 Marks)
PART A2 × 3 = 6 Marks

1. Write the mathematical equations of a typical RNN and state why parameter sharing across time is beneficial. [3M]

2. Why is a Bidirectional RNN unsuitable for real-time streaming predictions? Give an example where BiRNN helps. [3M]

PART B (Answer EITHER 3 OR 4)1 × 9 = 9 Marks

3. (a) Explain Encoder–Decoder Seq2Seq architecture for unequal input/output lengths, noting the context vector bottleneck. [5M]
(b) Explain BPTT and show how Recursive Neural Networks compress path complexity from O(T) to O(log T). [4M]

— OR —

4. (a) Explain LSTM cell architecture with equations and diagram. Given Ct−1=[2,5,3]ᵀ and ft=[1,0,0.5]ᵀ, find retained cell memory. [5M]
(b) Describe GRU equations and compare GRU vs. LSTM in a table. [4M]

Show Complete Mock Exam Solutions
  • Q1: a⁽ᵗ⁾, h⁽ᵗ⁾=tanh(…), o⁽ᵗ⁾, ŷ⁽ᵗ⁾=softmax(…); sharing handles arbitrary sequence lengths with fixed weights (U,W,V).
  • Q2: Needs entire sequence t=1…T beforehand to run backward pass g⁽ᵗ⁾. Helps disambiguate "The bank is near the river", NER, POS tagging.
  • Q3: (a) Draw Fig 3.3, Encoder→C→Decoder(SOS..EOS) + P(Y|X) + fixed-C bottleneck (→ Attention). (b) Unroll + gradient sum + Recursive binary tree composition 8→4→2→1.
  • Q4: (a) Fig 3.5 + 6 equations + fₜ ⊙ Cₜ₋₁ = [2, 0, 1.5]ᵀ. (b) Reset/Update/Candidate/Update equations + 4-row LSTM vs GRU table.