Search

Search papers and lessons

DayDreamer: World Models for Physical Robot Learning

Philipp Wu, Alejandro Escontrela, Danijar Hafner et al. · 2022

DayDreamer runs the Dreamer world-model agent on four physical robots, learning online without simulators, and a quadruped learns to stand and walk in about an hour.

On this page

  • Colour = topic mix
  • Probability
  • Reinforcement learning
  • Calculus
  • Discrete math
  • Inference
  • Linear algebra
  • ReadReady to readNot yet

TL;DR

DayDreamer asks whether the Dreamer agent, which had worked in video games and simulators, can learn directly on physical robots. The authors run one unchanged algorithm, learning online on the hardware, on four robots: a quadruped, two robot arms and a wheeled robot. The agent learns a World Model from its own past experience and trains its behaviour on rollouts it imagines inside that model, so the real robot needs far fewer physical trials. The quadruped learned to roll over, stand up and walk in about one hour, with no simulator and no resets.

Builds on: Dreamer, Recurrent State Space Model, Experience Replay, Actor-Critic Methods · Leads to: World Model, Model-Based Reinforcement Learning

Why it mattered

Most robot learning from scratch used to happen in simulation. Researchers trained a policy in a simulator with randomised physics, then moved it to hardware, or they designed hand-made trajectory generators and recovery controllers that kept the robot safe. Both routes take effort: simulators need careful tuning, and hand-made structure limits what the robot can learn. DayDreamer showed that a general model-based algorithm could learn walking, grasping and navigation on real hardware within hours, using one set of hyperparameters for all four robots. The authors released their software infrastructure, so the result is a reproducible starting point. It gives later robot-learning work a concrete real-world, online baseline to compare against.

The problem

Three things make real-robot learning hard.

  1. Each trial costs real time and wears hardware. A model-free method such as Soft Actor-Critic or Proximal Policy Optimization (PPO) learns mostly from raw trial and error, and each piece of experience is used only briefly. On a physical robot, that is a slow and mechanically harsh way to learn.
  2. Rewards are often sparse. In a pick-and-place task, the robot gets a reward only when it grasps or drops an object. Random behaviour rarely hits that moment, so the learning signal is weak for a long time. This is the Sparse Reward Problem.
  3. Inputs are high-dimensional. Camera images, joint angles, force readings and motor states arrive together, and the robot must work out from them where objects are and where its own body is.

Simulators solve the first problem by making trials cheap, but they miss contact friction, lighting, sensor noise and soft objects. DayDreamer asks whether a learned model can play the role of the simulator, learned from the real robot itself.

How it works

DayDreamer runs two loops at the same time. An actor thread runs the current policy on the robot and writes every step into a replay buffer (Experience Replay). A learner thread, running in parallel, trains the world model on sequences from that buffer and trains the actor and critic on rollouts imagined by the model. The learner never waits for the robot to move, so training continues while the robot acts.

flowchart LR
  A[Robot acts with current policy] --> B[Replay buffer]
  B --> C[Train world model on sequences]
  C --> D[Imagine latent rollouts]
  D --> E[Train actor and critic]
  E --> A

Take one tiny instance: a toy robot with a 3-number sensor reading and two motor commands. Here is one pass of the loop.

  1. Collect. At time step t the robot reads its sensors x_t and sends action a_t. The buffer stores the triple (x_t, a_t, r_t). Check: after 500 steps the buffer holds 500 triples.
  2. Encode. The encoder takes the sensor reading x_t together with the model's memory from the previous step, and produces a compact code z_t. The 3-number reading becomes a 2-number code. Check: the code is smaller than the input, so it keeps only what the model needs.
  3. Predict. The dynamics network guesses the next code from the memory and the action, without looking at the next sensor reading. Check: predicting in code space is cheaper than predicting full camera images.
  4. Learn reward and reconstruction. A reward network predicts r_t from the next state s_{t+1}, and a decoder rebuilds the sensor reading x_t from the code. The decoder lets a human inspect the predictions and gives a learning signal, but behaviour learning does not use it. Check: a reward of 1 at a step should be predicted as about 1 at that state.
  5. Imagine. From a state taken from the buffer, the model rolls forward H = 16 steps, choosing actions with the policy and predicting codes, rewards and values. The robot does not move. Check: 16 imagined steps cost 16 forward passes through small networks, with no motor time.
  6. Learn behaviour. The critic learns to predict the return along each imagined path. The actor learns to raise the probability of actions whose return beat the critic's expectation. Check: an action that led to a higher return than expected becomes more likely.
  7. Act. The latest actor runs on the robot, new experience goes into the buffer, and the loop repeats.

Step 5 is what makes this sample-efficient. The learner can train the actor and critic on large batches of imagined starting states (the paper's typical batch size is about 16K on a single GPU), so the policy improves faster than the robot's clock.

The math

Step 2 and step 3 in symbols: the world model

The paper uses a recurrent state-space model (RSSM). Its model state s_t has two parts: a deterministic memory h_t carried forward by a recurrent network, and a stochastic code z_t. Four networks share the state:

encθ(st∣st−1,at−1,xt)encoder: sensor reading to code\mathrm{enc}_\theta(s_t \mid s_{t-1}, a_{t-1}, x_t) \qquad \text{encoder: sensor reading to code}

dynθ(st∣st−1,at−1)dynamics: predict the code without the sensors\mathrm{dyn}_\theta(s_t \mid s_{t-1}, a_{t-1}) \qquad \text{dynamics: predict the code without the sensors}

decθ(st)≈xtdecoder: rebuild the sensor reading\mathrm{dec}_\theta(s_t) \approx x_t \qquad \text{decoder: rebuild the sensor reading}

rewθ(st+1)≈rtreward: predict the reward\mathrm{rew}_\theta(s_{t+1}) \approx r_t \qquad \text{reward: predict the reward}

Here x_t is the sensor reading, a_{t-1} the previous action, r_t the reward, and theta the shared network weights. The encoder sees the real sensors; the dynamics network must do without them. The gap between the two is what the model learns to close. The paper trains all four jointly by stochastic backpropagation, the reparameterization trick covered in its own lesson (Reparameterization Trick).

Step 5 and step 6 in symbols: the λ-return

The critic v(s_t) estimates the future reward from state s_t. Given an imagined path of length H, the paper uses a λ-return, which blends short and long estimates:

Vtλ=rt+γ((1−λ) v(st+1)+λ Vt+1λ),VHλ=v(sH)V^{\lambda}_{t} = r_{t} + \gamma\Big((1-\lambda)\, v(s_{t+1}) + \lambda\, V^{\lambda}_{t+1}\Big), \qquad V^{\lambda}_{H} = v(s_{H})

Here gamma is the discount, lambda in [0, 1] sets the mix, and V^λ_t is the target the critic learns from state s_t. With lambda = 0 the target is one reward plus the critic's guess at the next state, which is one-step temporal-difference learning (Temporal-Difference Learning). With lambda = 1 it is the full imagined return. Values in between average over all horizons from 1 to H minus 1, so the paper does not have to choose one length. The planning horizon is H = 16. To compute these targets the paper uses a slowly updated copy of the critic, a standard stabilising choice.

Example, by hand. Take H = 3, gamma = 1 (so the discount does nothing here) and lambda = 0.5. The imagined rewards are r_1 = 1 and r_2 = 2, and the critic gives v(s_1) = 5, v(s_2) = 4, v(s_3) = 3.

  1. The horizon end is the critic's value: V^λ_3 = v(s_3) = 3.
  2. V^λ_2 = r_2 + (1 - λ) v(s_3) + λ V^λ_3 = 2 + 0.5 times 3 + 0.5 times 3 = 5.
  3. V^λ_1 = r_1 + (1 - λ) v(s_2) + λ V^λ_2 = 1 + 0.5 times 4 + 0.5 times 5 = 5.5.

The imagined path from state 1 is worth 5.5, while the critic currently says 5. The gap is 0.5, so the actor should make the action that started this path a little more likely.

Step 6 in symbols: the actor and critic losses

The critic regresses its prediction toward V^λ_t. The actor maximises the same return, with an entropy bonus that keeps it exploring:

L(π)=−E[∑t=1H(ln⁡π(at∣st) sg(Vtλ−v(st))+η H[π(at∣st)])]\mathcal{L}(\pi) = -\mathbb{E}\left[\sum_{t=1}^{H} \Big( \ln \pi(a_t \mid s_t)\, \mathrm{sg}\big(V^{\lambda}_t - v(s_t)\big) + \eta\, \mathrm{H}\big[\pi(a_t \mid s_t)\big] \Big)\right]

Read it term by term. The factor V^λ_t minus v(s_t) is an advantage: how much better the imagined outcome was than the critic expected. The operator sg stops gradients, so the advantage is treated as a fixed number when the actor updates. The term ln pi(a_t given s_t) is the log-probability of the action taken, and multiplying it by the advantage raises that probability when the advantage is positive and lowers it when negative. The entropy H of the policy, weighted by eta, rewards a spread-out distribution. This is the REINFORCE form of the gradient (Policy Gradient); the paper uses it for discrete actions, and uses reparameterization gradients through the dynamics network for continuous actions. Both networks are optimised with Adam (Adam).

Example, one actor step. Take a discrete action with four choices. The taken action has probability 0.25, so the uniform policy has entropy H = ln 4 = 1.386. Use the advantage 5.5 minus 5 = 0.5 from the example above, and let eta = 0.01, an illustrative weight rather than the paper's value. The log-probability is ln 0.25 = -1.386, times 0.5 gives -0.693. The entropy term is 0.01 times 1.386 = 0.0139. The per-step contribution to the loss is minus the sum: -(-0.693 + 0.0139) = 0.679. Gradient descent on this loss raises ln pi for the taken action, so it becomes more likely, because it did better than expected. A negative advantage would lower it.

Results

  • Quadruped (Unitree A1, 12 motors, 20 Hz). Dreamer learns to roll over, stand up and walk forward in about one hour of real training, with no simulator and no resets. SAC learns only to roll over in the same budget. After one hour, when the robot is pushed, it adapts within about 10 minutes. The paper's figure shows a single training run for this task.
  • UR5 multi-object pick and place (2 Hz). Dreamer reaches about 2.5 picks per minute within 8 hours, approaching the human demonstrators. Rainbow and PPO learn only to grasp and immediately drop the object in the same bin. A clean cycle is worth +11 under the paper's reward (+1 for a grasp, +10 for placing it in the opposite bin), while a drop in the same bin costs -1.
  • XArm pick and place (about 0.5 Hz, soft object on a string). Dreamer reaches about 3.1 picks per minute in 10 hours, comparable to the human baseline. Rainbow does not learn the task. When lighting changed sharply at sunrise, performance dropped and recovered within about 5 hours of further training.
  • Sphero Ollie navigation (2 Hz, images only). Dreamer learns to reach and hold a fixed goal within about 2 hours, with an average distance of 0.15 in units of the area size. DrQv2, a strong model-free image-based method, performs similarly.

To read the UR5 rate, note that 2 Hz is 120 control steps a minute, so 2.5 picks a minute is about one pick every 48 steps, or roughly 24 seconds. Eight hours at 2 Hz is 57,600 control steps.

The limits are stated in the paper. Hours of hardware training wear the robots and can need human intervention or repair. The authors did not train for longer to find the limits of Dreamer or of the baselines. The results cover four robots and few runs per task, so they show feasibility rather than a complete benchmark.

Reading guide

Check yourself

QuestionWhat does the replay buffer store at each step, and why does DayDreamer train from it rather than only from the newest step?Show answer

The buffer stores the sensor reading, the action and the reward for each step. Training from many stored sequences, rather than the newest step only, reuses each real experience many times, and it breaks the strong correlation between consecutive steps. This matters most when the robot has to spend real time collecting data.

QuestionWith H = 3, gamma = 1, lambda = 0, the rewards r_1 = 1 and r_2 = 2, and the critic values v(s_1) = 5, v(s_2) = 4, v(s_3) = 3, what is V^λ_1?Show answer

With lambda = 0, the recursion becomes V^λ_t = r_t + gamma times v(s_{t+1}). So V^λ_1 = r_1 + v(s_2) = 1 + 4 = 5. The target is one reward plus the critic's guess at the next state, which is one-step temporal-difference learning. Compare with 5.5 when lambda = 0.5 in the worked example above.

QuestionWhy does the actor train on imagined rollouts in latent space rather than on decoded images, and what does the paper give as the reason?Show answer

Imagined rollouts in latent space are cheap and can be batched very widely, with batches of about 16K on one GPU. The paper says that predicting codes rather than raw inputs reduces the accumulation of errors over a rollout. The decoder helps train the representations and lets humans inspect predictions, but the behaviour is learned without it.

QuestionA team wants to run DayDreamer on a robot that needs a human to reset it after every fall. Which parts of the paper's limitations and design apply, and what would you change first?Show answer

The paper's quadruped ran without resets, but the authors note that long hardware training needs human intervention and wears the robot. For a robot that must be reset after falls, the team should first design the task so that falls are rare or recoverable, plan a safe reset procedure, and measure how many real steps are needed before the policy is good enough. Simulation pre-training with transfer is a second option, but it is the route the paper's approach avoids.

Sources

Read the full paper

Philipp Wu, Alejandro Escontrela, Danijar Hafner et al., 2022. arXiv:2206.14176