Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

DQN improvements: double DQN, prioritised replay and dueling

Notes on three DQN improvements — Double DQN to reduce overestimation, Prioritised Experience Replay to sample important transitions more often, and Dueling Network architecture to separate state-value and action-advantages.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Deep Q-Networks (DQN) are widely used to learn policies from high-dimensional inputs (images, sensors). The three improvements — Double DQN, Prioritised Replay, and Dueling networks — make training more stable, faster and sample-efficient. An engineer uses these when building RL agents for games, robotics or autonomous systems where data is expensive or value estimates are noisy.

Key ideas

Start from the DQN baseline: DQN learns a function Q(s,a; θ) approximating the action-value function Q^π(s,a) (expected discounted return from state s taking action a under policy π) using a neural network with parameters θ. Training minimizes the mean-squared error between current Q and a target y.

Define: TD-target: a bootstrapped target used to update value estimates, commonly y = r + γ max_a' Q(s', a'; θ^-), where θ^- are parameters of a separate target network. θ^- are updated either by periodic hard updates (copy θ to θ^- every C steps) or by soft/Polyak averaging θ^- ← τ θ + (1−τ) θ^-.

Problem 1 — overestimation bias: the max over noisy estimates tends to be larger than the true max. If Q estimates have zero-mean noise, E[max(Q + noise)] ≥ max(Q). This causes optimistic value estimates and unstable learning in DQN.

Solution: Double DQN (DDQN). Idea: use the online network to choose the action (argmax) but use the target network to evaluate that action's value. Target becomes y_DDQN = r + γ Q(s', argmax_a Q(s',a; θ); θ^-). This decouples selection and evaluation reducing upward bias.

Derivation sketch universities ask: show how decoupling reduces expected max. Let q_i = true Q_i + ε_i where ε_i are independent zero-mean noises. Then E[max_i q_i] ≥ max_i true Q_i. By using argmax from one estimator and value from another (uncorrelated noise), you reduce expected over-max because selection and evaluation errors do not compound as when using the same estimator for both. For proofs assume independent estimation errors between networks or at least lower correlation.

Problem 2 — inefficient sampling: DQN uses uniform sampling from a replay buffer (a dataset of past transitions) to break correlation and stabilize updates. Uniform sampling ignores that some transitions are far more informative (large TD error).

Solution: Prioritised Experience Replay (PER). Assign each transition i a priority p_i (commonly p_i = |δ_i| + ε, where δ_i is TD error and ε small). Sample probability P(i) = p_i^α / sum_j p_j^α. Parameter α controls how much prioritisation is used (α = 0 => uniform). Prioritisation changes the sampling distribution, creating bias which is corrected by importance-sampling (IS) weights w_i = (N · P(i))^{-β}, where N is buffer size and β anneals from initial value to 1 to fully correct bias at the end of training. In practice w_i is normalized by dividing by max_j w_j so updates are stable.

Problem 3 — inefficient architecture for value estimation: a vanilla DQN maps state to Q-values for all actions in a single stream. When many states share the same state-value V(s) across actions, learning separate Q(s,a) values is wasteful.

Solution: Dueling network architecture. The network splits into two streams after convolutional or shared layers: one outputs a scalar state-value V(s; θ, β), the other outputs advantage estimates A(s,a; θ, α). They are combined to produce Q via Q(s,a) = V(s) + (A(s,a) − mean_{a'} A(s,a')). Subtracting the mean (or max in alternative variants) makes the decomposition identifiable (V and A are not uniquely determined otherwise).

Describe diagrams to draw in an exam:

  • For Double DQN: draw two boxes labelled Online network θ and Target network θ^-, draw s' input to both, show argmax from online feeding index to target network which outputs value, then plus reward and γ to form y. Label arrows.
  • For PER: draw replay buffer with N transitions, show priorities p_i and a pie chart of sampling probabilities P(i). Show IS weights calculator using N and β.
  • For Dueling: draw shared layers, then a split into two streams labelled V(s) (single output) and A(s,a) (|A| outputs), then a merge block computing Q(s,a) using the formula and outputting Q-values.

Assumptions frequently used in proofs: independence or reduced correlation between online and target network errors (Double DQN); non-zero ε to avoid zero priorities in PER; finite action set for dueling mean subtraction.

Formulas

y_DQN = r + γ · max_{a'} Q(s', a'; θ^- )

  • r: scalar reward received (unitless), γ: discount factor (dimensionless, 0 ≤ γ ≤ 1), Q: action-value estimate (unitless). Applies to standard DQN target.

y_DDQN = r + γ · Q(s', argmax_{a'} Q(s', a'; θ); θ^- )

  • same symbol meanings; uses online network θ to choose action, target network θ^- to evaluate.

p_i = |δ_i| + ε

  • p_i: priority of transition i (unitless), δ_i: TD error for i (unitless), ε: small positive constant to ensure p_i > 0 (unitless). Applies in PER.

P(i) = p_i^α / Σ_j p_j^α

  • P(i): sampling probability for transition i, α ≥ 0 controls prioritisation (dimensionless), Σ_j runs over all transitions.

w_i = (N · P(i))^{-β}

  • w_i: importance-sampling weight for transition i (unitless), N: replay buffer size (integer), β ∈ [0,1] controls bias correction. In practice normalize w_i within each sampled minibatch by dividing by max_j w_j in that minibatch to stabilize updates. These weights are applied in the loss: L = E_i[ w_i · (y_i − Q(s_i, a_i; θ))^2 ].

Q(s,a) = V(s) + ( A(s,a) − (1/|A|) Σ_{a'} A(s,a') )

  • Q(s,a): final Q-value (unitless), V(s): scalar state-value (unitless), A(s,a): advantage (unitless), |A|: number of discrete actions. Applies to dueling architecture combination.

Worked examples

Example 1 — Explain numerically how Double DQN reduces overestimation. Question (model answer): Suppose two actions at state s' have true Q values Q*_1 = 5.0 and Q*_2 = 4.5. The online network has estimation noise ε_online ~ {+0.6, −0.3} for actions 1 and 2 respectively, giving Q_online = {5.6, 4.2}. The target network has errors ε_target ~ {+0.1, +0.2}, giving Q_target = {5.1, 4.7}. Compute standard DQN target and Double DQN target for γ = 0.9 and reward r = 1.0. Solution steps:

  1. Standard DQN uses max over target network: max_a Q_target = max(5.1, 4.7) = 5.1.
  2. y_DQN = r + γ · 5.1 = 1.0 + 0.9·5.1 = 1.0 + 4.59 = 5.59.
  3. Double DQN: argmax over online network is argmax(5.6, 4.2) = action 1.
  4. Evaluate that action with target network: Q_target(s', action1) = 5.1.
  5. y_DDQN = r + γ · 5.1 = 1.0 + 0.9·5.1 = 5.59 (same here because target happened to also be highest). But consider if Q_target had larger positive noise on the wrong action; DDQN prevents choosing an action only because target net's overestimate is large. If target had Q_target = {5.1, 6.0}, then y_DQN would be 1 + 0.9·6.0 = 6.4 (overestimate), while DDQN would still pick action 1 from online and give 1 + 0.9·5.1 = 5.59. Final emphasised point: DDQN reduces cases where a single overestimated target value raises the max, because selection and evaluation are decoupled.

Example 2 — PER numeric calculation. Question (model answer): A replay buffer has N = 4 transitions with TD errors δ = {2.0, 0.5, 1.5, 0.0}. Let ε = 1e-6, α = 0.6, β = 0.4. Compute priorities p_i, sampling probabilities P(i), and (unnormalised) IS weights w_i. Solution steps:

  1. p_i = |δ_i| + ε ≈ {2.0, 0.5, 1.5, 0.0 + 1e-6} = {2.0, 0.5, 1.5, 1e-6}.
  2. p_i^α = {2.0^0.6, 0.5^0.6, 1.5^0.6, (1e-6)^0.6} ≈ {2^0.6≈1.5157, 0.5^0.6≈0.6598, 1.5^0.6≈1.2756, (1e-6)^0.6≈1e-3.6≈2.51e-4}.
  3. Sum ≈ 1.5157 + 0.6598 + 1.2756 + 0.000251 ≈ 3.4514.
  4. P(i) = each / sum ≈ {0.4392, 0.1912, 0.3696, 0.0000727}.
  5. w_i = (N · P(i))^{-β} = (4·P(i))^{-0.4}. Compute 4·P(i) ≈ {1.7568, 0.7648, 1.4784, 0.000291}. Raise to −0.4: w_i ≈ {1.7568^{-0.4}≈0.80, 0.7648^{-0.4}≈1.11, 1.4784^{-0.4}≈0.86, 0.000291^{-0.4}≈26.0}.
  6. In practice we clip tiny probabilities by ε to avoid enormous w; PER implementations normalize w_i by dividing by max_j w_j, giving final normalized weights ≈ {0.80/26.0≈0.031, 0.043, 0.033, 1.0}. Final answer: Transitions with larger δ have larger sampling probability; very small δ produce tiny P(i) and huge raw w_i which must be numerically stabilized.

Common mistakes

  • Forgetting to add ε when computing priorities (causes zero probabilities).
  • Using β but not explaining it anneals to 1 to fully correct bias.
  • For dueling, writing Q = V + A without subtracting mean (identifiability issue) and not stating action count |A|.
  • Numerical errors computing p^α or IS weights and forgetting to normalize weights by max for stability.

For your exam

Typical questions:

  • Define Double DQN and derive its target; explain why it reduces overestimation. Full answer: precise formula for y_DDQN, explanation of selection vs evaluation, short derivation or example showing bias reduction.
  • Explain Prioritised Experience Replay. Full answer: derive P(i) formula, explain α and β roles, show IS weight formula and mention normalization/clip practice and complexity (sum-tree for O(log N) sampling) — mention but need not implement.
  • Draw dueling network architecture and state the combination formula; explain why subtraction of mean is needed.
  • Numerical: compute sampling probabilities and IS weights for given δs — show steps and final normalized weights.
  • Diagram question: clear labelled diagrams as described in Key ideas.

Quick check

  1. What is the core idea of Double DQN in one sentence?
  2. In PER, what does the exponent α control?
  3. In dueling architecture, why subtract the mean of A(s,a) when composing Q? Answers: 1) Use online network to choose the argmax action and the target network to evaluate it (decouple selection and evaluation). 2) α controls how much prioritisation affects sampling (α = 0 => uniform). 3) To make V(s) and A(s,a) identifiable and avoid arbitrary split between value and advantages.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?