Predictive Coding for Boosting Deep Reinforcement Learning with Sparse Rewards

Xingyu Lu, Stas Tiomkin, Pieter AbbeelarXiv 2019

Abstract

Deep Reinforcement Learning (DRL) often struggles with sparse reward environments where agents receive feedback only upon task completion. Traditional solutions involve manual reward shaping, which is expert-dependent and prone to "reward hacking." This paper introduces an unsupervised method that utilizes Contrastive Predictive Coding (CPC) to learn environment dynamics from raw observations. By mapping states into a latent embedding space, the proposed framework automatically generates supplemental reward signals. Experimental results across GridWorld and MuJoCo benchmarks demonstrate that these learned rewards can guide agents as effectively as hand-crafted functions while maintaining robustness against visual noise.

Introduction

In many real-world reinforcement learning scenarios, the "needle-in-a-haystack" problem of sparse rewards prevents efficient policy discovery. An agent navigating a complex maze may receive no feedback until the final goal is reached, leading to inefficient exploration. While reward shaping—adding intermediate rewards—can mitigate this, it typically requires significant domain expertise. This research proposes a pipeline to automate reward shaping by learning the underlying topology of the environment's state space without human intervention.

Methods: Representation Learning and Reward Shaping

The proposed approach follows a two-stage process:

  1. Unsupervised Representation Learning: The agent first performs random exploration to collect a dataset of trajectories. These are used to train a Contrastive Predictive Coding (CPC) model. CPC optimizes an encoder to maximize the mutual information between current and future latent states, forcing the model to capture essential dynamics rather than superficial visual features.
  2. Automated Reward Generation: The learned embeddings are used to provide supplemental rewards:
  3. Discrete Environments (Clustering): Latent states are grouped into clusters. The agent is rewarded for transitioning into the cluster containing the goal state.
  4. Continuous Environments (Embedding Distance): The agent receives a penalty proportional to the Euclidean distance between its current embedding and the goal's embedding.
The pipeline from raw state observations to learned embeddings and discrete clusters for reward shaping.

Key Insights: Functional vs. Raw Distance

A critical advantage of using predictive coding is its ability to capture the "functional" distance of an environment. In a maze, two points separated by a wall might be physically close in raw coordinate space but are functionally distant because reaching one from the other requires a long path. CPC embeddings naturally reflect this topology because they are trained on temporal transitions.

Comparison of raw distance versus functional distance in a U-Maze, showing how embeddings capture the true environment topology.

Furthermore, by focusing on features that predict change, the model becomes "texture agnostic." It ignores static background noise that does not impact the physics of the task, a property demonstrated in experiments with varying visual textures in the Pendulum environment.

Experimental Results

The method was evaluated on several standard benchmarks:

  • GridWorld: In U-Maze and Four-Rooms layouts, success rates improved from ~60-70% with standard RL to 98% using the learned clustering rewards.
  • Continuous Control: In the Reacher task, the embedding-based reward led to faster and more stable convergence than standard hand-shaped rewards.
  • High-Dimensional Tasks: In the AntMaze, the learned rewards successfully guided a quadruped robot through a complex environment, matching the performance of expert-designed reward functions.

Conclusion and Future Work

This work demonstrates that unsupervised predictive coding can effectively automate reward shaping, reducing the need for manual engineering in sparse reward tasks. While the current method relies on an initial random exploration phase, future research could explore online training where the representation and policy are learned simultaneously. Additionally, combining this approach with advanced exploration strategies may extend its utility to extremely long-horizon tasks where random actions are insufficient to discover the state space.

Summary updated

BibTeX
@misc{lu2019predictive,
  author = {Xingyu Lu and Stas Tiomkin and Pieter Abbeel},
  title = {{Predictive Coding for Boosting Deep Reinforcement Learning with Sparse Rewards}},
  year = {2019},
  eprint = {1912.13414},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1912.13414},
}
Figure