Memory-Consistent Neural Networks for Imitation Learning

Kaustubh Sridhar, Souradeep Dutta, Dinesh Jayaraman, James Weimer, Insup Lee

The Challenge of Compounding Errors in Imitation Learning

Behavior Cloning (BC) is a popular, straightforward imitation learning technique where an agent learns to perform a task by mimicking expert demonstrations via supervised learning. However, BC suffers from a notorious "compounding error" problem.

During deployment, if an agent makes a tiny mistake, it lands in a state slightly different from anything in its training data. Because standard deep neural networks can behave erratically on out-of-distribution inputs, the agent is likely to make an even larger error in this unfamiliar state. This snowballs into a vicious cycle of compounding errors, eventually leading to total task failure.

To address this, researchers have introduced Memory-Consistent Neural Networks (MCNNs). This novel semi-parametric approach hard-constrains a neural network's outputs to stay close to known "memory" examples from the training set, preventing wild extrapolations and significantly boosting performance across various architectures and robotic tasks—especially when training data is scarce.

How Memory-Consistent Neural Networks Work

Instead of relying solely on a parametric neural network, MCNNs blend nearest-neighbor lookups with deep learning to ensure safe, predictable behavior. The approach relies on a few key mechanisms:

  1. Memory Codebook: The system uses the "Neural Gas" algorithm to subsample the expert training data into a smaller set of representative prototype states, referred to as "memories."
  2. Hard-Constrained Interpolation: For any given input state during deployment, the MCNN finds the nearest memory. The final action output is a distance-weighted mixture of the nearest memory's action and the neural network's prediction.
  3. Bounded Extrapolation: Crucially, the neural network's contribution is passed through a compressive non-linearity (a dynamic tanh-like function). This creates a "permissible region" shaped like a double-cone around each memory.
Memory-Consistent Neural Network constraining outputs within permissible regions around memory points.

The further the agent strays from a known memory, the more it relies on the neural network—but the output is strictly bounded so it cannot make wildly unpredictable jumps. Furthermore, MCNN acts as a plug-and-play architectural wrapper. The underlying neural network can be anything: a standard Multi-Layer Perceptron (MLP), a Behavior Transformer (BeT), or a Diffusion model.

Key Insights and Performance Gains

The MCNN function class has a mathematically bounded width, allowing the authors to prove a guaranteed upper bound on the imitation learning sub-optimality gap—a rare theoretical guarantee for deep imitation learning.

Empirically, MCNNs were evaluated on 10 tasks across three domains: Adroit Dexterous Manipulation, CARLA Autonomous Driving, and Franka Kitchen multimodal interactions.

MCNN performance gains over standard BC across varying numbers of demonstration trajectories.

Massive Gains in Low-Data Regimes: On highly realistic, low-data Adroit "human" tasks (using only 25 demonstrations), MCNN+MLP outperformed the nearest baseline by 33% on the Pen task. Remarkably, it was the only method to achieve a positive return on the Hammer task, jumping from a score of -11 to 262. As shown in the performance trends, MCNNs provide the most dramatic relative improvements when demonstration trajectories are severely limited.

Scaling to High-Data and Complex Tasks: * High-Data Regime: On Adroit "expert" tasks with 5,000 demonstrations, MCNN+MLP still improved aggregate performance by over 100% compared to the nearest baseline. * Franka Kitchen: MCNN+Diffusion matched the state-of-the-art Diffusion-BC baseline on 1-to-4 object interactions (100% success) but achieved a 4x improvement on the hardest 5-object interaction task. * Visual Driving: In the high-dimensional CARLA driving task (using image inputs mapped to 512D embeddings), MCNN+MLP outperformed the nearest baseline by 27%.

Surprisingly, a simple MLP wrapped in the MCNN framework often outperformed state-of-the-art, highly complex Diffusion models that lacked memory-consistency constraints. The authors also found a "sweet spot" for memory efficiency: using just 10-20% of the dataset as the memory codebook provided the best balance of high performance and computational speed.

Limitations and Future Directions

Because MCNN requires a nearest-neighbor search at every step, it incurs a higher computational overhead during inference than a vanilla neural network. However, by keeping the memory bank small, it remains much faster than pure k-Nearest Neighbor approaches.

While the double-cone constraint is a highly effective heuristic for enforcing memory consistency, future work may explore alternative mathematical formulations. The authors also suggest expanding the MCNN model class beyond simple behavior cloning, potentially applying it to offline reinforcement learning and meta-learning scenarios where safe extrapolation is equally critical.

Summary updated

BibTeX
@inproceedings{sridhar2024memory,
  author = {Kaustubh Sridhar and Souradeep Dutta and Dinesh Jayaraman and James Weimer and Insup Lee},
  title = {{Memory-Consistent Neural Networks for Imitation Learning}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=R3Tf7LDdX4},
}
Figure