Skip to content
AI360XpertBeta

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.

The learner rolls out to 0.40, the expert labels that exact wobble, and retraining cuts the shoulder error from 0.0847 to 0.000016
The learner rolls out to 0.40, the expert labels that exact wobble, and retraining cuts the shoulder error from 0.0847 to 0.000016

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 TT.

Concretely, a per-step slip rate ϵ\epsilon grows into total cost near ϵT2\epsilon T^2 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 D1\mathcal{D}_1. Later rounds mix execution as πn=βnπ∗+(1−βn)π^n\pi_n = \beta_n \pi^* + (1 - \beta_n) \hat{\pi}_n, with βn\beta_n decaying so the learner soon drives alone. Each round rolls the mixer, visits states sts_t from its own distribution, asks the expert for at∗=π∗(st)a_t^* = \pi^*(s_t) on exactly those states, merges them as Dn=Dn−1∪{(st,at∗)}\mathcal{D}_n = \mathcal{D}_{n-1} \cup \{(s_t, a_t^*)\}, 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 ϵN\epsilon_N plus a 1/N1/N term bounds the deployed slip, so total cost grows like ϵT\epsilon T instead of ϵT2\epsilon T^2. The square is gone because recovery moves are now in the data.

Worked example

Lane position xx with dynamics xt+1=xt+atx_{t+1} = x_t + a_t and expert steer π∗(x)=−x\pi^*(x) = -x. Demos cover only xx in [−0.10,0.10][-0.10, 0.10].

A gust drops the car at x0=0.400x_0 = 0.400 where the expert wants −0.400-0.400. The cloned policy never trained there and steers −0.109-0.109, landing at 0.2910.291. Squared error on the shoulder: (−0.109+0.400)2=0.2912≈0.0847(-0.109 + 0.400)^2 = 0.291^2 \approx 0.0847. Drift continues through 0.1410.141 before crawling home.

DAgger labels the visited trio 0.4000.400, 0.2910.291, 0.1410.141 with expert steers −0.400-0.400, −0.291-0.291, −0.141-0.141 and retrains. From 0.4000.400 again it now steers −0.396-0.396, landing at 0.0040.004. New error: (−0.396+0.400)2=0.0042≈0.000016(-0.396 + 0.400)^2 = 0.004^2 \approx 0.000016. 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.000016

The 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 ϵT2\epsilon T^2.
  • DAgger rolls the learner, labels its own visits with at∗=π∗(st)a_t^* = \pi^*(s_t), merges, and retrains.
  • Our lane trio of corrections cuts shoulder error from 0.08470.0847 to 0.0000160.000016.
  • The bound drops to ϵT\epsilon T because recovery moves join the data.
  • Gate queries on doubt or danger when the expert is human.