Self-Supervised Policy Adaptation during Deployment

Nicklas Hansen, Rishabh Jangir, Yu Sun, Guillem Alenyà, Pieter Abbeel, Alexei A. Efros, Lerrel Pinto, Xiaolong Wang

In the world of Reinforcement Learning (RL), agents are often trained in pristine simulations only to fail miserably the moment they encounter a slightly different "real-world" environment. A change in lighting, a new floor texture, or a distracting background can be enough to break a policy that looked perfect during training.

The standard fix is Domain Randomization—training the agent on every possible variation imaginable. But what if you cannot anticipate the changes? In their ICLR 2021 paper, Hansen et al. present a more elegant solution: Policy Adaptation during Deployment (PAD). Instead of trying to be ready for everything, the agent simply keeps learning after it is deployed, even when there are no rewards to guide it.

The Generalization Gap

The "Generalization Gap" is the Achilles' heel of vision-based RL. An agent trained to walk in a gray simulation might freeze if the floor turns red.

The core challenge is that rewards are usually unavailable during deployment. In training, we have a "god-view" reward function (e.g., "distance traveled"). In the real world, calculating that reward often requires the very sensors and calibration we are trying to avoid relying on. Consequently, most RL agents are "frozen" once they leave the lab. If the environment shifts, the agent cannot adjust because it has no feedback signal to tell it how it is doing.

Methodology: Policy Adaptation during Deployment (PAD)

To solve this, the authors propose an architecture that leverages self-supervised learning to provide a continuous training signal. The architecture consists of three parts:

  1. A Shared Feature Extractor ($\pi_e$): The "eyes" of the agent that turn pixels into abstract features.
  2. An RL Head ($\pi_a$): The "brain" that decides which action to take based on those features.
  3. A Self-Supervised Head ($\pi_s$): An auxiliary task that provides a "free" training signal from the raw data.
PAD Architecture: Training vs. Deployment

The Secret Sauce: Self-Supervision

During training, the agent learns to maximize reward and solve a self-supervised task simultaneously.

  • For Control Tasks: They use an Inverse Dynamics Model (IDM). The agent looks at two consecutive frames ($s_t, s_{t+1}$) and tries to predict which action ($a_t$) caused the transition.
  • For Navigation Tasks: They use Rotation Prediction. The agent takes an image, rotates it (0, 90, 180, or 270 degrees), and tries to guess the rotation.

The Deployment Phase: When the agent is deployed in a new environment, the reward signal is turned off. However, the agent can still see its own actions and the resulting images. It continues to solve the self-supervised task, using the resulting gradients to update the Shared Feature Extractor. This forces the "eyes" of the agent to adapt to the new visual distribution of the test environment while the "brain" (the policy head) remains fixed.

Datasets and Environments

The researchers evaluated PAD across three diverse domains, introducing drastic visual shifts to test the agent's adaptability:

Visual variations in DMC and ViZDoom environments
  1. DeepMind Control (DMC) Suite: 9 continuous control tasks (like Walker and Cheetah) tested against randomized colors, natural video backgrounds, and distracting objects.
  2. CRLMaze (ViZDoom): A 3D navigation task where the agent must find items in a maze with changing wall, floor, and ceiling textures.
  3. Real-World Robotics: A Kinova Gen3 robot arm performing "reaching" and "pushing" tasks. They introduced visual changes like a patterned tablecloth and non-stationary "disco lights" to simulate extreme lighting shifts.

Key Insights and Results

  • Adaptation > Invariance: Instead of trying to learn a single policy that ignores all visual changes (which is hard and requires massive models), it is more efficient to learn a policy that knows how to re-calibrate itself.
  • Broad Success: PAD improved generalization in 31 out of 36 tested environments, consistently beating Domain Randomization (+DR), especially in environments with highly complex "natural video" backgrounds.
  • Sim-to-Real: On the real robot "pushing" task, PAD achieved an 88% success rate on a patterned tablecloth compared to just 60% for a standard Soft Actor-Critic (SAC) agent. In the "disco lights" environment, PAD maintained an 84% success rate, while the baseline struggled at 60%.
  • Online is Better than Offline: Updating the model "online" (step-by-step as data arrives) proved significantly better than "offline" adaptation, allowing the agent to handle non-stationary environments where conditions change continuously.

Limitations and Future Work

While PAD is a significant step forward, it has limitations. The choice of the self-supervised task is highly task-specific; IDM worked great for motor control but failed for navigation, where Rotation Prediction was needed. Furthermore, PAD primarily adapts the visual representation. If the physics of the environment changes (e.g., gravity changes or the floor becomes slippery), current self-supervised tasks might not fully compensate.

Ultimately, this work points toward a future of "embodied agents" that learn continuously, seamlessly switching between rewarded and reward-less learning throughout their entire lifespan.

Paper Citation: Hansen, N., Jangir, R., Sun, Y., Alenya, G., Abbeel, P., Efros, A. A., Pinto, L., & Wang, X. (2021). Self-Supervised Policy Adaptation during Deployment. International Conference on Learning Representations (ICLR).",

Summary updated

BibTeX
@inproceedings{hansen2021self,
  author = {Nicklas Hansen and Rishabh Jangir and Yu Sun and Guillem Alenyà and Pieter Abbeel and Alexei A. Efros and Lerrel Pinto and Xiaolong Wang},
  title = {{Self-Supervised Policy Adaptation during Deployment}},
  booktitle = {International Conference on Learning Representations},
  year = {2021},
}
Figure