Dataset Aggregation (DAgger)
Let the learner drive, watch where it wobbles, and ask the expert what it should have done there. Collect those corrections and the wobbles disappear.
Why Does This Exist?
Copying an expert looks like supervised learning: gather state-action pairs and fit. That is behavioral cloning, and it works until the first mistake. Training saw only expert states, so the first wobble lands somewhere the dataset never covered. The next move is worse, the one after worse still, and errors stack quadratically in horizon .
Concretely, a per-step slip rate grows into total cost near under cloning, because one early slip poisons every later step. This page teaches the interactive repair. For the broader family, see imitation learning and its adversarial cousin GAIL.
Think of It Like This
A driving coach with spare pedals
Cloning is studying a perfect driver's notebook, then driving solo. The notebook shows flawless lane centers. One gust pushes you onto gravel and the notebook has zero gravel entries, so you freeze and crash.
DAgger puts the coach beside you with spare pedals. You drive from day one. When you slide onto gravel, the coach says turn this much right here, and that exact pair goes in the book. After a few lessons the book holds your wobbles plus their rescues, which the perfect driver's notebook never had.
Where it stops: the coach rides along continuously while the algorithm works in batch rounds of roll out, label, and retrain.
How It Actually Works
Round one is plain cloning on expert demos . Later rounds mix execution as , with decaying so the learner soon drives alone. Each round rolls the mixer, visits states from its own distribution, asks the expert for on exactly those states, merges them as , and retrains. Training finally matches deployment because the data comes from the learner's own wobbles.
Theory reads this as online learning with no regret. Average training slip plus a term bounds the deployed slip, so total cost grows like instead of . The square is gone because recovery moves are now in the data.
Worked example
Lane position with dynamics and expert steer . Demos cover only in .
A gust drops the car at where the expert wants . The cloned policy never trained there and steers , landing at . Squared error on the shoulder: . Drift continues through before crawling home.
DAgger labels the visited trio , , with expert steers , , and retrains. From again it now steers , landing at . New error: . Three corrections turn a long slide into a one-step save.
Code
The shoulder check before and after, in plain Python:
expert: float = -0.400before: float = -0.109after: float = -0.396print(f"{(before - expert) ** 2:.4f}") # -> 0.0847print(f"{(after - expert) ** 2:.6f}") # -> 0.000016The first line is the cloning wobble, the second the retrained save. Same start, same expert, three extra labels between them.
Watch Out For
An expert who cannot keep up
Symptom: thousands of frame labels pile on a human annotator, quality sags, and live rollouts risk hardware before anyone intervenes.
Fix: ask only when unsure. Gate queries on ensemble disagreement or a safety margin, and let autonomy run the confident stretches. Most queries vanish while the rescues that matter stay.
The Quick Version
- Cloning trains on expert states but deploys on learner states, so one slip compounds toward .
- DAgger rolls the learner, labels its own visits with , merges, and retrains.
- Our lane trio of corrections cuts shoulder error from to .
- The bound drops to because recovery moves join the data.
- Gate queries on doubt or danger when the expert is human.