Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Three fixes for DQN
If you pick the best of ten restaurants by one noisy review each, the winner’s review is probably too good: you picked it because it was lucky. Double DQN asks a second, independent opinion about the chosen option. Dueling networks notice that in many situations all moves are about equally good and learn how good the situation is separately from which move is slightly better. Prioritised replay rereads the most surprising pages of the diary more often.
Combined with three other improvements, these methods form Rainbow, which more than doubled DQN’s median Atari score.
- 1. Picking the best of many noisy estimates tends to…
- 2. Double DQN gets a second opinion on…
- 3. Prioritised replay rereads…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Maximisation bias: E[max_a Q̂(s, a)] ≥ max_a E[Q̂(s, a)], so Q-learning’s target is biased upward when estimates are noisy.
- Double Q-learning: two estimates; choose the action with one, evaluate it with the other. Double DQN: y = r + γQ(s’, argmax_a’ Q(s’, a’; θ); θ⁻), using the online network to choose and the target network to evaluate.
- Dueling network: two streams, V(s) and A(s, a), combined as Q = V + A − mean_a A. The value stream learns from every action’s update.
- Prioritised experience replay (PER): sample transition i with probability P(i) ∝ (|δ_i| + ε)^α; correct the bias with importance weights w_i = (N·P(i))^(−β)/max w, with β annealed toward 1.
- Sum tree: a binary tree of priority sums makes proportional sampling and priority updates O(log N).
- 1. Double DQN chooses the next action with…
- 2. The dueling aggregation subtracts…
- 3. PER's importance weights correct…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.The maximisation bias
Exercise 1.
- The example of Sutton and Barto: from A, ‘right’ ends with reward 0, ‘left’ leads to B with reward 0; in B, each of 10 actions ends with a reward from N(−0.1, 1). ‘Left’ is worse on average.
- Tabular Q-learning against Double Q-learning, ε = 0.1, α = 0.1, no discounting, 300 episodes, 2,000 runs computed together.
- The share of runs choosing ‘left’ in A in each episode; the best ε-greedy policy chooses it 5% of the time.
Practice.
- Use Double DQN by default: it costs nothing (the target network already exists) and removes the upward bias of the max.
- Dueling helps when many actions have similar values, for example when most actions do not matter in most states.
- Prioritised replay speeds up learning from rare, informative transitions; anneal β and add new transitions with maximal priority.
- Check the value estimates against actual returns: bias can go either way, and a frozen target can make values too low early in training.
- Expect small effects on easy problems: the published gains come from Atari-scale tasks; test on your own problem with several seeds.
- Tools: Stable-Baselines3 (DQN with Double DQN targets), Dopamine and CleanRL (Rainbow components).
def double_target(r, q_online_next, q_target_next, terminated, gamma):
a2 = np.argmax(q_online_next, -1)
q = np.take_along_axis(q_target_next, a2[..., None], -1)[..., 0]
return r + gamma * (1 - terminated) * q- 1. Double DQN costs…
- 2. Dueling helps most when…
- 3. New transitions in PER get…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Bias of the max. For unbiased estimates Q̂_a = q_a + ε_a, max_b Q̂_b ≥ Q̂_a for every a, so E[max_b Q̂_b] ≥ max_a q_a. With n actions of equal true value and independent N(0, σ²) noise the bias is σ times the expected maximum of n standard normals, about 1.54σ for n = 10.
Double estimator. With two independent sets of estimates, the second set’s value at the first set’s argmax is unbiased for the value of the chosen action, which is at most max_a q_a: the double estimator can underestimate but does not overestimate (van Hasselt 2010).
Dueling identifiability. Q = V + A alone does not determine V and A (any constant can move between them). Subtracting mean_a A fixes this; then mean_a Q = V.
Prioritised replay. Sampling with probabilities P(i) instead of 1/N changes the expected gradient. Weights 1/(N·P(i)) restore it exactly (β = 1); smaller β trades some bias for lower variance early in training.
- 1. The expected max of 10 standard normals is about…
- 2. The double estimator can…
- 3. Importance weights with β = 1 make the expected gradient…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.How large is the maximisation bias in a small example, and how much do Double DQN, dueling networks and prioritised replay each change DQN on cart-pole?
History.
- H. van Hasselt (2010) introduced Double Q-learning; van Hasselt, A. Guez and D. Silver (2016) carried it over to DQN.
- Z. Wang and colleagues (2016) introduced dueling network architectures.
- T. Schaul, J. Quan, I. Antonoglou and D. Silver (2016) introduced prioritised experience replay.
- M. Hessel and colleagues (2018) combined six improvements in Rainbow.
Exercise 2.
- Cart-pole as in topic L3-1 (two hidden layers of 32 units, replay and a target network), 5,000 steps, three runs each of DQN, Double DQN, dueling DQN and DQN with prioritised replay, all trained side by side.
- Prioritised replay with α = 0.5 and β = 0.5 for the first half of training, 1 afterwards.
- All matrix products use numbers on a fixed binary grid, so they are exact and the results are identical on every machine.
- Measured over 5 greedy episodes: episode length (out of 200), the discounted return obtained from the start, and the network’s own estimate of it; and the steps until the training average first reached 150.
Seed 0:
| variant | greedy length | return obtained | estimate | steps to an average of 150 (per run) |
|---|---|---|---|---|
| DQN | 176.9 | 82.0 | 20.3 | not reached, 3,564, 3,246 |
| Double DQN | 198.7 | 86.4 | 18.8 | 3,769, 3,276, 3,332 |
| dueling | 179.1 | 82.7 | 20.6 | 4,718, 3,606, 3,356 |
| prioritised replay | 168.6 | 80.4 | 18.8 | 3,293, not reached, 3,524 |
- The maximisation bias is large where rewards are noisy (Exercise 1): Q-learning chose the worse action in up to 94.2% of runs early on, against at most 50.4% for Double Q-learning, and still 13.1% against 6.9% after 250 episodes (the best possible is 5%).
- Double DQN lowered the value estimates in every seed: 18.8 against 20.3, 18.1 against 18.9, and 17.9 against 19.6.
- On cart-pole the estimates were far below the returns actually obtained (about 20 against 80 to 86), because a frozen target lets values grow slowly. Here the bias was downward, so lowering the estimates further did not make them more accurate.
- No improvement was consistently better than DQN at this scale: across seeds 0, 1 and 2 the greedy lengths were 176.9, 183.6, 199.9 for DQN; 198.7, 199.1, 196.4 for Double DQN; 179.1, 188.4, 175.9 for dueling; 168.6, 188.4, 194.7 for prioritised replay. All variants learned to balance the pole; the differences are within the run-to-run spread.
- Seeds 1 and 2: estimates for DQN, Double DQN, dueling and prioritised replay were 18.9, 18.1, 19.3, 18.5 and 19.6, 17.9, 19.2, 20.5.
The improvements in practice
- Rainbow combines Double DQN, dueling networks, prioritised replay, n-step returns, distributional value estimates (next topic) and noisy networks for exploration.
- Ablations matter: in Rainbow, prioritised replay and multi-step returns contributed most; the importance of each component depends on the domain.
- Overestimation in actor-critic methods: TD3 (topic L4-5) uses the minimum of two critics, the continuous-action version of the same idea.
- Exact arithmetic for reproducibility: rounding inputs to a binary grid makes matrix products independent of the order of summation, one way to make RL experiments bit-reproducible across machines.
References
- H. van Hasselt (2010). “Double Q-learning.” NeurIPS.
- H. van Hasselt, A. Guez and D. Silver (2016). “Deep reinforcement learning with double Q-learning.” AAAI.
- Z. Wang, T. Schaul, M. Hessel, H. van Hasselt, M. Lanctot and N. de Freitas (2016). “Dueling network architectures for deep reinforcement learning.” ICML.
- T. Schaul, J. Quan, I. Antonoglou and D. Silver (2016). “Prioritized experience replay.” ICLR.
- M. Hessel et al. (2018). “Rainbow: combining improvements in deep reinforcement learning.” AAAI.