Keyframe-Focused Visual Imitation Learning

Chuan Wen, Jierui Lin, Jianing Qian, Yang Gao, Dinesh Jayaraman

Behavioral Cloning (BC) is one of the most straightforward forms of imitation learning: an agent watches an expert and learns to map observations to actions. However, in complex visual environments like autonomous driving, BC models often fall into a trap known as the "copycat problem." This paper introduces a simple yet powerful method to fix this issue by identifying and upweighting "changepoints"—critical moments where an expert's action cannot be predicted simply by looking at their previous actions.

The Copycat Problem in Imitation Learning

In the real world, agents operate in partially observable environments where they cannot see everything at once. To compensate, models are typically given an "observation history"—a sequence of past frames.

While history is helpful, it introduces the copycat problem (also known as the inertia problem). Because expert actions are highly correlated over time—if a car is driving straight now, it was likely driving straight a fraction of a second ago—a model can achieve very low training error by simply repeating its previous action. This "shortcut" fails catastrophically during execution. For example, a car waiting at a red light might never move when the light turns green because its history is dominated by "staying still." The model learns to prioritize its own past behavior over critical new visual cues.

Illustration of the copycat issue. A model might correctly stay stopped at a red light but fail to move when it turns green because it over-relies on its previous "stopped" state.

The authors frame this copycatting as a form of "shortcut learning." Deep networks find the easiest statistical pattern to minimize loss, even if that pattern fails to capture the true underlying task logic. In driving datasets, "boring" moments (driving straight) vastly outnumber "interesting" moments (turning, stopping, starting). Standard training treats every frame equally, allowing the model to ignore the vital minority of frames where real decisions are made.

A Keyframe-Focused Solution

To combat this, the authors propose a "Keyframe-Focused" approach that identifies and upweights these critical moments. The core of their method is a two-step process:

  1. Identify Changepoints: The researchers train a small "copycat" network that only sees past actions to predict the current action. They then calculate the Action Prediction Error (APE) for every sample in the dataset. A high APE means the current action is a "surprise" that cannot be explained by history alone. By measuring what cannot be predicted from past actions, APE naturally highlights the moments where external visual stimuli (like a traffic light changing) are the primary cause of an action.
  2. Reweighted Training: They train the actual visual policy by upweighting samples with high APE. This forces the model to pay extra attention to the frames where "just copying" would fail, effectively discouraging the copycat shortcut.
Action Prediction Error (APE) peaks at keyframes like braking or accelerating, where the expert's action deviates from the recent trend.

This approach is remarkably simple and efficient. Unlike interactive algorithms like DAGGER, it requires no environmental interaction during training and adds minimal computational overhead—taking less than 15 minutes of preprocessing even for large datasets.

Experimental Validation

The method was evaluated across four diverse simulated environments, including CARLA (a photorealistic urban driving simulator) and three standard MuJoCo robotics tasks (Hopper, HalfCheetah, and Walker2D) modified to use raw pixel inputs.

The results demonstrate significant improvements:

  • Superior Driving Performance: In CARLA, the proposed method achieved a 43.4% success rate, significantly outperforming standard BC with history (33.0%) and even beating the interactive DAGGER algorithm (35.2%).
  • Robustness to Hidden Information: In a modified CARLA setting where the model must infer velocity entirely from history, the improvement was even more stark: 36.8% success compared to 25.7% for the baseline.
  • Reduced Distributional Shift: The models suffered less from "rollout error," meaning they stayed closer to the expert's distribution when running live in the simulator.

Limitations and Future Directions

While highly effective, the authors note a few limitations. The choice of the weighting function applied to the APE is sensitive; if the weights are too steep, the model might overfit to keyframes and perform poorly on ordinary, smooth driving sections. Additionally, if a dataset contains noisy expert actions (like random jitters), the APE might mistakenly flag these as important changepoints.

Ultimately, this keyframe-focused approach proves that we can significantly improve offline imitation learning simply by teaching models when to pay attention to their environment rather than their own history.

Summary updated

BibTeX
@inproceedings{wen2021keyframe,
  author = {Chuan Wen and Jierui Lin and Jianing Qian and Yang Gao and Dinesh Jayaraman},
  title = {{Keyframe-Focused Visual Imitation Learning}},
  booktitle = {International Conference on Machine Learning},
  year = {2021},
}
Figure