Skip to content

Rainbow: six fixes to DQN, and how to tell which mattered

Rainbow combines double targets, dueling heads, prioritized replay, n-step returns, distributional values and noisy networks. Learn what each part does, project a return distribution onto fixed atoms, and read an ablation honestly.

Advanced ~13 min8 steps

What runs in CodeSplash

You will be able to

  • Name Rainbow's six components and the problem each addresses
  • Project a shifted return distribution back onto fixed atoms
  • Explain the bias prioritized replay introduces and how it is corrected
  • Read an ablation table without over-generalizing it

Read first

01

Six parts

Read

RainbowRainbow DQNDQN with six additions combined: double targets, dueling heads, prioritized replay, n-step returns, distributional values, noisy nets. put six DQN extensions into one agent:

PartWhat it fixes
Double Q targetsOverestimation from the max
Dueling headLearning state values when actions barely matter
Prioritized replayPrioritized experience replayReplay transitions with large TD errors more often, with importance weights to correct the bias that introduces.Replaying informative transitions more often
n-step returnsn-step returnSum n real rewards before bootstrapping from a value estimate: less bias than one step, more variance.Slow propagation of rewards through one-step targets
Distributional valuesDistributional RL (C51)Learn the whole distribution of returns on fixed atoms instead of only its mean; the Bellman target is projected back onto the atoms.Learning only the mean of an uncertain return
Noisy networksExploration by random actions alone

CodeSplash's DQN has the first two; the rest are explained here.

02

Distributions on fixed atoms

Read

Distributional RL learns the probability of each return value on a fixed grid of atoms z1,…,zKz_1, \dots, z_K. The Bellman target shifts and shrinks the next state's distribution, r+γzjr + \gamma z_j, which no longer lands on the grid. Each shifted atom's probability is split between its two neighboring grid points, in proportion to how close it lands.

In the reference's example, three atoms at −1, 0 and 1 are shifted and projected back; the result is 0.1, 0.4 and 0.5, still summing to one. The network is trained with the cross-entropy to that projection, here 1.030.

03

Priorities need a correction

Read

Prioritized replay samples transitions with probability rising with their TD error. That speeds learning, but the gradient no longer averages over the buffer as it should: high-error transitions are over-represented. Importance weights, inversely related to each transition's sampling probability, scale its update back, usually more strongly as training goes on.

n-step returns add nn real rewards before bootstrapping: rewards travel back faster, at the cost of more variance and of mixing in the old behavior's actions.

04

Reading the ablation

Read

Rainbow's paper removed one part at a time. On its benchmark, dropping prioritized replay or n-step returns hurt most, and dropping the dueling head or double targets hurt little.

Treat that as a result about that benchmark, those settings and that budget. Parts interact: double targets may matter less once distributional values change the target. A different task or a tuned baseline can reorder the list. And a gain measured on a handful of seeds needs an interval before anyone ranks it.

05

Predict: removing a part

Predict

Predict first

Rainbow's ablation found the dueling head added little. You're building an agent for a new task. Should you drop the dueling head?

It will matter little on your task tooYou can't tell without testing on your task with several seeds
Reveal

You can't tell without testing. Ablations rank parts for one benchmark and budget; interactions change on another task. Compare with and without it on your task, over several seeds.

06

What runs here

Read
07

Check: Rainbow

Checkpoint

Check yourself

A shifted atom lands at 0.25 on a grid with points at 0 and 1. How is its probability p split?

Show the answer

Answer: a

The split is linear in distance: the closer neighbor gets the larger share, and the total stays p.

Check yourself

Why does prioritized replay need importance weights?

Show the answer

Answer: a

Without the correction, the network fits the high-error transitions more than the data distribution warrants.

Check yourself

Which of Rainbow's parts are options of CodeSplash's decide.rl_dqn?

Show the answer

Answer: a

The other four are explained here; the Policy learning studio's small environments rarely need them.

Check yourself

What do n-step returns trade?

Show the answer

Answer: a

Each extra real reward adds noise but relies less on a possibly wrong value estimate.

08

Recap

Recap
  • Rainbow combines double targets, dueling heads, prioritized replay, n-step returns, distributional values and noisy nets.
  • Distributional RL projects shifted returns back onto fixed atoms and trains with cross-entropy.
  • Prioritized replay needs importance weights to undo its sampling bias.
  • An ablation ranks parts for one benchmark and budget; test on your own task with several seeds.

Concepts in this lesson