Unit 7 of 11 · about 4 hours · explain, implement
Policy-induced shift, data aggregation and fallback replanning
A model is fitted to yesterday's policy and used by tomorrow's. Without aggregation and fallback, each improvement walks further off the data.
You'll be able to
- Explain policy-induced shift: why improving the policy invalidates the model that suggested the improvement.
- Implement a data-aggregation loop (collect under the new policy, refit, repeat) and show error falling on the new distribution.
- Define a fallback rule: when uncertainty is high, shorten the horizon, replan sooner, or hand control back.
Covers
Read
In this order, only the parts listed
0 of 3 done
- Lecture 15: Model-Based RL Part 1, Part 2Berkeley CS 185/285 Deep Reinforcement Learning (Spring 2026) - Model-Based RL
Part 2 (Distributional shift in model-based RL: do not change the policy too much, stick to confident places, pessimism penalty)
- Lecture 11: Model-Based RL, distribution-shift slidesStanford CS224R Spring 2026 - Model-Based RL
Slides 13 to 17: data distribution mismatch under the updated policy, partial trajectories from all states in the data, horizon plot from MBPO
- MBPO: model generalization under policy shiftWhen to Trust Your Model: Model-Based Policy Optimization
arXiv:1906.08253v3, Section 4.3 with Figure 1: model error rises with policy KL, and more data from the collecting policy flattens the rise
Focus on
- Shift is mechanical: the planner optimizes under , the resulting policy visits new states, and was never fitted there. Improvement creates its own invalidation.
- Aggregation answers with fresh real data: run the new policy in the system, append the transitions, refit. Imitation has the same loop under the name DAgger, except here the system (not an expert) labels the new states.
- Fallback is a predeclared rule, not a feeling: above an uncertainty threshold, shorten , replan every step, or refuse the imagined plan and collect real data.
Common mistakes · 3
- Refitting on imagined rollouts. The model teaching itself confirms its own errors; only real transitions from the new policy fix the shift.
- Constraining the policy so tightly to the data that it cannot improve. The trust region must bind the step, not freeze it; aggregation (not a smaller step) is what permits progress.
- Replanning without a compute budget. Closed-loop control at every step costs a full planning run per step; state the replanning rate alongside the horizon.
Try it yourself
Closed-book, before checking anything
np.random.default_rng(seed), let the true system bend slightly: plus noise, with actions . Fit on 200 transitions with ; its held-out MSE stays near the noise variance 0.0025. Test it on 200 transitions from a policy living at : over seeds 0 to 9 the MSE jumps to 0.13 to 0.30. Append 200 real far transitions, refit, and test on fresh far data: the MSE falls to about 0.003, while near-data error rises only slightly. Run on CPU.Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.Why does a better policy mean a worse model, without any bug?Answer
The model was fitted under the old policy's visitation. The better policy visits new states where the fit is untested, so error rises with the policy change.
2.What does Figure 1 of MBPO add beyond that qualitative story?Answer
Two measured facts: model error grows with policy KL, and models trained on more collecting-policy data both start lower and rise more slowly. Data volume buys generalization, not just fit.
3.How does model-based aggregation differ from DAgger?Answer
Both collect under the new policy and retrain. DAgger queries an expert for the right action; here the system supplies the true next state and reward, with no expert needed.
4.State a concrete fallback rule for an MPC controller.Answer
If ensemble disagreement at the current state exceeds a fixed threshold, halve the horizon and replan next step; past a second threshold, execute a safe default action and log a real transition.
You're done when
You reproduce the before and after MSE ranges and can state your aggregation and fallback rules before running any planner.
Only when you can do this without notes.
Leads to
Notes
Resources · 3 for this unit, 5 more in the section
- Berkeley CS 185/285 Deep Reinforcement Learning (Spring 2026) - Model-Based RLUC Berkeley · primary
Slides are public at https://rail.eecs.berkeley.edu/deeprlcourse/static/slides/lec-N.pdf; current videos are not, and the public Fall 2023 playlist numbers lectures differently. Study Lectures 15 and 16 (model-based RL: learned dynamics, open-loop and closed-loop planning, random shooting and CEM, MPC, model-based policy learning). There is no model-based homework, so build the planner yourself on a small environment with known dynamics first.
- Stanford CS224R Spring 2026 - Model-Based RLStanford University · support
Use Lecture 11 (model-based RL) and its MBPO reading as a second treatment of model error, uncertainty and short model rollouts.
- When to Trust Your Model: Model-Based Policy OptimizationJanner et al. · required
Study the model-error analysis and short model-rollout design. Reproduce a reduced real-plus-imagined-data comparison and retain the horizon where model bias reverses the gain.
Also in this section
- Reinforcement Learning: An Introduction (2nd ed.) - Chapter 8Richard Sutton and Andrew Barto · required
The authors post the full second edition free at incompleteideas.net; cite the printed page numbers. Study Sections 8.1 to 8.3 (models, Dyna-Q, when the model is wrong) and Sections 8.8 to 8.11 (decision-time planning, rollout algorithms and Monte Carlo Tree Search). Reproduce the Dyna-Q versus Dyna-Q+ ranking on the blocking or shortcut maze.
- Deep Reinforcement Learning in a Handful of Trials using Probabilistic Dynamics Models (PETS)Chua et al. (NeurIPS 2018) · support
Read the split between aleatoric uncertainty (probabilistic networks) and epistemic uncertainty (ensembles) and the trajectory-sampling planner. Implement an ensemble on a small task and show where the members disagree.
- Mastering Diverse Domains through World ModelsDeepMind · depth
Read DreamerV3 only after the small explicit dynamics and planning path passes. Trace representation, latent dynamics, imagination and actor-critic state, but do not make a large benchmark reproduction part of the exit gate.
- Hands-on Modern RL - Model-Based and World-Model SectionsWalking Labs · support
Use Sections 9.3 and 9.4 as concept maps for model-based RL, search and world models. No runnable dynamics or planner script exists, so reproduce its error-recursion numbers by hand and verify algorithm claims against the original papers. Pin commit 9231bab of walkinglabs/hands-on-modern-rl; its
code/chapterNNfolders do not follow the site chapter numbers. - Reinforcement Learning Control Laboratory - Model-Based StretchRoadmap-Final · support
Add a learned-dynamics stretch with a known-dynamics sanity case, prediction and planning tests, horizon sweeps, model-exploitation failure and matched model-free comparison.