Instance-based Generalization in Reinforcement Learning

Martín Bertrán, Natalia Martínez, Mariano Phielipp, Guillermo Sapiro

TL;DR

Reinforcement Learning (RL) agents often fail to generalize because they "cheat" by memorizing specific training levels (instances) rather than learning the underlying rules of the environment. This paper formalizes this behavior as "instance-based overfitting" and introduces Instance Agnostic Policy Ensembles (IAPE), a method that uses an ensemble of policies and a shared belief representation to force agents to learn generalizable strategies instead of level-specific "speed-runs."

What Problem Does This Paper Address?

In deep RL, we often train agents on a fixed set of levels (like in the Procgen benchmark) and expect them to perform well on new, unseen levels. However, agents frequently exhibit a massive "generalization gap."

Instance-dependent POMDP formulation

The authors argue that when an agent is trained on a finite number of levels, the environment's dynamics effectively change. In a single, deterministic level, the sequence of past observations can uniquely identify exactly which level the agent is in. Instead of learning to navigate a platformer by reacting to obstacles, the agent learns a specific "button-press sequence" (a speed-run) that only works for that specific level ID. This is a form of overfitting where the agent learns to infer the instance rather than the state of the environment.

Methods

The authors provide a theoretical framework using Partially Observable Markov Decision Processes (POMDPs) to show how training on finite instances breaks the Markov property and encourages sub-optimal "speed-running" policies. To combat this, they propose Instance Agnostic Policy Ensembles (IAPE):

  1. Shared Representation: All levels share a common "belief" encoder that processes observations into a latent representation.
  2. Policy Ensembles: The training levels are split into subsets. Each subset has its own specialized policy and value "head" that branches off the shared representation.
  3. Consensus for Data Collection: This is the "secret sauce." During training, the agent interacts with the environment using a consensus policy (the average of all ensemble heads) rather than the specialized head for that specific level.
  4. Regularization: By forcing the agent to collect data using a consensus policy, it prevents any single head from exploiting level-specific quirks. This encourages the shared representation to capture features that are useful across all levels, not just one.

Datasets

The researchers evaluated their approach using the CoinRun benchmark (part of OpenAI’s Procgen).

  • Training: A fixed set of 500 levels.
  • Testing: An unbounded set of unseen levels sampled from the same distribution.
  • Baseline: They compared IAPE against standard PPO, $\ell_2$ regularization, and "Cutout" (a common data augmentation technique in RL).

Key Insights and Ideas

  • The "Speed-Run" Trap: The paper proves that as the number of training instances increases, the "effective" dynamics of the training set converge to the true environment dynamics. With few levels, the agent finds it easier to memorize the level than to learn the physics.
  • Information Bottleneck: Generalization error is mathematically linked to the mutual information between the learned policy and the specific training instances. If the policy "knows" too much about which level it's in, it won't generalize.
  • Data Collection Matters: Most RL generalization research focuses on the loss function or architecture. This paper highlights that how you collect experience is vital. Using a "generalist" policy to explore "specialist" levels prevents the agent from discovering (and thus memorizing) instance-specific exploits.

Key Results

The IAPE method significantly outperformed standard regularization techniques on unseen levels.

IAPE performance and ensemble similarity
  • Test Performance: IAPE achieved a test reward of 8.23, compared to 7.47 for the base model and 7.99 for the best-performing standard regularization ($\ell_2$ + Cutout).
  • Behavioral Shift: The authors measured a metric called $\Delta T_{base} | R$ (the difference in time-to-reward). High values indicate "speed-running." IAPE showed much lower values on training sets compared to the base model, proving it was playing more "cautiously" and generally, rather than exploiting the levels.
  • Consistency: Analysis of the ensemble heads showed high cosine similarity (around 0.92), indicating that the different heads actually converged on a similar, generalizable strategy rather than diverging into level-specific tricks.

Limitations and Future Work

  • Computational Cost: Training an ensemble of policy heads and a shared encoder is more computationally expensive than a single-head model.
  • Subset Sensitivity: The method relies on splitting levels into subsets; the paper assumes these subsets are large enough to be representative, but doesn't deeply explore how to optimize this partitioning.
  • Scope: While highly effective on CoinRun, the method's performance on more complex 3D environments or tasks with sparse rewards remains an open question for future research.

Summary updated

BibTeX
@inproceedings{bertran2020instance,
  author = {Martín Bertrán and Natalia Martínez and Mariano Phielipp and Guillermo Sapiro},
  title = {{Instance-based Generalization in Reinforcement Learning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2020},
  url = {https://openreview.net/forum?id=QXAFRvuYfnc},
}
Figure