Exercises — Deep Q-Networks (DQN)
A quick reminder of every symbol that appears below, in plain words:
The figures on this page are visual-first: each core intuition (Bellman update, replay shuffling, moving-vs-frozen target) gets its own picture so you can see the idea before the algebra.
L1 — Recognition
Problem 1.1
Which component of DQN is responsible for breaking correlation between consecutive frames? (a) target network, (b) -greedy, (c) experience replay, (d) discount factor.
Figure 1 shows the intuition: raw play produces a correlated stream; the buffer shuffles it into a scrambled minibatch.

Recall Solution
(c) experience replay. Why: consecutive frames of a game look almost identical, so training on them in order feeds the optimiser near-duplicate, non-independent samples. Sampling a random minibatch from the buffer (defined above: the notebook of past transitions) shuffles far-apart moments together, restoring the "independent samples" assumption that gradient descent relies on. The target network (a) fixes a different problem — a moving target. See Experience Replay.
Problem 1.2
For a terminal transition, what is the target ?
Recall Solution
. Why: "terminal" means the episode ended, so there is no next state to look forward from — the term has nothing to evaluate and is dropped.
L2 — Application
Problem 2.1
Non-terminal transition. , . The target network outputs, for the next state : , , . The current network says . Compute the target and the TD error .
Figure 2 pictures this one update: pick the best next value, discount it, add the reward, then compare to the current guess.

Recall Solution
Step 1 — best next action. . Why: Bellman assumes we act optimally from onward, so we take the largest value. Step 2 — target. . Step 3 — TD error. . Positive means the net underestimates; the update nudges up toward .
Problem 2.2
Same numbers as 2.1, but now is terminal. Recompute and .
Recall Solution
(drop the future term). . Negative ⇒ the net overestimates here; update pushes down.
Problem 2.3
One SGD step. With from Problem 2.1, learning rate , and pointing so that a scalar update approximates the effect on the single output, what is the updated estimate ?
Recall Solution
. Why: one gradient step moves the output a fraction of the way toward the target; it does not jump all the way to , which keeps learning stable.
L3 — Analysis
Problem 3.1
Explain, in terms of a fixed point, why we do not backpropagate through the target even though contains a value.
Recall Solution
We want to equal its Bellman target — that is a fixed-point condition:
"left side = a function of the right side." We solve it like a regression: freeze the right side
as a label and pull the left side toward it. If instead we differentiated through ,
the optimiser would also move the label as it moves the prediction — it minimises the gap by
dragging the target down toward the prediction rather than lifting the prediction to the true
value. That collapses the fixed-point equation into an unstable feedback loop and diverges. This
is exactly why uses the frozen and is .detach()-ed. See Bellman Equation
and Temporal Difference Learning.
Problem 3.2
The plot below (Figure 3) shows a scalar toy where the target is (a Bellman-like update) and the true fixed point is where . Trace what "chasing a moving target" looks like versus a frozen target, and state which one converges.

Recall Solution
The true fixed point solves (the mint dot where the line crosses the diagonal ).
- Frozen target (lavender path): hold fixed for several steps, take small steps toward it, then refresh . Each staircase segment is stable and the sequence climbs steadily to .
- Moving target (coral path): recompute every step while also moving . The label slides as you approach, producing the overshooting / oscillating behaviour the figure shows. The frozen scheme converges reliably — this is the geometric reason the target network exists.
L4 — Synthesis
Problem 4.1 — Double DQN vs DQN target
In vanilla DQN the target is . Suppose the online network's values for are , , and the target network's are , , with , . (a) Compute the vanilla-DQN target. (b) Compute the Double DQN target, which uses the online net to pick the action and the target net to evaluate it: . (c) Which is smaller, and why does that reduce overestimation?
Recall Solution
(a) Vanilla: , so . (b) Double: the online net picks the action: . Then evaluate up with the target net: . So . (c) The Double target () is smaller than the vanilla target (). Vanilla DQN takes a over noisy estimates, and of noisy numbers is systematically too high (it latches onto whichever action happened to be over-estimated — here "down" with value ). Decoupling selection (online) from evaluation (target) breaks that coupling: the action the online net believes is best is scored by an independent network, so the inflated is not automatically picked up. This is the overestimation fix behind Double DQN.
Problem 4.2 — Off-policy justification of replay
A transition was collected 50,000 steps ago while acting nearly randomly (). Argue whether it is still valid to train on today, when .
Recall Solution
Valid. DQN learns , the value of acting greedily, regardless of the (exploratory) policy that generated the data — that is what off-policy means. The target contains a , i.e. it bakes in "act optimally next," so it never assumes the stored action came from the greedy policy. Hence old, random-ish transitions carry correct one-step reward + transition information and can be replayed. This reuse is precisely the sample efficiency of Experience Replay. (Contrast: an on-policy method like Policy Gradient Methods would be invalidated by stale data.)
L5 — Mastery
Problem 5.1 — Design the annealing schedule
You want to decay linearly from to over the first steps, then stay at . (a) Write for . (b) Evaluate at . (c) In one sentence, why anneal at all instead of a constant ?
Recall Solution
(a) Linear interpolation from down to :
= 1.0 - 0.9\cdot\frac{t}{N},\qquad t\le N,$$ and $\epsilon(t)=0.1$ for $t>N$. **(b)** $\epsilon(250000) = 1.0 - 0.9\cdot\frac{250000}{1000000} = 1.0 - 0.9(0.25) = 1.0 - 0.225 = 0.775$. **(c)** Explore heavily **early** (the net is ignorant, so try everything), then exploit the learned $Q$ **later** — a constant $\epsilon$ either explores too little at the start or wastes reward on randomness forever. See [[Epsilon-Greedy Exploration]].Problem 5.2 — Convergence of the frozen-target update (prove the geometry)
For the scalar Bellman map with , show that repeatedly setting (fully solving each frozen target) converges to a unique fixed point, and give its value for . Relate this to Figure 3.
Recall Solution
Contraction. For any two guesses : Since , each application of shrinks the gap by factor — is a contraction. By the Banach fixed-point idea, iterating pulls any starting guess geometrically toward one unique . Fixed point. Set . For : . Link to Figure 3: is the mint dot where meets the diagonal ; the lavender staircase is exactly this contraction, each step multiplying the remaining distance to 10 by .
Recall One-line self-check before you leave
Non-terminal target ::: Terminal target ::: TD error ::: Scalar Bellman fixed point ::: Double DQN target :::
Connections
- Deep Q-Networks (DQN) — the parent note these exercises drill.
- Q-Learning · Bellman Equation · Temporal Difference Learning — the theory behind the targets.
- Experience Replay — why old data (Problem 4.2) stays valid.
- Double DQN — the overestimation fix in Problem 4.1.
- Dueling DQN · Policy Gradient Methods · Epsilon-Greedy Exploration — neighbours referenced above.