Exercises — World models and embodied AI
Before we start, one tiny reminder of the cast of characters so no symbol appears unexplained:
Level 1 — Recognition
L1.1
Which of these is a world model, and which is model-free? (a) A network that outputs — the expected return of taking in . (b) A network that outputs — a guess of the next state.
Recall Solution
(a) is model-free. scores actions directly from trial-and-error; it never says what the world will do next. (b) is a world model. It predicts consequences — the "if I push this, it falls" knowledge. With it you can imagine futures before acting. Answer: (b).
L1.2
True or false: In the Ha–Schmidhuber architecture, the component that compresses a 64×64 image into a short vector is the M (memory) network.
Recall Solution
False. Compression is done by V (Vision) — a Variational Autoencoder (Variational-Autoencoders) mapping observation to latent . M predicts over time; V squeezes space, M predicts time.
L1.3
Match each term to its one-line job: forward model, MPC, Dyna, MDN.
Recall Solution
- Forward model — predicts next state from .
- MPC (Model Predictive Control) — searches action sequences to maximise imagined return, then executes the first action.
- Dyna — mixes real and model-simulated experience to update the policy.
- MDN (Mixture Density Network) — outputs a mixture of Gaussians so the model can predict a multimodal future (left OR right).
Level 2 — Application
L2.1
A stochastic model gives, from state with a fixed action, three equally likely next states with rewards . What is the expected one-step reward ?
Recall Solution
Expectation = probability-weighted average. Each has probability : Answer: 6. This is exactly what integrating collapses to when the distribution is a discrete set of outcomes.
L2.2
You run MPC with horizon , no discount. A candidate action sequence gives a single sampled trajectory with per-step rewards . What return does MPC assign this candidate?
Recall Solution
Answer: 8. MPC would compare this against other candidates and keep the largest, then execute only before re-planning.
L2.3
Repeat L2.2 with discount , i.e. .
Recall Solution
, so . Answer: 7.03. Discounting shrinks later rewards, so the model trusts its own far-future guesses less — which is wise, since model errors compound.
The figure below makes the two effects visible side by side: the orange bars are the raw rewards, the magenta bars are the same rewards after multiplying by . Notice how the step-0 magenta bar exactly equals its orange bar (because ), while step 2 is visibly shrunk. Summing the three magenta bars gives .

Level 3 — Analysis
L3.1
A model rolls out trajectories under one action sequence, with returns . What is the Monte-Carlo estimate , and why do we average instead of taking the best?
Recall Solution
Answer: 5. We average because the true objective is the expectation over all possible futures (the model is stochastic). Taking the max would reward action sequences that got lucky on one rollout — over-optimistic bias. The mean is an unbiased estimate of .
L3.2
Model error per step is a factor (each imagined step drifts off truth, compounding multiplicatively). Compare the accumulated trust factor for a short rollout vs a long one . What does this justify?
Recall Solution
.
- → about reliable.
- → about reliable. Answer: vs . Long imagined rollouts decay fast, so Dyna uses short -step rollouts — where (the rollout length from the symbol dictionary) is kept small — starting from real states. You re-anchor to reality before the compounding error swamps the signal.
L3.3
Explain why M uses a mixture of Gaussians rather than one Gaussian, using the following concrete numbers: at a fork the car goes left () or right (), each with probability . What does a single Gaussian's mean predict, and why is that catastrophic?
Recall Solution
A single Gaussian is forced to place its mean at the average: Answer: mean — the middle of the road, which is a tree/wall. The model predicts an outcome that never actually happens. A mixture keeps two peaks (one at , one at ), preserving the real bimodal choice. This is the whole reason M is a Mixture Density Network — see Recurrent-Neural-Networks for the RNN that feeds it context .
The figure contrasts the two: the orange curve is the single Gaussian forced to sit at — its peak (dashed line) lands exactly where the road forks into a wall. The magenta curve is the mixture, with two clean peaks at and marking the real "go left" / "go right" outcomes. Read off the peaks: the single Gaussian's most-likely prediction is the impossible middle.

Level 4 — Synthesis
L4.1
Chain-rule planning. Suppose a deterministic differentiable model with one-dimensional state gives with at every step, and reward depends only on the final state with . Action enters only through . Compute where .
Recall Solution
Trace the chain of influence : Numbers: Answer: 6. This is exactly the "backprop through the model" gradient from the parent's formula callout — action 's effect on reward flows through every future state by multiplying the per-step Jacobians. Related idea: gradient descent through a differentiable simulator underlies Sim-to-Real-Transfer.
L4.2
Dyna budget design. Real samples cost 1 "unit" each; simulated samples cost units. You have a budget of 20 units and want the policy to receive at least 500 total gradient updates (real + simulated). If you collect real and simulated samples with (30 dreams per real step), find , , total updates, and check the cost fits the budget.
Recall Solution
Cost: . So → take . Then ; total updates . That is below 500, so bump to : cost — over budget. So within budget the max is , giving 465 updates. Answer: , total updates at cost units. The lesson: cheap simulated data (Reinforcement-Learning-Basics policy updates) multiplies your effective learning per expensive real sample — the core Dyna win.
Level 5 — Mastery
L5.1
Design + justify. You must control a real robot arm that is expensive to run (each real trajectory risks hardware). You have: (i) a camera, (ii) 5,000 offline demonstration trajectories, (iii) a strict real-interaction budget. Sketch a full world-model pipeline naming V, M, C, the loss for M, where imagination replaces reality, and one safeguard against model exploitation.
Recall Solution
Pipeline (V, M, C are defined in the symbol dictionary above):
- V (Vision): Train a VAE (Variational-Autoencoders) on camera frames → latent . Compresses pixels to "what matters." Could swap the encoder for a Vision-Transformers backbone for richer features.
- M (Memory): An RNN + MDN predicting . Loss = negative log-likelihood Mixture is needed for multimodal futures.
- C (Controller): A tiny policy , trained inside M's dream — rollouts sampled from M, no robot needed.
- Bootstrapping data: Seed V and M from the 5,000 demonstrations via Imitation-Learning, so you never start from random flailing on real hardware.
- Safeguard against model exploitation: the controller can find fantasy action sequences that score high only because M is wrong there. Fixes: short -step rollouts, a weight downscaling simulated gradients (Dyna), and periodic re-collection of a few real trajectories to correct M where it drifts — the Sim-to-Real-Transfer loop. Answer: a V→M→C loop trained mostly in imagination, seeded by imitation, guarded by short rollouts + trust + real recalibration.
L5.2
Numeric mastery. Combine everything: horizon , discount . Two candidate action sequences give discounted returns and from imagined rollouts:
- A: rewards
- B: rewards Which does MPC execute the first action of, and by how much does its return beat the other?
Recall Solution
by . Answer: execute from sequence A; it wins by . MPC then re-plans at the next real step (receding horizon), because the world is stochastic and the model is imperfect.