AI205 Module5 Note
AI205 Module5 Note
T E C H A I & M L · S E M E S T E R I V
Module V — Learning
& Reinforcement Learning
Complete notes · Every key term defined · PYQ questions highlighted in gold · Learning part
only (Robotics excluded)
PYQ Asked Key Concept / Term Formula / Equation Important for Exam
Algorithm Pseudocode
CONTENTS
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
8. Comparison Tables & Quick Revision
Inductive Learning
Learning a general rule (hypothesis) from specific examples. Given a set
of training examples (input-output pairs), the agent must infer the
underlying function that generated them.
Input: {(x₁,y₁), (x₂,y₂), …, (xₙ,yₙ)} — labelled training data
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Output: A hypothesis h(x) that approximates the true function f(x)
Goal: Generalise well to unseen examples (low test error)
Ockham's Razor (in inductive learning): Among all hypotheses consistent with
the data, prefer the simplest. Complex hypotheses risk overfitting — memorising
training noise instead of learning the true pattern.
Explanation-Based Learning
The agent already has a domain theory (background knowledge). When
given a single training example, it explains why that example is an
instance of a concept using its domain theory, then generalises this
explanation into a reusable rule.
Key difference from inductive learning: EBL needs only one example because it
uses prior knowledge. Inductive learning needs many examples because it has
no prior knowledge.
Example: Given one example of a cup holding liquid, EBL uses the domain
theory (stable base + concave shape → holds liquid) to generalise: "Any object
with a stable base and concave upper surface is a cup," without needing
thousands of cup examples.
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
2 Reinforcement Learning — Framework & All Key Terms
★ PYQ — 10 MARKS TOTAL
★ PYQ
"Explain the terms Policy, Discounted reward and Bellman equation in context to
value iteration in reinforcement learning."
End Sem 2024 — Q5(a) [5 marks]
★ PYQ
"Explain with an example Q-learning. What are its limitations. How is it overcome?"
End Sem 2024 — Q5(b) [5 marks]
★ PYQ
Action: aₜ
AGENT ENVIRON-
(Learner / Decision Maker) MENT
State: sₜ₊₁ Reward: rₜ₊₁
At each time step t: agent observes state sₜ, takes action aₜ, receives reward rₜ₊₁, moves to sₜ₊₁
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Core elements of RL: Agent, Environment, State (S), Action (A), Reward (R),
Policy (π), Value function (V), Q-function (Q). Every RL concept connects back to
this loop.
State — sₜ
A complete description of the world at time t. The agent's perception of
the environment at a given moment.
State space S: Set of all possible states
Example (Grid world): State = agent's (row, column) position on the
grid
Example (Chess): State = complete board configuration
Markov Property: A state sₜ has the Markov property if P(sₜ₊₁ | sₜ, aₜ) =
P(sₜ₊₁ | s₀, a₀, …, sₜ, aₜ). The future depends only on the present, not the
past. RL assumes this property (Markov Decision Process).
CORE TERM
Action — aₜ
The choice made by the agent at time t. The agent selects an action from
the action space A.
Discrete actions: {Up, Down, Left, Right} in a grid world
Continuous actions: Torque applied to a robot joint (real number)
The action transitions the environment from state sₜ to sₜ₊₁
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Positive reward: Reinforces the action (agent should repeat it)
Negative reward (penalty): Discourages the action
Zero reward: Neutral — no signal in many time steps
Example: In chess → +1 for win, −1 for loss, 0 for each move
Example: In Pac-Man → +10 for eating pellet, −500 for dying
γᵏ Rₜ₊ₖ₊₁
γ (gamma) = discount factor (0 ≤ γ < 1) | Rₜ₊ₖ₊₁ = reward at
Gₜ = Rₜ₊₁ + γ · Gₜ₊₁
Current return = immediate reward + discounted future return
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
π(s) = a — maps state s directly to a π(a|s) = P(aₜ=a | sₜ=s) — gives a
single action a. No randomness. probability distribution over
Example: π(A) = Right, π(B) actions.
= Up Example: π(Right|A)=0.7,
π(Up|A)=0.3
Optimal Policy π*: The policy that maximises expected return from every
state. This is what RL algorithms are trying to find.
Intuition: The policy is like a "rulebook" the agent carries. A bad policy
might walk into walls repeatedly. The optimal policy always takes the best
action in every state.
γ
Behaviour Agent cares about Use case
value
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Why discount? Three reasons: (1) Mathematical — ensures convergence
of infinite sums (γ < 1 → sum converges). (2) Uncertainty — future
rewards are less certain than immediate ones. (3) Financial analogy —
money now is worth more than money later (time value).
G₀ = 8.146
Rₜ₊ₖ₊₁ | sₜ = s ]
High V(s) → state s is good (agent expects large future reward from
here)
Low V(s) → state s is bad (agent expects low/negative future reward)
Example: In chess, V(state with queen advantage) > V(state with piece
deficit)
CORE TERM
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
CORE TERM
Why Q is more useful than V: V(s) tells you how good a state is, but you
still need to know transition probabilities to pick actions. Q(s,a) directly
gives you the value of each action — you just pick argmax_a Q(s,a). This is
why Q-learning works without a model of the environment.
Derivation (for V)
Start from the definition:
γ Vπ(s')]
Intuition
Value of current state = (weighted) sum over all actions and successor
states of: [immediate reward + discounted value of next state]
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Bellman Optimality Equation
The optimal value function V* satisfies:
V*(s')]
The optimal policy takes the action that maximises this quantity
max_a' Q*(s',a')]
Bellman optimality for Q-function — basis of Q-learning update
rule
CORE TERM
CORE TERM
Exploitation Exploration
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Take the action currently believed Try new, uncertain actions to
to be best. Maximises reward based gather information. May sacrifice
on current knowledge. But may immediate reward but could find
miss better options. better long-term strategies.
CORE TERM
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
★ PYQ
Passive RL — Definition
In passive RL, the agent's policy is fixed (given, not learned). The agent
simply executes the policy and tries to learn the value function V(s) — i.e.,
how good each state is under that policy.
The agent's task: given policy π, estimate Vπ(s) by observing outcomes of
following π.
METHOD 1 METHOD 2
METHOD 3
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
V(sₜ) ← V(sₜ) + α [Rₜ₊₁ + γV(sₜ₊₁) − V(sₜ)]
α = learning rate | [Rₜ₊₁ + γV(sₜ₊₁) − V(sₜ)] = TD error (δ) — how
Active RL — Definition
In active RL, the agent must both learn and decide what actions to take. It
learns the policy π itself by trying actions and observing outcomes. Must
balance exploration (trying new things) and exploitation (using what it
knows).
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Criterion Passive RL Active RL
Value Iteration
Algorithm
VALUE-ITERATION(MDP, θ):
// θ = small threshold for convergence
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
for each state s:
π*(s) ← argmax_a Σₛ' P(s'|s,a) [R(s,a,s') + γ·V(s')]
Actions: Right
S1 S2 S3 S4
(start) (goal, R=+1)
Setup: 4 states in a row. Only action = "Right". Goal S4 gives reward +1. All others
give 0. γ = 0.9
k=0 0 0 0 0
(init)
k=1 0 0 0 + 0.9×1 = +1
0.9 (terminal)
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Policy Iteration
Alternates between two steps until convergence:
Policy Evaluation: Given current policy π, compute Vπ(s) exactly (solve
Bellman equations)
Policy Improvement: For each state, make policy greedy w.r.t. current
Vπ. If π unchanged → converged → π is optimal.
Core idea Sweep value function until Alternate between full policy
convergence, then extract evaluation and improvement
policy
★ PYQ
"Explain with an example Q-learning. What are its limitations. How is it overcome?"
End Sem 2024 — Q5(b) [5 marks]
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Q-Learning
Q-learning is a model-free, off-policy reinforcement learning algorithm.
It learns the optimal Q-function Q*(s,a) directly from interaction with the
environment — without needing a model of P or R.
Off-policy: Learns about the greedy policy while following an
exploratory (ε-greedy) behaviour policy
Model-free: No need to know transition probabilities P(s'|s,a)
Goal: Learn Q*(s,a) = optimal action-value function
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Algorithm Pseudocode
else:
a ← argmax_a Q(s,a) // exploit
Take action a, observe reward R, next state s'
// Q-learning update
Q(s,a) ← Q(s,a) + α[R + γ·max_a' Q(s',a') − Q(s,a)]
s ← s'
until s is terminal
R R
S1 S2 S3
(start) GOAL R=+10
L L
S1 0 0
S2 0 0
S3 (goal) — —
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Episode 1 Trace (following ε-greedy, say ε=0 initially for clarity)
1 t=1: State=S1, Action=Right
Observe: R=−1, next state=S2
Update: Q(S1,R) ← 0 + 0.5×[−1 + 0.9×max(Q(S2,R),Q(S2,L)) − 0]
= 0 + 0.5×[−1 + 0.9×0 − 0] = 0 + 0.5×(−1) = −0.5
S1 −0.5 0
S2 +5.0 0
Episode 2 Trace
1 t=1: State=S1, Action=Right
Observe: R=−1, next=S2, max Q(S2,·)=5
Q(S1,R) ← −0.5 + 0.5×[−1 + 0.9×5 − (−0.5)] = −0.5 + 0.5×[−1+4.5+0.5] = −0.5 + 0.5×4
= +1.5
S1 +1.5 0
S2 +7.5 0
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
6.2 Limitations of Q-Learning
# Limitation Explanation
1 Curse of Q-table has size |S| × |A|. For large or continuous state
Dimensionality (Q- spaces (e.g., Atari pixels → 10⁴ states), table becomes
Table) impossibly large — cannot be stored or updated.
★ PYQ
"What are its limitations. How is it overcome?" — The answer is Deep Q-Network
(DQN).
End Sem 2024 — Q5(b) [5 marks]
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
DQN replaces the Q-table with a deep neural network that approximates
the Q-function. Input: state s (e.g., raw pixels). Output: Q(s,a) for all
actions a simultaneously.
Q(s, a; θ) ≈ Q*(s, a)
θ = neural network parameters (weights). The network is trained to
Limitation
DQN Innovation How it helps
Addressed
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
DQN vs Q-Learning
Generalisation in RL
Generalisation
The ability to apply knowledge from seen (state, action) pairs to unseen
ones. Without generalisation, the agent must visit every state-action pair
— infeasible in large spaces.
Trade-off: More expressive functions generalise better but are harder to train
(more parameters, risk of instability). Simpler approximations are stable but
may be too coarse.
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Policy Search
Instead of learning V(s) or Q(s,a) and deriving a policy, policy search
directly optimises the policy π(a|s;θ) as a parameterised function (e.g.,
neural network). Adjusts θ to maximise expected return.
METHOD METHOD
SARSA (State-Action-Reward-State-Action)
On-policy version of Q-learning. Updates Q using the action actually taken
in sₜ₊₁ (not the max):
γ·Q(sₜ₊₁,aₜ₊₁) − Q(sₜ,aₜ)]
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
aₜ₊₁ is the action actually selected in sₜ₊₁ under current policy
Cliff Finds shortest path (but may fall Takes safer longer path away
walking off cliff) from cliff
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Term One-line definition Formula
Passive RL Fixed policy, learn V(s) by Uses TD, ADP, Direct util.
observation
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
PYQ Answers — Direct Writeup Points
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF