Simple Algorithm
Reinforcement Learning · Fixed Point · 26 min

Exploration Bonuses at Scale

Counts, pseudo-counts, curiosity and random network distillation in deep RL.

Counting visits is the backbone of provable exploration, and it breaks the moment no state is ever seen twice. Deep RL replaced counts with density models, hashes, prediction errors and episodic memories, and pushed Montezuma's Revenge from near-zero scores to superhuman play. This lesson examines what each bonus actually measures, what the landmark experiments showed and did not show, and why a television full of static still haunts the field.

What you’ll learn

  • Explain why count-based bonuses β/N(s,a)\beta/\sqrt{N(s,a)} are justified in tabular MDPs and why they fail when observations never repeat.
  • Compare pseudo-counts, hashing, elliptical bonuses, prediction-error curiosity (ICM) and random network distillation by what they measure and how they fail.
  • Decompose prediction error into epistemic and aleatoric parts, and use it to explain the noisy-TV problem and what RND and inverse-dynamics features do about it.
  • Describe episodic novelty (NGU), the bandit meta-controller of Agent57, and Go-Explore's answer to detachment and derailment.
  • State precisely what the key experiments established, and the controls and caveats that qualify them.

From counts to bonuses

In a tabular MDP, optimism can be implemented as a reward bonus. MBIE-EB (Strehl & Littman, 2008) plans with r^(s,a)+β/N(s,a)\hat r(s,a)+\beta/\sqrt{N(s,a)}, where N(s,a)N(s,a) counts visits: the bonus is a confidence width, as in UCB, and with β\beta chosen from the horizon and the confidence level the algorithm is PAC-MDP. Deep RL keeps the recipe, an extrinsic reward plus a scaled intrinsic one, rt+β rtir_t+\beta\,r^{i}_t, and changes what rir^i measures. This is intrinsic motivation, and count-based exploration is its best-understood form.

The trouble is that counts need repetition. In an Atari game, almost every frame is new, so N(s)N(s) is 0 or 1 everywhere and a count bonus is uniformly uninformative. Every method below is a way of saying "this state is like states I have seen many times" without exact repeats.

FamilyIntrinsic rewardMeasuresTypical failure
Pseudo-counts, hashingβ/N^(s)\beta/\sqrt{\hat N(s)} from a density model or a hash of ssHow familiar ss is, through a generalizing countDepends on what the model or hash treats as similar
Ellipticalϕ(s)⊤C−1ϕ(s)\phi(s)^\top C^{-1}\phi(s), CC the feature covarianceNovelty of ss in feature spaceOnly as good as the features ϕ\phi
Forward-model curiosityError of predicting st+1s_{t+1} (or its features)Surprise about the dynamicsRewards irreducible noise: the noisy TV
Random network distillationError of predicting a fixed random function of ssNovelty of ssAny genuinely new observation, relevant or not
Episodic memoryNovelty relative to this episode's memoryCoverage within an episodeNeeds a good embedding; fails if states never repeat
The main families of deep exploration bonuses. Go-Explore, discussed last, is not a bonus at all: it remembers states and returns to them.

Generalized counts

Pseudo-counts (Bellemare et al., 2016) derive a count from any sequential density model: if the model assigns probability ρn(x)\rho_n(x) to a state, and ρn′(x)\rho_n'(x) after one more update on it, the pseudo-count is N^n(x)=ρn(x)(1−ρn′(x))/(ρn′(x)−ρn(x))\hat N_n(x)=\rho_n(x)(1-\rho_n'(x))/(\rho_n'(x)-\rho_n(x)), which equals the empirical count when the model is a table. Their Theorem 1 ties it to information gain: with PGn=ln⁡ρn′(x)−ln⁡ρn(x)\mathrm{PG}_n=\ln\rho'_n(x)-\ln\rho_n(x) the model's prediction gain and IGn\mathrm{IG}_n the information gain of a mixture model, IGn(x)≤PGn(x)≤N^n(x)−1\mathrm{IG}_n(x)\le\mathrm{PG}_n(x)\le\hat N_n(x)^{-1} and PGn(x)≤N^n(x)−1/2\mathrm{PG}_n(x)\le\hat N_n(x)^{-1/2}. A bonus ∝N^−1/2\propto\hat N^{-1/2} therefore explores at least as much as an information-gain bonus. With a simple pixel density model (CTS) and the bonus β(N^+0.01)−1/2\beta(\hat N+0.01)^{-1/2}, a DQN agent learned within 50 million frames a policy that consistently navigated 15 of the 24 rooms of Montezuma's Revenge's first level, where most published agents had explored only a few. Ostrovski et al. (2017) replaced CTS by a PixelCNN density model.

Hashing (Tang et al., 2017) skips the density model: map a state to a binary code, ϕ(s)=sgn⁡(Ag(s))∈{−1,1}k\phi(s)=\operatorname{sgn}(Ag(s))\in\{-1,1\}^k with AA a random Gaussian k×Dk\times D matrix and gg a preprocessing (SimHash), and count codes. The code length kk sets the granularity: too coarse and distinct situations collide, too fine and nothing repeats.

Elliptical bonuses generalize counts to continuous features. E3B (Henaff, Raileanu, Jiang & Rocktäschel, 2022) uses, within each episode, b(st)=ϕ(st)⊤Ct−1−1ϕ(st)b(s_t)=\phi(s_t)^\top C_{t-1}^{-1}\phi(s_t) with Ct−1=∑i<tϕ(si)ϕ(si)⊤+λIC_{t-1}=\sum_{i<t}\phi(s_i)\phi(s_i)^\top+\lambda I and ϕ\phi learned by an inverse-dynamics model. It is the exploration width of linear bandits: the same quadratic form sets LinUCB's bonus (Linear Bandits: LinUCB & OFUL).

Predict before you look

Take one-hot features, ϕ(s)=es\phi(s)=e_s, and λ=0.1\lambda=0.1. A state already visited 3 times in this episode is visited again. What elliptical bonus es⊤(∑iϕ(si)ϕ(si)⊤+λI)−1ese_s^\top(\sum_i\phi(s_i)\phi(s_i)^\top+\lambda I)^{-1}e_s does it receive?

Show the answer

0.32

With one-hot features the matrix is diagonal with entries N(s)+λN(s)+\lambda, so the bonus is 1/(N(s)+λ)=1/3.1≈0.321/(N(s)+\lambda)=1/3.1\approx0.32: an inverse count. With learned features, visits to similar states also enlarge CC in the relevant directions, which is how the elliptical bonus generalizes a count.

Prediction error: curiosity and random network distillation

Curiosity rewards surprise. The intrinsic curiosity module (ICM; Pathak, Agrawal, Efros & Darrell, 2017) trains its features ϕ\phi on an inverse-dynamics task, recovering the action ata_t from ϕ(st)\phi(s_t) and ϕ(st+1)\phi(s_{t+1}), so the features retain the parts of the observation that the agent's actions affect. A forward model then predicts ϕ(st+1)\phi(s_{t+1}) from ϕ(st)\phi(s_t) and ata_t, and its squared error in feature space, η2∥ϕ^(st+1)−ϕ(st+1)∥2\tfrac\eta2\norm{\hat\phi(s_{t+1})-\phi(s_{t+1})}^2, is the intrinsic reward.

A large-scale study (Burda, Edwards, Pathak, Storkey, Darrell & Efros, 2019) ran agents on curiosity alone, with no extrinsic reward, in 54 environments including the Atari suite. Many reached substantial game scores anyway, which the authors read as evidence that game designers align progress with novelty. Two design findings stuck: frozen random features were sufficient on many benchmarks, though learned inverse-dynamics features generalized better to new Super Mario Bros. levels; and the end-of-episode signal was removed, since a "game over" leaks information about the task (in some games, a reward for merely staying alive already yields a high score).

Random network distillation (RND; Burda, Edwards, Storkey & Klimov, 2019) predicts something simpler than the future: the output f(s)f(s) of a fixed, randomly initialized network. A predictor f^\hat f is trained on the states the agent visits, and the intrinsic reward is ∥f^(s)−f(s)∥2\norm{\hat f(s)-f(s)}^2, large on states unlike those seen before. The authors list four sources of prediction error: too little training data near ss (epistemic uncertainty, the useful one), a stochastic target (aleatoric uncertainty), model misspecification, and failures of optimization. A deterministic target that the predictor's architecture can represent removes the second and third by construction.

DerivationWhy stochastic targets keep paying
  1. E[∥Y−g(x)∥2∣x]=E[∥Y−m(x)∥2∣x]⏟aleatoric: never shrinks+∥m(x)−g(x)∥2⏟epistemic: shrinks with data\E\big[\norm{Y-g(x)}^2\mid x\big]=\underbrace{\E\big[\norm{Y-m(x)}^2\mid x\big]}_{\text{aleatoric: never shrinks}}+\underbrace{\norm{m(x)-g(x)}^2}_{\text{epistemic: shrinks with data}}

    For a predictor gg of a random target YY given input xx, add and subtract the conditional mean m(x)=E[Y∣x]m(x)=\E[Y\mid x]; the cross term has conditional mean zero:

  2. For a forward model, Y=st+1Y=s_{t+1} (or its features) and x=(st,at)x=(s_t,a_t). A transition with random outcomes, a screen showing static or a coin flip, keeps its first term positive however much data the model sees, so a surprise-seeking agent is paid forever for watching it: the noisy-TV problem. Inverse-dynamics features help only if the noise is beyond the agent's control; a television with a remote is not.

  3. For RND, Y=f(x)Y=f(x) is a deterministic function of the input, so the first term is zero and only novelty is rewarded. A source of new observations, a screen showing images never seen before, still produces large errors: RND rewards novelty, not usefulness.

The large-scale study tested the thought experiment literally: a 3D maze with a TV whose channel the agent could change. The TV drastically slowed learning with both random and inverse-dynamics features, although with enough training the agents sometimes still learned to collect the extrinsic reward consistently. In the Atari games themselves the authors did not observe the effect.

RND's results depended on engineering as much as on the bonus: separate value heads for intrinsic and extrinsic returns, intrinsic returns treated as non-episodic (a game over does not end the stream of novelty), and normalization of observations and of the intrinsic reward, which the random target network needs. With these, the best agent often found 22 of the 24 rooms of Montezuma's Revenge's first level and occasionally passed it; the authors describe it as the first method to exceed average human performance on the game without demonstrations or access to the emulator's internal state.

Check your understanding

Why is RND not drawn to transitions with random outcomes the way a forward-model curiosity bonus is?

  1. Because its predictor is trained with a smaller learning rate
  2. Because it ignores the observations and rewards only the actions
  3. Because its target is a deterministic function of the current observation, so the irreducible (aleatoric) part of its prediction error is zero
  4. Because it caps the intrinsic reward at a fixed value
Show the answer

C. Because its target is a deterministic function of the current observation, so the irreducible (aleatoric) part of its prediction error is zero

In the decomposition, the aleatoric term is the conditional variance of the target. RND's target f(s)f(s) has none, so its error shrinks wherever data accumulate. It is still attracted by genuinely new observations, which is the intended effect when they are informative and a distraction when they are not.

Lifelong and episodic novelty: NGU and Agent57

A lifelong bonus decays as the world becomes familiar, and with it the drive to explore. Never Give Up (NGU; Badia et al., 2020) adds an episodic bonus that resets every episode. Observations are embedded by an inverse-dynamics network into "controllable states", kept in an episodic memory, and the bonus is an inverse square root of a soft count of nearby memories:

rtepisodic=1∑fi∈NkK(f(xt),fi)+c,rti=rtepisodic⋅min⁡{max⁡{αt,1},L},r^{\text{episodic}}_t=\frac{1}{\sqrt{\sum_{f_i\in N_k}K\big(f(x_t),f_i\big)+c}},\qquad r^i_t=r^{\text{episodic}}_t\cdot\min\big\{\max\{\alpha_t,1\},L\big\},

where NkN_k holds the kk nearest neighbors of f(xt)f(x_t) in this episode's memory, KK is a kernel, and the lifelong modulator αt=1+(err(xt)−μe)/σe\alpha_t=1+(\mathrm{err}(x_t)-\mu_e)/\sigma_e is RND's normalized error, clipped to [1,L][1,L] with L=5L=5. The agent is driven to cover its controllable states in every episode, while states that are familiar over its lifetime pay less. NGU trains a family of policies with different intrinsic weights βj\beta_j and discounts γj\gamma_j in one network, and was the first algorithm to score in Pitfall! without demonstrations or hand-crafted features.

Agent57 (Badia et al., 2020) asks which member of that family to run, and answers with a bandit. A meta-controller treats each pair (βj,γj)(\beta_j,\gamma_j) as an arm, picks one per episode and receives the episode's extrinsic return as its reward. The returns change as the agent learns, a nonstationary bandit, so the meta-controller runs a simplified sliding-window UCB with ε-greedy exploration. With separate value networks for intrinsic and extrinsic rewards, Agent57 became the first deep RL agent to exceed the standard human benchmark on all 57 Atari games. The cost is part of the result: it passed the benchmark on 51 games within its first 5 billion frames, and on the last, Skiing, only after 78 billion.

E3B later diagnosed why such methods work in some suites and not others: their success relies heavily on the episodic, count-like term, which is effective when observations repeat within an episode, as in MiniGrid, and fails in noisy, high-dimensional settings where every state is unique. Replacing the count by the elliptical bonus in a learned feature space gave E3B the best results on 16 MiniHack tasks without task-specific features.

Remembering where to go, and what the evidence shows

Ecoffet, Huizinga, Lehman, Stanley and Clune (2021) argued that bonus-driven agents fail in two ways a bonus cannot fix. Detachment: an agent consumes the intrinsic reward near one frontier, drifts elsewhere, and loses track of the promising region it left. Derailment: on the way back, exploratory noise keeps it from reaching the frontier at all.

Go-Explore separates returning from exploring. It keeps an archive of cells, coarse groupings of visited states, each with the best trajectory found to reach it. Repeatedly, it picks a promising cell, returns there (by restoring the simulator state, or with a goal-conditioned policy), and only then explores. In the version that restores states, the trajectories found are then robustified into a policy that works under the game's randomness by learning from them as demonstrations. The robustified policies averaged 1,731,645 points on Montezuma's Revenge and 102,571 on Pitfall!, close to that game's maximum of 112,000, and the paper reports surpassing human performance on all Atari games then considered unsolved under the community's evaluation standards.

Think first Restoring the simulator to an archived state is a strong assumption. What does it buy, and what does it cost?

It buys a perfect "go" step: returning costs nothing and cannot derail, so all effort goes into exploring from the frontier, the idealized directed exploration that the theory of optimism assumes when it plans a path to an under-explored state. It costs realism: real robots and most deployed systems cannot be reset to arbitrary states, and the exploration phase alone yields brittle action sequences, not a robust policy, which is why the robustification phase is needed. The policy-based variant removes the assumption by learning a goal-conditioned policy to return, at the price of more training.

How much of the progress is due to the bonuses? Taïga, Fedus, Machado, Courville and Bellemare (2019) fixed the base agent (Rainbow) and the protocol (sticky actions, 200 million frames, hyperparameters tuned on Montezuma's Revenge) and compared bonuses directly. On Montezuma's Revenge, ε-greedy performed poorly while the bonuses consistently reached 2,500 points, with the old CTS pseudo-count matching newer methods at about 5,000. On the other games labeled hard-exploration, there was no visible difference between ε-greedy and the bonuses, ε-greedy was even clearly better on Gravitar, and bonuses could hurt on easy games. Their conclusion: progress on many of these games may come from stronger base agents and better credit assignment rather than from the exploration bonus.

Key takeaways

  • Count bonuses β/N(s,a)\beta/\sqrt{N(s,a)} implement optimism with guarantees in tabular MDPs; deep RL bonuses replace exact counts with similarity: pseudo-counts from density models, hashes and elliptical widths in feature space.
  • Prediction error is epistemic plus aleatoric: forward-model curiosity is paid forever by random transitions (the noisy TV), while RND's deterministic random target removes the aleatoric part and rewards novelty, relevant or not.
  • RND, NGU and Agent57 owe much to engineering: separate intrinsic and extrinsic value heads, non-episodic intrinsic returns, normalization, episodic memories, and a sliding-window UCB bandit choosing how much to explore.
  • Go-Explore attacks detachment and derailment by archiving states and returning before exploring, which with simulator resets produced record scores on Montezuma's Revenge and Pitfall!.
  • Under controlled comparisons many bonus gains shrink outside Montezuma's Revenge; representation, noise, theory and evaluation protocols remain open.

Check yourself

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

Question 1

Why does a plain count bonus β/N(s)\beta/\sqrt{N(s)} over raw Atari frames fail to guide exploration?

  1. Because the bonus decays too fast
  2. Because almost every frame is new, so the counts are 0 or 1 everywhere and the bonus does not distinguish familiar situations from novel ones
  3. Because counts cannot be stored for images
  4. Because the bonus is negative for unvisited states
Show the answer

B. Because almost every frame is new, so the counts are 0 or 1 everywhere and the bonus does not distinguish familiar situations from novel ones

Counts need exact repeats, and pixels almost never repeat. Pseudo-counts, hashing, elliptical bonuses and prediction errors all replace exact equality by a learned or designed notion of similarity, so that visits to similar states lower the bonus.

Question 2

What does NGU's episodic bonus provide that a lifelong novelty bonus alone does not?

  1. Protection against the noisy-TV problem
  2. A guarantee of PAC-MDP sample complexity
  3. A replacement for the extrinsic reward
  4. A drive that does not fade over training: within every episode the agent is rewarded for covering states it has not yet visited in that episode
Show the answer

D. A drive that does not fade over training: within every episode the agent is rewarded for covering states it has not yet visited in that episode

Lifelong bonuses vanish as states become familiar, so exploration dies out. The episodic memory resets every episode, which keeps the agent revisiting and covering its controllable states, while the lifelong RND modulator scales the reward down for states that are familiar over its whole lifetime.

Question 3

What did Taïga et al. find when they compared exploration bonuses on a common Rainbow agent under the same protocol?

  1. Bonuses helped on Montezuma's Revenge, where they were tuned, but on the other hard-exploration games showed no visible advantage over ε-greedy, and ε-greedy was even better on Gravitar
  2. Every bonus beat ε-greedy on every game
  3. Only the newest bonus, RND, made progress on Montezuma's Revenge
  4. Bonuses made no difference anywhere, including Montezuma's Revenge
Show the answer

A. Bonuses helped on Montezuma's Revenge, where they were tuned, but on the other hard-exploration games showed no visible advantage over ε-greedy, and ε-greedy was even better on Gravitar

Under a fixed agent and protocol, gains concentrated on the game the methods were tuned on, and the old CTS pseudo-count matched newer bonuses there. The authors suggest that much of the progress elsewhere came from stronger base agents and credit assignment rather than from the bonuses.

Question 4

An agent uses up the intrinsic reward near a promising frontier, wanders to another region, and later cannot find its way back. What is this failure called, and how does Go-Explore avoid it?

  1. Derailment; by adding more noise to exploration
  2. The noisy-TV problem; by using random network distillation
  3. Detachment; by keeping an archive of visited cells and explicitly returning to promising ones before exploring
  4. Overfitting; by training on more games
Show the answer

C. Detachment; by keeping an archive of visited cells and explicitly returning to promising ones before exploring

Detachment is losing track of where to explore from. Go-Explore remembers states in an archive and returns to them first, by restoring the simulator or with a goal-conditioned policy, which also prevents derailment, failing to get back because of exploratory noise along the way.

Further reading

  • M. G. Bellemare, S. Srinivasan, G. Ostrovski, T. Schaul, D. Saxton & R. Munos, "Unifying count-based exploration and intrinsic motivation," Advances in Neural Information Processing Systems (2016).
  • Y. Burda, H. Edwards, A. Storkey & O. Klimov, "Exploration by random network distillation," International Conference on Learning Representations (2019).
  • A. P. Badia, B. Piot, S. Kapturowski, P. Sprechmann, A. Vitvitskyi, D. Guo & C. Blundell, "Agent57: Outperforming the Atari human benchmark," International Conference on Machine Learning (2020).
  • A. Ecoffet, J. Huizinga, J. Lehman, K. O. Stanley & J. Clune, "First return, then explore," Nature 590, 580–586 (2021).
  • A. A. Taïga, W. Fedus, M. C. Machado, A. Courville & M. G. Bellemare, "Benchmarking bonus-based exploration methods on the Arcade Learning Environment," arXiv:1908.02388 (2019).