Simple Algorithm
Reinforcement Learning · Fixed Point · 28 min

Rainbow: Six Improvements to DQN

Double, dueling, prioritized, multi-step, distributional and noisy, and what each one buys.

Rainbow put six separately published fixes to DQN into one agent, then removed them one at a time to see which mattered. This lesson writes each component as an equation and shows how they fuse into a single loss, proves the two facts the target-side fixes rest on (a small optimism per backup grows by the effective horizon; uncorrected multi-step targets converge to the value of a different control problem), explains why a dueling head must be centered and how factorized noise keeps noisy layers cheap, and reads the ablations closely: what they show, what they cannot, and what a cheaper replication changed.

What you’ll learn

  • Write the target, loss or architecture of each of Rainbow's six components, and how Rainbow fuses them into one multi-step, double, distributional loss with KL priorities.
  • Prove that a backup optimistic by bb everywhere moves the fixed point up by at least b/(1−γ)b/(1-\gamma), and characterize the fixed point of uncorrected nn-step Q-learning targets.
  • Explain what centering identifies in a dueling head, and count the noise variables of factorized and independent noisy layers.
  • Interpret Rainbow's ablations and their small-scale replication, separating findings that held up from ones tied to one combination and budget.

Six components, one loss

Rainbow (Hessel et al., 2018) starts from DQN, with online parameters θ\boldsymbol\theta and a target network θ−\boldsymbol\theta^-, and adds six extensions: five published between 2016 and 2018, and multi-step targets, an old idea (Sutton, 1988) that A3C had recently used with deep networks:

ComponentWhat it computesIn Rainbow
Double Q-learning (van Hasselt et al., 2016)a⋆=arg max⁡a′Qθ(s′,a′)a^\star=\argmax_{a'}Q_{\boldsymbol\theta}(s',a'), scored by the target network at (s′,a⋆)(s',a^\star)Inside the distributional target
Prioritized replay (Schaul et al., 2016)P(i)=pi ω/∑kpk ωP(i)=p_i^{\,\omega}/\sum_kp_k^{\,\omega}, update weights wi=(N P(i))−β/max⁡jwjw_i=(N\,P(i))^{-\beta}/\max_jw_jProportional; ω=0.5\omega=0.5; β\beta from 0.4 to 1
Dueling head (Wang et al., 2016)Q(s,a)=V(s)+A(s,a)−1∣A∣∑a′A(s,a′)Q(s,a)=V(s)+A(s,a)-\frac{1}{\abs{\mathcal A}}\sum_{a'}A(s,a')Per atom, before the softmax
Multi-step targets (Sutton, 1988)Gt:t+n=∑k=0n−1γkRt+k+1+γnmax⁡a′Q(St+n,a′)G_{t:t+n}=\sum_{k=0}^{n-1}\gamma^kR_{t+k+1}+\gamma^n\max_{a'}Q(S_{t+n},a')n=3n=3
Distributional (C51) (Bellemare et al., 2017)Probabilities pi(s,a)p^i(s,a) on atoms z1<⋯<zNz_1<\dots<z_N evenly spaced on [Vmin⁡,Vmax⁡][V_{\min},V_{\max}]51 atoms on [−10,10][-10,10]
Noisy layers (Fortunato et al., 2018)y=(μw+σw⊙εw)x+μb+σb⊙εb\mathbf y=(\boldsymbol\mu^w+\boldsymbol\sigma^w\odot\boldsymbol\varepsilon^w)\mathbf x+\boldsymbol\mu^b+\boldsymbol\sigma^b\odot\boldsymbol\varepsilon^bEvery linear layer; ε\varepsilon-greedy switched off
Rainbow writes the prioritization exponent as ω\omega (Schaul et al. call it α\alpha), keeping α\alpha for the step size.

Four of the six fuse into one loss. The target distribution takes the target network's distribution at St+nS_{t+n}, for the action the online network prefers, shrinks its atoms by γn\gamma^n and shifts them by the truncated return Rt(n)=∑k=0n−1γkRt+k+1R_t^{(n)}=\sum_{k=0}^{n-1}\gamma^kR_{t+k+1}:

dt(n)=(Rt(n)+γnz, pθ−(St+n,a⋆)),a⋆=arg max⁡a∑izi pθi(St+n,a),Lt=DKL(Φzdt(n) ∥ pθ(St,At))d_t^{(n)}=\Big(R_t^{(n)}+\gamma^n\mathbf z,\ \mathbf p_{\boldsymbol\theta^-}(S_{t+n},a^\star)\Big),\qquad a^\star=\argmax_a\sum_iz_i\,p^i_{\boldsymbol\theta}(S_{t+n},a),\qquad\loss_t=\KL\Big(\Phi_{\mathbf z}d_t^{(n)}\ \Big\|\ \mathbf p_{\boldsymbol\theta}(S_t,A_t)\Big)
Φz\Phi_{\mathbf z} projects the shifted atoms back onto the support (Distributional RL); the discount is cut short at a terminal state. Each transition's priority is its loss, pt∝Lt ωp_t\propto\loss_t^{\,\omega}. The dueling streams combine per atom, pθi(s,a)∝exp⁡(vi(s)+ai(s,a)−1∣A∣∑a′ai(s,a′))p^i_{\boldsymbol\theta}(s,a)\propto\exp\big(v^i(s)+a^i(s,a)-\frac{1}{\abs{\mathcal A}}\sum_{a'}a^i(s,a')\big), and every linear layer is noisy.

The settings, identical across all 57 games: learning starts after 80,000 frames (prioritized replay made it safe to start earlier than DQN's 200,000); Adam with step size 6.25×10−56.25\times10^{-5}, a quarter of DQN's, and ϵAdam=1.5×10−4\epsilon_{\text{Adam}}=1.5\times10^{-4}; the target network is refreshed every 32,000 frames; noisy layers start at σ0=0.5\sigma_0=0.5; n=3n=3 (3 and 5 both did well early, 3 best at the end); with KL priorities, performance was robust to ω\omega. A full run of 200 million frames took about 10 days on one GPU.

Check your understanding

Rainbow prioritizes replay by each transition's KL loss rather than by its absolute TD error. Why?

  1. The KL loss is cheaper to compute
  2. With KL priorities no importance-sampling correction is needed
  3. It makes replay closer to on-policy
  4. The distributional agent minimizes the KL loss, so it prioritizes by that loss (a TD error of the mean values could be computed, but it is not what the agent minimizes); the authors also suggest the KL is more robust when returns are random
Show the answer

D. The distributional agent minimizes the KL loss, so it prioritizes by that loss (a TD error of the mean values could be computed, but it is not what the agent minimizes); the authors also suggest the KL is more robust when returns are random

Prioritized replay replays transitions in proportion to a power of how badly they are currently fitted, and for a distributional agent the natural measure is the loss it minimizes. Hessel et al. suggest that KL priorities may be more robust in stochastic environments, because the loss can keep decreasing even when returns are not deterministic. They kept the importance weights, with β\beta annealed from 0.4 to 1.

What the target fixes: double estimates and multi-step returns

Double Q-learning exists because the max in the target is optimistic (Maximization Bias & Double Q-Learning). Why should a small optimism matter? Because bootstrapping compounds it, by a factor set by the effective horizon.

DerivationProof
  1. T⋆Q~ ≥ T⋆(Q⋆+D1)=Q⋆+γD1\mathcal T^\star\tilde Q\ \ge\ \mathcal T^\star(Q^\star+D\mathbf 1)=Q^\star+\gamma D\mathbf 1

    Let D=min⁡s,a(Q~−Q⋆)(s,a)D=\min_{s,a}(\tilde Q-Q^\star)(s,a), finite for a finite MDP, so Q~≥Q⋆+D1\tilde Q\ge Q^\star+D\mathbf 1. T⋆\mathcal T^\star is monotone and shifts constants by γ\gamma, T⋆(Q+c1)=T⋆Q+γc1\mathcal T^\star(Q+c\mathbf 1)=\mathcal T^\star Q+\gamma c\mathbf 1, hence

  2. Q~=T~Q~ ≥ T⋆Q~+b1 ≥ Q⋆+(γD+b)1\tilde Q=\tilde{\mathcal T}\tilde Q\ \ge\ \mathcal T^\star\tilde Q+b\mathbf 1\ \ge\ Q^\star+(\gamma D+b)\mathbf 1

    Apply the optimism of T~\tilde{\mathcal T} at its fixed point:

  3. Q~ ≥ Q⋆+b1−γ1■\tilde Q\ \ge\ Q^\star+\frac{b}{1-\gamma}\mathbf 1\qquad\blacksquare

    Taking the minimum over (s,a)(s,a) gives D≥γD+bD\ge\gamma D+b, that is D≥b/(1−γ)D\ge b/(1-\gamma). For T~=T⋆+b1\tilde{\mathcal T}=\mathcal T^\star+b\mathbf 1, which is a γ\gamma-contraction, Q⋆+c1Q^\star+c\mathbf 1 is a fixed point exactly when c=γc+bc=\gamma c+b, and the fixed point is unique.

Predict before you look

Thrun and Schwartz's estimate: with 18 equally good actions whose estimates carry independent errors uniform on [−0.1,0.1][-0.1,0.1], each backup is optimistic by about b=γ⋅0.1⋅1719b=\gamma\cdot0.1\cdot\frac{17}{19}. With γ=0.99\gamma=0.99, if every backup carried this bias, how far above Q⋆Q^\star would the fixed point sit?

Show the answer

8.9

b=0.99×0.1×0.895≈0.0886b=0.99\times0.1\times0.895\approx0.0886, and b/(1−γ)≈8.9b/(1-\gamma)\approx8.9, on a scale where no clipped Atari return exceeds 1/(1−γ)=1001/(1-\gamma)=100. The model is crude: real errors are neither uniform nor independent nor fresh at every backup. It shows why a bias too small to notice in one backup becomes large in the values when γ\gamma is near 1.

Rainbow's ablation (last step) found little aggregate effect of double Q-learning, and the authors' explanation is this mechanism in reverse. C51's support ends at Vmax⁡=10V_{\max}=10, so values cannot run away upward; true clipped returns often exceeded 10, and the agent without double Q-learning underestimated. Their caveat: with a wider support, double Q-learning may matter again.

Multi-step targets are the other target-side change, and in Rainbow they are uncorrected: the n−1n-1 intermediate actions come from the replayed behavior bb, older ε\varepsilon-greedy or noisy policies, not from the greedy policy being learned, and no importance ratio compensates. With the behavior fixed, the expected target is the operator Bn=(Tb)n−1T⋆\mathcal B_n=(\mathcal T^b)^{n-1}\mathcal T^\star, where Tb\mathcal T^b is the Bellman evaluation operator of bb.

DerivationProof sketch
  1. Qn(s,a)=E[∑k=0n−1γkRt+k+1+γnmax⁡a′Qn(St+n,a′) ∣ St=s, At=a, At+1:t+n−1∼b]Q_n(s,a)=\E\Big[\textstyle\sum_{k=0}^{n-1}\gamma^kR_{t+k+1}+\gamma^n\max_{a'}Q_n(S_{t+n},a')\ \Big|\ S_t=s,\ A_t=a,\ A_{t+1:t+n-1}\sim b\Big]

    Each Tb\mathcal T^b and T⋆\mathcal T^\star is a γ\gamma-contraction in ∥⋅∥∞\norm\cdot_\infty, so their nn-fold composition contracts by γn\gamma^n, and Banach's theorem gives a unique fixed point QnQ_n. Unrolling Qn=BnQnQ_n=\mathcal B_nQ_n:

  2. BnQ⋆≤(T⋆)nQ⋆=Q⋆⟹Qn=lim⁡k→∞BnkQ⋆≤Q⋆\mathcal B_nQ^\star\le(\mathcal T^\star)^nQ^\star=Q^\star\quad\Longrightarrow\quad Q_n=\lim_{k\to\infty}\mathcal B_n^kQ^\star\le Q^\star

    This is the Bellman optimality equation of a problem whose "steps" are blocks of nn real steps: the agent picks the first action of each block and bb the rest. That gives the interpretation. For the inequality: Tb≤T⋆\mathcal T^b\le\mathcal T^\star pointwise (an average is at most a max), and both are monotone, so

  3. If bb is greedy with respect to Q⋆Q^\star then TbQ⋆=T⋆Q⋆=Q⋆\mathcal T^bQ^\star=\mathcal T^\star Q^\star=Q^\star, so Q⋆Q^\star is the fixed point. ■\blacksquare

So uncorrected nn-step targets are biased toward the behavior, and downward, the opposite sign from the max's bias; how the two biases trade off inside a deep agent is rarely measured. What nn-step targets buy is speed: reward propagates nn steps per update, and the bootstrapped estimate is weighted by γn\gamma^n rather than γ\gamma. Unbiased alternatives cut traces with importance ratios (Off-Policy Traces: Tree Backup & Retrace), and in Experience Replay in Depth uncorrected nn-step returns turn out to be what lets larger replay buffers help.

What the network fixes: dueling heads and noisy layers

In many states the choice of action barely matters: what matters is the state. A dueling head (Wang et al., 2016) gives the network a stream for the state's value V(s)V(s) and one for the actions' advantages A(s,a)A(s,a), so that every update at ss, whatever the action, moves the shared V(s)V(s). Adding the two streams naively is ambiguous: (V+c(s), A−c(s))(V+c(s),\,A-c(s)) gives the same QQ for any per-state constant c(s)c(s), so nothing pins down what VV learns.

Proof. Average the mean-centered equation over aa: the two advantage terms cancel, leaving 1∣A∣∑aQ(s,a)=V(s)\frac{1}{\abs{\mathcal A}}\sum_aQ(s,a)=V(s), and subtracting gives the second identity. For the max version, evaluate at a⋆=arg max⁡aA(s,a)a^\star=\argmax_aA(s,a), where Q(s,a⋆)=V(s)Q(s,a^\star)=V(s) and a⋆a^\star also maximizes Q(s,⋅)Q(s,\cdot). ■\blacksquare So the mean-centered VV is an action-average, not VπV^\pi or V⋆V^\star: "off-target by a constant", in Wang et al.'s words. They chose it anyway because it trained more stably: its advantages need only track the mean, instead of compensating whenever the best action's advantage changes. In a corridor task with 5, 10 and 20 actions (the extra ones no-ops), plain and dueling networks learned equally fast with 5 actions, and the dueling network faster with more.

Noisy layers (Fortunato et al., 2018) replace each weight by a learned mean plus a learned scale times fresh noise, so exploration comes from perturbing the network's own preferences, and gradient descent tunes how much perturbation each part of the network keeps; the network can learn to ignore the noise in some states sooner than in others. Rainbow acts greedily (ε=0\varepsilon=0). Independent noise needs a Gaussian sample per weight and per bias, pq+qpq+q for a layer with pp inputs and qq outputs. Factorized noise draws pp samples for the inputs and qq for the outputs and sets εijw=f(εi)f(εj)\varepsilon^w_{ij}=f(\varepsilon_i)f(\varepsilon_j) and εjb=f(εj)\varepsilon^b_j=f(\varepsilon_j) with f(x)=sign⁡(x)∣x∣f(x)=\sign(x)\sqrt{\abs x}: only p+qp+q samples. Means start uniform on [−1/p,1/p][-1/\sqrt p,1/\sqrt p] and scales at σ0/p\sigma_0/\sqrt p with σ0=0.5\sigma_0=0.5.

Think first DQN's largest layer maps p=3136p=3136 inputs to q=512q=512 units. How many Gaussian samples does one noise draw need with independent noise, and with factorized noise? What happens to the number of learnable parameters?

Independent: pq+q=3136⋅512+512=1,606,144pq+q=3136\cdot512+512=1{,}606{,}144. Factorized: p+q=3,648p+q=3{,}648, about 440 times fewer. Either way the learnable parameters double, a mean and a scale for every weight and bias, from 1,606,144 to 3,212,288 in this layer. That cost is why the data-efficient agent BBF later dropped noisy layers: in its larger network they multiplied the computation per forward pass by 2.5 and the memory by 1.6, with no significant effect on its performance (Plasticity Loss & Scaling Deep RL).

Reading the ablations

Hessel et al. removed one component at a time from the full agent and compared median human-normalized scores over 57 games, through 200 million frames:

  • Prioritized replay and multi-step learning mattered most. Removing either caused a large drop in median score and hurt early learning; removing multi-step learning also hurt final performance. Both helped almost uniformly: the full agent beat both ablations on 53 of the 57 games.
  • Distributional learning came next. For the first 40 million frames removing it made no difference; afterwards the agent lagged, mostly on games where it was already near or above human level.
  • Noisy layers helped in aggregate, but removing them gave small gains on some games while causing large drops on several others.
  • Dueling showed no significant aggregate effect and double Q-learning only a limited one, each helping some games and hurting others.
AgentNo-op startsHuman starts
DQN79%68%
Double DQN117%110%
Prioritized Double DQN140%128%
Dueling Double DQN151%117%
Noisy DQN118%102%
Distributional DQN (C51)164%125%
Rainbow223%153%
Median human-normalized scores of the best agent snapshots on 57 games (Hessel et al., 2018, Table 2). The rows come from three sources (the original publications, the dueling-network paper for DQN, and Hessel et al.'s own implementations), so close comparisons between rows are unreliable.

What an ablation of this kind cannot show: the importance of a component in general. It measures each component's contribution inside one combination, at one budget, with hyperparameters tuned for the full agent, through a median over games that hides effects of opposite sign. The double Q-learning result is the clearest example: its effect may have been masked by C51's bounded support. The authors themselves frame the findings "in the context of this specific combination".

Obando-Ceron and Castro (2021) reran the additions to DQN and the removals from Rainbow on four classic-control tasks (CartPole, Acrobot, LunarLander, MountainCar) and five MinAtar games, cheap enough for many seeds and sweeps. They agree that the components' effects vary by environment and that combining all of them gave the best overall agent. They differ on distributional learning: added alone to DQN it sometimes hurt (Acrobot, Freeway), and removing it from Rainbow sometimes helped (MountainCar, Seaquest). They also tested a piece of folk wisdom: with the Adam optimizer, the squared loss beat the Huber loss on all their small environments, and across the 60 Atari games they tested, Adam with the squared loss beat DQN's RMSProp with the Huber loss "overwhelmingly". With RMSProp, the Huber loss did better, which may be why DQN adopted it.

Key takeaways

  • Rainbow fuses nn-step returns (n=3n=3), double Q-learning (online network chooses, target network evaluates) and C51 (KL to the projected target on 51 atoms in [−10,10][-10,10]) into one loss, prioritizes by that loss, and adds a per-atom dueling head and noisy linear layers.
  • A backup optimistic by bb everywhere has a fixed point at least b/(1−γ)b/(1-\gamma) above Q⋆Q^\star: bootstrapping multiplies a small per-backup bias by the effective horizon.
  • Uncorrected nn-step targets are a γn\gamma^n-contraction toward the optimal value of a problem where the behavior picks the intermediate actions, a value at most Q⋆Q^\star.
  • Mean-centering makes the dueling split identifiable (VV is the action-average of QQ) without changing the greedy action; factorized noise needs p+qp+q Gaussian samples per layer instead of pq+qpq+q, though noisy layers still double the parameters.
  • In Rainbow's ablation, prioritization and multi-step returns mattered most, distributional learning mattered late, and dueling and double Q-learning had little aggregate effect, all within one combination and budget; a small-scale replication agreed on the combination but found that distributional learning can hurt on its own.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

Uncorrected nn-step targets, with intermediate actions from a fixed ε\varepsilon-greedy behavior, converge in expectation (tabular, exact updates) to what?

  1. Q⋆Q^\star, because the max at step nn corrects the earlier actions
  2. The optimal value of a problem in which every nn-th action is chosen greedily and the others by the behavior, which is at most Q⋆Q^\star
  3. QbQ^b, the action-value of the behavior policy
  4. Nothing: the expected update is not a contraction, so it may not converge
Show the answer

B. The optimal value of a problem in which every nn-th action is chosen greedily and the others by the behavior, which is at most Q⋆Q^\star

The expected backup is (Tb)n−1T⋆(\mathcal T^b)^{n-1}\mathcal T^\star, a γn\gamma^n-contraction whose fixed point values the behavior's intermediate actions. Since averaging under bb never exceeds maximizing, the fixed point lies below Q⋆Q^\star, approaching it as the behavior approaches greedy.

Question 2

Why does a backup that is optimistic by bb everywhere produce a fixed point at least b/(1−γ)b/(1-\gamma) above Q⋆Q^\star, rather than just bb?

  1. Each backup passes on γ\gamma times the bias already in its inputs and adds bb anew: b+γb+γ2b+⋯=b/(1−γ)b+\gamma b+\gamma^2b+\dots=b/(1-\gamma)
  2. Because the max is taken over about 1/(1−γ)1/(1-\gamma) actions
  3. Because the target network is refreshed every 1/(1−γ)1/(1-\gamma) updates
  4. Because the variance of returns grows like 1/(1−γ)21/(1-\gamma)^2
Show the answer

A. Each backup passes on γ\gamma times the bias already in its inputs and adds bb anew: b+γb+γ2b+⋯=b/(1−γ)b+\gamma b+\gamma^2b+\dots=b/(1-\gamma)

The proof's inequality D≥γD+bD\ge\gamma D+b is exactly this geometric series: the bias inherited from the next state's value, discounted once, plus the new optimism. The factor is the effective horizon, 100 at γ=0.99\gamma=0.99.

Question 3

Which conclusion do Rainbow's ablations support best?

  1. Double Q-learning is unnecessary in deep RL
  2. Every component improved the score on every game
  3. Within this combination and budget, prioritized replay and multi-step returns mattered most, while dueling and double Q-learning had little aggregate effect
  4. Distributional learning was the most important component from the start of training
Show the answer

C. Within this combination and budget, prioritized replay and multi-step returns mattered most, while dueling and double Q-learning had little aggregate effect

That is what removing one component at a time from the full agent measured, through a median over 57 games at 200 million frames. It does not rank the components in general: their effects interact, as when C51's bounded support counteracts the overestimation that double Q-learning targets.

Question 4

A mean-centered dueling head represents some QQ exactly. What does its value stream V(s)V(s) equal?

  1. Vπ(s)V^\pi(s) for the behavior policy
  2. max⁡aQ(s,a)\max_aQ(s,a)
  3. Nothing in particular: the split between VV and AA is arbitrary
  4. The average of Q(s,a)Q(s,a) over the actions
Show the answer

D. The average of Q(s,a)Q(s,a) over the actions

Averaging Q(s,a)=V(s)+A(s,a)−1∣A∣∑a′A(s,a′)Q(s,a)=V(s)+A(s,a)-\frac{1}{\abs{\mathcal A}}\sum_{a'}A(s,a') over aa cancels the advantage terms, leaving V(s)=1∣A∣∑aQ(s,a)V(s)=\frac{1}{\abs{\mathcal A}}\sum_aQ(s,a). Centering is what makes the split identifiable; its choice of center decides what VV means.

Further reading

  • M. Hessel, J. Modayil, H. van Hasselt, T. Schaul, G. Ostrovski, W. Dabney, D. Horgan, B. Piot, M. Azar & D. Silver, "Rainbow: Combining improvements in deep reinforcement learning", AAAI (2018).
  • Z. Wang, T. Schaul, M. Hessel, H. van Hasselt, M. Lanctot & N. de Freitas, "Dueling network architectures for deep reinforcement learning", ICML (2016).
  • M. Fortunato et al., "Noisy networks for exploration", ICLR (2018).
  • J. S. Obando-Ceron & P. S. Castro, "Revisiting Rainbow: Promoting more insightful and inclusive deep reinforcement learning research", ICML (2021).