Deep & Advanced RL
Level 4 (Application: novel/unseen problems) Time limit: 60 minutes Total marks: 60
Answer all questions. Show all working. Calculators permitted. Assume all logarithms are natural unless stated.
Question 1 — DQN Targets & Double DQN (12 marks)
An agent uses a Deep Q-Network with discount factor . For a sampled transition with reward and non-terminal, the online network and target network give the following action-values at (three actions ):
| Network | |||
|---|---|---|---|
| Online | 5.0 | 8.0 | 3.0 |
| Target | 6.0 | 4.0 | 7.0 |
(a) Compute the standard DQN TD target . (3) (b) Compute the Double DQN TD target . (4) (c) Explain precisely which estimation problem Double DQN mitigates, and using the numbers above argue why here. (5)
Question 2 — REINFORCE with Baseline (14 marks)
A single-step (one-action) episodic task uses a softmax policy over two actions with parameter vector and logits equal to . Currently , (so ).
(a) Compute the policy probabilities and . (3) (b) The agent samples and receives return . Using a learned baseline , and learning rate , write the REINFORCE-with-baseline gradient update and compute the new . Use the softmax gradient , where is the one-hot of the taken action. (7) (c) State the purpose of the baseline and prove that subtracting a state-dependent (action-independent) baseline leaves the policy-gradient estimator unbiased. (4)
Question 3 — PPO Clipped Objective (12 marks)
PPO uses the clipped surrogate objective for a single sample: with .
(a) For and , evaluate . (3) (b) For and , evaluate . (3) (c) For a positive advantage, once , what is , and what does this imply about the gradient signal? Contrast with a vanilla (unclipped) importance-weighted objective. (6)
Question 4 — Actor-Critic Advantage & TD (10 marks)
An A2C agent observes a trajectory fragment with rewards (from ), (from ), and . The critic estimates , , .
(a) Compute the one-step TD advantage . (3) (b) Compute the 2-step advantage estimate . (3) (c) Using GAE with , , compute from the two TD errors (at ) and (at ), where . (4)
Question 5 — Reward Shaping & Design (12 marks)
A robot navigates a sparse-reward gridworld: reward only at the goal, elsewhere. A designer adds a shaping reward.
(a) State the potential-based reward shaping form and the key theoretical guarantee it provides. (4) (b) A colleague instead adds every time the robot moves closer to the goal (measured by Euclidean distance), regardless of a potential function. Describe one concrete failure mode (reward hacking) this can produce. (4) (c) Suppose where is grid distance to goal, and . For a step from a cell with to a cell with , compute . Then explain why potential-based shaping does not change the optimal policy. (4)
Answer keyMark scheme & solutions
Question 1 (12 marks)
(a) Standard DQN: uses the target network for both action selection and evaluation.
- Correct max of target net (7.0): 1
- Correct discount+reward assembly: 1
- Answer : 1
(b) Double DQN: online net selects the argmax action, target net evaluates it.
- Online argmax at : (value 8.0 is largest). (2)
- Evaluate with target: . (1) (1)
(c) (5 marks)
- Double DQN mitigates maximization bias / overestimation of Q-values (2). The single operator in standard DQN couples selection and evaluation, so noise/errors are systematically over-selected: (2).
- Here the online net picks (its optimistic choice), but the target net values only at 4.0, whereas the standard target greedily grabs the target net's own max (7.0). Decoupling yields the smaller, less optimistic target (1).
Question 2 (14 marks)
(a) Softmax over logits :
- Setup: 1, each probability: 1+1
(b) Update rule (REINFORCE-with-baseline): .
- . (1)
- . (2)
- Update vector: . (2)
- New parameters: (2)
(Interpretation: positive advantage on raises its logit, lowers 's.)
(c) (4 marks)
- Purpose: baseline reduces variance of the gradient estimate without introducing bias, giving faster/stabler learning (2).
- Unbiasedness proof (2): the extra term is Since it adds zero in expectation, the estimator's expectation is unchanged.
Question 3 (12 marks)
(a) , , clip range .
- Unclipped: ; clipped: .
- . (3)
(b) , .
- Unclipped: ; clipped: .
- . (3)
(c) (6 marks)
- For positive advantage with , the clipped branch is constant in , and since it is the smaller of the two when , , so (3).
- Implication: no gradient once the policy has moved "too far" in the improving direction → prevents excessively large policy updates / destructive steps (2).
- Contrast: a vanilla importance-weighted objective has constant gradient and keeps pushing up without bound, causing large, unstable off-policy updates (1).
Question 4 (10 marks)
(a) . (3)
(b) . (3)
(c) TD errors:
- (same as (a)). (1)
- . (1)
- GAE: . (2)
Question 5 (12 marks)
(a) (4 marks)
- Form: for a real-valued potential over states (2).
- Guarantee: potential-based shaping preserves the optimal policy (policy invariance) — the set of optimal policies of the shaped MDP equals that of the original (Ng, Harada & Russell) (2).
(b) (4 marks) Adding for every "closer" move (not potential-based) creates exploitable cycles: e.g. the robot can oscillate/loop to repeatedly gain the shaping bonus, or take a longer meandering path that maximizes distance-decreasing steps rather than reaching the goal fast. It can even avoid the goal to keep farming the bonus. Any concrete reward-hacking loop earns full marks (4).
(c) (4 marks)
- . (2)
- Reason: the shaping term telescopes over any trajectory — its cumulative contribution depends only on start/end potentials (with weighting), adding a state-only offset to the value function that does not alter the relative ordering of actions, hence the argmax (optimal) policy is unchanged (2).
[
{"claim":"DQN target = 8.3, Double DQN target = 5.6","code":"gamma=Rational(9,10); r=2; y_dqn=r+gamma*7; y_ddqn=r+gamma*4; result=(y_dqn==Rational(83,10)) and (y_ddqn==Rational(56,10))"},
{"claim":"REINFORCE update gives theta0=-0.0125, theta1=ln3+0.0125","code":"alpha=Rational(1,10); Gb=Rational(1,2); grad0=Rational(-1,4); grad1=Rational(1,4); t0=0+alpha*Gb*grad0; t1=alpha*Gb*grad1; result=(t0==Rational(-1,80)) and (t1==Rational(1,80))"},
{"claim":"PPO L values: 3.6 for A=3,rho=1.5 and -3.0 for A=-2,rho=1.5","code":"def clip(x,lo,hi): return Max(lo,Min(hi,x))\nrho=Rational(3,2); eps=Rational(1,5)\nL1=Min(rho*3, clip(rho,1-eps,1+eps)*3)\nL2=Min(rho*(-2), clip(rho,1-eps,1+eps)*(-2))\nresult=(L1==Rational(18,5)) and (L2==-3)"},
{"claim":"A2C: A1step=1.4, A2step=-0.04, GAE=0.68","code":"g=Rational(8,10); d0=1+g*3-2; A2=1+g*0+g**2*Rational(3,2)-2; d1=0+g*Rational(3,2)-3; lam=Rational(1,2); gae=d0+(g*lam)*d1; result=(d0==Rational(7,5)) and (A2==Rational(-1,25)) and (gae==Rational(17,25))"}
]