TEA: Trajectory Encoding Augmentation for Robust and Transferable Policies in Offline Reinforcement Learning

Batıkan Bora Ormancı, Phillip Swazinna, Steffen Udluft, Thomas A. RunklerarXiv 2024

TL;DR

Trajectory Encoding Augmentation (TEA) addresses a major hurdle in offline reinforcement learning: generalizing to new environments without further training. By using an AutoEncoder to compress short trajectories into a latent "dynamics signature" and appending it to the agent's state, TEA enables a single policy to adapt to unseen physical parameters, significantly outperforming standard offline baselines.

What Problem Does This Paper Address?

Reinforcement Learning (RL) agents often struggle when the "rules of the game"—the environment dynamics—change. For example, a robot trained to walk on carpet might fail on ice. This challenge is amplified in offline RL, where agents must learn entirely from pre-collected datasets without the luxury of trial-and-error in the real world.

Existing methods like domain randomization or meta-RL often require online interaction or explicit task identifiers. The authors identify a gap: how can we train a single, robust policy using only offline data from a few "source" environments so that it generalizes to "target" environments with unobserved dynamics?

Methods

The authors introduce Trajectory Encoding Augmentation (TEA). The core idea is to treat the environment's specific physical properties (like mass or friction) as a latent context that the agent can "sense" through its own movement.

  1. Sequence Encoding: They use an AutoEncoder (AE) to process sequences of 16 state-action pairs. The AE is trained to reconstruct these sequences, forcing its 4-dimensional bottleneck layer to capture the essential characteristics of the environment's dynamics.
  2. State Augmentation: This 4D latent vector is appended to the original state vector. Instead of just seeing "where I am," the agent now sees "where I am + what kind of world I'm in."
  3. Offline Training: They use Batch-Constrained Q-learning (BCQ), a standard algorithm for offline RL that prevents the agent from taking "unrealistic" actions not present in the training data.
  4. Deployment: When the agent is placed in a new environment, it observes a few initial trajectories to generate the latent encoding, then proceeds with its fixed policy.

Datasets

The study uses the classic CartPole-v1 environment as a testbed, but with a twist. They created a variety of environments by modifying two transition-defining parameters: pole length and cart mass.

  • Source Environments: Five environments were used for training, with parameters sampled uniformly (Pole Length: 0.1–2.0, Cart Mass: 0.5–2.0).
  • Evaluation Environments: Ten new environments (N1 through N10) with different parameter combinations were used to test generalization.
This scatter plot shows the distribution of pole lengths and cart masses for the source training environments (blue) and the new test environments (red).

Key Insights and Ideas

  • Dynamics as Latent Context: The most powerful idea here is that you don't need to tell the agent the mass of the cart. The agent can infer the mass by looking at how the cart reacts to its actions over a short window of time.
  • Implicit System Identification: The AutoEncoder acts as an implicit system identifier. It maps raw trajectories to a compact representation that distinguishes between different physical setups without needing manual feature engineering.
  • Zero-Shot Transferability: Once trained on a diverse enough set of source environments, the TEA-augmented policy can be deployed to a new environment "zero-shot"—it just needs a tiny bit of initial observation (5 sequences of 16 steps) to orient itself to the new dynamics.

Key Results

The TEA method consistently outperformed the baseline (BCQ without state augmentation) across all test environments.

  • Average Performance: TEA achieved an average return of 63.7 ± 1.9, compared to the baseline's 48.7 ± 0.4.
  • Consistency: As shown in the 3D visualization below, the performance ratio (TEA / Baseline) was greater than 1.0 in every single test case, indicating that the augmentation never hurt and almost always helped significantly.
  • Specific Gains: In some environments (like N1 and N5), TEA nearly doubled the performance of the baseline.
This 3D plot illustrates the performance improvement of TEA over the baseline across various pole lengths and cart masses. The ratio is consistently above 1.0, showing universal gains.

Detailed results for each environment are captured in the following table:

Table 1: Quantitative comparison of returns for Baseline vs. TEA across 10 unseen environments.

Limitations and Future Work

While promising, the paper notes several areas for growth:

  • Task Complexity: The experiments were limited to CartPole, which has a relatively low-dimensional state-action space. Testing on more complex robotics simulations (like MuJoCo) is a necessary next step.
  • Encoder Architectures: The authors used a simple AutoEncoder. They suggest that recurrent architectures like LSTMs or Transformers might capture temporal dynamics even more effectively.
  • Offline-to-Online Transition: A major goal for future work is exploring how a TEA-pretrained policy can be further fine-tuned through online interaction, potentially leading to even faster adaptation in real-world deployments.

Summary updated

BibTeX
@misc{ormanc2024tea,
  author = {Batıkan Bora Ormancı and Phillip Swazinna and Steffen Udluft and Thomas A. Runkler},
  title = {{TEA: Trajectory Encoding Augmentation for Robust and Transferable Policies in Offline Reinforcement Learning}},
  year = {2024},
  eprint = {2411.19133},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2411.19133},
}
Figure