Search

Search papers and lessons

Rainbow: Combining Improvements in Deep Reinforcement Learning

Matteo Hessel, Joseph Modayil, Hado van Hasselt et al. · 2017

Rainbow puts six separate improvements to DQN into one agent, then removes them one at a time to show which ones carry the gain on 57 Atari games.

On this page

  • Colour = topic mix
  • Reinforcement learning
  • Probability
  • Calculus
  • Discrete math
  • Linear algebra
  • Neural network basics
  • ReadReady to readNot yet

TL;DR

Rainbow is one reinforcement-learning agent that combines six separate improvements to the deep Q-network (DQN) method. The six are: double Q-learning, prioritized replay, a dueling network, multi-step returns, distributional value learning, and noisy networks for exploration. The authors also removed each part in turn to measure what it adds. On 57 Atari games, the full agent reached a median score of 223 percent of human level, far above any single-improvement agent of the time.

Builds on: Deep Q-Network, Double Q-Learning, dueling networks, Prioritized Experience Replay, Distributional Reinforcement Learning, noisy networks · Leads to: the later agents that combine several replay and learning improvements, with Noisy Networks and Prioritized Experience Replay as the two pieces most often read alongside it.

Why it mattered

Rainbow became a common reference point for value-based agents on the Atari benchmark. It showed that improvements which fix different problems in DQN can be stacked, instead of competing. The paper has been cited more than 2,700 times on Semantic Scholar. Its ablation method, which removes one component at a time from a combined agent, became a standard way to ask whether a new piece of a learning system is really needed.

The paper also gave a concrete recipe. It listed the hyperparameters, the network shape, and the training budget, so later groups could reproduce the agent and compare against it.

History in brief. By 2017, DQN had been published in 2015 and had reached human-level play on many Atari games. Several groups then proposed separate improvements. Double Q-learning fixed overestimation. Prioritized replay and the dueling network improved how data and the network were used. Multi-step returns and distributional learning changed the target, and noisy networks changed exploration. Each had been tested alone, usually against plain DQN. Rainbow, from a DeepMind team, tested them together on the same 57-game suite with the same training setup. It was presented at AAAI in 2018, and it caught on because it turned a list of separate papers into one reproducible agent with clear evidence for each part.

The problem

DQN, from Deep Q-Network, learns an action-value function Q(s,a)Q(s, a) with a neural network. It works from raw pixels, but it has several known weaknesses:

  • It overestimates action values, because the same noisy estimate is used both to pick and to score the best next action.
  • It samples its replay memory uniformly, so it spends as much time on transitions it has already learned from as on surprising ones.
  • Its single-step target carries reward information slowly backwards through time.
  • It explores with a fixed [[epsilon-greedy-policy|ϵ\epsilon-greedy rule]], which does not adapt to what the network is unsure about.
  • It estimates only the average return, which throws away information about spread.

Each of these had a published fix. The open question was whether the fixes were complementary, and whether their gains would add up. Rainbow is the paper that tested this directly.

How it works

Rainbow changes the usual DQN loop in six places. Here is the path of one transition, from the moment the agent acts to the moment the network learns from it.

  1. Act. The agent sees a stack of recent frames, passes it through a Convolutional Neural Network, and gets a return distribution for each action. It does not add an ϵ\epsilon term, because its noisy layers already make it explore.
  2. Store. The transition (state, action, reward, next state) goes into a replay buffer, tagged with the highest priority seen so far. New transitions get extra priority so they are reviewed soon.
  3. Sample. Transitions are drawn at random, but with probability that grows with their priority. Each one also gets an importance weight that corrects for the non-uniform sampling.
  4. Build a multi-step target. Instead of one reward, the target sums three rewards and then bootstraps from the state three steps later.
  5. Choose and score. The online network picks the best next action. The slower target network scores that action. Together they give a distribution to aim at.
  6. Learn and reprioritise. The loss is the distance between the predicted distribution and the target. That loss is also used as the new priority for this transition.

A tiny instance of step 4, with three rewards of 1, 0 and 2 and a discount of 0.9 per step (chosen for illustration; the paper uses 0.99 in its experiments):

  1. Rewards are R1=1R_1 = 1, R2=0R_2 = 0, R3=2R_3 = 2.
  2. The weights are 11, γ=0.9\gamma = 0.9 and γ2=0.81\gamma^2 = 0.81.
  3. Multiply each reward by its weight: 1⋅1=11 \cdot 1 = 1, 0⋅0.9=00 \cdot 0.9 = 0, 2⋅0.81=1.622 \cdot 0.81 = 1.62.
  4. Add them: 1+0+1.62=2.621 + 0 + 1.62 = 2.62. Check: the third reward is multiplied by 0.9 twice, so 0.81 is right.
  5. The bootstrap value is then multiplied by 0.93=0.7290.9^3 = 0.729, not by 0.9.
  6. Interpretation: the reward two steps ahead still counts, but less than a reward now.

A tiny network, to show how the two streams make action values. Here the return distribution sits on fixed support points called atoms, each with a probability, and its mean is the action value. Suppose there are two atoms, z1=−1z_1 = -1 and z2=1z_2 = 1, and two actions. For one state the value stream gives v=(0,0)v = (0, 0), and the advantage stream gives a(⋅,left)=(0.5,−0.5)a(\cdot, \text{left}) = (0.5, -0.5) and a(⋅,right)=(−0.5,0.5)a(\cdot, \text{right}) = (-0.5, 0.5).

  1. The mean advantage over the two actions is (0,0)(0, 0) for each atom, because 0.5−0.5=00.5 - 0.5 = 0 and −0.5+0.5=0-0.5 + 0.5 = 0.
  2. For left, the logits are (0.5,−0.5)(0.5, -0.5). Softmax gives p≈(0.731,0.269)p \approx (0.731, 0.269).
  3. Its expected value is Q=(−1)(0.731)+(1)(0.269)=−0.462Q = (-1)(0.731) + (1)(0.269) = -0.462.
  4. For right, the logits are (−0.5,0.5)(-0.5, 0.5), which gives p≈(0.269,0.731)p \approx (0.269, 0.731) and Q=0.462Q = 0.462.
  5. Interpretation: right is the greedy action. The advantage stream encoded the difference, and the softmax turned the atom scores into a distribution whose mean is the Q value.

The pipeline in one picture:

flowchart LR
  A[Stack of frames] --> B[Conv encoder]
  B --> C[Dueling streams<br/>value and advantage]
  C --> D[Softmax over atoms<br/>per action]
  D --> E[Expected Q for each action]
  E --> F[Act greedily, noisy layers explore]
  F --> G[Replay buffer<br/>priority by loss]
  G --> H[3-step target<br/>online net picks, target net scores]
  H --> I[KL loss between distributions]
  I --> G

The math

Write the discounted return as in Discounted Return. The three-step return used by Rainbow is

Rt(n)=∑k=0n−1γkRt+k+1,n=3,R_t^{(n)} = \sum_{k=0}^{n-1} \gamma^k R_{t+k+1}, \qquad n = 3,

where Rt+k+1R_{t+k+1} is the reward kk steps after time tt and γ\gamma is the discount factor.

Step 4 in symbols: the multi-step target

The bootstrap uses the state St+nS_{t+n} and the discount γn\gamma^n. The paper writes the target as a distribution. Let z1,…,zNz_1, \ldots, z_N be fixed support points ("atoms") spread evenly between Vmin⁡=−10V_{\min} = -10 and Vmax⁡=10V_{\max} = 10, with N=51N = 51. The predicted return distribution for state ss and action aa puts probability pi(s,a)p_i(s, a) on atom ziz_i, and its expected value is

Q(s,a)=∑i=1Nzi pi(s,a).Q(s, a) = \sum_{i=1}^{N} z_i \, p_i(s, a).

The target distribution is the bootstrap distribution shifted by the truncated return and squeezed by the discount:

dt(n)=(Rt(n)+γnz,  pθˉ(St+n,at+n∗)),d_t^{(n)} = \left( R_t^{(n)} + \gamma^n z, \; p_{\bar\theta}(S_{t+n}, a^*_{t+n}) \right),

where θˉ\bar\theta are the target-network weights, and at+n∗a^*_{t+n} is the greedy action.

Step 5 in symbols: choose with one network, score with another

The double-Q part chooses the bootstrap action with the online weights θ\theta and scores it with the target weights θˉ\bar\theta:

at+n∗=arg⁡max⁡aQθ(St+n,a).a^*_{t+n} = \arg\max_{a} Q_\theta(S_{t+n}, a).

Using a single set of weights for both steps would reward whichever action happened to get an overestimate. Splitting the two roles removes that upward bias. This is the same idea as in Double Q-Learning, applied to the distribution.

Step 6 in symbols: the loss and the priority

Let Φz\Phi_z project the shifted target back onto the fixed atoms zz, so the two distributions have the same support. The loss is the KL divergence from Kullback–Leibler Divergence:

Lt=DKL(Φzdt(n) ∥ dt).L_t = D_{\mathrm{KL}}\big( \Phi_z d_t^{(n)} \,\|\, d_t \big).

Transitions are then sampled with priority

pt∝(Lt)ω,ω=0.5.p_t \propto \big( L_t \big)^{\omega}, \qquad \omega = 0.5.

The paper uses the loss, not the absolute TD error, as the priority, because the KL loss can keep falling in stochastic environments even when the true return is not fixed.

The network in symbols

The shared trunk fξ(s)f_\xi(s) feeds a value stream vηv_\eta with NN outputs and an advantage stream aψa_\psi with N×∣A∣N \times |\mathcal{A}| outputs. For each atom ii, the two streams are combined as in the dueling network and passed through a Softmax over atoms:

pθi(s,a)=exp⁡(vηi+aψi(ϕ,a)−aˉψi(s))∑jexp⁡(vηj+aψj(ϕ,a)−aˉψj(s)),p_\theta^i(s, a) = \frac{\exp\big( v^i_\eta + a^i_\psi(\phi, a) - \bar a^i_\psi(s) \big)}{\sum_j \exp\big( v^j_\eta + a^j_\psi(\phi, a) - \bar a^j_\psi(s) \big)},

where ϕ=fξ(s)\phi = f_\xi(s) and aˉψi(s)\bar a^i_\psi(s) is the mean of the advantage over actions. Subtracting that mean is what makes the split between value and advantage unique, as explained in Advantage Function.

Results

The main numbers are median human-normalised scores over the 57 games. Human-normalised means each game's score is scaled so that random play is 0 and the human baseline is 100.

  • Rainbow, no-op starts: 223 percent. Human starts: 153 percent.
  • DQN (from the dueling paper's numbers): 79 and 68 percent.
  • Dueling DDQN: 151 and 117 percent. Prioritised DDQN: 140 and 128 percent. Distributional DQN: 164 and 125 percent. Noisy DQN: 118 and 102 percent. A3C: 116 percent with human starts.
  • Learning speed: Rainbow matches DQN's final score after 7 million frames, far earlier in training than DQN needs.

Try it: Rainbow reaches 223 percent with no-op starts, and DQN reaches 79. What is the gap in percentage points, and what is the ratio? Answer: the gap is 223−79=144223 - 79 = 144 points, and the ratio is 223/79≈2.82223 / 79 \approx 2.82. With human starts the gap is 153−68=85153 - 68 = 85 points.

The ablation results change the picture:

  • Removing prioritised replay or multi-step learning causes the largest drops in median score.
  • Removing the distributional part or the noisy networks causes smaller drops.
  • Removing the dueling network makes little difference in aggregate.

It is tempting to think Rainbow is a new algorithm. In fact it is six existing ideas, each with its own paper, and its contribution is the test of how well they fit together. The paper shows that they are largely complementary, because they fix different problems.

It is also tempting to think that more components always help. The ablations show that the components differ a lot in value. Stacking more parts costs compute and tuning time, because each one brings its own hyperparameters. The authors tuned only by a limited manual search, starting from each component's original paper, so the reported numbers are one careful setting, not the best possible one.

Limits: the results are on Atari games with a fixed frame budget. They say nothing about continuous control, partial observation, or real-world robots. The median hides large differences between games, which is why the paper also shows per-game gains. The tradeoff to keep in mind: the combined recipe is a strong value-based baseline with a discrete action set and a large data budget. For continuous actions, scarce data, or a budget where a single extension is enough, a plain DQN or a policy-gradient method is simpler.

Reading guide

The lesson's chain of ideas: DQN has several separate weaknesses, six fixes address different ones, Rainbow wires all six into one loss and one network that outputs a distribution over atoms for each action, and the ablations show that prioritised replay and multi-step learning matter most. Read the paper in its order, with these prerequisites at hand.

Check yourself

QuestionName the six components that Rainbow combines.Show answer

Double Q-learning, prioritised replay, the dueling network architecture, multi-step learning, distributional value learning, and noisy networks for exploration.

QuestionWith rewards 2, 1, 0, a discount of 0.5, and n = 3, what is the three-step return?Show answer

The sum is 2+0.5⋅1+0.25⋅0=2.52 + 0.5 \cdot 1 + 0.25 \cdot 0 = 2.5. Each later reward is multiplied by one more factor of 0.5, and the third reward is zero, so it adds nothing.

QuestionWhy does Rainbow use the online network to pick the bootstrap action and the target network to score it?Show answer

If one network both chose and scored the action, the action with the highest noisy estimate would also get the highest score, which biases the target upward. Splitting the roles, as in double Q-learning, removes most of that bias.

QuestionIn an ablation, removing a component drops Rainbow's median score a lot but barely changes its per-game scores in most games. What would you conclude, and what would you check before trusting it?Show answer

The component matters for the median, which is driven by many mid-level games, but it may help a few games a lot and not others. Check the per-game breakdown and the learning curves over time, because the median can hide changes in individual games and the timing of the gain.

Sources

Read the full paper

Matteo Hessel, Joseph Modayil, Hado van Hasselt et al., 2017. arXiv:1710.02298