Model-Based Deep RL
The agent learns a small simulator of the world from real tries, then practices thousands of imagined moves inside it before each real move.
Why Does This Exist?
Model free control treats the world as a black box and needs millions of real tries. On hardware that means wear, time, and crashes. Each transition updates one value or gradient and throws away what it reveals about how the world moves.
Model based deep RL keeps that structure. It fits neural nets to transition and reward from the same real logs, then rolls out imagined trajectories on GPU. Supervised fitting is far cheaper than trial and error, so real samples drop by an order or more. This page shows the ensemble guard and one accepted imagined step. For the plain idea see model based RL, for the seeding trick see Dyna, and for pixel worlds see learning latent dynamics.
You need one idea first. Aleatoric noise is randomness in the world itself. Epistemic doubt is the model not knowing some region yet. Only the second one tells you to stop imagining.
Think of It Like This
A chess player thinking before touching a piece
A novice learns only from tournament games where every blunder costs a match. A stronger player pictures five replies ahead, drops bad lines in the head, and plays one tested move on the board.
When the pictured position feels unfamiliar, the strong player picks a safe solid line rather than a sharp trap built on a guess.
Where the analogy stops: chess rules are fixed and known. A world model starts with no physics and learns from noisy logs, so its imagined lines can invent moves that do not exist.
How It Actually Works
Let be state, action, and real transitions . Let be the learned transition and the learned reward. Many nets predict a Gaussian over the change:
Here is predicted mean change and is predicted noise. Training minimizes Gaussian log loss on .
One net hallucinates outside its data, and the policy chases the hallucination. The fix is a bootstrap ensemble of nets with different starts and data bags. Let and be member mean and noise, with average mean :
- Aleatoric noise: , the world randomness.
- Epistemic doubt: , the member disagreement.
High disagreement means unknown ground. Short branching rollouts keep errors small: seed a real state from , imagine only steps with from 1 to 15, store in , and train the actor critic on a mix with most weight on imagined data plus some real anchor.
Worked example
Three nets see and and report means , , with noise , , :
- Mean .
- Aleatoric .
- Epistemic .
- Total .
Gate . Since sits far below it, the imagined step joins . The diagram shows the same three dots, the 1.50 mean, and the open gate.
Code
The snippet splits the same two uncertainties and applies the gate.
def ensemble_stats(means: list[float], noises: list[float]) -> tuple[float, float, float]: """Mean, aleatoric noise, and epistemic disagreement.""" b = len(means) mean = sum(means) / b aleatoric = sum(noises) / b epistemic = sum((m - mean) ** 2 for m in means) / b return (round(mean, 4), round(aleatoric, 6), round(epistemic, 6))
if __name__ == "__main__": print(ensemble_stats([1.48, 1.52, 1.5], [0.01, 0.02, 0.015])) print(0.000267 < 0.05)# -> expected output:(1.5, 0.015, 0.000267)TrueWatch Out For
Rolling a thousand imagined steps and believing the fantasy
The symptom: imagined returns climb while the real robot falls on step one. Feeding each prediction back in compounds error about as , so after 15 to 20 steps the states are unphysical yet the critic trusts them.
The fix: branch short runs from real states, schedule from 1 upward only as validation steadies, and cut any branch the moment epistemic disagreement passes your gate.
The Quick Version
- Model based deep RL fits transition and reward nets with supervised loss, then trains the policy mostly on imagined rollouts.
- A bootstrap ensemble splits world noise from model doubt measured by member disagreement.
- In the example the mean is , aleatoric , epistemic , total .
- Doubt below gate accepts the step, while far regions spike doubt and halt the branch.
- Short branches from real states bound drift, which is where the sample savings come from.