Abstract
Reinforcement learning (RL) from raw pixels is often hindered by high-dimensional noise and the non-Markovian nature of individual images. We present CoDy (COntrastive learning with DYnamic models), a framework that enhances sample efficiency by learning latent representations that are simultaneously Markovian, robust to augmentations, and linearly predictive. CoDy integrates three auxiliary tasks: Temporal Mutual Information (TMI) for linear dynamics, Explicit Prediction (Pred) for Markovianity, and Multi-View Mutual Information (MVMI) for transition model invariance. Evaluated on the DeepMind Control Suite, CoDy matches the performance of state-based agents and demonstrates superior generalization to unseen tasks.
Introduction
Training RL agents directly from raw pixels remains a significant challenge due to the "sample-hungry" nature of high-dimensional inputs. Images often contain task-irrelevant noise and lack the Markov property—a single frame typically does not capture velocity or acceleration necessary for future prediction. Existing approaches generally rely on pixel reconstruction, which can waste capacity on irrelevant details, or contrastive learning, which may fail to guarantee a Markovian state representation.
CoDy addresses these issues by explicitly improving the Markovianity of learned embeddings. By combining contrastive signals with explicit non-linear transition models, the framework "squeezes" the representation to retain only the information necessary for predicting future states, thereby improving both sample efficiency and generalization.
Methods: The CoDy Framework
CoDy integrates three auxiliary tasks into a standard Soft Actor-Critic (SAC) agent to regularize the latent space. The architecture, shown in Figure 1, utilizes target networks updated via Exponential Moving Average (EMA) to stabilize training.
Auxiliary Objectives
- Temporal Mutual Information (TMI): This task uses an InfoNCE loss to maximize the mutual information between the current state-action pair $(z_t, c_t)$ and the next state $z_{t+1}$. By employing a log-bilinear classifier, it encourages the latent space to exhibit linear dynamics.
- Explicit Prediction (Pred): CoDy trains a non-linear transition model to minimize the squared error between the predicted next-state embedding $\hat{z}_{t+1}$ and the actual embedding $z_{t+1}$. This forces the encoder to retain features essential for future prediction, enhancing the Markovianity of the state.
- Multi-View Mutual Information (MVMI): This novel component ensures robustness to data augmentations. It maximizes the mutual information between predicted next-state embeddings generated from two different augmentations of the same current state. This ensures that both the encoder and the transition model learn transformation-invariant logic.
Experimental Evaluation
The method was evaluated on six diverse tasks from the DeepMind Control Suite, including Ball-in-cup Catch, Cartpole Swingup, and Cheetah Run. These tasks cover challenges such as sparse rewards, partial observability, and complex contact dynamics.
Key Results
- Sample Efficiency: CoDy consistently outperformed leading baselines, including CURL, PISAC, SAC-AE, and the model-based Dreamer.
- Performance Parity: At 500k environment steps, CoDy's performance from raw images matched or nearly matched "State SAC"—an agent trained with access to ground-truth physics.
- Generalization: In transfer learning experiments, CoDy's representations generalized significantly better to unseen tasks. For instance, on the Cartpole task, CoDy achieved nearly double the reward of CURL when transferred to a new starting configuration.
- Latent Space Structure: t-SNE visualizations indicate that CoDy naturally organizes the latent space based on robot configurations (e.g., joint positions) without explicit supervision.
Conclusion and Future Work
CoDy demonstrates that integrating contrastive learning with explicit dynamic models creates a powerful synergy for image-based RL. While the current implementation uses the transition model solely for representation learning, future work could involve integrating this model into planning or "imagination" frameworks. Additionally, extending CoDy to handle multimodal sensory inputs, such as tactile or auditory data, remains a promising direction for creating more robust and versatile agents.
Summary updated