Improving Generalization in Meta-RL with Imaginary Tasks from Latent Dynamics Mixture

Suyoung Lee, Sae-Young Chung

TL;DR

Meta-Reinforcement Learning (meta-RL) often fails when faced with tasks outside its training distribution. Latent Dynamics Mixture (LDM) solves this by synthesizing "imaginary tasks" from mixtures of learned latent task representations. This allows agents to practice on out-of-distribution scenarios during training, enabling them to generalize to unseen test tasks without requiring any extra updates.

The Challenge of Out-of-Distribution Tasks

The "meta" in meta-RL refers to an agent's ability to "learn to learn." Ideally, an agent trained on a variety of tasks (e.g., running at different speeds) should quickly adapt to a new, similar task. However, most current methods suffer from a narrow comfort zone: they generalize well to tasks sampled from the same distribution as training, but fail miserably when faced with distribution shift (out-of-distribution or OOD tasks).

For example, if an agent is trained to navigate to goals in the North and East, it might have no idea how to handle a goal in the Northeast. Context-based meta-RL agents—which encode experience into a "context" variable—struggle because they have never seen the specific context for "Northeast" and do not know how to map that context to optimal actions.

Latent Dynamics Mixture (LDM)

To address this, the authors introduce Latent Dynamics Mixture (LDM), which builds on the variational Bayes-adaptive meta-RL framework (specifically the variBAD algorithm). Instead of augmenting raw observations, LDM augments the task space itself.

Core Architecture

  1. Normal Workers: These agents interact with real training tasks. They use a Latent Dynamics Network (a VAE-like structure) to encode their experience into a latent variable $m$, which represents the task's underlying properties (like goal location or friction).
  2. The Mixture Worker: This acts as the "imagination" engine. It does not receive real rewards from the environment. Instead, it takes the latent representations ($m$) from the normal workers and mixes them using a Dirichlet distribution to create a new, "imaginary" latent task $\hat{m}$.
  3. Imaginary Rewards: A learned reward decoder takes this mixed latent $\hat{m}$ and generates synthetic rewards. The agent then trains its policy on these imaginary rewards.
  4. Input Dropout: To prevent the reward decoder from simply memorizing the training tasks' state-reward mappings, the authors apply dropout to the state/action inputs. This forces the decoder to rely on the latent task variable $m$, ensuring it generates meaningful rewards for the "mixed" tasks.

By adjusting a hyperparameter $\beta$, the system can perform interpolation (mixing tasks within the training range) or extrapolation (generating tasks slightly outside the training range).

Experimental Setup and Key Results

The authors evaluated LDM on environments where the training and test task distributions were strictly disjoint to truly test OOD generalization.

Gridworld Navigation

In this environment, the agent must find a hidden goal. Training goals were restricted to one set of cells, while test goals were placed in a completely different set.

Gridworld training/test split and mean returns for LDM versus baselines.

Superior OOD Performance: As shown in the figure above, LDM reached 19 out of 27 test goals on average. In stark contrast, standard meta-RL baselines like RL$^2$ and variBAD failed to generalize to almost any test goals, demonstrating the effectiveness of training on imaginary mixed tasks.

MuJoCo Continuous Control

The method was also tested on more complex continuous control tasks:

  • Ant-direction: Training on four cardinal directions; testing on diagonal directions.
  • Ant-goal: Training on goals near the origin or very far; testing on goals at intermediate distances.
  • Half-cheetah-velocity: Training on very slow or very fast target velocities; testing on medium velocities.

Bridging the Gap: In these MuJoCo tasks, LDM significantly outperformed non-oracle baselines, often approaching the performance of an "Oracle" agent that was explicitly allowed to train on the test distribution. Furthermore, in the "Ant-goal" task where test tasks were outside the convex hull of training tasks, LDM with $\beta > 1$ (extrapolation mode) successfully reached goals that other methods couldn't even find.

Limitations and Future Work

While LDM presents a significant step forward for OOD generalization in meta-RL, the authors note a few limitations:

  • Reward-Centric Focus: Most experiments focused on tasks where only the reward function changed (e.g., goal location). While the theory supports changes in transition dynamics (e.g., changing gravity or friction), this was less thoroughly explored in the benchmarks.
  • Heuristic Mixing: The current method uses a Dirichlet distribution for mixing weights. More advanced OOD generation techniques, such as adversarial task generation, could potentially create even more challenging and useful imaginary tasks.
  • Dependence on Latent Quality: The success of LDM hinges entirely on the Latent Dynamics Network's ability to learn a meaningful, disentangled representation of the tasks. If the latent space is messy, the synthesized "mixtures" will not provide a useful learning signal.

Summary updated

BibTeX
@inproceedings{lee2021improving,
  author = {Suyoung Lee and Sae-Young Chung},
  title = {{Improving Generalization in Meta-RL with Imaginary Tasks from Latent Dynamics Mixture}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=PnpS7_SlNZi},
}
Figure