summaries: * This paper uses the insights from Bayesian RL to solve the problem of generalization in RL. In particular, the authors formulated the generalization problem as an epistemic POMDP and proposed an ensemble-based algorithm, called LEEP, to approximately solve the problem.  * The authors empirically demonstrated the performance of LEEP in generalizing to unseen contexts in the Procgen benchmark. They have shown that:   * LEEP performed better than PPO in Maze, Heist, BigFish, and Dodgeball.   * An ablation study to show that the better generalization performance of LEEP does not only come from the use of ensembles.   * An ablation study to show that the better generalization performance of LEEP does come from the inductive bias conferred by the `max_i π_i` link function proposed by the authors.

summaries: The paper addresses the problem of a reinforcement learning generalizing across different dynamics (with the same state/action space). Specifically, the paper frames this problem as a POMDP, where the properties of the environment are encoded as hidden information. An algorithm LEEP is introduced, which learns different policies for different sampled environments, regularized to make the policies similar, and then combines the policy into a single, hopefully robust policy.

summaries: The paper considers the problem of generalization in contextual MDPs, where the state of the environment consists of a context that remains fairly constant throughout an episode of the MDP. In such a setting the problem of generalization arises when an RL agent learns on a set of training MDPs (MDPs with contexts sampled from a set of training contexts) and then this trained RL agent must perform well on an unseen context test MDP. This paper underlines the challenges of learning and generalizing in such settings, namely, that methods that are not able to handle epistemic uncertainty fail at generalizing in such settings. The paper formulates this problem of generalization as a special POMDP and proposes a new sampling-based method for approximately solving this POMDP. Experimental results show that the proposed methods beats other baselines on a benchmark suite.

summaries: The paper investigates the topic of generalization in reinforcement learning. It starts from the observation that even in fully observed environments, a kind of partial observability arises from epistemic uncertainty about the true MDP the agent faces at test time. This observation gives rise to what the paper calls an epistemic POMDP, which has the property that expected return in the epistemic POMDP equals test time agent performance in expectation over the posterior distribution of MDPs (given the prior is accurate).   This insight is used to point out that, being a POMDP, the optimal policy of the epistemic POMDP is in general memory-based, and in the class of memoryless policies, stochastic. In the same vein, even a policy that is optimal on all training contexts can have very poor generalization performance, and the optimal policy for the epistemic POMDP might not be optimal in any single MDP.  The remainder of the paper focuses on memoryless policies in the empirical epistemic POMDP, where the latter arises from a finite number of samples from the MDP posterior. It is shown that one can lower-bound the performance of an ensemble of policies on the empirical epistemic POMDP by their average performance minus a disagreement penalty to the combined policy \pi and that optimizing this bound gives the optimal policy for the empirical epistemic POMDP.  Based on these insights, the paper proposes a practical algorithm (LEEP) that combines bootstrap sampling from the training contexts, choosing max for combining the individual policies, PPO as the base algorithm, and the derived regularization term into an algorithm where the n individual policies are optimized in a round-robin fashion.  The proposed algorithm is evaluated on the procgen benchmark, where it compares favorably to pure PPO and Distral. The algorithm is also shown to avoid overfitting when only few training contexts are available. Finally, an ablation study shows that both the agreement penalty term and the max link function contribute to the performance advantage of LEEP.

abstractText: Generalization is a central challenge for the deployment of reinforcement learning (RL) systems in the real world. In this paper, we show that the sequential structure of the RL problem necessitates new approaches to generalization beyond the well-studied techniques used in supervised learning. While supervised learning methods can generalize effectively without explicitly accounting for epistemic uncertainty, we show that, perhaps surprisingly, this is not the case in RL. We show that generalization to unseen test conditions from a limited number of training conditions induces implicit partial observability, effectively turning even fullyobserved MDPs into POMDPs. Informed by this observation, we recast the problem of generalization in RL as solving the induced partially observed Markov decision process, which we call the epistemic POMDP. We demonstrate the failure modes of algorithms that do not appropriately handle this partial observability, and suggest a simple ensemble-based technique for approximately solving the partially observed problem. Empirically, we demonstrate that our simple algorithm derived from the epistemic POMDP achieves significant gains in generalization over current methods on the Procgen benchmark suite.

authors:
Jesse Farebrother
Marlos C. Machado
Michael H. Bowling

title: Generalization and regularization in dqn

venue: ArXiv,

authors:
C. Zhang
Oriol Vinyals
R. Munos
S. Bengio

title: A study on overfitting in deep reinforcement

venue: learning. ArXiv,

authors:
Niels Justesen
R. Torrado
Philip Bontrager
Ahmed Khalifa
J. Togelius
S. Risi

title: Illuminating generalization in deep reinforcement learning through procedural level generation

venue: arXiv: Learning,

authors:
Xingyou Song
Yiding Jiang
Stephen Tu
Yilun Du
Behnam Neyshabur

title: Observational overfitting in reinforcement learning

authors:
R. Dearden
N. Friedman
Stuart J. Russell

title: Bayesian q-learning

venue: In AAAI/IAAI,

authors:
M. Duff
A. Barto

title: Optimal learning: computational procedures for bayes-adaptive markov decision processes

title: A bayesian framework for reinforcement learning

venue: In ICML,

authors:
M. Ghavamzadeh
Shie Mannor
Joelle Pineau
Aviv Tamar

title: Bayesian reinforcement learning: A survey

venue: Found. Trends Mach. Learn.,

authors:
A. Zhang
Yuxin Wu
Joelle Pineau

title: Natural environment benchmarks for reinforcement

authors:
A. Zhang
Nicolas Ballas
Joelle Pineau

title: A dissection of overfitting and generalization in continuous reinforcement

authors:
S. Whiteson
B. Tanner
Matthew E. Taylor
P. Stone

title: Protecting against evaluation overfitting in empirical reinforcement learning

venue: IEEE Symposium on Adaptive Dynamic Programming and Reinforcement Learning (ADPRL),

authors:
Zhuang Liu
Xuanlin Li
Bingyi Kang
Trevor Darrell

title: Regularization matters in policy optimization – an empirical study on continuous control

authors:
Alex Nichol
Vicki Pfau
Christopher Hesse
Oleg Klimov
John Schulman

title: Gotta learn fast: A new benchmark for generalization in

venue: rl. ArXiv,

authors:
K. Cobbe
Oleg Klimov
Christopher Hesse
Taehoon Kim
John Schulman

title: Quantifying generalization in reinforcement learning

authors:
Heinrich Kuttler
Nantas Nardelli
Alexander H. Miller
Roberta Raileanu
Marco Selvatici
Edward Grefenstette
Tim Rocktäschel

title: The nethack learning environment

authors:
K. Cobbe
Christopher Hesse
Jacob Hilton
John Schulman

title: Leveraging procedural generation to benchmark reinforcement learning

authors:
Austin Stone
Oscar Ramirez
K. Konolige
Rico Jonschkowski

title: The distracting control suite - a challenging benchmark for reinforcement learning

venue: pixels. ArXiv,

authors:
Max Jaderberg
V. Mnih
Wojciech Czarnecki
Tom Schaul
Joel Z. Leibo
D. Silver
K. Kavukcuoglu

title: Reinforcement learning with unsupervised auxiliary

venue: tasks. ArXiv,

authors:
Adam Stooke
Kimin Lee
P. Abbeel
M. Laskin

title: Decoupling representation learning from reinforcement learning

authors:
A. Zhang
Rowan McAllister
R. Calandra
Y. Gal
Sergey Levine

title: Learning invariant representations for reinforcement learning without reconstruction

authors:
Rishabh Agarwal
Marlos C. Machado
P.S. Castro
Marc G. Bellemare

title: Contrastive behavioral similarity embeddings for generalization in reinforcement

authors:
Maximilian Igl
K. Ciosek
Yingzhen Li
Sebastian Tschiatschek
C. Zhang
Sam Devlin
Katja Hofmann

title: Generalization in reinforcement learning with selective noise injection and information bottleneck

venue: NeurIPS,

authors:
Kimin Lee
Kibok Lee
Jinwoo Shin
H. Lee

title: Network randomization: A simple technique for generalization in deep reinforcement learning

venue: In ICLR,

authors:
Ilya Kostrikov
Denis Yarats
R. Fergus

title: Image augmentation is all you need: Regularizing deep reinforcement learning from pixels

authors:
Roberta Raileanu
Maxwell Goldstein
Denis Yarats
Ilya Kostrikov
R. Fergus

title: Automatic data augmentation for generalization in deep reinforcement learning

authors:
Fereshteh Sadeghi
Sergey Levine

title: cad)2rl: Real single-image flight without a single real

venue: image. ArXiv,

authors:
Joshua Tobin
Rachel Fong
Alex Ray
J. Schneider
W. Zaremba
P. Abbeel

title: Domain randomization for transferring deep neural networks from simulation to the real world

venue: IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS),

authors:
A. Rajeswaran
Sarvjeet Ghotra
Sergey Levine
Balaraman Ravindran

title: Epopt: Learning robust neural network policies using model

venue: ensembles. ArXiv,

authors:
Xue Bin Peng
Marcin Andrychowicz
Wojciech Zaremba
Pieter Abbeel

title: Sim-to-real transfer of robotic control with dynamics randomization

venue: IEEE International Conference on Robotics and Automation (ICRA),

authors:
Katie Kang
Suneel Belkhale
Gregory Kahn
Pieter Abbeel
Sergey Levine

title: Generalization through simulation: Integrating simulated and real data into deep reinforcement learning for vision-based autonomous flight

venue: In 2019 international conference on robotics and automation (ICRA),

authors:
F. Stulp
E. Theodorou
J. Buchli
S. Schaal

title: Learning to grasp under uncertainty

venue: IEEE International Conference on Robotics and Automation,

authors:
X. Lu
Kimin Lee
P. Abbeel
Stas Tiomkin

title: Dynamics generalization via information bottleneck in deep reinforcement learning

authors:
Deepak Ramachandran
E. Amir

title: Bayesian inverse reinforcement learning

venue: In IJCAI,

authors:
A. Lazaric
M. Ghavamzadeh

title: Bayesian multi-task reinforcement learning

authors:
Wonseok Jeon
Seokin Seo
Kee-Eung Kim

title: A bayesian approach to generative adversarial imitation learning

venue: In NeurIPS,

authors:
Luisa M. Zintgraf
K. Shiarlis
Maximilian Igl
Sebastian Schulze
Y. Gal
Katja Hofmann
S. Whiteson

title: Varibad: A very good method for bayes-adaptive deep rl via meta-learning

title: On the gittins index for multiarmed bandits

venue: Annals of Applied Probability,

authors:
P. Poupart
N. Vlassis
J. Hoey
K. Regan

title: An analytic solution to discrete bayesian reinforcement learning

venue: Proceedings of the 23rd international conference on Machine learning,

authors:
R. Dearden
N. Friedman
D. Andre

title: Model based bayesian exploration

venue: In UAI,

authors:
Ian Osband
Daniel Russo
Benjamin Van Roy

title: more) efficient reinforcement learning via posterior sampling

venue: In NIPS,

authors:
Daniel Russo
Benjamin Van Roy

title: Learning to optimize via posterior sampling

venue: Math. Oper. Res.,

authors:
Stephane Ross
Brahim Chaib-draa
Joelle Pineau

title: Bayes-adaptive pomdps

venue: In NIPS, pages 1225–1232,

authors:
Sergey Levine
Aviral Kumar
George Tucker
Justin Fu

title: Offline reinforcement learning: Tutorial, review, and perspectives on open problems

venue: arXiv preprint arXiv:2005.01643,

authors:
Han Xiao
Kashif Rasul
Roland Vollgraf

title: Fashion-mnist: a novel image dataset for benchmarking machine learning algorithms, 2017

authors:
Volodymyr Mnih
Koray Kavukcuoglu
David Silver
Andrei A. Rusu
Joel Veness
Marc G. Bellemare
Alex Graves
Martin Riedmiller
Andreas K. Fidjeland
Georg Ostrovski
Stig Petersen
Charles Beattie
Amir Sadik
Ioannis Antonoglou
Helen King
Dharshan Kumaran
Daan Wierstra
Shane Legg
Demis Hassabis

title: Human-level control through deep reinforcement learning

title: State of the art—a survey of partially observable markov decision processes: theory, models, and algorithms

authors:
Satinder P. Singh
Tommi S. Jaakkola
Michael I. Jordan

title: Learning without state-estimation in partially observable markovian decision processes

venue: In Proceedings of the Eleventh International Conference on International Conference on Machine Learning,

authors:
Guido Montúfar
K. Zahedi
N. Ay

title: Geometry and determinism of optimal stationary control in partially observable markov decision processes

authors:
Ilge Akkaya
Marcin Andrychowicz
Maciek Chociej
Mateusz Litwin
Bob McGrew
Arthur Petron
Alex Paino
Matthias Plappert
Glenn Powell
Raphael Ribas

title: Solving rubik’s cube with a robot hand

authors:
Benjamin Eysenbach
Sergey Levine

title: If maxent rl is the answer, what is the question

venue: arXiv preprint arXiv:1910.01913,

authors:
Ian Osband
Charles Blundell
Alexander Pritzel
Benjamin Van Roy

title: Deep exploration via bootstrapped dqn

venue: Advances in Neural Information Processing Systems,

authors:
John Schulman
F. Wolski
Prafulla Dhariwal
Alec Radford
Oleg Klimov

title: Proximal policy optimization

venue: algorithms. ArXiv,

authors:
Yee Teh
Victor Bapst
Wojciech M. Czarnecki
John Quan
James Kirkpatrick
Raia Hadsell
Nicolas Heess
Razvan Pascanu

title: Distral: Robust multitask reinforcement learning

authors:
Dibya Ghosh
Avi Singh
Aravind Rajeswaran
Vikash Kumar
Sergey Levine

title: Divide-andconquer reinforcement learning

venue: In International Conference on Learning Representations,

authors:
Scott Fujimoto
H.V. Hoof
D. Meger

title: Addressing function approximation error in actorcritic

venue: methods. ArXiv,

title: Pytorch implementations of reinforcement learning algorithms

authors:
Sham Kakade
John Langford

title: Approximately optimal approximate reinforcement learning

venue: Proc. 19th International Conference on Machine Learning. Citeseer,

authors:
Kimin Lee
Younggyo Seo
Seunghyun Lee
Honglak Lee
Jinwoo Shin

title: Context-aware dynamics model for generalization in model-based reinforcement learning

heading: 1 Introduction

text:
Generalization is a central challenge in machine learning. However, much of the research on reinforcement learning (RL) has been concerned with the problem of optimization: how to master a specific task through online or logged interaction. Generalization to new test-time contexts has received comparatively less attention, although several works have observed empirically [1, 2, 3, 4] that generalization to new situations poses a significant challenge to RL policies learned from a fixed training set of situations. In standard supervised learning, it is known that in the absence of distribution shift and with appropriate inductive biases, optimizing for performance on the training set (i.e., empirical risk minimization) translates into good generalization performance. It is tempting to suppose that the generalization challenges in RL can be solved in the same manner as empirical risk minimization in supervised learning: when provided a training set of contexts, learn the optimal policy within these contexts and then use that policy in new contexts at test-time.
Perhaps surprisingly, we show that such “empirical risk minimization” approaches can be sub-optimal for generalizing to new contexts in RL, even when these new contexts are drawn from the same distribution as the training contexts. As an anecdotal example of why this sub-optimality arises, imagine a robotic zookeeper for feeding otters that must be trained on some set of zoos. When placed
∗Equal contribution. 1 UC Berkeley, 2 Princeton University, 3 Facebook AI Research. Correspond to: dibya@berkeley.edu, jrahme@math.princeton.edu.
35th Conference on Neural Information Processing Systems (NeurIPS 2021).
in a new zoo, the robot must find and enter the otter enclosure. It can use one of two strategies: either peek through all the habitat windows looking for otters, which succeeds with 95% probability in all zoos, or to follow an image of a hand-drawn map of the zoo that unambiguously identifies the otter enclosure, which will succeed as long as the agent is able to successfully parse the image. In every training zoo, the otters can be found more reliably using the image of the map, and so an agent trained to seek the optimal policy in the training zoos would learn a classifier to predict the identity of the otter enclosure from the map, and enter the predicted enclosure. This classification strategy is optimal on the training environments because the agent can learn to perfectly classify the training zoo maps, but it is sub-optimal for generalization, because the learned classifier will never be able to perfectly classify every new zoo map at test-time. Note that this task is not partially observed, because the map provides full state information even for a memoryless policy. However, if the learned map classifier succeeds on anything less than 95% of new zoos at test-time, the strategy of peeking through the windows, although always sub-optimal in the training environments, turns out to be a more reliable strategy for finding the otter habitat in a new zoo, and results in higher expected returns at test-time.
Although with enough training zoos, the zookeeper can learn a policy by solving the map classification problem, to generalize optimally when given a limited number of zoos requires a more intricate policy that is not learned by standard RL methods. How can we more generally describe the set of behaviors needed for a policy to generalize from a finite number of training contexts in the RL setting? We make the observation that, even in fully-observable domains, the agent’s epistemic uncertainty renders the environment implicitly partially observed at test-time. In the zookeeper example, although the hand-drawn map provides the exact location of the otter enclosure (and so the enclosure’s location is technically fully observed), the agent cannot identify the true parameters of the map classifier from the small set of maps seen at training time, and so the location of the otters is implicitly obfuscated from the agent. We formalize this observation, and show that generalizing optimally at test-time corresponds to solving a partially-observed Markov decision process that we call an epistemic POMDP, induced by the agent’s epistemic uncertainty about the test environment.
That uncertainty about MDP parameters can be modelled as a POMDP is well-studied in Bayesian RL when training and testing on a single task in an online setting, primarily in the context of exploration [5, 6, 7, 8]. However, as we will discuss, this POMDP interpretation has significant consequences for the generalization problem in RL, where an agent cannot collect more data online, and must instead learn a policy from a fixed set of training contexts that generalizes to new contexts at test-time. We show that standard RL methods that do not explicitly account for this implicit partial observability can be arbitrarily sub-optimal for test-time generalization in theory and in practice. The epistemic POMDP underscores the difficulty of the generalization problem in RL, as compared to supervised learning, and provides an avenue for understanding how we should approach generalization under the sequential nature and non-uniform reward structure of the RL setting. Maximizing expected return in an approximation of the epistemic POMDP emerges as a principled approach to learning policies that generalize well, and we propose LEEP, an algorithm that uses an ensemble of policies to approximately learn the Bayes-optimal policy for maximizing test-time performance.
The primary contribution of this paper is to use Bayesian RL techniques to reframe generalization in RL as the problem of solving a partially observed Markov decision process, which we call the epistemic POMDP. The epistemic POMDP highlights the difficulty of generalizing well in RL, as compared to supervised learning. We demonstrate the practical failure modes of standard RL methods, which do not reason about this partial observability, and show that maximizing test-time performance may require algorithms to explicitly consider the agent’s epistemic uncertainty during training. Our
work highlights the importance of not only finding ways to help neural networks in RL generalize better, but also on learning policies that degrade gracefully when the underlying neural network eventually does fail to generalize. Empirically, we demonstrate that LEEP, which maximizes return in an approximation to the epistemic POMDP, achieves significant gains in test-time performance over standard RL methods on several ProcGen benchmark tasks.

heading: 2 Related Work

text:
Many empirical studies have demonstrated the tendency of RL algorithms to overfit significantly to their training environments [1, 2, 3, 4], and the more general increased difficulty of learning policies that generalize in RL as compared to seemingly similar supervised learning problems [9, 10, 11, 12]. These empirical observations have led to a newfound interest in algorithms for generalization in RL, and the development of benchmark RL environments that focus on generalization to new contexts from a limited set of training contexts sharing a similar structure (state and action spaces) but possibly different dynamics and rewards [13, 14, 15, 16, 17].
Generalization in RL. Approaches for improving generalization in RL have fallen into two main categories: improving the ability of function approximators to generalize better with inductive biases, and incentivizing behaviors that are easier to generalize to unseen contexts. To improve the representations learned in RL, prior work has considered imitating environment dynamics [18, 19], seeking bisimulation relations [20, 21], and more generally, addressing representational challenges in the RL optimization process [22, 23]. In image-based domains, inductive biases imposed via neural network design have also been proposed to improve robustness to certain factors of variation in the state [24, 25, 26]. The challenges with generalization in RL that we will describe in this paper stem from the deficiencies of MDP objectives, and cannot be fully solved by choice of representations or functional inductive biases. In the latter category, one approach is domain randomization, varying environment parameters such as coefficients of friction or textures, to obtain behaviors that are effective across many candidate parameter settings [27, 28, 29, 30, 31]. Domain randomization sits within a class of methods that seek robust policies by injecting noise into the agent-environment loop, whether in the state [32], the action (e.g., via max-entropy RL) [14], or intermediary layers of a neural network policy (e.g., through information bottlenecks) [22, 33]. In doing so, these methods effectively introduce partial observability into the problem; while not necessarily equivalent to that of the epistemic POMDP, it may indicate why these methods generalize well empirically.
Bayesian RL: Our work recasts generalization in RL within the Bayesian RL framework, the problem of acting optimally under a belief distribution over MDPs (see Ghavamzadeh et al. [8] for a survey). Bayesian uncertainty has been studied in many sub-fields of RL [34, 35, 36, 37], the most prominent being for exploration and learning efficiently in the online RL setting. Bayes-optimal behavior in RL is often reduced to acting optimally in a POMDP, or equivalently, a belief-state MDP [6], of which our epistemic POMDP is a specific instantiation. Learning the Bayes-optimal policy exactly is intractable in all but the simplest problems [38, 39], and many works in Bayesian RL have studied relaxations that remain asymptotically optimal for learning, for example with value of perfect information [5, 40] or Thompson sampling [7, 41, 42]. Our main contribution is to revisit these classic ideas in the context of generalization for RL. We find that the POMDP interpretation of Bayesian RL [5, 6, 43] provides new insights on inadequacies of current algorithms used in practice, and explains why generalization in RL can be more challenging than in supervised learning. Being Bayesian in the generalization setting also requires new tools and algorithms beyond those classically studied in Bayesian RL, since test-time generalization is measured using regret over a single evaluation episode, instead of throughout an online training process. As a result, algorithms and policies that minimize short-term regret (i.e., are more exploitative) are preferred over traditional algorithms like Thompson sampling that explore thoroughly to ensure asymptotic optimality at the cost of short-term regret.

heading: 3 Problem Setup

text:
We consider the problem of learning RL policies given a set of training contexts that generalize well to new unseen contexts. This problem can be formalized in a Markov decision process (MDP) where the agent does not have full access to the MDP at training time, but only particular initial states or conditions. Before we describe what this means, we must describe the MDPM, which is given by a tuple (S,A, r, T, ρ, γ), with state space S, action space A, Markovian transition function T (st+1|st, at), bounded reward function r(st, at), and initial state distribution ρ(s0). A policy π induces a discounted state distribution dπ(s) = (1−γ)Eπ[ ∑ t≥0 γ t1(st = s)], and achieves
return JM(π) = Eπ[ ∑ t≥0 γ
tr(st, at)] in the MDP. Classical results establish that a deterministic Markovian (memoryless) policy π∗ maximizes this objective amongst all history-dependent policies.
We focus on generalization in contextual MDPs where the agent is only trained on a training set of contexts, and seeks to generalize well to new contexts. A contextual MDP is an MDP in which the state can be decomposed as st = (c, s′t), a context vector c ∈ C that remains constant throughout an episode, and a sub-state s′ ∈ S ′ that may vary: S := C × S ′. Each context vector corresponds to a different situation that the agent might be in, each with slightly different dynamics and rewards, but some shared structure across which an agent can generalize. During training, the agent is allowed to interact only within a sampled subset of contexts Ctrain ⊂ C. The generalization performance of the agent is measured by the return of the agent’s policy in the full contextual MDP J(π), corresponding to expected performance when placed in potentially new contexts. While our examples and experiments will be in contextual MDPs, our theoretical results also apply to other RL generalization settings where the full MDP cannot be inferred unambiguously from the data available during training, for example in offline reinforcement learning [44].

heading: 4 Warmup: A Sequential Classification RL Problem

text:
We begin our study of generalization in RL with an example problem that is set up to be close to a supervised learning task where generalization is relatively well understood: image classification on the FashionMNIST dataset [45]. In this environment (visualized in Figure 2), an image from the dataset is sampled (the context) at the beginning of an episode and held fixed; the agent must identify the label of the image to complete the episode. If the agent guesses correctly, it receives a reward of 0 and the episode ends; if incorrect, it receives a reward of −1 and the episode continues, so it must attempt another guess for the same image at the next time step. This RL problem is near identical to supervised classification, the core distinction being that an agent may interact with the same image over several timesteps in an episode instead of only one attempt as in supervised learning. Note that since episodes may last longer than a single timestep, this problem is not a contextual bandit.
The optimal policy in both the one-step and sequential RL version of the problem deterministically outputs the correct label for the image, because the image fully determines the label (in other words, it is a fully observed MDP). However, this optimal strategy generally cannot be learned from a finite training set, since some generalization error is unavoidable. With a fixed training set, the strategy for generalizing in classification re-
mains the same: deterministically choose the label the agent is most confident about. However, the RL setting introduces two new factors: the agent gets multiple tries at classifying the same image, and it knows if an attempted label is incorrect. To generalize best to new test images, an RL policy must leverage this additional structure, for example by trying many possible labels, or by changing actions if the previous guess was incorrect.
A standard RL algorithm, which estimates the optimal policy on the empirical MDP defined by the dataset of training images does not learn to leverage these factors, and instead learns behavior highly sub-optimal for generalization. We obtained a policy by running DQN [46] (experimental details in Appendix A.1), whose policy deterministically chooses the same label for the image at every timestep. Determinism is not specific to DQN, and is inevitable in any RL method that models the problem as an MDP because the optimal policy in the MDP is always deterministic and Markovian. The learned deterministic policy either guesses the correct label immediately, or guesses incorrectly and proceeds to make the same incorrect guess on every subsequent time-step. We compare performance in Figure 3 with a version of the agent that starts to guess randomly if incorrect on the first timestep, and a different agent that acts by process of elimination: first choosing the action it is most confident about, if incorrect, then the second, and so forth. Although all three versions have the same training performance, the learned RL policy generalizes more poorly than these alternative variants that exploit the sequential nature of the problem. In Section 5.2, we will see that this process-of-elimination is, in some sense, the optimal way to generalize for this task. This experiment reveals a tension: learning policies for generalization that rely on an MDP model fail, even though the underlying environment is an MDP. This failure holds in any MDP model with limited data, whether the empirical MDP or more sophisticated MDPs that use uncertainty estimates in their construction.

heading: 5 Modeling Generalization in RL as an Epistemic POMDP

text: To better understand test-time generalization in RL, we study the problem under a Bayesian perspective. We show that training on limited training contexts leads to an implicit partial observability at test-time that we describe using a formalism called the epistemic POMDP.

heading: 5.1 The Epistemic POMDP

text:
In the Bayesian framework, when learning given a limited amount of evidence D from an MDPM, we can use a prior P(M) to construct a posterior belief distribution P(M|D) over the identity of the MDP. For learning in a contextual MDP, D corresponds to the environment dynamics and reward in training contexts Ctrain that the agent can interact with, and the posterior belief distribution P(M|D) models the agent’s uncertainty about the behavior of the environment in contexts that it has not seen before (e.g. uncertainty about the label for a test-set image in the example from Section 4).
Since the agent only has partial access to the MDPM during training, the agent does not know which MDP from the posterior distribution is the true environment, and must act at test-time under this uncertainty. Following a reduction common in Bayesian RL [6, 8], we model this test-time uncertainty using a partially observed MDP that we will call the epistemic POMDP. The epistemic POMDP is structured as follows: each new episode in the POMDP begins by sampling a single MDPM∼ P(M|D) from the posterior, and then the agent interacts withM until the episode ends in this MDP. The agent does not observe which MDP was sampled, and since the MDP remains fixed for the duration of the episode, this induces implicit partial observability. Effectively, each episode in the epistemic POMDP corresponds to acting in one of the possible environments that is consistent with the evidence that the agent is allowed access to at training time.
The epistemic POMDP is formally defined as the tuple Mpo = (Spo,Opo,A, T po, rpo, ρpo, γ). A state in this POMDP spot = (M, st) contains the identity of the current MDP being acted in M, and the current state in this MDP st; we write the state space as Spo = M× S, where M is the space of MDPs with support under the prior. The agent only observes opot = st, the state in the MDP (Opo = S), but not the identity of the MDP,M. The initial state distribution is defined by the posterior distribution: ρpo((M, s0)) = P(M|D)ρM(s0), and the transition and reward functions in the POMDP reflect the dynamics in the current MDP:
T po((M′, s′) | (M, s), a) = δ(M′ =M)TM(s′|s, a) rpo((M, s), a) = rM(s, a) . (1)
Example (Sequential Image Classification). We begin by explicitly describing the induced epistemic POMDP for the task from Section 4. The agent’s uncertainty concerns how images are mapped to labels, and each MDPM in the posterior distribution corresponds to a different potential labelling function YM : x 7→ y that is consistent with the training dataset. Each episode in the epistemic POMDP, a different MDPM and corresponding labeller YM is sampled from the posterior distribution, alongside an image x ∼ p(x). The agent must guess the label assigned by this labelling function y := YM(x), but is only provided the image x and not the identity of the labeller YM. We
emphasize that the context remains fully observed in the epistemic POMDP (the image x is provided to the agent); what is partially observed is how the environment dynamics will behave for the context (what label the image corresponds to).
What makes the epistemic POMDP a useful tool for understanding generalization in RL is that performance in the epistemic POMDPMpo corresponds exactly to the expected return of the agent at test-time when the prior is well-specified. Proposition 5.1. If the true MDPM is sampled from P(M), and evidence D fromM is provided to an algorithm during training, then the expected test-time return of π is equal to its performance in the epistemic POMDPMpo.
JMpo(π) = EM∼P(M)[JM(π) | D]. (2) In particular, the optimal policy inMpo is Bayes-optimal for generalization to the unknown MDP M: it receives the highest expected test-time return amongst all possible policies.
The epistemic POMDP is based on well-understood concepts in Bayesian reinforcement learning, and Bayesian modeling more generally. However, in contrast to prior works on Bayesian RL, we are specifically concerned with settings where there is a training-test split, and performance is measured by a single test episode. While using Bayesian RL to accelerate exploration or minimize regret has been well-explored [8], we rather use the Bayesian lens specifically to understand generalization – a perspective that is distinct from prior work on Bayesian RL. Towards this goal, the equivalence between test-time return and expected return in the epistemic POMDP allows us to use performance in the POMDP as a proxy for understanding how well current RL methods can generalize.

heading: 5.2 Understanding Optimality in the Epistemic POMDP

text:
We now study the structure of the epistemic POMDP, and use it to characterize properties of Bayesoptimal test-time behavior and the sub-optimality of alternative policy learning approaches. The majority of our results follow from well-known results about POMDPs, so we present them here informally, with formal statements and proofs in Appendix B.
Example ctd. Acting optimally in the epistemic POMDP for the sequential image classification task requires maximizing return over the distribution of labels that is induced by the posterior distribution p(y|x,D) = EM∼P(M|D)[1(YM(x) = y)]. A deterministic policy (as is learned by standard RL algorithms) is a high-risk strategy in the POMDP; it receives exceedingly low return if the labeller outputs a different label than the one predicted. The Bayes-optimal generalization strategy corresponds to a process of elimination: first choose the most likely label a = argmax p(y|x,D); if this is incorrect, eliminate it and choose the next-most likely, repeating until the correct label is finally chosen. Amongst memoryless policies, the optimal behavior is stochastic, sampling actions according to the distribution π∗(a|x) ∝ √ p(y|x,D) (derivation in Appendix A.2).
The characteristics of the optimal policy in the epistemic POMDP for the image classification RL problem match well-established results that optimal POMDP policies are generally memory-based [47], and amongst memoryless policies, the optimal policy may be stochastic [48, 49]. Because of the equivalence between the epistemic POMDP and test-time behavior, these maxims are also true for Bayes-optimal behavior when maximizing test-time performance. Remark 5.1. The Bayes-optimal policy for maximizing test-time performance is in general nonMarkovian. When restricted to Markovian policies, the Bayes-optimal policy is in general stochastic.
The reason that Bayes-optimal generalization often requires memory is that the experience collected thus far in the episode contains information about the identity of the MDP being acted in (which is hidden from the agent observation), and to maximize expected return, the agent must adapt its subsequent behavior to incorporate this new information. The fact that acting optimally at test-time formally requires adaptivity (or stochasticity for memoryless policies) highlights the difficulty of generalizing well in RL, and provides a new perspective for understanding the success various empirical studies have found in improving generalization performance using recurrent networks [50, 51] and stochastic regularization penalties [32, 14, 22, 33].
It is useful to understand to what degree the partial observability plays a role in determining Bayesoptimal behavior. When the partial observability is insignificant, the epistemic POMDP objective can coincide with a surrogate MDP approximation, and Bayes-optimal solutions can be attained with standard fully-observed RL algorithms. For example, if there is a policy that is simultaneously
optimal in every MDP from the posterior, then an agent need not worry about the (hidden) identity of the MDP, and just follow this policy. Perhaps surprisingly, this kind of condition is difficult to relax: we show in Proposition B.1 that even if a policy is optimal in many (but not all) of the MDPs from the posterior, this seemingly “optimal” policy can generalize poorly at test-time.
Moreover, under partial observability, optimal policies for the MDPs in the posterior may differ substantially from Bayes-optimal behavior: in Proposition B.2, we show that the Bayes-optimal policy may take actions that are sub-optimal in every environment in the posterior. These results indicate the brittleness of learning policies based on optimizing return in an MDP model when the agent has not yet fully resolved the uncertainty about the true MDP parameters.
Remark 5.2 (Failure of MDP-Optimal Policies, Propositions B.1, B.2). The expected test-time return of policies that are learned by maximizing reward in any MDP from the posterior, as standard RL methods do, may be arbitrarily low compared to that of Bayes-optimal behavior.
As Bayes-optimal memoryless policies are stochastic, one may wonder if simple strategies for inducing stochasticity, such as adding -greedy noise or entropy regularization, can alleviate the suboptimality that arose with deterministic policies in the previous paragraph. In some cases, this may be true; one particularly interesting result is that in certain goal-reaching problems, entropy-regularized RL can be interpreted as optimizing an epistemic POMDP objective with a specific form of posterior distribution over reward functions (Proposition B.3) [52]. For the more general setting, we show in Proposition B.4 that entropy regularization and other general-purpose techniques can similarly catastrophically fail in epistemic POMDPs.
Remark 5.3 (Failure of Generic Stochasticity, Proposition B.4). The expected test-time return of policies learned with stochastic regularization techniques like maximum-entropy RL that are agnostic of the posterior P(M|D) may be arbitrarily low compared to that of Bayes-optimal behavior.
This failure happens because the degree of stochasticity used by the Bayes-optimal policy reflects the agent’s epistemic uncertainty about the environment; since standard regularizations are agnostic to this uncertainty, the learned behaviors often do not reflect the appropriate level of stochasticity needed. A maze-solving agent acting Bayes-optimally, for example, may choose to act deterministically in mazes like those it has seen at training, and on others where it is less confident, rely on random exploration to exit the maze, inimitable behavior by regularization techniques agnostic to this uncertainty.
Our analysis of the epistemic POMDP highlights the difficulty of generalizing well in RL, in the complexity of Bayes-optimal policies (Remark 5.1) and the deficiencies of our standard MDP-based RL algorithms (Remark 5.2, 5.3) . While MDP-based algorithms can serve as a useful starting point for acquiring generalizable skills, learning policies that perform well in new test-time scenarios may require more complex algorithms that attend to the epistemic POMDP structure that is implicitly induced by the agent’s epistemic uncertainty.

heading: 6 Learning Policies that Generalize Well Using the Epistemic POMDP

text:
When the epistemic POMDPMpo can be exactly obtained, we can learn RL policies that generalize well to the true (unknown) MDPM by learning an optimal policy in the POMDP. In this oracle setting, any POMDP-solving method will suffice, and design choices like policy function classes (e.g. recurrent vs Markovian policies) or agent representations (e.g. belief state vs PSRs) made based on the requirements of the specific domain. However, in practice, the epistemic POMDP can be challenging to approximate due to the difficulties of learning coherent MDP models and maintaining a posterior over such MDP models in high-dimensional domains.
In light of these challenges, we now focus on practical methods for learning generalizable policies when the exact posterior distribution (and therefore true epistemic POMDP) cannot be recovered exactly. We derive an algorithm for learning the optimal policy in the epistemic POMDP induced by an approximate posterior distribution P̂(M|D) with finite support. We use this to motivate LEEP, a simple ensemble-based algorithm for learning policies in the contextual MDP setting.

heading: 6.1 Policy Optimization in an Empirical Epistemic POMDP

text:
Towards a tractable algorithm, we assume that instead of the true posterior P(M|D), we only have access to an empirical posterior distribution P̂(M|D) defined by n MDP samples from the posterior distribution {Mi}i∈[n]. This empirical posterior distribution induces an empirical epistemic POMDP
M̂po; our ambition is to learn the optimal policy in this POMDP. Rather than directly learning this optimal policy as a generic POMDP solver might, we recognize that M̂po corresponds to a collection of n MDPs 2 and decompose the optimization problem to mimic this structure. We will learn n policies π1, · · · , πn, each policy πi in one of the MDPsMi from the empirical posterior, and combine these policies together to recover a single policy π for the POMDP. Reducing the POMDP policy learning problem into a set of MDP policy learning problems can allow us to leverage the many recent advances in deep RL for scalably solving MDPs. The following theorem links the expected return of a policy π in the empirical epistemic POMDP M̂po, in terms of the performance of the policies πi on their respective MDPsMi. Proposition 6.1. Let π, π1, · · ·πn be memoryless , and define rmax = maxi,s,a |rMi(s, a)|. The expected return of π in M̂po is bounded below as:
JM̂po(π) ≥ 1
n n∑ i=1 JMi(πi)− √ 2rmax (1− γ)2n n∑ i=1 Es∼dπiMi [√ DKL (πi(·|s) || π(·|s)) ] , (3)
This proposition indicates that if the policies in the collection {πi}i∈[n] all achieve high return in their respective MDPs (first term) and are imitable by a single policy π (second term), then π is guaranteed to achieve high return in the epistemic POMDP. In contrast, if the policies cannot be closely imitated by a single policy, this collection of policies may not be useful for learning in the epistemic POMDP using the lower bound. This means that it may not sufficient to naively optimize each policy πi on its MDPMi without any consideration to the other policies or MDPs, since the learned policies are likely to be different and difficult to jointly imitate. To be useful for the lower bound, each policy πi should balance between maximizing performance on its MDP and minimizing its deviation from the other policies in the set. The following proposition shows that if the policies are trained jointly to ensure this balance, it in fact recovers the optimal policy in the empirical epistemic POMDP.
Proposition 6.2. Let f : {πi}i∈[n] 7→ π be a function that maps n policies to a single policy satisfying f(π, · · · , π) = π for every policy π, and let α be a hyperparameter satisfying α ≥ √ 2rmax
(1−γ)2n . Then letting π∗1 , . . . π ∗ n be the optimal solution to the following optimization problem:
{π∗i }i∈[n] = argmax π1,··· ,πn
1
n n∑ i=1 JMi(πi)− α n∑ i=1 Es∼dπiMi [√ DKL (πi(·|s) || f({πi})(·|s)) ] , (4)
the policy π∗ := f({π∗i }i∈[n]) is optimal for the empirical epistemic POMDP M̂po.

heading: 6.2 A Practical Algorithm for Contextual MDPs: LEEP

text:
Proposition 6.2 provides a foundation for a practical algorithm for learning policies when provided training contexts Ctrain from an unknown contextual MDP. In order to use the proposition in a practical algorithm, we must discuss two problems: how posterior samplesMi ∼ P(M|D) can be approximated, and how the function f that combines policies should be chosen.
Approximating the posterior distribution: Rather than directly maintaining a posterior over transition dynamics and reward models, which is especially difficult with image-based observations, we can approximate samples from the posterior via a bootstrap sampling technique [53]. To sample a candidate MDPMi, we sample with replacement from the training contexts Ctrain to get a new set of contexts Citrain, and defineMi to be the empirical MDP on this subset of training contexts. Rolling out trials from the posterior sampleMi then corresponds to selecting a context at random from Citrain, and then rolling out that context. Crucially, note thatMi still corresponds to a distribution over contexts, not a single context, since our goal is to sample from the posterior entire contextual MDPs.
Choosing a link function: The link function f in Proposition 6.2 that combines the set of policies together effectively serves as an inductive bias: since we are optimizing in an approximation to the true epistemic POMDP and policy optimization is not exact in practice, different choices can yield combined policies with different characteristics. Since optimal behavior in the epistemic POMDP must consider all actions, even those that are potentially sub-optimal in all MDPs in the posterior (as discussed in Section 5.2), we use an “optimistic” link function
2Note that when the true environment is a contextual MDP, the sampled MDP Mi does not correspond to a single context within a contextual MDP — each MDP Mi is an entire contextual MDP with many contexts.
Algorithm 1 Linked Ensembles for the Epistemic POMDP (LEEP) 1: Receive training contexts Ctrain, number of ensemble members n 2: Bootstrap sample training contexts to create C1train, . . . Cntrain, where Citrain ⊂ Ctrain. 3: Initialize n policies: π1, . . . πn 4: for iteration k = 1, 2, 3, . . . do 5: for policy i = 1, . . . , n do 6: Collect environment samples in training contexts Citrain using policy πi 7: Take gradient steps wrt πi on these samples with augmented RL loss:
πi ← πi − η∇i(LRL(πi) + αEs∼πi,Citrain [DKL(πi(a|s)‖maxj πj(a|s))])
8: Return π = maxi π: π(a|s) = maxi πi(a|s)∑ a′ maxi πi(a ′|s) .
that does not dismiss any action that is considered by at least one of the policies, specifically f({πi}i∈[n]) = (maxi πi)(a|s) := maxπi(a|s)∑
a′ maxπi(a ′|s) .
Algorithm: We learn a set of n policies {πi}i∈[n], using a policy gradient algorithm to implement the update step. To update the parameters for πi, we take gradient steps via the surrogate loss used for the policy gradient, augmented by a disagreement penalty between the policy and the combined policy f({πi}i∈[n]) with a penalty parameter α > 0, as in Equation 5:
L(πi) = LRL(πi) + αEs∼πi,Mi [DKL(πi(a|s)‖max j πj(a|s))]. (5)
Combining these elements together leads to our method, LEEP, which we summarize in Algorithm 1. In our implementation, we use PPO for LRL(πi) [54]. In summary, LEEP bootstrap samples the training contexts to create overlapping sets of training contexts C1train, . . . Cntrain. Every iteration, each policy πi generates rollouts in training contexts chosen uniformly from its corresponding Citrain, and is then updated according to Equation 5, which both maximizes the expected reward and minimizes the disagreement penalty between each πi and the combined policy π = maxj πj .
While this algorithm is structurally similar to algorithms for multi-task learning that train a separate policy for each context or group of contexts with a disagreement penalty [55, 56], the motivation and the interpretation of these approaches are completely distinct. In multi-task learning, the goal is to solve a given set of tasks, and these methods promote transfer via a loss that encourages the solutions to the tasks to be in agreement. In our setting, while we also receive a set of tasks (contexts), the goal is not to maximize performance on the training tasks, but rather to learn a policy that maximizes performance on unseen test tasks. The method also has a subtle but important distinction: each of our policies πi acts on a sample from the contextual MDP posterior (which captures epistemic uncertainty), not a single training context [55] or element from a disjoint partitioning [56] (which does not). This distinction is crucial, since our generalization performance requires our aim is not to make it easier to solve the training contexts, but the opposite: prevent the algorithm from overfitting to the individual training contexts. Correspondingly, our experiments confirm that such multi-task learning approaches do not provide the same generalization benefits as our approach.

heading: 7 Experiments

text:
The primary ambition of our empirical study is to test the hypothesis that policies that are learned through (approximations of) the epistemic POMDP do in fact attain better test-time performance than those learned by standard RL algorithms. We do so on the Procgen benchmark [16], a challenging suite of diverse tasks with image-based observations testing generalization to unseen contexts.
1. Does LEEP derived from the epistemic POMDP lead to improved test-time performance over standard RL methods?
2. Can LEEP prevent overfitting when provided a limited number of training contexts? 3. How do different algorithmic components of LEEP affect test-time performance ?
The Procgen benchmark is a set of procedurally generated games, each with different generalization challenges. In each game, during training, the algorithm can interact with 200 training levels, before it is asked to generalize to the full distribution of levels. The agent receives a 64 × 64 × 3 image observation, and must output one of 15 possible actions. We instantiate our method using an ensemble
of n = 4 policies, a penalty parameter of α = 1, and PPO [54] to train the individual policies (full implementation details in Appendix C).
We evaluate our method on four games in which prior work has found a large gap between training and test performance, and which we therefore conclude pose a significant generalization challenge [16, 23, 26]: Maze, Heist, BigFish, and Dodgeball. In Figure 4, we compare the test-time performance of the policies learned using our method to those learned by a PPO agent with entropy regularization. In three of these environments (Maze, Heist, and Dodgeball), our method outperforms PPO by a significant margin, and in all cases, we find that the generalization gap between training and test performance is lower for our method than PPO (Appendix D.1).
To understand how LEEP behaves with fewer training contexts, we ran on the Maze task with only 50 levels (Figure 5 (top)); the test return of the PPO policy decreases through training, leading to final performance worse than the starting random policy, but our method avoids this degradation.
We perform an ablation study on the Maze and Heist environments (Maze in Figure 4, Heist in Appendix D.1) to rule out potential confounding causes for the improved generalization that our method displays on the Procgen benchmark tasks. First, to see if the performance benefit derives solely from the use of ensembles, we compare LEEP to a Bayesian model averaging strategy that trains an ensemble of policies without regularization (“Ensemble (no reg)”), and uses a mixture of these policies. This strategy does improve performance over the PPO policy, but does not match LEEP, indicating the usefulness of the regularization. Second, we compared to a version of LEEP that combines the ensemble policies together using the average 1n ∑n i=1 πi(a|s) (“LEEP (avg)”). This link function achieves worse test-time performance than the optimistic version, which indicates that the inductive bias conferred by the maxi πi link function is a useful component of the algorithm. We also compare to Distral, a multi-task learning method with different motivations
but similar structure to LEEP: this method helps accelerate learning on the provided training contexts (figures in Appendix D.1), but does not improve generalization performance as LEEP does. We additionally ablated the two key hyperparameters in LEEP, the number of ensemble members n and the penalty coefficient α (Table in Appendix D.2).

heading: 8 Discussion

text:
It has often been observed experimentally that generalization in RL poses a significant challenge, but it has so far remained an open question as to whether the RL setting itself presents additional generalization challenges beyond those seen in supervised learning. In this paper, we answer this question in the affirmative, and show that, in contrast to supervised learning, generalization in RL results in a new type of problem that cannot be solved with standard MDP solution methods, due to partial observability induced by epistemic uncertainty. We call the resulting partially observed setting the epistemic POMDP, where uncertainty about the true underlying MDP results in a challenging partially observed problem. We present a practical approximate method that optimizes a bound for performance in an approximation of the epistemic POMDP, and show empirically that this approach, which we call LEEP, attains significant improvements in generalization over other RL methods that
do not properly incorporate the agent’s epistemic uncertainty into policy optimization. A limitation of this approach is that it optimizes a crude approximation to the epistemic POMDP with a small number of posterior samples, and may be challenging to scale to better approximations to the true objective. Developing algorithms that better model the epistemic POMDP and optimize policies within is an exciting avenue for future work, and we hope that this direction will lead to further improvements in generalization in RL.

heading: Acknowledgements

text: This research was supported by an NSF graduate fellowship, the DARPA assured autonomy program, the NSF IIS-2007278 grant, a Princeton SEAS Innovation Grant and compute support from Google and Microsoft. We thank Benjamin Eysenbach, Xinyang Geng, and Justin Fu as well as members of the Princeton Laboratory for Intelligent Probabilistic Systems for helpful discussions and feedback.

title: Why Generalization in RL is Difficult: Epistemic POMDPs and Implicit Partial Observability