Modern Deep Reinforcement Learning/Exploration in Deep RL: Posterior Sampling and Go-Explore

Lesson 5.82,081 words

Exploration in Deep RL: Posterior Sampling and Go-Explore

A companion to the novelty-as-reward lesson. Pseudo-counts and curiosity reward the unfamiliar after the agent stumbles into it; this lesson covers two ideas that go further.

╌╌╌╌

This builds on Exploration in Deep RL: Novelty as Reward, which showed why ε-greedy fails when reward is sparse and deep, and built the two dominant families of intrinsic reward: pseudo-counts (an approximate visit count from a density model) and curiosity (a reward for prediction error, as in ICM and RND). Both convert novelty into a reward and let the agent chase it.

Both of those reward novelty only after the agent reaches an unfamiliar state. This lesson takes two ideas that change that — a posterior over value functions that drives committed exploration, and an archive that reliably returns to the frontier — then the modern systems that combine them.

Posterior sampling: bootstrapped DQN

The three schemes above are optimism- or curiosity-driven. A different lineage, inherited from Thompson sampling on the bandit, is posterior-driven: keep a distribution over how good the actions are, sample one plausible value function from it, and act greedily with respect to that sample. On a bandit this is principled and simple — the posterior over each arm's mean has a closed form. In deep RL there is no closed-form posterior over a -network's millions of weights, so we need an approximation cheap enough to run.

Bootstrapped DQN, from Osband et al. (2016), approximates the posterior with an ensemble.1 Instead of one -network, train heads that share a convolutional trunk but diverge in their final layers, each head fit on a different bootstrap resampling of the experience (implemented with per-transition Bernoulli masks). Because the heads see different data and start from different initializations, they disagree about the value of poorly-explored actions and agree about well-explored ones. That disagreement is a usable approximation to the posterior spread.

The exploration mechanism is deep exploration by commitment, and it is what fixes ε-greedy's central defect. At the start of each episode, sample one head and follow greedily for the entire episode. That single head encodes one internally consistent hypothesis about the world, so acting on it produces a directed, committed trajectory — the temporally extended exploration ε-greedy can never manage, because ε-greedy re-randomizes every single step and so cannot follow any hypothesis to its conclusion.

Algorithm:Bootstrapped-DQN\textsc{Bootstrapped-DQN} — deep exploration by posterior sampling
  1. 1
    input: number of heads KK, masking probability pp
  2. 2
    initialize shared network with KK value heads Q1,,QKQ_1, \ldots, Q_K
  3. 3
    for each episode do
  4. 4
    sample a head kUniform{1,,K}k \sim \text{Uniform}\{1, \ldots, K\}
  5. 5
    initialize state SS
  6. 6
    repeat
  7. 7
    AargmaxaQk(S,a)A \gets \arg\max_a Q_k(S, a)
    commit to head kk all episode
  8. 8
    take action AA, observe RR, SS'
  9. 9
    draw a mask m{0,1}Km \in \{0,1\}^K, each mjBernoulli(p)m_j \sim \text{Bernoulli}(p)
  10. 10
    store (S,A,R,S,m)(S, A, R, S', m) in replay buffer
  11. 11
    sample a minibatch and update each head QjQ_j on transitions with mj=1m_j = 1
  12. 12
    SSS \gets S'
  13. 13
    until SS is terminal

The mask decides which heads learn from each transition, giving each head its own bootstrap sample of experience and keeping them diverse. As a state becomes well-explored the heads converge there and stop disagreeing, so exploration of that region naturally winds down — the ensemble spread plays the role UCB's bonus played on the bandit, but recovered from disagreement instead of a count.

Bootstrapped DQN approximates a posterior over value functions with heads on a shared trunk, each trained on a bootstrap of the data. Heads agree on well-explored states and disagree on novel ones; sampling one head per episode and following it greedily yields committed, directed exploration.

Bootstrapped DQN's cost is modest — extra heads are cheap next to the shared trunk — and it needs no separate density model, hash, or curiosity network. Its limitation is that ensemble disagreement is a coarse posterior, and on the very hardest sparse-reward tasks it is outperformed by explicit novelty bonuses. The two ideas are complementary and are often combined.

Go-Explore: remember and return

Every method so far converts novelty into a reward and relies on the RL optimizer to follow it. Ecoffet et al. (2021) argued that on the hardest problems this coupling itself is the flaw, through two failure modes they named detachment and derailment.2 Detachment: an intrinsic-reward agent that wanders away from a promising but not-yet-exhausted frontier may forget it was there, because the intrinsic reward it once found has been consumed and no signal draws it back. Derailment: even when the agent remembers a promising state, its exploratory noise corrupts the long action sequence needed to return to that state, so it can never reliably build on progress it has already made.

Go-Explore attacks both by decoupling returning from exploring and maintaining an explicit archive of the distinct states (or, in practice, low-dimensional cells that group similar states) it has reached, each stored with a trajectory that reaches it. The loop is remember-and-return:

Algorithm:Go-Explore\textsc{Go-Explore} — archive promising states, return, then explore
  1. 1
    initialize archive with the start state and its (empty) trajectory
  2. 2
    repeat
  3. 3
    select a cell cc from the archive
    bias toward promising / rarely-chosen cells
  4. 4
    return to cc by replaying its stored trajectory
    no exploration on the way back
  5. 5
    explore from cc for a short horizon
    e.g. random or policy actions
  6. 6
    for each state ss' newly reached do
  7. 7
    if ss' maps to a new cell or a shorter path to its cell then
  8. 8
    add or update ss' in the archive with the trajectory that reached it
  9. 9
    until budget exhausted
  10. 10
    robustify the best archived trajectories into a policy
    imitation learning

The first phase deliberately sidesteps derailment: to return to a promising cell the agent replays a known trajectory (or resets a deterministic simulator to that state) rather than trying to navigate back through noisy exploration, so it arrives reliably every time. Only after arriving does it explore, and every new cell it discovers is added to the archive — so the frontier is never forgotten, which is what defeats detachment. Because returning is reliable and the frontier persists, the archive grows outward across the whole reachable state space instead of collapsing back toward the start.

Go-Explore keeps an archive of reached cells. Each iteration selects a promising cell, returns to it reliably (replaying a stored trajectory rather than exploring), then explores a short horizon from there. New cells are archived, so the frontier is never forgotten (no detachment) and returning never fails (no derailment).

A final phase robustifies the best trajectories: the archive's paths may depend on a deterministic environment, so Go-Explore trains a neural policy to imitate them and withstand stochasticity, using imitation learning from the discovered demonstrations. Empirically, Go-Explore scored over points on Montezuma's Revenge and solved it in the sense of reaching past all rooms, and it cleared the previously-unsolved game Pitfall, both far beyond every reward-bonus method. The conclusion: on the hardest exploration problems, reliably remembering and returning to the frontier can matter more than any particular definition of novelty.

Beyond the reward bonus: episodic memory, model-based exploration, and Agent57

The methods above define novelty at the scale of a whole training run: RND's predictor, a density model, or an ensemble all forget slowly, so a state seen many episodes ago still reads as familiar. The work after 2019 refined when novelty should reset and tied exploration back to the model-based and value-based lines.

Never-Give-Up and episodic novelty. RND's slow-fading novelty has a cost: once the agent has thoroughly explored a region, the intrinsic reward there is gone for good, so within a single long episode it has no incentive to revisit a junction and try a different branch. Never Give Up (Badia et al., 2020) adds a second, faster novelty signal — an episodic memory that is wiped at the start of every episode and scores a state by how different it is from the states already seen this episode (a -nearest-neighbor distance in an embedding).3 The intrinsic reward is the product of the fast episodic signal and the slow lifelong (RND-style) modulator ,

with the nearest neighbors of the embedded state in . The agent is thus pushed to visit new states both across training and within each episode — the within-episode drive that lets it keep probing a maze it has already partly mapped.

Agent57 ties exploration to value. The distributional lesson noted Agent57 (Badia et al., 2020) as the first agent above the human baseline on all 57 Atari games; the exploration side is what earned the last few.4 It runs the Never-Give-Up intrinsic reward on top of a distributional Q-learning core, but maintains a family of policies indexed by — the intrinsic weight and discount — each optimizing . A meta-controller — a bandit, closing the loop back to the bandit lesson this course opened with — selects per episode which to run by treating undiscounted episode return as the bandit reward, so the agent behaves as a cautious exploiter ( small, high) on easy games and a relentless explorer on Montezuma's Revenge without retuning. Directed exploration is a selectable mode of one agent, not a bolt-on.

Model-based exploration: Plan2Explore. Every method in this lesson so far explores then (or while) learning a task. Plan2Explore (Sekar et al., 2020) explores with no task reward at all, using a Dreamer-style world model.5 Its novelty signal is the disagreement of an ensemble of one-step latent models — the variance of their predicted next latent, with the ensemble mean — the same epistemic-uncertainty idea PETS used, now driving exploration rather than cautious planning. Because the world model is learned, the agent can plan toward predicted future novelty (states the ensemble expects to disagree about) instead of only reacting to surprise after visiting a state. After a purely self-supervised exploration phase it solves downstream tasks zero-shot or with little adaptation: a good world model turns exploration into a planning problem — seek the states your model is most unsure about.

Two axes the post-RND methods added. Lifelong novelty (top, RND-style) fades slowly over training; episodic novelty (bottom, NGU) resets each episode to drive within-episode exploration; their product is the NGU reward. Plan2Explore instead plans toward predicted model disagreement, exploring before any task reward.

The shared blueprint

The methods differ in machinery but agree on strategy. Directed, memory-bearing exploration replaces undirected dithering, and in almost every case the mechanism is the same: score novelty, convert the score into an intrinsic reward , and let the return-maximizing agent chase it via . The count-based archetype recovers the bandit's UCB bonus directly, from an approximate visit count ; every other row replaces with a surrogate that generalizes across an astronomical state space.

MethodNovelty signalRecoversCost
Pseudo-countsdensity-model surprise UCB's bonusa density model
Hash countscount of state's hash codeUCB's count, cheaplya hash + table
ICMforward-model error in controllable featurescuriosity, noise-filteredinverse + forward nets
RNDerror vs. a fixed random netnovelty, noise-proofone extra net
Bootstrapped DQNensemble disagreementThompson posterior + commitment value heads
Go-Explorenew cell in an archivedirected frontier growthan archive + replay

Read the table against the earlier one: each row recovers one bandit tool the deep setting had broken — a count, a posterior, optimism — in a form that generalizes across an enormous state space. The exploration–exploitation tension the bandit isolated never disappeared; scale only forced us to build approximate counts and approximate posteriors, then feed them back to the agent as a reward it will pursue on its own.

Footnotes

  1. Osband, Blundell, Pritzel, Van Roy (2016), Deep Exploration via Bootstrapped DQN, NeurIPS — approximates a posterior over value functions with an ensemble of bootstrapped -heads on a shared network, and explores by sampling one head per episode and following it greedily, achieving temporally-extended deep exploration.
  2. Ecoffet, Huizinga, Lehman, Stanley, Clune (2021), First Return, Then Explore, Nature — the Go-Explore family: an archive of reached cells with return-then-explore, diagnosing detachment and derailment as the failures of intrinsic-reward exploration, solving Montezuma's Revenge and Pitfall before robustifying trajectories into a policy by imitation learning.
  3. Badia, Sprechmann, Vitvitskyi, Guo, Piot, Kapturowski, Tieleman, Arjovsky, Pritzel, Bolt, Blundell (2020), Never Give Up: Learning Directed Exploration Strategies, ICLR — combines a slow lifelong novelty (RND-style) with a fast episodic novelty from a per-episode memory scored by -nearest-neighbor distance in an embedding, multiplying the two so the agent explores both across training and within each episode.
  4. Badia, Piot, Kapturowski, Sprechmann, Vitvitskyi, Guo, Blundell (2020), Agent57: Outperforming the Atari Human Benchmark, ICML — a parameterized family of policies over exploration weights and discounts on a distributional Q-learning core with the Never-Give-Up intrinsic reward, and a bandit meta-controller selecting the policy per episode; the first agent above the human baseline on all 57 Atari games, including the hard-exploration holdouts.
  5. Sekar, Rybkin, Daniilidis, Abbeel, Hafner, Pathak (2020), Planning to Explore via Self-Supervised World Models, ICML — Plan2Explore: task-agnostic exploration in a Dreamer world model driven by the disagreement of an ensemble of latent one-step models (epistemic uncertainty), planning toward expected future novelty and solving downstream tasks zero-shot or with little adaptation.

╌╌ END ╌╌