Papers
Topics
Authors
Recent
Search
2000 character limit reached

VariBAD: Bayesian Meta-Learning in Deep RL

Updated 17 January 2026
  • 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 SS denote the state space and AA the action space. Each environment is parameterized by a latent variable θΘ\theta\in\Theta, influencing both transition dynamics Tθ(ss,a)T_\theta(s'|s,a) and reward functions Rθ(rs,a,s)R_\theta(r|s,a,s'). The agent maintains a prior belief b0(θ)=p(θ)b_0(\theta)=p(\theta) and, using its trajectory τ:t=(s0,a0,r1,s1,,st)\tau_{:t}=(s_0,a_0,r_1,s_1,\ldots,s_t), updates its posterior bt(θ)=p(θτ:t)b_t(\theta)=p(\theta|\tau_{:t}).

In this framework, the "hyper-state" st+=(st,bt)s_t^+ = (s_t, b_t) produces an augmented BAMDP M+M^+ whose transition and reward kernels are given by: AA0

AA1

The Bayes-optimal policy AA2 maximizes the expected discounted return in AA3 over horizon AA4: AA5 Exact inference and planning are intractable for high-dimensional AA6, motivating the variational-approximate approach of variBAD.

2. Generative Model and Variational Approximation

variBAD leverages a joint generative model AA7, where: AA8 Actions AA9 are sampled from a policy conditioned on current belief.

The method introduces an amortized variational posterior θΘ\theta\in\Theta0, parameterized as a diagonal Gaussian θΘ\theta\in\Theta1 output by a recurrent inference network. The training objective employs the evidence lower bound (ELBO) at each time step θΘ\theta\in\Theta2: θΘ\theta\in\Theta3 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 θΘ\theta\in\Theta4 for θΘ\theta\in\Theta5, the decoder θΘ\theta\in\Theta6 for θΘ\theta\in\Theta7, and the policy θΘ\theta\in\Theta8 for θΘ\theta\in\Theta9, where Tθ(ss,a)T_\theta(s'|s,a)0 denotes the sampled latent. The total loss at each meta-training iteration is: Tθ(ss,a)T_\theta(s'|s,a)1 Tθ(ss,a)T_\theta(s'|s,a)2 is the standard expected RL return; Tθ(ss,a)T_\theta(s'|s,a)3 controls the balance between RL and ELBO terms. Training proceeds with policy-gradient updates (PPO/A2C) for Tθ(ss,a)T_\theta(s'|s,a)4 and Adam updates on Tθ(ss,a)T_\theta(s'|s,a)5 using ELBO gradients.

The meta-training workflow is summarized as follows:

Step Operation Update Type
Sample task Tθ(ss,a)T_\theta(s'|s,a)6 Reset environment, encoder hidden state Initialization
Collect trajectory Encode Tθ(ss,a)T_\theta(s'|s,a)7 via GRU to Tθ(ss,a)T_\theta(s'|s,a)8 Forward Pass
Sample latent Tθ(ss,a)T_\theta(s'|s,a)9 Forward Pass
Condition policy Rθ(rs,a,s)R_\theta(r|s,a,s')0s_tRθ(rs,a,s)R_\theta(r|s,a,s')1 Action
Compute ELBO Rθ(rs,a,s)R_\theta(r|s,a,s')2 over batch Loss Evalu.
Optimizer step Adam/PPO update on Rθ(rs,a,s)R_\theta(r|s,a,s')3 Learning

4. Online Adaptation and Uncertainty-Driven Action Selection

During evaluation, only the encoder Rθ(rs,a,s)R_\theta(r|s,a,s')4 and policy Rθ(rs,a,s)R_\theta(r|s,a,s')5 are retained. With each new trajectory Rθ(rs,a,s)R_\theta(r|s,a,s')6, the encoder maintains and updates the latent posterior Rθ(rs,a,s)R_\theta(r|s,a,s')7, yielding: Rθ(rs,a,s)R_\theta(r|s,a,s')8 As data accumulates, posterior variance Rθ(rs,a,s)R_\theta(r|s,a,s')9 collapses (b0(θ)=p(θ)b_0(\theta)=p(\theta)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 b0(θ)=p(θ)b_0(\theta)=p(\theta)1: MLP embedding, one layer of size 32 (ReLU); GRU (hidden size 64–128); final linear mapping to b0(θ)=p(θ)b_0(\theta)=p(\theta)2 for a b0(θ)=p(θ)b_0(\theta)=p(\theta)3-dimensional Gaussian (b0(θ)=p(θ)b_0(\theta)=p(\theta)4 typical).
  • Decoder b0(θ)=p(θ)b_0(\theta)=p(\theta)5: Transition model b0(θ)=p(θ)b_0(\theta)=p(\theta)6 – MLP (64,32), ReLU; output Gaussian/categorical for b0(θ)=p(θ)b_0(\theta)=p(\theta)7. Reward model b0(θ)=p(θ)b_0(\theta)=p(\theta)8 – similar MLP, scalar output.
  • Policy network b0(θ)=p(θ)b_0(\theta)=p(\theta)9: MLP (32 for grid, 128 for MuJoCo), TanH activation, input τ:t=(s0,a0,r1,s1,,st)\tau_{:t}=(s_0,a_0,r_1,s_1,\ldots,s_t)0; critic head of similar dimensions.
  • Optimization: PPO/A2C, Adam (τ:t=(s0,a0,r1,s1,,st)\tau_{:t}=(s_0,a_0,r_1,s_1,\ldots,s_t)1 grid, τ:t=(s0,a0,r1,s1,,st)\tau_{:t}=(s_0,a_0,r_1,s_1,\ldots,s_t)2 MuJoCo), clipping τ:t=(s0,a0,r1,s1,,st)\tau_{:t}=(s_0,a_0,r_1,s_1,\ldots,s_t)3, value coefficient τ:t=(s0,a0,r1,s1,,st)\tau_{:t}=(s_0,a_0,r_1,s_1,\ldots,s_t)4, entropy τ:t=(s0,a0,r1,s1,,st)\tau_{:t}=(s_0,a_0,r_1,s_1,\ldots,s_t)5, τ:t=(s0,a0,r1,s1,,st)\tau_{:t}=(s_0,a_0,r_1,s_1,\ldots,s_t)6–τ:t=(s0,a0,r1,s1,,st)\tau_{:t}=(s_0,a_0,r_1,s_1,\ldots,s_t)7, GAE τ:t=(s0,a0,r1,s1,,st)\tau_{:t}=(s_0,a_0,r_1,s_1,\ldots,s_t)8. VAE: Adam τ:t=(s0,a0,r1,s1,,st)\tau_{:t}=(s_0,a_0,r_1,s_1,\ldots,s_t)9; ELBO bt(θ)=p(θτ:t)b_t(\theta)=p(\theta|\tau_{:t})0 (grid), bt(θ)=p(θτ:t)b_t(\theta)=p(\theta|\tau_{:t})1 (MuJoCo). Max grad norm bt(θ)=p(θτ:t)b_t(\theta)=p(\theta|\tau_{:t})2. No extra dropout used; KL regularizes latent bt(θ)=p(θτ:t)b_t(\theta)=p(\theta|\tau_{:t})3.

6. Empirical Evaluation

  • Gridworld: 5bt(θ)=p(θτ:t)b_t(\theta)=p(\theta|\tau_{:t})45 grid, unknown goal in 24 cells. Actions: {up, right, down, left, stay}, horizon bt(θ)=p(θτ:t)b_t(\theta)=p(\theta|\tau_{:t})5, BAMDP horizon bt(θ)=p(θτ:t)b_t(\theta)=p(\theta|\tau_{:t})6. Sparse reward. variBAD achieves returns matching Bayes-optimal by episode 3, outperforming posterior sampling. Decoder’s bt(θ)=p(θτ:t)b_t(\theta)=p(\theta|\tau_{:t})7rewardbt(θ)=p(θτ:t)b_t(\theta)=p(\theta|\tau_{:t})8cellbt(θ)=p(θτ:t)b_t(\theta)=p(\theta|\tau_{:t})9 belief concentrates on true goal, with rapid collapse of latent st+=(st,bt)s_t^+ = (s_t, b_t)0 confirming uncertainty-driven exploration.
  • MuJoCo Meta-RL: Tasks include AntDir (forward/back, 2), HalfCheetahDir (left/right, 2), HalfCheetahVel (varied speeds, st+=(st,bt)s_t^+ = (s_t, b_t)110), Walker (randomized body, st+=(st,bt)s_t^+ = (s_t, b_t)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 st+=(st,bt)s_t^+ = (s_t, b_t)3 frames (off-policy); variBAD/RL² require st+=(st,bt)s_t^+ = (s_t, b_t)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 st+=(st,bt)s_t^+ = (s_t, b_t)520 steps, and variance st+=(st,bt)s_t^+ = (s_t, b_t)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 st+=(st,bt)s_t^+ = (s_t, b_t)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 st+=(st,bt)s_t^+ = (s_t, b_t)8 for model-based planning at test time, learning a faster-adapting prior st+=(st,bt)s_t^+ = (s_t, b_t)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).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Variational Bayes-Adaptive Deep Reinforcement Learning (variBAD).