Worked examples — Double DQN and Dueling DQN
This page drills the two ideas from Double DQN and Dueling DQN — the optimism cure (Double DQN) and the network reshaping (Dueling DQN) — through worked examples that between them touch every case class you can meet in an exam or a codebase. If a symbol here feels unfamiliar, the parent note builds it first; we only use the tools here.
Several symbols recur, so let us pin them all down before any of them appears inside an equation:
The scenario matrix
Every example below is tagged with the cell it exercises. Read this table first — it is the map.
| Cell | Case class | What is special | Example |
|---|---|---|---|
| C1 | Overestimation, ordinary case | Online & target disagree on best action | Ex 1 |
| C2 | Sign flip / negative values | Best estimate is negative | Ex 2 |
| C3 | Degenerate: single action | , no max to inflate | Ex 3 |
| C4 | Degenerate: agreement | Online & target agree → Double = DQN | Ex 4 |
| C5 | Terminal transition | Next state does not exist ( terminal) | Ex 5 |
| C6 | Dueling: raw mean already zero | Centering changes nothing | Ex 6 |
| C7 | Dueling: raw mean non-zero | Centering absorbs the offset | Ex 7 |
| C8 | Dueling: mean vs max aggregation | Two anchors, two meanings | Ex 8 |
| C9 | Limiting behaviour: bias grows with | Many actions inflate the max | Ex 9 |
| C10 | Word problem + exam twist | Combine Double + Dueling end-to-end | Ex 10 |
There is also one limiting edge-case that needs no separate example: the zero-discount case . When the target collapses to for every variant — DQN, Double DQN, and any Dueling recombination alike. The whole /select/center machinery is multiplied away, so overestimation and identifiability both vanish; the agent becomes purely myopic (it trusts only the immediate reward). We flag this here so no reader wonders what happens at that boundary; every numbered example below uses where the machinery actually runs.
Prerequisites we lean on: Deep Q-Networks (DQN), Target Networks and Experience Replay, Advantage Function, Overestimation Bias in Q-learning.
Ex 1 — The ordinary overestimation (Cell C1)
Step 1 — Plain DQN takes the max of the target net. Why this step? Plain DQN uses one network () for both choosing and scoring. It grabs the largest target number — which is exactly the one whose noise was luckiest.
Step 2 — Form the DQN target. Why this step? The Bellman target is "reward now, plus discounted value of the best next move". We plug the max from Step 1 into to get the single number the network trains toward.
Step 3 — Double DQN: select with online, evaluate with target. Why this step? The online net's lucky action has noise independent of the target net's reading. We do not get to reuse the same lucky spoon twice.
Step 4 — Form the Double DQN target. Why this step? Same Bellman shape as Step 2, but now the discounted term is the decoupled value from Step 3 — this is precisely where the two methods diverge in their answer.
Verify: truth is . DQN overshoots to ; Double lands at . , so Double is closer to . The optimism was cut. ✔
Read the figure: the cyan bars are the online net, the amber bars the target net. Notice DQN's amber arrow points at the tallest amber bar (), while Double's cyan arrow first picks the tallest cyan bar () and then reads the amber value sitting under (). The picture makes visible that the two methods read different cells of the target row.
Ex 2 — When the best estimate is negative (Cell C2)
Step 1 — DQN max over target. Why this step? "Max" means largest, even among negatives — beats . The optimism bias survives sign changes; it always favours the luckiest reading.
Step 2 — Double selects with online. Why this step? Selection in Double DQN always uses the online net, regardless of sign. Among the online numbers the largest is at , so the online net's chosen action is — and crucially this is a different action from the target's own favourite .
Step 3 — Evaluate with target. Why this step? Online and target disagree on which action is best ( vs ). Double honours the online's choice and reads its target value, refusing to grab the single luckiest cell.
Verify: . Double gives the lower (less optimistic) target even in fully negative territory — exactly the intended direction of the correction. ✔
Ex 3 — Degenerate: only one action (Cell C3)
Step 1 — The max over one element is that element. Why this step? From the parent's bound : at the numerator , so the whole bound is and the bias is exactly zero. There is no "lucky pick" when there is nothing to pick from.
Step 2 — Both targets. Why this step? Selection and evaluation are forced onto the same and only action , so both methods read the identical target value and pass it through the same — there is no room for them to diverge.
Verify: identical. Double DQN reduces to DQN whenever there is one action — the cure and disease coincide because there is no over-optimism to cure. ✔
Ex 4 — Degenerate: the networks agree (Cell C4)
Step 1 — DQN max. at . Why this step? Plain DQN reads the largest target value; among that is at . We record both the value and the action so we can compare against the online net's choice next.
Step 2 — Double selection. — same action. Why this step? Double selects with the online net; its largest value also sits at . Because both nets nominate the very same action, the decoupling has nothing to separate.
Step 3 — Double evaluation. . Why this step? When selection and evaluation land on the same cell, Double reads exactly the value DQN read (). The decoupling only bites when the two nets disagree.
Step 4 — Targets. Why this step? Both methods feed the identical discounted value into with , so they must produce the identical target .
Verify: both . Double DQN is a soft correction — it never harms the agreeing case, it only trims the disagreeing (biased) ones. ✔
Ex 5 — Terminal transition (Cell C5)
Step 1 — Terminal means no future. For a terminal there is no next action and no bootstrap. The Bellman target collapses: Why this step? being terminal is coded by a done-flag ; the general target is . With the whole block is multiplied by .
Step 2 — Plug in. Why this step? We substitute , , ; the factor annihilates whatever bootstrap value would have sat there, leaving only .
Verify: . Overestimation cannot occur at a terminal step because there is no max to inflate — Double DQN and DQN are trivially identical here, and both equal the raw reward. ✔
Ex 6 — Dueling, raw mean already zero (Cell C6)
Step 1 — Compute the mean of . Why this step? Mean-centering subtracts from every advantage, so we must first know . Averaging the three raw advantages gives here.
Step 2 — Center. (unchanged). Why this step? The mean-centering step is what pins to (see the parent's aggregation formula). If the mean is already , it is a no-op — but we still must run it so behaviour is uniform across states.
Step 3 — Recombine. Why this step? The dueling aggregation is with the centered advantages; adding to each centered advantage produces the per-action values.
Verify: . The anchor holds; the best action is with advantage . ✔
Ex 7 — Dueling, raw mean non-zero (Cell C7)
Step 1 — Mean of raw advantages. . Why this step? Again centering needs first; here the raw advantages average to , a non-zero offset that centering must strip out.
Step 2 — Center. . Why this step? Centering strips the shared offset out of the advantage stream. Advantages are relative quantities — only their differences carry meaning — so removing a constant is legitimate.
Step 3 — Correct recombination. Why this step? Adding to the centered advantages keeps pinned to , exactly as the aggregation formula guarantees.
Step 4 — The naïve (wrong) version. Why this step? We deliberately skip centering to expose the failure: the offset leaks into , giving . The value stream has silently inflated by , and the split is no longer identifiable (the parent's identifiability trap).
Verify: centered ✔; naïve — anchor broken, confirming why centering is mandatory. ✔
Read the figure: the cyan bars (correctly centered ) hug the dashed white line — their average lands exactly on it. The amber bars (naïve ) float a full higher, their average marked by the amber dotted line at . The picture shows the offset physically "lifting" the whole row away from when centering is skipped.
Ex 8 — Mean vs max aggregation (Cell C8)
Step 1 — Mean anchor (from Ex 6/7). Why this step? This is the standard mean-centered aggregation; we restate its result so we have a baseline to compare the max anchor against.
Step 2 — Max anchor. , so subtract from each advantage: Why this step? The max anchor pins : subtracting forces the best action to advantage , so its equals exactly. Here .
Step 3 — Compare interpretations.
- Mean anchor: ("how good is this state on average").
- Max anchor: ("how good is this state if I play optimally").
Why this step? The two anchors do not just produce different vectors — they redefine what the scalar means, which is why the choice of anchor is a modelling decision, not a cosmetic one.
Verify: ✔ and ✔. Both anchor to here by coincidence of numbers, but their meanings differ. The mean version is preferred in practice: subtracting a fixed mean is lower-variance than chasing a moving . ✔
Ex 9 — Limiting behaviour: bias grows with number of actions (Cell C9)
Step 1 — Evaluate the bound at each . Why this step? Each number is the worst-case average upward inflation of the DQN target from the operation alone, holding truth at and . It is the size of the disease Double DQN treats.
Step 2 — Read the trend. — monotonically increasing. Why this step? Lining the four values up shows the bias is not constant: doubling the action count keeps pushing the ceiling higher, which is the whole point of the cell.
Verify: at the bound is exactly (matches Ex 3's single-action result), and it climbs with . So DQN's overestimation is worst in large-action-space environments — precisely where Double DQN pays off most. ✔
Read the figure: the cyan curve is the bound plotted against the action count ; the amber-filled dots mark the four cases we computed. See how it starts pinned at for (a single action, no bias) and rises steadily — the visual proof that "more actions ⇒ more optimism to cure".
Ex 10 — Word problem + exam twist: full Double-Dueling pass (Cell C10)
Step 1 — Build online (center its advantages). Why this step? Selection in Double DQN uses the online net, and this net is dueling — so we must reconstruct from its two streams (mean-centered, as in Ex 6/7) before taking any argmax.
Step 2 — Online selection (the argmax on ). Why this step? Double DQN's selection rule says the action is whichever gives the largest online . Among that is at , so the online net picks "straight". This is the action we will hand to the target net.
Step 3 — Build target (center its advantages). Why this step? The evaluation uses the target net, which is also dueling, so we must reconstruct its from its own two streams the same way before we can read a value off it.
Step 4 — Evaluate the online-selected action with the target net. Why this step? Double DQN evaluates the online's choice using the target net — not the target's own max. The target's own best is ("right", ), so the two nets disagree; Double honours the online's pick and reads its (lower) target value, dodging the optimism.
Step 5 — Form the target. Why this step? The final step is the same Bellman shape used everywhere on this page, now fed the decoupled value from Step 4 with — giving the single number the network trains toward.
Verify: exam-twist answer — online selects ("straight"), target's own argmax is ("right"), so they disagree; Double DQN uses 's target value giving . And note the dueling payoff: because dominates and the advantages are tiny (), all three values sit within of each other — confirming "steering barely matters", and the shared stream learned this state's worth from every transition. ✔
Recall Which cells did we cover?
Ordinary bias (C1) ::: Ex 1 Negative-valued state (C2) ::: Ex 2 Single action degenerate (C3) ::: Ex 3 Networks agree degenerate (C4) ::: Ex 4 Terminal transition (C5) ::: Ex 5 Dueling raw-mean-zero (C6) ::: Ex 6 Dueling raw-mean-nonzero (C7) ::: Ex 7 Mean vs max anchor (C8) ::: Ex 8 Bias grows with m (C9) ::: Ex 9 Word problem + twist, full pass (C10) ::: Ex 10 Zero-discount edge-case (gamma=0) ::: covered in the matrix note (target collapses to r)
Related deep vaults: Actor-Critic Methods (where the Advantage Function returns as a first-class citizen) and Rainbow DQN (which stacks Double + Dueling with more tricks). See also Overestimation Bias in Q-learning for the statistical root.