Modern Deep Reinforcement Learning/Distributional RL and Rainbow

Lesson 5.22,082 words

Distributional RL and Rainbow

A companion to the DQN improvements lesson. C51 fixed the return atoms and learned their probabilities; QR-DQN does the reverse — fix the probabilities, learn the values — which removes the projection and trains with a quantile loss.

╌╌╌╌

This builds on Sharpening DQN: Improvements and the Distributional Idea, which recapped the five improvements that keep the scalar -value and then developed the sixth — distributional RL — through the distributional Bellman equation and the C51 algorithm. Recall the shift: the return is a random variable, is only its mean, and C51 learns the whole distribution by fixing a grid of return atoms and learning a probability for each, snapping every Bellman-updated distribution back onto the grid with a projection .

This lesson picks up the complement to C51, folds all six improvements into one agent — Rainbow — and follows the distributional line to its modern endpoint.

Quantile methods: QR-DQN

C51 fixes a set of return values and learns how much probability sits on each. The equally natural dual is to fix the probabilities and learn where the return values sit. That swap is QR-DQN, and it removes the projection step.

QR-DQN: learn the quantiles instead

C51 fixes the return values and learns their probabilities. QR-DQN (Dabney et al., 2018) does the reverse: fix the probabilities and learn the return values.1 It represents by quantiles — the network outputs values , one for each of the fixed cumulative probabilities (the midpoints of equal-probability bins). The distribution is a mixture of point masses at the learned locations,

Swapping which axis is fixed removes the projection entirely: because the support is learned, the Bellman-updated atoms need not be snapped back onto a grid. In its place QR-DQN minimizes the quantile (Huber) regression loss, which trains each toward the -quantile of the target return distribution. The trade is clean: C51 carries a fixed support and a projection but a simple cross-entropy; QR-DQN drops the support constraint and the projection but pays with an asymmetric quantile loss. Both learn a distribution; they differ only in which coordinate of the histogram they let the network move.

The asymmetry is what makes a regression target a quantile estimate. Ordinary squared error, minimized, returns the mean; the pinball loss at level weights over- and under-shoots differently,

and its minimizer is the -quantile of the target. Here is the target minus the estimate, so means the estimate sat below the target (an under-estimate). If the loss is ; if it is . For an under-estimate () is penalized as hard as an over-estimate, so the estimate is dragged upward until only of the target mass remains above it — the definition of the -quantile. QR-DQN replaces the kink at with a Huber softening (the quantile Huber loss) for a smoother gradient near zero. For example, to estimate the median () of target samples , the pinball loss weights overshoot and undershoot equally, so it is minimized at the middle value — the sample median — whereas squared error would return the mean , pulled up by the outlier. Fixing recovers the median; sweeping across the heads recovers the whole distribution.

The pinball (quantile) loss at level tau=0.9, with u = target minus estimate. Under-estimates (u>0) are weighted by tau=0.9 and cost steeply; over-estimates (u<0) by 1-tau=0.1 and cost gently, so the minimizer rises to the 0.9-quantile. Squared error (dashed) is symmetric and returns the mean instead.
Two ways to represent the same return distribution. C51 (left) fixes the return atoms on the horizontal axis and learns the bar heights (probabilities); QR-DQN (right) fixes the probabilities (equal-height bars) and learns the atom positions along the return axis.

Why the distribution helps even when you act on the mean

C51 and QR-DQN still select actions by — the extra information is thrown away at decision time. So why does modeling the full distribution improve the resulting policy? Three reasons the papers give.2 First, the distributional target is a richer, denser learning signal: predicting fifty-one probabilities (or fifty-one quantiles) per action shapes the representation with far more constraints than a single scalar, and a better representation yields a better-estimated mean. Second, it interacts well with function approximation: a categorical target reframes the regression as a classification over atoms, whose cross-entropy loss is better-behaved for a neural network than chasing a moving scalar, and it keeps predictions bounded to . Third, learning the distribution appears to reduce the chattering and instability that plague approximate value iteration, giving more stable updates. The mean you act on is simply estimated better when it is estimated as one summary of a distribution the network was forced to get right.

Rainbow: all six at once

Each improvement was published on its own, measured against the DQN baseline. The natural question — do they add up, or do they overlap and cancel? — is what Rainbow (Hessel et al., 2018) answered by integrating all six into one agent and measuring the whole.3 The integration is mostly a matter of choosing compatible pieces:

  • The value head is C51's distributional output, and the network uses the dueling decomposition — but applied to the atom logits: a shared state-value stream and a per-action advantage stream, combined before the softmax.
  • The target is the multi-step () distributional target, run through Double-DQN action selection: the online network picks , the target network supplies its distribution.
  • Transitions are drawn by prioritized replay, with the priority set to the distributional loss (the KL / cross-entropy) rather than the absolute TD error, since there is no longer a scalar TD error to take the absolute value of.
  • Exploration is NoisyNets throughout, so the schedule is dropped entirely.
Rainbow as one Q-learning loop with each of the six improvements dropped into a different slot. Prioritized replay picks the data; the multi-step Double-DQN distributional target sets the regression target; the dueling distributional head is the network; NoisyNets replaces the exploration. Because the slots are distinct, the six compose without conflict.

Nothing here is a new algorithm; it is the same Q-learning skeleton — act, store, sample, form a bootstrapped target, regress toward it, periodically sync the target network — with a distributional head, a multi-step Double-DQN target, prioritized sampling, and learned exploration noise all slotted in at once. On the 57-game Atari benchmark Rainbow set a new state of the art in both final score and sample efficiency: it reached the previous best DQN's performance in a fraction of the frames.

The ablation

The paper's most cited figure is the ablation study: retrain Rainbow six times, each run with one component removed, and compare against the full agent. A component matters in proportion to how much removing it hurts. Some of the results were unexpected.3

Rainbow ablation (schematic, following Hessel et al. 2018). Each curve is the full agent with one component removed; a curve that falls well below the full Rainbow marks a component that contributes strongly. Prioritized replay and the multi-step target hurt most when removed; removing Double DQN barely moved the distributional agent.

Prioritized replay and multi-step returns were the two most important components: removing either produced the largest drop, and multi-step in particular sped up early learning across almost every game. The distributional head was next, its contribution growing over training and dominating in the later stages — evidence that the richer target matters most late in training. Dueling and NoisyNets helped moderately, each carrying a subset of games. Double DQN, on its own, barely mattered inside Rainbow — the distributional target already bounds the values and curbs the overestimation that Double DQN was invented to fix, so its separate correction becomes largely redundant. That last finding is the clearest illustration of why an integrated study was needed: a component's value is not a fixed property but depends on what else is in the agent.

Component removedEffect when ablatedReading
Prioritized replaylarge dropmost important single component
Multi-step returnslarge drop, worst earlyfastest early learning
Distributional (C51)drop, growing laterichest target, pays off over time
Duelingmoderate drophelps on a subset of games
NoisyNetsmoderate dropbetter exploration on hard-exploration games
Double DQNnegligibleredundant given the distributional head

Beyond Rainbow: implicit quantiles, full parametrization, and Agent57

Rainbow was not the end of the distributional line. Work after 2018 made the return distribution more expressive while keeping the same Q-learning skeleton, then folded the result into agents that finally cleared the whole Atari suite.

IQN (Dabney et al., 2018) turns QR-DQN's fixed quantile levels into a continuous sampling of them.4 QR-DQN learns heads at the fixed levels . IQN instead learns a single network that, given a quantile level sampled fresh, outputs the return at that level — an implicit quantile function . Because is an input, the network represents the entire inverse CDF rather than a fixed histogram, and the action value is a Monte Carlo average over sampled levels. Two payoffs follow. First, expressiveness is no longer capped by a head count: more samples buy a finer distribution at test time without retraining. Second, the sampling of can be reshaped to encode risk sensitivity — the reason the distributional view matters even though the agents still act on the mean. Sample from the low end and the induced policy is risk-averse (it optimizes a conservative quantile, a CVaR-like objective); sample from the high end and it is risk-seeking. On the 57-game Atari benchmark IQN surpassed Rainbow's distributional component and closed much of the gap to a full Rainbow with far less machinery.

FQF (Yang et al., 2019) takes the last step: it also learns where to place the quantile levels.5 IQN samples uniformly; FQF adds a small fraction proposal network that outputs an adjusted set of values, trained to minimize the -Wasserstein distance between the quantile approximation and the true distribution — so the atoms cluster where the distribution has structure and thin out where it is flat. It is the fully-parametrized quantile function: both the levels and the values are learned, generalizing C51 (fixed values, learned probabilities) and QR-DQN (fixed probabilities, learned values) at once.

The distributional family by what each fixes and learns. C51 fixes the return atoms and learns probabilities; QR-DQN fixes quantile levels and learns return values; IQN samples levels continuously; FQF learns the levels too. Each step frees one more coordinate of the return distribution.

The endpoint of the value-based line is Agent57 (Badia et al., 2020), the first agent to exceed the human baseline on all 57 Atari games — including the hard-exploration holdouts Montezuma's Revenge and Pitfall that had resisted every DQN-style method.6 It layers three things onto the distributional Q-learning core: a family of policies indexed by a discount and an exploration weight, so a single network holds both near-sighted exploiting policies and far-sighted exploring ones; a separate intrinsic-reward stream (the never-give-up novelty bonus) to drive the hard-exploration games; and a bandit that picks, per episode, which policy in the family to follow. The distributional head is still there — the ancestry runs straight from C51 through Rainbow and IQN — but the win on the last few games came from bolting on the directed exploration this course treats in the exploration lesson. Value-based deep RL, begun by DQN and consolidated by Rainbow, was completed when the distributional target was combined with a serious exploration mechanism.

Where this leaves value-based deep RL

Every improvement from DQN to Rainbow kept the Q-learning frame — act, store to a replay buffer, sample a mini-batch, build a bootstrapped target with a frozen target network, regress toward it — and changed exactly one slot: the target (Double DQN, multi-step), the network (dueling), the sampling (prioritized replay), the exploration (NoisyNets), or the thing being predicted (distributional). Because they touched different slots they composed, and Rainbow's ablation confirmed that the sum genuinely exceeds any part.

The deepest of the six, distributional RL, is the one that reframed the objective: learn the return distribution and recover as a by-product. That perspective — a value is a distribution, not a number — carries beyond discrete-action Atari. It reappears in the distributional critics of continuous-control agents and in risk-sensitive control, where an agent that knows the spread of returns, not just their mean, can prefer the safe action over the equal-mean gamble. Rainbow is the endpoint of the value-based line begun by DQN; the policy-based and model-based lines take up from actor-critic and PPO and model-based RL.

Footnotes

  1. Dabney et al. (2018), Distributional Reinforcement Learning with Quantile Regression, AAAI — the QR-DQN complement to C51: fix equal-probability quantile levels and learn the atom locations , eliminating the projection and training with the quantile (Huber) regression loss.
  2. Bellemare, Dabney & Munos (2017), A Distributional Perspective on Reinforcement Learning, ICML — the return distribution with , the distributional Bellman equation , and the C51 algorithm: fixed atoms on , a softmax over atoms, the categorical projection of the scaled-shifted target onto the fixed grid, and a cross-entropy loss; state of the art on Atari while acting on the mean.
  3. Hessel et al. (2018), Rainbow: Combining Improvements in Deep Reinforcement Learning, AAAI — the integrated agent combining Double DQN, dueling networks, prioritized replay, multi-step returns, distributional (C51) learning, and NoisyNets; new state of the art on the 57-game Atari benchmark with markedly better sample efficiency; and the component ablation showing prioritized replay and multi-step returns most important, the distributional head growing in importance over training, and Double DQN largely redundant given the distributional target. 2
  4. Dabney, Ostrovski, Silver, Munos (2018), Implicit Quantile Networks for Distributional Reinforcement Learning, ICML — represents the return's inverse CDF by a network taking a sampled quantile level as input, , so the full distribution is learned rather than a fixed histogram; enables risk-sensitive policies by reshaping the sampling of ; surpasses QR-DQN and Rainbow's distributional component on Atari.
  5. Yang, Zhao, Lin, Qin, Bian, Liu (2019), Fully Parameterized Quantile Function for Distributional Reinforcement Learning, NeurIPS — FQF adds a fraction-proposal network that learns the quantile levels (minimizing the -Wasserstein error) on top of IQN's learned quantile values, so both coordinates of the quantile function are parameterized.
  6. Badia, Piot, Kapturowski, Sprechmann, Vitvitskyi, Guo, Blundell (2020), Agent57: Outperforming the Atari Human Benchmark, ICML — the first agent above the human baseline on all 57 Atari games; a parameterized family of policies over discounts and exploration weights, a never-give-up intrinsic-reward stream for hard-exploration games, and a meta-controller (bandit) selecting the policy per episode, on a distributional Q-learning core.

╌╌ END ╌╌