MoCoDA: Model-based Counterfactual Data Augmentation

Silviu Pitis, Elliot Creager, Ajay Mandlekar, Animesh Garg · DOI

Introduction

Reinforcement Learning (RL) agents often struggle with the "curse of dimensionality," particularly in environments containing multiple interacting objects. In offline RL settings, where agents must learn from a fixed dataset without further exploration, this issue is exacerbated. If the training data lacks coverage of specific object combinations required for a target task, standard algorithms typically fail to generalize. MoCoDA (Model-based Counterfactual Data Augmentation) addresses this by leveraging local causal structures to generate physically plausible "counterfactual" transitions that were never observed in the original data.

The MoCoDA Framework

The core innovation of MoCoDA is its ability to synthesize novel experiences by recombining components of observed transitions. The framework follows a structured pipeline to bridge the gap between empirical data and out-of-distribution (OOD) tasks:

  1. Modeling the Parent Distribution: The system identifies the "parents"—the specific state and action variables that influence a given outcome—and models their distribution using Gaussian Mixture Models (GMMs).
  2. Locally Factored Dynamics: Unlike global "black box" models, MoCoDA uses a masked neural network that respects the environment's causal structure. This allows the model to learn how individual components (e.g., an object's position) change based solely on their relevant parents.
  3. Counterfactual Data Generation: By sampling parents from different observed transitions and recombining them, the system creates novel state-action pairs. The factored dynamics model then predicts the resulting next state.
The MoCoDA training pipeline: from causal structure and experience data to augmented training for the agent.

Experimental Evaluation

The authors evaluated MoCoDA on two primary domains: a 2D Navigation task and a complex robotics task called HookSweep2.

In the 2D Navigation task, the training data was restricted to an "L-shaped" distribution, while the optimal path required diagonal movement through unseen regions. MoCoDA successfully filled this gap, providing the agent with the necessary coverage to learn the optimal policy.

Visualization of data coverage in the 2D Navigation task across different methods. MoCoDA significantly improves state-space coverage compared to empirical data (EMP) or standard Dyna.

In the HookSweep2 task, a Fetch robot had to sweep two boxes simultaneously. The training data only contained examples of sweeping a single box. While standard offline RL algorithms (like BCQ and TD3-BC) failed completely (near 0% success), MoCoDA-augmented training achieved an 84% success rate, demonstrating zero-shot generalization to multi-object interactions.

Key Insights

  • Local Factorization and Generalization: The paper proves that locally factored dynamics models can generalize to OOD combinations of inputs. If a model understands how a robot and an object move independently, it can accurately predict their joint behavior in new configurations.
  • Entanglement in Policies: While dynamics are often sparse and factored, optimal policies and value functions are usually "entangled" over long horizons. MoCoDA uses factored models to generate the data needed for the policy to learn these complex, entangled relationships.
  • Sample Efficiency: Utilizing local causal structure can lead to an exponential reduction in the data required to train accurate dynamics models.

Conclusion

MoCoDA provides a powerful mechanism for offline RL agents to "imagine" and learn from scenarios they have never encountered. By grounding data augmentation in the causal physics of the environment, it enables zero-shot generalization to complex, multi-object tasks. Future work aims to automate the discovery of these causal structures and extend the method to high-dimensional visual inputs.

Summary updated

BibTeX
@inproceedings{pitis2022mocoda,
  author = {Silviu Pitis and Elliot Creager and Ajay Mandlekar and Animesh Garg},
  title = {{MoCoDA: Model-based Counterfactual Data Augmentation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=w6tBOjPCrIO},
}
Figure