Skip to content

Planning with learned models: MuZero and PlaNet

Learn a model of the environment and plan with it. MuZero searches a tree in a latent model trained to predict rewards, values and policies; PlaNet plans with the cross-entropy method in a learned latent model.

Advanced ~14 min8 steps

What runs in CodeSplash

You will be able to

  • Explain what a world model is and why plans exploit its errors
  • Describe MuZero's three learned functions and what its training targets are
  • Run one round of the cross-entropy method by hand
  • Give the honest readiness of each method in CodeSplash

Read first

01

Why learn a model?

Read

Model-free methods (DQN, PPO) learn values or policies straight from experience and need a great deal of it. A world modelWorld modelA learned model of how the environment responds to actions, used to plan or to imagine training data. learns how the environment responds to actions; the agent can then plan, trying actions in its head before taking one, or train on imagined experience.

The catch: a planner searches for whatever the model rates highly, including the model's mistakes. A model accurate one step ahead can be badly wrong ten steps ahead, and the plan goes exactly there.

02

MuZero

Read

MuZeroMuZeroPlans with tree search inside a learned latent model trained only to predict rewards, values and the search's policy. learns three functions: a representation that maps observations to a latent state, a dynamics function that predicts the next latent state and the reward for an action, and a prediction function that gives a policy and a value for a latent state. It plans with Monte Carlo tree searchMonte Carlo tree search (MCTS)Plan by growing a search tree of actions, balancing promising branches against rarely tried ones, then act on visit counts. inside that latent model.

The latent state never has to reconstruct the observation. It is trained only so that, unrolled along real actions, it predicts the observed rewards, the bootstrapped values and the search's own action distribution.

03

MuZero's loss

Read

Each unrolled step adds three terms: squared error on the reward, squared error on the value target, and cross-entropy from the search's visit distribution to the predicted policy. In the reference's example, the reward term is 0.025, the value term 0.145 and the policy term 0.517, for a total of 0.687.

The search improves on the network's policy, and the network learns to imitate the search: each makes the other better.

04

PlaNet and the cross-entropy method

Read

PlaNet learns a latent dynamics model from image observations and plans by the cross-entropy methodCross-entropy method (CEM)Sample action sequences, keep the best-scoring few (the elites), refit the sampling distribution to them, repeat.: sample many action sequences from a Gaussian, imagine each one's return in the model, keep the best few (the elites), refit the Gaussian to them, and repeat. Then take the first action of the final mean, and replan at the next step.

In the reference's example, two elites out of four candidates give a new mean whose first action is 0.3, and standard deviations of 0.2, 0.1 and 0.01: the last was floored so the search never stops exploring.

05

What runs here

Read

What does carry over is the habit: when a policy was chosen by searching a model, check it on the real process, not on the model that chose it.

Reference · DRL015 · Needs a data type CodeSplash doesn't load yetPlaNet: deep planning networkLearn a compact stochastic latent world model from image trajectories and choose continuous actions through online planning inside that model. PlaNet supplies a distinct model-based control route;
06

Predict: a confident plan

Predict

Predict first

A planner finds an action sequence its learned model rates far above anything in the training data. What should you expect when you run it for real?

The real return will probably matchThe real return may fall short: the plan may exploit model errors
Reveal

It may fall short. Searching a model favors exactly the places where the model is wrong in your favor, often outside the data it learned from.

07

Check: planning

Checkpoint

Check yourself

What is MuZero's latent model trained to predict?

Show the answer

Answer: a

It never reconstructs observations; the latent state only has to support planning.

Check yourself

How do MuZero's search and network improve each other?

Show the answer

Answer: a

Search acts as a policy-improvement step, and imitation distills it back into the network.

Check yourself

In one round of the cross-entropy method, what happens after the candidates' imagined returns are computed?

Show the answer

Answer: a

Refitting to the elites concentrates the search around promising action sequences; a floor on the spread keeps it exploring.

Check yourself

Why does PlaNet carry the label "Needs a data type CodeSplash doesn't load yet"?

Show the answer

Answer: a

The method is about planning from pixels; CodeSplash's policy environments have small, tabular states.

08

Recap

Recap
  • World models let an agent plan or imagine experience, but plans exploit model errors.
  • MuZero plans with tree search in a latent model trained on rewards, values and search policies.
  • PlaNet plans with the cross-entropy method in a latent model learned from images.
  • MuZero is explained here; PlaNet needs image observations CodeSplash doesn't load.

Concepts in this lesson