Quantifying Generalisation in Imitation Learning

Nathan Gavenski, Odinaldo RodriguesarXiv 2025

TL;DR

Imitation learning (IL) has a generalization problem: current benchmarks are so uniform that agents can succeed through simple memorization rather than true task comprehension. To address this, the authors introduce Labyrinth, a highly customizable, discrete grid-world benchmark that gives researchers precise control over environment structure, start/goal positions, and procedural complexity to rigorously evaluate an agent's ability to generalize.

What Problem Does This Paper Address?

In imitation learning, an agent learns a skill by observing expert demonstrations. While training looks like supervised learning, evaluation is agentic—the model must interact dynamically with an environment. Ideally, we want these agents to generalize to unseen scenarios.

However, this paper highlights a glaring flaw in standard IL benchmarks (like CartPole, MountainCar, and MuJoCo continuous control tasks): the evaluation environments barely differ from the training environments. The authors analyzed 100,000 initial states across these popular suites and found exceptionally low variation. In fact, in environments like MountainCar, an agent can achieve near-expert rewards simply by blindly replaying a single recorded sequence of expert actions. This leniency masks a critical issue—agents are just memorizing trajectories rather than learning the underlying logic of the task.

Furthermore, continuous control benchmarks lack explicit state abstractions and ground-truth optimal actions, making it incredibly difficult to diagnose why an agent fails.

Methods

To force a clear separation between training and testing data, the authors developed Labyrinth, an open-source environment built on top of the widely used gymnasium library.

Formally defined as a graph where nodes are tiles and edges represent open paths, Labyrinth allows researchers to procedurally generate unique maze structures. It features four distinct task configurations to test different aspects of generalization:

  1. Standard Navigation: The agent must find the shortest path from a start tile ($s_0$) to a goal tile ($g$). Positions can be biased (fixed corners) or unbiased (randomly sampled).
  2. Partial Observability: The environment restricts the agent's view to its immediate vicinity, forcing it to handle out-of-distribution local perspectives.
  3. Key and Door: Introduces sequential sub-goals. The agent must retrieve a key before it can unlock a door and reach the final goal.
  4. Ice Floor: A safety-critical mode where stepping on a "frozen" tile terminates the episode in failure, requiring the agent to actively plan safe alternative routes.
Figure 1: Different state representations for each task in the Labyrinth.

Labyrinth also includes a built-in solver using Johnson’s algorithm to calculate the exact optimal action for any given state, providing a clear mathematical baseline for perfect generalization. To make custom experiments easy to design, the authors created a lightweight text-based configuration language to easily save, load, and modify maze layouts.

Save files for all possible settings.

Datasets

The authors released standardized datasets on HuggingFace (via the IL-Datasets toolkit) featuring squared labyrinths of sizes $3\times3$, $4\times4$, and $5\times5$. Each dataset contains distinct train, validation, and test splits. Every single maze structure is uniquely hashed to guarantee that the evaluation and test sets contain completely unseen layouts, preventing any possibility of structural memorization.

Key Insights and Ideas

  • The Illusion of Performance: Popular continuous control benchmarks are highly forgiving. In the Hopper environment, simply executing the expert action from the closest training state on a completely different seed yields a nearly identical reward to the expert. This proves current benchmarks fail to test true robustness.
  • Pure IL vs. Inverse RL: Pure imitation learning methods (like Behavioral Cloning) actually generalize better in Labyrinth than complex Inverse Reinforcement Learning (IRL) methods (like GAIL or SQIL). Supervised losses encourage pure IL models to learn richer image encodings that focus on surrounding wall structures rather than just the agent's absolute position.
  • The Goal-Conditioned Wall: When both the starting position and the goal position are randomized simultaneously, every single tested imitation learning method completely fails in larger ($5\times5$) mazes. Current IL paradigms struggle deeply with trajectory-level reasoning when decoupled from the specific goal states seen during training.

Key Results

The authors benchmarked six prominent IL algorithms: Behavioral Cloning (BC), DAgger, GAIL, BCO, SQIL, and IUPE.

In the $5\times5$ maze navigation task, the performance drop-off from training to testing was severe:

  • Behavioral Cloning (BC): Achieved a 37% success rate on the training set but plummeted to just 2% on the test set.
  • IUPE (Imitating Unknown Policies via Exploration): The top performer, reaching a 75% success rate on training and 21% on validation, but it still crashed to 5% on the test set.
  • The $s_0$ and $g$ Split: When evaluated on configurations where both the start and goal positions were altered, the success rate for all six methods dropped uniformly to 0%.

To see if scaling up representation power would help, the authors trained BC for 10,000 epochs using a robust ResNet-18 backbone. While this boosted validation success to 56% and test success to 53%, it confirmed that while better visual representations mitigate the gap, they do not solve the underlying algorithmic inability to reason over novel structures.

Limitations and Future Work

Currently, Labyrinth only supports discrete action spaces (moving up, down, left, right). This makes it incompatible with certain modern imitation learning frameworks designed exclusively for continuous actions (such as OPOLO or CILO).

For future iterations, the authors plan to introduce continuous action spaces while preserving Labyrinth's core benefits (like ground-truth optimality). They also plan to implement a more flexible, custom tile-behavior system to let researchers script unique environmental hazards and mechanics directly into the configuration files.

Summary updated

BibTeX
@misc{gavenski2025quantifying,
  author = {Nathan Gavenski and Odinaldo Rodrigues},
  title = {{Quantifying Generalisation in Imitation Learning}},
  year = {2025},
  eprint = {2509.24784},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.24784},
}
Figure