Imitation Learning and Behavior Cloning
Writing a reward function for folding a towel or pouring coffee without spilling is surprisingly hard. Often the simplest way to teach a robot a finicky skill is just to show it — guiding the arm yourself with a joystick, leader-follower rig, or VR controller, and asking a neural network to imitate your hands.
Core ideas covered in this module
- Teleoperation datasets & covariate shift
- Action chunking (ACT)
- Multimodal diffusion policies
Behavior cloning and the covariate shift trap
The most direct form of imitation learning is Behavior Cloning (BC): record pairs of (observation, expert action) during human teleoperation and train a network with supervised regression to predict the human's next move. On paper it looks just like standard image classification or curve fitting.
On a real robot, naive single-step BC runs into a nasty feedback loop called compounding covariate shift. Every physical rollout has tiny execution noise. A 2-millimeter drift puts the gripper slightly outside the clean path the human demonstrated. Because the network never saw that slightly off-center state during training, its next prediction is a bit worse — which pushes it even farther off course until the gripper drifts completely off the table.
Fixing jitter and mode-averaging: Action Chunking & Diffusion
Two practical ideas turned imitation learning from a fragile lab demo into a workhorse for bimanual manipulation:
- Action Chunking (ACT): instead of predicting just one tiny action for the next 20 ms step, predict a short sequence (chunk) of the next 16–50 steps at once. Executing chunks enforces temporal consistency, cuts out high-frequency hesitation, and slashes the number of sequential decisions where errors can compound.
- Diffusion Policies: suppose a human demonstrator sometimes goes left around a mug and sometimes goes right. A plain MSE regression model averages the two choices and drives straight through the middle of the mug. Diffusion policies treat action generation as iterative denoising from random noise, letting the model represent multi-modal choices cleanly and commit to one valid path.
Collecting demonstrations that actually generalize
Even with action chunking and diffusion, imitation learning is only as broad as the demonstrations you feed it. If all fifty demos start with the mug in the exact same square centimeter, the policy will freeze or flail the first time someone sets the mug down crooked.
Good teleop datasets deliberately vary object starting poses, lighting, and clutter — and increasingly mix in recovery demos where the human gently bumps an object out of place and corrects it, teaching the policy what to do when a state is slightly messy.
Quadratic compounding error vs. action chunking
E[J(π_BC)] ≤ O(ε · T²) → chunking horizon H reduces decision steps from T to T/H
Single-step errors ε grow quadratically over episode length T due to covariate shift; predicting H-step chunks shrinks effective horizon and smooths motion.
In half your teleoperation demos, you reach around the left side of a water bottle to grab a snack; in the other half, you reach around the right side. What happens if you train a plain MSE regression behavior-cloning policy on that dataset?
Modern visuomotor policies like ACT, Diffusion Policy, and Flow-Matching VLA action heads all predict multi-step action chunks rather than single frames, typically blending overlapping chunks with temporal ensembling.
Hands-On Python Notebook
03 · Behavior Cloning, Covariate Shift & Action Chunking
Demonstrate compounding drift on single-step imitation and fix multimodal averaging & jitter with action chunking.
Try this on your own inside the notebook
- Compare MSE mode-averaging when demonstrations go both left and right around a post
- Test chunk sizes K=1 vs. K=8 under small observation perturbations
In Google Colab, use File → Save a copy in Drive to keep your own edits and notes. Or download the files directly:
uvx marimo edit --sandbox notebooks/course-6/03_imitation_learning_behavior_cloning.pyWrap up this module
Saved automatically in your browser profile so you can pick up right where you left off.