5.2.1 · D5Deep & Advanced RL

Question bank — Deep Q-Networks (DQN)

1,823 words8 min readBack to topic

The building blocks are Q-Learning, the Bellman Equation, Experience Replay, and Temporal Difference Learning. This page is self-contained: the symbol reminder below defines every piece of notation you will meet, so you never have to leave to answer a question.

The picture below fixes these symbols visually before you start — the online net and its frozen twin feeding one squared-error arrow.

Figure — Deep Q-Networks (DQN)

True or false — justify

TF1. A neural network in DQN stores one weight per state, just like a table stores one number per state.
False. The whole point is that the ==network shares weights across states==, so learning about one screen generalises to similar screens — a table cannot do that.
TF2. DQN is on-policy because it acts with the same -greedy policy it is training.
False. DQN is off-policy: it acts -greedily but the target uses , i.e. it learns the value of the greedy policy, not the behaviour policy.
TF3. If the loss reaches exactly zero on the buffer, the agent has found the optimal policy.
False. Zero loss only means satisfies Bellman on the sampled transitions with the current bootstrapped targets; targets can still be biased (e.g. overestimation) or the buffer may not cover the state space.
TF4. Because , the infinite reward sum in is guaranteed finite for bounded rewards.
True. With rewards bounded by , the sum is at most , so discounting keeps the value finite — this is why exists.
TF5. Setting removes the contraction that makes bootstrapped training stable.
True. At the Bellman update is no longer a strict contraction mapping, so errors need not shrink each step and the target becomes sensitive to episode length — that is why we keep .
TF6. The target network and the online network must eventually converge to identical weights.
True in spirit. Since every steps, once stops changing the copies coincide; the freezing only delays , it does not make it a permanently different function.
TF7. Experience replay is useless once the agent is good, because old data was collected by a bad policy.
False. Q-learning is off-policy, so old transitions remain valid Bellman samples; reusing them is precisely where DQN's sample efficiency comes from.
TF8. The TD error being negative means the agent made a mistake in the environment.
False. Negative just means the current estimate overshoots the bootstrapped target, so we nudge down — it is about estimate calibration, not about a wrong action.

Spot the error

SE1. "To compute the target , differentiate through so gradients flow into both terms."
The target is treated as a fixed label (detached). Backpropagating through it turns a fixed-point equation into a self-referential moving target and diverges — that is why the target network exists.
SE2. "For a terminal transition, where is the terminal state."
Wrong. At a terminal there is ==no future reward and no valid to evaluate==, so ; the term must be dropped.
SE3. "DQN handles a robot arm with continuous torque because it handles continuous Atari-pixel states."
Continuous states are fine, but requires enumerating actions, so actions must be discrete. Continuous actions need DDPG/SAC or Policy Gradient Methods.
SE4. "We use the same network for choosing and evaluating the next action, and that's optimal."
Using one network to both pick and value the max causes overestimation bias (positive noise gets selected then trusted). Double DQN fixes this by splitting selection and evaluation.
SE5. "Keep the replay buffer tiny and only recent, so training stays relevant."
A tiny recent buffer reintroduces correlation and forgetting — the very problem replay solves. Off-policy validity means old data is still usable; a large buffer helps.
SE6. "Anneal up over time so the agent explores more as it learns."
Backwards. We ==anneal down== (e.g. ): explore heavily early when nothing is known, exploit late once is trustworthy. See Epsilon-Greedy Exploration.
SE7. "Since the target uses , we should also act using ."
No. The target network is ==only for computing ==; action selection uses the current online net , which is more up to date.
SE8. "The Bellman split works because we assume the next action is also ."
No. The tail is evaluated under the ==best next action == via the , not by repeating ; that recursion is what makes it optimality, not just policy evaluation.

Why questions

W1. Why bootstrap with our own estimate instead of the true ?
Because == is unknown==; bootstrapping plugs in our current best guess of the next state's value, which is what Temporal Difference Learning does — learn a guess from a guess.
W2. Why does freezing the target for steps stabilise training?
It stops the regression target from moving while we chase it. A target that shifts every gradient step is like a dog chasing its tail — the fixed target gives supervised-learning-like stability.
W3. Why does random minibatch sampling matter for SGD here, beyond "breaking correlation"?
SGD's convergence guarantees assume unbiased gradient estimates with bounded variance; correlated consecutive frames make each minibatch gradient a biased, high-variance estimate of the true loss gradient, so steps point the wrong way. Random sampling from the buffer restores near-i.i.d. batches, reducing gradient variance and letting the averaged updates actually descend the loss — plus it recycles rare transitions so their signal is not seen once and forgotten.
W4. Why is DQN's ability to generalise both its strength and a source of instability?
Weight sharing means updating one state also shifts nearby states' Q-values, including the bootstrap targets — great for efficiency, but it can cause self-reinforcing feedback loops (the "deadly triad" of function approximation + bootstrapping + off-policy).
W5. Why is a squared TD error a reasonable loss to minimise?
If satisfied Bellman, the two sides would be equal so the TD error is zero; squaring makes zero the unique minimum and penalises large violations more, giving a smooth gradient toward the fixed point.
W6. Why can't tabular Q-Learning scale to Atari pixels?
The state space ( images) is astronomically large and rarely revisited, so a table has no entry to look up and no way to generalise between similar screens.

Edge cases

EC1. What is when the reward is at a non-terminal step?
— the future value still matters; a zero immediate reward does not zero the target.
EC2. What happens if every action has identical Q-value in a state under -greedy?
The ties, so greedy picks arbitrarily; exploration still happens via , so learning continues and the tie usually breaks as estimates diverge.
EC3. In the very first update, before any learning, are the targets meaningful?
Barely — with random the bootstrap is noise, but ==the immediate reward in is a real signal==, so learning slowly grounds the estimates from rewards outward.
EC4. What if the replay buffer only ever contains transitions with reward (rewards are sparse)?
Q-values can stay flat until a rewarding transition is stored; this is the sparse-reward problem, motivating better exploration or reward shaping — replay reuses the rare rewarding sample many times once found.
EC5. A transition is stored, then the network improves a lot before it's sampled. Is the stored still valid?
Yes. The tuple records environment dynamics, not policy quality; the target is recomputed with current at sample time, so stale data still yields a correct Bellman target.
EC6. What if (copy the target net every step)?
Then always, so you have effectively no target network, reintroducing the moving-target instability the trick was meant to remove.
EC7. The same leads to terminal reward half the time and the other half. What does learn, and why?
It learns the ==expected reward ==. The squared loss is minimised where its derivative , i.e. . So a stochastic target pulls toward its mean, not toward either individual value.

Recall One-line summary of the traps

Detach the target, drop at terminals, DQN is off-policy with discrete actions, anneal down, and never confuse "loss is zero" with "policy is optimal".

Connections