Uncertainty-Aware Models: PILCO & PETS
Gaussian processes, probabilistic ensembles and planning under model uncertainty.
A model that does not know what it does not know gets exploited exactly where it is ignorant. PILCO learned to swing up and balance a real pendulum on a cart from about 17.5 seconds of experience by carrying its own uncertainty through every prediction; PETS matched model-free agents with a small fraction of their samples by planning through an ensemble. This lesson separates two kinds of uncertainty, shows how each method propagates them, and derives how the same estimates make an agent optimistic while it can explore and pessimistic when it cannot.
What you’ll learn
- Distinguish epistemic from aleatoric uncertainty, and split a predictive variance into the two with the law of total variance.
- Explain PILCO: Gaussian-process dynamics, moment matching of state distributions, and analytic policy gradients, with its data efficiency and its limits.
- Explain PETS: probabilistic ensembles, TS1 and TS∞ trajectory sampling, and planning with the cross-entropy method.
- Derive a MOPO-style pessimistic lower bound from the simulation lemma, and contrast it with optimistic exploration in H-UCRL.
Two kinds of not knowing
Aleatoric uncertainty is randomness in the world itself: a die roll, a gust of wind, the spread of the true . More data cannot remove it, and a planner should average over it, because it is part of what will really happen. Epistemic uncertainty is the model's ignorance: in regions it has seen little data from, many dynamics are consistent with what it knows. More data removes it, and it is exactly where a planner can be fooled, since an overconfident model there invites the planner to exploit whatever it happens to predict.
A Bayesian model, or an ensemble standing in for one, predicts with a distribution over models , each of which predicts a distribution over next states. The law of total variance splits the result in two.
Five ensemble members predict a next-state coordinate with means , each with predicted variance . What is the total predictive variance?
Show the answer
0.06
The aleatoric part is the average predicted variance, . The means average to with squared deviations , so the epistemic part is . Total: . Ten times more data near this input should shrink the but not the .
PILCO: carrying a Gaussian through a Gaussian process
PILCO (Deisenroth & Rasmussen, 2011) models each state dimension's change from with a Gaussian process with a squared-exponential kernel, and evaluates a policy by its expected cost over a horizon , , with a saturating cost . The expectation is over a distribution of states that already contains the model's uncertainty: the planner sees not one predicted trajectory but a spreading cloud of them.
Feeding an uncertain input into a GP gives a non-Gaussian output. PILCO approximates it by the Gaussian with the same mean and covariance, moment matching, because with Gaussian inputs and a squared-exponential kernel those moments are integrals of Gaussians against Gaussians, available in closed form.
For one dimension and a fixed policy, let and let the GP predict with noise variance . Total expectation and total variance give the exact moments of :
PILCO replaces by and repeats. (It actually predicts the change , so it also tracks the covariance between and that change; the logic is the same.) The predicted cloud widens wherever the trajectory passes through regions with little data, and the saturating cost penalizes plans that rely on them.
Every is a closed-form function of , and each moment is a differentiable function of the previous ones and of . The chain rule through time gives an exact gradient, with no sampling variance, for a conjugate-gradient or L-BFGS optimizer:
The loop is short: run the policy once on the system, refit the GP to all data, optimize against the model with analytic gradients, repeat. On a real cart-pole, PILCO learned the swing-up and balance from scratch in a handful of trials, 17.5 seconds of interaction in total. It also learned a cart-double-pendulum swing-up in 20–30 trials (60–90 s of experience) and, in a realistic simulation, riding a unicycle in about 20 trials. The decisive ablation used the same framework with only the GP's posterior mean, a deterministic model with the uncertainty removed, and failed to learn the simulated swing-up: without a representation of its uncertainty, the planner trusted predictions it had no basis for.
The limits are equally clear. Exact GPs cost cubic time in the number of data points, prefer smooth dynamics and low-dimensional states, and a single Gaussian cannot represent a state distribution that splits in two. PILCO also treats model errors at successive steps as independent, which can understate the uncertainty of a whole trajectory.
Run with only the GP posterior mean as a deterministic model, PILCO failed to learn the simulated cart-pole swing-up. What was lost?
- The ability to fit the observed transitions
- The analytic gradients
- The penalty, through the expected cost, on plans that pass through states where the model knows little
- The saturating cost function
Show the answer
C. The penalty, through the expected cost, on plans that pass through states where the model knows little
The mean model fits the data equally well, and gradients can still be computed. What disappears is the widening of the predicted state distribution in poorly known regions, which makes plans that depend on unreliable predictions look expensive. Without it, the optimizer exploits the mean model's guesses, the model bias PILCO was designed to avoid.
PETS: probabilistic ensembles and trajectory sampling
PETS (Chua, Calandra, McAllister & Levine, 2018) keeps PILCO's principle and replaces each part with something that scales. The model is a probabilistic ensemble: neural networks, each outputting the mean and diagonal covariance of a Gaussian over the next state and trained by negative log-likelihood, each on its own bootstrap resample of the data, in the spirit of deep ensembles (Lakshminarayanan, Pritzel & Blundell, 2017). Each member's variance captures aleatoric noise; disagreement between members captures epistemic uncertainty.
Uncertainty is propagated by particles rather than moments. Each of particles is pushed through the model by sampling a next state at every step. TS1 assigns each particle a new random member at every step. TS∞ fixes each particle's member for the whole horizon, so every particle lives in one internally consistent plausible world and the two kinds of uncertainty stay separable. Actions are chosen by model predictive control: the cross-entropy method searches over action sequences by their average return across particles, the first action is executed, and planning starts again.
import numpy as np
def sequence_returns(models, reward, s0, actions, particles, rng, ts_inf=True):
"""Mean return of each candidate sequence under an ensemble.
models[b](s, a) -> (mean, std) of the next state; actions: (N, H, action_dim)."""
N, H, _ = actions.shape
s = np.repeat(s0[None], N * particles, axis=0) # one row per (sequence, particle)
a_seq = np.repeat(actions, particles, axis=0) # (N * particles, H, action_dim)
member = rng.integers(len(models), size=N * particles) # TS-inf: one member per particle
G = np.zeros(N * particles)
for t in range(H):
if not ts_inf: # TS1: a new member every step
member = rng.integers(len(models), size=N * particles)
a = a_seq[:, t]
G += reward(s, a)
mean, std = np.zeros_like(s), np.zeros_like(s)
for b, f in enumerate(models):
idx = member == b
if idx.any():
mean[idx], std[idx] = f(s[idx], a[idx])
s = mean + std * rng.standard_normal(s.shape) # aleatoric sample
return G.reshape(N, particles).mean(axis=1) # CEM ranks sequences by thisThe inner loop of PETS's planner. The cross-entropy method calls it once per iteration on sequences drawn from a Gaussian, refits that Gaussian to the best ones, and after a few iterations executes the first action of the mean sequence.
Chua et al. report that PETS matched the asymptotic performance of model-free algorithms on several benchmark tasks while needing far fewer samples, for example 8 and 125 times fewer than soft actor–critic and PPO, respectively, on the half-cheetah task. The price moved to decision time: every real step runs a full CEM optimization through the ensemble. MBPO later reused the probabilistic ensemble to generate training data instead of planning at every step (When to Trust a Model: MBPO).
Optimism to explore, pessimism when you cannot
PETS averages over its uncertainty, which is neutral: it neither seeks nor avoids the unknown. What an agent should do with epistemic uncertainty depends on whether it can still collect data. Online, unknown regions may hide better behavior, so optimism sends the agent to find out. Offline, with a fixed dataset, an unknown region can never be checked, so pessimism keeps the policy where the data are.
With exact rewards, the simulation lemma of Model Errors & Value-Equivalent Models and admissibility give a two-sided bound for every policy:
The lower half says the penalized model return never overstates the truth:
Chain the optimality of for with both halves, for any comparison policy .
The guarantee is relative: does at least as well as any policy whose trajectories stay where the model is confident, the behavior policy included, minus twice that policy's accumulated uncertainty. In practice is a heuristic computed from the ensemble, and admissibility cannot be checked, so the bound explains the design rather than certifying a policy. MOReL (Kidambi et al., 2020) implements pessimism differently, ending imagined trajectories in an absorbing, penalized state wherever the ensemble disagrees. Both connect to the theory of Pessimism: The Theory of Offline RL.
Key takeaways
- Aleatoric uncertainty is noise in the world and should be averaged over; epistemic uncertainty is the model's ignorance, shrinks with data, and is where planners get fooled. Their sum is the law-of-total-variance split .
- PILCO propagates Gaussian state distributions through GP dynamics by moment matching and differentiates the expected cost analytically; it learned a real cart-pole swing-up from 17.5 seconds of data, and failed when its uncertainty was removed.
- PETS scales the idea with probabilistic ensembles, particle propagation (TS1 or TS∞) and CEM-based MPC, matching model-free asymptotic performance with far fewer samples.
- Online, epistemic uncertainty should drive optimism (H-UCRL's hallucinated controls); offline, pessimism: penalizing reward by gives , by two uses of the simulation lemma.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
An agent gathers ten times more data in one region of its state space. Which part of its model's predictive uncertainty there should shrink?
- Both parts, equally
- The epistemic part: disagreement between plausible models
- The aleatoric part: the noise in the transitions
- Neither; uncertainty depends only on the model class
Show the answer
B. The epistemic part: disagreement between plausible models
More data narrows the set of models consistent with it, shrinking epistemic uncertainty. Aleatoric noise is a property of the environment and stays; a well-specified model's noise estimate converges to it instead of shrinking.
In PETS's TS∞ propagation, why does each particle keep the same ensemble member for the whole planning horizon?
- To make planning faster
- Because ensemble members cannot be switched during a rollout
- To remove aleatoric noise from the rollouts
- So that each particle follows one internally consistent plausible dynamics, keeping epistemic and aleatoric uncertainty separable
Show the answer
D. So that each particle follows one internally consistent plausible dynamics, keeping epistemic and aleatoric uncertainty separable
A particle that keeps its member traces what would happen if that model were the truth, with that model's noise. Spread across particles of the same member is aleatoric; spread between members is epistemic. TS1 instead mixes members within a trajectory.
MOPO maximizes the model return with reward . Against which policies does its guarantee make the learned policy competitive?
- Policies whose trajectories in the model stay where the uncertainty is small, such as the behavior policy
- Every policy, including the optimal one
- Only the behavior policy
- Policies that explore the most uncertain regions
Show the answer
A. Policies whose trajectories in the model stay where the uncertainty is small, such as the behavior policy
The comparison term subtracts , so the guarantee is strong for policies with small accumulated uncertainty and weak for the rest. The optimal policy is covered only if it stays near the data.
Further reading
- M. P. Deisenroth & C. E. Rasmussen, "PILCO: A model-based and data-efficient approach to policy search," ICML (2011).
- K. Chua, R. Calandra, R. McAllister & S. Levine, "Deep reinforcement learning in a handful of trials using probabilistic dynamics models," NeurIPS (2018).
- B. Lakshminarayanan, A. Pritzel & C. Blundell, "Simple and scalable predictive uncertainty estimation using deep ensembles," NeurIPS (2017).
- S. Curi, F. Berkenkamp & A. Krause, "Efficient model-based reinforcement learning through optimistic policy search and planning," NeurIPS (2020).
- T. Yu, G. Thomas, L. Yu, S. Ermon, J. Zou, S. Levine, C. Finn & T. Ma, "MOPO: Model-based offline policy optimization," NeurIPS (2020).