Search

Search papers and lessons

Imitation Learning and Structured Prediction as No-Regret Online Learning

Stephane Ross, Geoffrey J. Gordon, J. Andrew Bagnell · 2010

DAgger fixes imitation learning's compounding-error problem by repeatedly running the learner, asking the expert to label the states it actually reaches, and retraining on the growing dataset.

On this page

  • Colour = topic mix
  • Probability
  • Calculus
  • Linear algebra
  • Learning basics
  • Reinforcement learning
  • Neural network basics
  • Sign in to see your progress

TL;DR

Training a robot to copy an expert from recorded demonstrations usually fails once the robot starts making its own small mistakes, because it then reaches situations the expert never showed it. DAgger (Dataset Aggregation) runs the learner, asks the expert to label the states the learner actually visits, adds those labelled states to a growing dataset, and retrains. The authors prove that this yields a policy whose errors grow linearly with the task horizon instead of quadratically.

Where you'll see it: in robot learning pipelines that refine a demonstration-trained policy with expert corrections, in self-driving and drone control experiments, and as the template for interactive imitation learning in general.

The problem

Imitation learning trains a policy by supervised learning on expert demonstrations. Each demonstration gives pairs of observed states and expert actions, and the learner fits a classifier or regressor to them. This is behaviour cloning in its plain form, and it looks like ordinary supervised learning.

It is not ordinary supervised learning, because the learner's own actions change which states it sees next. The training data comes from the expert's distribution of states, but at test time the states come from the learner's distribution. This is a case of covariate shift, except that the shift is caused by the learner itself. The paper states the consequence precisely: a classifier that errs with probability ϵ\epsilon on expert states can make on the order of T2ϵT^2\epsilon mistakes in expectation over a horizon of TT steps, because one early mistake can push the learner into territory the expert never demonstrated (Ross and Bagnell, 2010, as cited in the paper). Errors compound, and the total number of mistakes grows quadratically with the horizon.

Earlier fixes existed. One trained a different policy for each time step, which is impractical when the horizon is large or undefined. Another, SMILe, trained a mixture of policies that was stable only in a weak sense, since some mixture members were worse than others. The problem the paper addresses is how to get a single, stationary, deterministic policy with a guarantee that scales linearly in TT.

Key idea

Let the learner drive, and let the expert label what happens. At each round, roll out the current policy, record every state it visits, ask the expert what it would have done in each of those states, and add these labelled states to a dataset that accumulates over all rounds. Then retrain the policy on the full dataset.

The dataset therefore contains the states the learner itself reaches, not only the states the expert reached. After a few rounds, the learner has been trained on the very mistakes it makes, with the expert's correction attached. The paper also allows a mixing parameter βi\beta_i that occasionally executes the expert's action during data collection, which helps early rounds where the learner is still poor. The simplest version uses β1=1\beta_1 = 1 and βi=0\beta_i = 0 afterwards: only the first round is pure expert demonstration, and every later round is the learner's own behaviour labelled by the expert.

The authors interpret this as a Follow-The-Leader rule from online learning. At round nn the algorithm picks the policy that does best on all data seen so far, which is the best policy in hindsight.

The method

Write dπd_\pi for the distribution of states visited by policy π\pi over TT steps, averaged over time. Let C(s,a)C(s,a) be the task cost, and let ℓ(s,π)\ell(s,\pi) be a surrogate loss that measures how far π\pi is from the expert in state ss, for example the 0-1 loss or a hinge loss. The goal is to find a policy π^\hat\pi that minimises the surrogate loss under its own state distribution:

π^=arg⁡min⁡π∈Π Es∼dπ[ℓ(s,π)].\hat{\pi} = \arg\min_{\pi \in \Pi} \ \mathbb{E}_{s \sim d_\pi}\big[\ell(s, \pi)\big].

The objective is non-convex in π\pi because the distribution dπd_\pi itself depends on π\pi. DAgger handles this by building the objective up one round at a time.

Algorithm (DAgger). Initialise an empty dataset D\mathcal{D} and any π^1∈Π\hat\pi_1 \in \Pi. For i=1,…,Ni = 1, \dots, N:

  1. Form the mixed policy πi=βiπ∗+(1−βi)π^i\pi_i = \beta_i \pi^* + (1-\beta_i)\hat\pi_i.
  2. Roll out πi\pi_i for TT steps to collect visited states.
  3. Label each visited state ss with the expert action π∗(s)\pi^*(s), giving Di\mathcal{D}_i.
  4. Aggregate: D←D∪Di\mathcal{D} \leftarrow \mathcal{D} \cup \mathcal{D}_i.
  5. Train π^i+1\hat\pi_{i+1} on D\mathcal{D}.

Return the best π^i\hat\pi_i on a validation set.

Guarantee. Assume the loss ℓ\ell is strongly convex and bounded, the mixing weights decay so that βi≤(1−α)i−1\beta_i \le (1-\alpha)^{i-1} for some constant α\alpha independent of TT, and let ϵN\epsilon_N be the loss of the best single policy in hindsight over the NN rounds. The paper's Theorem 3.1 says that if NN is O~(T)\tilde O(T), some policy in the sequence π^1:N\hat\pi_{1:N} satisfies

Es∼dπ^[ℓ(s,π^)]≤ϵN+O(1/T).\mathbb{E}_{s \sim d_{\hat\pi}}\big[\ell(s, \hat\pi)\big] \le \epsilon_N + O(1/T).

Theorem 3.2 turns this into a bound on the task cost. If ℓ\ell upper-bounds the 0-1 loss with respect to π∗\pi^* and the task cost is bounded by uu per step, then for NN of order O~(uT)\tilde O(uT) the cost satisfies J(π^)≤J(π∗)+uTϵN+O(1)J(\hat\pi) \le J(\pi^*) + uT\epsilon_N + O(1). The key point is the linear dependence on TT in place of the T2T^2 of plain behaviour cloning.

Proof idea. The analysis rests on a lemma that the state distributions of the mixed policy πi\pi_i and the learner's own policy π^i\hat\pi_i differ in total variation by at most 2Tβi2T\beta_i. Once βi\beta_i is small, the learner's loss on its own states is controlled by the loss the online learner already minimised on the mixed rollouts. The rest is a regret argument: average regret of a no-regret learner goes to zero, so the best policy in the sequence is nearly as good as the best fixed policy in hindsight.

Finite samples. In practice only mm trajectories are collected per round. Theorem 4.2 adds a term ℓmax⁡2log⁡(1/δ)/(mN)\ell_{\max}\sqrt{2\log(1/\delta)/(mN)} from Azuma–Hoeffding concentration. The authors note that a sample size of order T2log⁡(1/δ)T^2\log(1/\delta) suffices for the generalisation error to be O(1/T)O(1/T), and that a refined analysis using strong convexity may reduce this to roughly Tlog⁡(1/δ)T\log(1/\delta).

Reduction. Nothing in the analysis depends on the supervised learner beyond its ability to minimise a loss on the aggregated data. The paper calls DAgger a reduction: imitation learning is reduced to supervised learning plus a no-regret online learner, and any no-regret algorithm can be swapped in with the same guarantee, as the authors note in Section 4.

Results

The paper reports experiments on three problems. Its results are given mainly as learning curves in figures, so the summary below is qualitative.

  • Super Tux Kart (steering a kart on a 3D track, learned from images). The metric is the average number of falls per lap, with 95% confidence intervals plotted against the amount of training data over 20 iterations. The paper uses one lap of data per iteration (about 1000 points) and compares DAgger to SMILe.
  • Super Mario Bros. (platform game, learned from images and a near-optimal planner as expert). The metric is the average distance Mario travels per stage before dying, timing out, or finishing. Stages of difficulty 1 are about 4200 to 4300 units long, so the score range is roughly 0 to 4300. Each iteration collects 5000 points over 20 iterations. DAgger is compared with SMILe, SEARN and a purely supervised baseline. The paper reports that the simplest DAgger variant, which uses the expert only in the first round, performs best or close to best in practice.
  • Handwritten character recognition (OCR, structured prediction). The task predicts each character of a word in sequence, using the previous character as input, and the paper treats it as a degenerate imitation problem. DAgger is reported to be competitive with the state of the art using single-pass greedy prediction.

Across the three experiments, the paper's central empirical claim is that DAgger reaches good performance with less data and fewer iterations than SMILe and SEARN, and that it does not need the unstable mixture policies those methods produce.

Why it mattered

DAgger turned a well-known failure of imitation learning into a simple recipe with a provable guarantee. It needs no tuning beyond the choice of the supervised learner, which made it easy to adopt. The idea of collecting data under the learner's own policy and labelling it with an expert became the standard way to make imitation policies robust, and it underlies many later interactive imitation learning and human-in-the-loop systems. The reduction viewpoint also connected imitation learning to online learning, a link the paper argues makes the analysis transparent. The name DAgger, short for Dataset Aggregation, is the one the field uses.

Reading guide

Read the sections in this order, with these prerequisites in mind:

  1. Introduction. Needs behaviour cloning and the idea of covariate shift. The T2ϵT^2\epsilon compounding-error claim is the motivation for everything after.
  2. Preliminaries. Needs Markov decision processes for the state distribution dπd_\pi, and expectations for the cost J(π)J(\pi). The surrogate loss ℓ\ell is a convex function in the paper's main setting.
  3. DAgger algorithm (Section 3). Needs supervised learning to train π^i+1\hat\pi_{i+1} on the dataset. The mixing parameter βi\beta_i is the only algorithmic choice beyond the learner.
  4. Theoretical analysis (Section 4). Needs no-regret learning for the average-regret argument. The lemma on total variation distance uses basic probability.
  5. Experiments (Section 5). Needs the Results section of this lesson and the notion of structured prediction for the OCR task.
  6. Future work (Section 6). Short; it points to planners and inverse optimal control for learning cost functions.

Check yourself

QuestionWhy does plain behaviour cloning make up to T squared times epsilon mistakes, even when the per-state error is epsilon?Show answer

The learner's per-state error of ϵ\epsilon is measured on expert states, but the learner visits its own states after the first mistake. Once it is off the expert's path it may face states it was never trained on, so errors compound. Over TT steps the expected number of mistakes can grow with T2ϵT^2\epsilon rather than TϵT\epsilon.

QuestionIn DAgger with beta_1 = 1 and beta_i = 0 for i greater than 1, which policy collects the data at round 3?Show answer

Round 3 uses π3=π^3\pi_3 = \hat\pi_3, the learner's own current policy, with no expert actions executed. The expert only labels the states that this rollout visits. The data is therefore drawn from the learner's distribution, which is the point of the method.

QuestionWhy is the objective in the DAgger analysis non-convex in the policy, and how does the algorithm avoid optimising it directly?Show answer

The state distribution dπd_\pi depends on π\pi, so the expected loss Es∼dπ[ℓ(s,π)]\mathbb{E}_{s \sim d_\pi}[\ell(s,\pi)] changes shape as π\pi changes. DAgger avoids optimising it directly: each round fixes the data-collection distribution from the current policy and fits the next policy to the aggregated data, and a no-regret argument controls the total error across rounds.

QuestionA learner with horizon T equal to 100 and per-state error 0.001 is trained by plain behaviour cloning. Using the paper's T squared times epsilon scaling, roughly how many mistakes does it expect over the horizon, and what does a linear-in-T bound give instead?Show answer

The quadratic scaling gives about 1002×0.001=10100^2 \times 0.001 = 10 mistakes. A linear scaling gives about 100×0.001=0.1100 \times 0.001 = 0.1 mistakes, up to constant factors the paper leaves unspecified. The factor of TT saved is the practical gain the paper's analysis promises for long horizons.

Sources

Read the full paper

Stephane Ross, Geoffrey J. Gordon, J. Andrew Bagnell, 2010. arXiv:1011.0686