VariBAD: Bayesian Meta-Learning in Deep RL
- VariBAD is a meta-learning framework that applies variational inference and Bayes-adaptive principles to model latent task dynamics for efficient exploration.
- It jointly optimizes an encoder, decoder, and policy network to update beliefs over unknown environment parameters, enhancing adaptation.
- Empirical evaluations in gridworld and MuJoCo tasks show that variBAD approximates Bayes-optimal performance and outperforms several leading meta-RL methods.
Variational Bayes-Adaptive Deep Reinforcement Learning (variBAD) is a meta-learning framework for performing approximate Bayes-adaptive reinforcement learning in environments with unknown dynamics and rewards. It enables an agent to maintain a belief distribution over latent task parameters, adaptively trading off exploration and exploitation via a structured uncertainty-driven policy. The method achieves this by incorporating variational inference principles into the RL loop, learning both a posterior over task variables and a policy conditioned on the inferred latent state. Empirical results demonstrate that variBAD outperforms previous meta-RL algorithms on both discrete gridworld and continuous control tasks, closely approximating Bayes-optimal performance in key domains (Zintgraf et al., 2019).
1. Bayes-Adaptive MDP Formulation
The Bayes-Adaptive Markov Decision Process (BAMDP) framework addresses optimal exploration-exploitation tradeoff by augmenting the state space with a posterior belief over hidden task parameters. Let denote the state space and the action space. Each environment is parameterized by a latent variable , influencing both transition dynamics and reward functions . The agent maintains a prior belief and, using its trajectory , updates its posterior .
In this framework, the "hyper-state" produces an augmented BAMDP whose transition and reward kernels are given by: 0
1
The Bayes-optimal policy 2 maximizes the expected discounted return in 3 over horizon 4: 5 Exact inference and planning are intractable for high-dimensional 6, motivating the variational-approximate approach of variBAD.
2. Generative Model and Variational Approximation
variBAD leverages a joint generative model 7, where: 8 Actions 9 are sampled from a policy conditioned on current belief.
The method introduces an amortized variational posterior 0, parameterized as a diagonal Gaussian 1 output by a recurrent inference network. The training objective employs the evidence lower bound (ELBO) at each time step 2: 3 The ELBO enables tractable meta-learning of the underlying task posterior and dynamics decoder.
3. Meta-Training Algorithm
variBAD’s meta-training jointly optimizes three parameter sets: the encoder 4 for 5, the decoder 6 for 7, and the policy 8 for 9, where 0 denotes the sampled latent. The total loss at each meta-training iteration is: 1 2 is the standard expected RL return; 3 controls the balance between RL and ELBO terms. Training proceeds with policy-gradient updates (PPO/A2C) for 4 and Adam updates on 5 using ELBO gradients.
The meta-training workflow is summarized as follows:
| Step | Operation | Update Type |
|---|---|---|
| Sample task 6 | Reset environment, encoder hidden state | Initialization |
| Collect trajectory | Encode 7 via GRU to 8 | Forward Pass |
| Sample latent | 9 | Forward Pass |
| Condition policy | 0s_t1 | Action |
| Compute ELBO | 2 over batch | Loss Evalu. |
| Optimizer step | Adam/PPO update on 3 | Learning |
4. Online Adaptation and Uncertainty-Driven Action Selection
During evaluation, only the encoder 4 and policy 5 are retained. With each new trajectory 6, the encoder maintains and updates the latent posterior 7, yielding: 8 As data accumulates, posterior variance 9 collapses (0), smoothly annealing the policy from exploration to exploitation. This enables dynamically structured “uncertainty-driven” exploration, matching Bayes-optimal online adaptation.
5. Architecture and Implementation Specifications
- Encoder 1: MLP embedding, one layer of size 32 (ReLU); GRU (hidden size 64–128); final linear mapping to 2 for a 3-dimensional Gaussian (4 typical).
- Decoder 5: Transition model 6 – MLP (64,32), ReLU; output Gaussian/categorical for 7. Reward model 8 – similar MLP, scalar output.
- Policy network 9: MLP (32 for grid, 128 for MuJoCo), TanH activation, input 0; critic head of similar dimensions.
- Optimization: PPO/A2C, Adam (1 grid, 2 MuJoCo), clipping 3, value coefficient 4, entropy 5, 6–7, GAE 8. VAE: Adam 9; ELBO 0 (grid), 1 (MuJoCo). Max grad norm 2. No extra dropout used; KL regularizes latent 3.
6. Empirical Evaluation
- Gridworld: 545 grid, unknown goal in 24 cells. Actions: {up, right, down, left, stay}, horizon 5, BAMDP horizon 6. Sparse reward. variBAD achieves returns matching Bayes-optimal by episode 3, outperforming posterior sampling. Decoder’s 7reward8cell9 belief concentrates on true goal, with rapid collapse of latent 0 confirming uncertainty-driven exploration.
- MuJoCo Meta-RL: Tasks include AntDir (forward/back, 2), HalfCheetahDir (left/right, 2), HalfCheetahVel (varied speeds, 110), Walker (randomized body, 220). Evaluation metric is first-episode (online) return in new tasks. In all domains, variBAD’s first-rollout returns exceed those of RL², PEARL (off-policy posterior sampling), E-MAML, and ProMP. For example:
| Task | variBAD | RL² | PEARL | E-MAML | ProMP |
|---|---|---|---|---|---|
| AntDir | ~2150 | 2000 | 1500 | 400 | 600 |
| HalfCheetahDir | ~4000 | 3500 | 1000 | 500 | 800 |
| HalfCheetahVel | ~3200 | 2800 | 1100 | 300 | 500 |
| Walker | ~5000 | 4500 | 2000 | 600 | 700 |
PEARL converges in 3 frames (off-policy); variBAD/RL² require 4 frames (on-policy). At convergence, variBAD matches or exceeds oracle PPO returns (which know the true task). Posterior mean flips sign (e.g., direction tasks) within 520 steps, and variance 6 declines rapidly, enabling early exploitation.
7. Limitations and Future Directions
variBAD is the first scalable deep-RL algorithm to leverage an explicit approximate Bayesian belief over latent task variables for structured exploration. Its variational inference framework delivers a low-dimensional state to condition policies on, along with a quantifiable uncertainty estimate. However, the approach requires meta-training on a distribution 7 representative of test tasks and does not guarantee formal Bayes-optimality due to neural network approximation. Training complexity is substantial due to recurrent inference and on-policy learning, with off-policy methods left for future work. Further research directions include exploiting the decoder 8 for model-based planning at test time, learning a faster-adapting prior 9, and handling out-of-distribution (OOD) tasks via continual encoder fine-tuning.
Relevant experimental data, exact hyperparameters, and architecture specifications are available in the original codebase (Zintgraf et al., 2019).