Search

Search papers and lessons

End to End Learning for Self-Driving Cars

Mariusz Bojarski, Davide Del Testa, Daniel Dworakowski et al. · 2016

Bojarski and colleagues at NVIDIA train a convolutional network to map pixels from one front camera straight to steering, with the steering angle as the only training signal.

On this page

  • Colour = topic mix
  • Calculus
  • Discrete math
  • Probability
  • Linear algebra
  • Neural network basics
  • Learning basics
  • ReadReady to readNot yet

TL;DR

A convolutional neural network can learn to drive a car from raw camera pixels. The NVIDIA team trained one on about 72 hours of human driving, with the steering angle as its only training signal, and it learned to drive on local roads, highways, unpaved roads and in parking lots. The authors argue that a single end-to-end system, which optimises every processing step together, will eventually outperform systems built from separately designed stages such as lane detection, path planning and control.

Builds on: Convolutional Neural Network, Behavior Cloning, Data Augmentation · Leads to: end-to-end driving systems that learn steering from demonstration

Why it mattered

A self-driving stack of the period was usually a pipeline. One module found lane markings, another planned a path, a third turned the path into steering and throttle, and engineers wrote rules for each case. The paper proposes to replace that pipeline with one network that maps the image directly to a steering command. The authors call the system DAVE-2. It builds on DAVE, a DARPA project in which a sub-scale radio-control car drove through a junk-filled alley after training on human driving.

The result matters for two reasons. It shows that a large convolutional network trained on driving data can handle roads with and without lane markings and roads with no clear visual guidance. And the authors report that the network's internal features are interpretable in part: in the first two layers, the feature maps trace the outline of an unpaved road, although nobody labelled road outlines during training.

The problem

The earlier DAVE system could steer, but its reliability was poor. The paper reports that DAVE's mean distance between crashes was about 20 meters in complex environments, which is far from a system that could drive on public roads. The modular approach had a different problem: each module was tuned to a human-chosen intermediate target such as detecting lane lines, and those targets do not guarantee good driving. The authors want to avoid needing to recognise specific features such as lane markings, guard rails or other cars, and to avoid writing an "if, then, else" rule for each situation.

The learning problem is supervised. The network sees a camera image and must output the steering that a human driver gave in that situation. The difficulty is that a learner trained only on good driving has never seen recovery from mistakes, so small errors grow until the car leaves the road.

How it works

The walkthrough follows the pipeline from data collection to driving. Each stage addresses one failure mode of the one before.

flowchart LR
  A[Record video and steering] --> B[Select lane-keeping frames]
  B --> C[Augment with shifted and rotated views]
  C --> D[Train CNN on steering labels]
  D --> E[Drive from one front camera]
  1. Record the human driver. Three cameras sit behind the windshield, and each frame is time-stamped with the steering angle read from the vehicle's controller area network bus. The steering target is 1/r1/r, the inverse turning radius, so that driving straight (an infinite radius) gives the value 00 and left and right turns give values with opposite signs.
  2. Select frames. The authors keep only frames where the driver was staying in a lane, and they sample those at 10 frames per second, because more frames would be nearly identical. They add a higher proportion of curves so the network does not learn only to drive straight.
  3. Augment the views. Images from the left and right cameras stand in for car positions shifted off the lane centre. Other shifts and rotations are simulated by a viewpoint transformation of the nearest camera image. The transformation assumes that points below the horizon are on flat ground and that points above it are infinitely far away. The steering label for each transformed image is set to the command that would bring the car back to the lane centre and orientation within two seconds.
  4. Pass the image through the network. The input image is split into YUV planes. The first layer is a fixed normalisation step, followed by five convolutional layers and three fully connected layers. The output is the single number 1/r1/r.
  5. Train by backpropagation. The network output is compared with the desired command for that image, and the weights are adjusted to reduce the error. The authors used Torch 7 for the training.
  6. Drive. At run time the network reads one centre camera and outputs a steering command for each frame. The system runs at 30 frames per second.

A tiny check on step 4. A convolution with a 5×55 \times 5 kernel and stride 2, without padding, turns an input of width WW into an output of width (W−5)/2+1(W - 5)/2 + 1. For W=11W = 11 this gives (11−5)/2+1=4(11 - 5)/2 + 1 = 4 columns. The paper's first three layers all use this stride.

The math

Steering target. The network predicts κ^=1/r\hat{\kappa} = 1/r for each frame, and the label is κ=1/r\kappa = 1/r from the human driver or the adjusted command for an augmented image. A straight road has κ=0\kappa = 0.

Training loss. The paper trains the weights to minimise the mean squared error between predicted and target steering:

L=1N∑i=1N(κ^i−κi)2\mathcal{L} = \frac{1}{N}\sum_{i=1}^{N} \left(\hat{\kappa}_i - \kappa_i\right)^2

where NN is the number of training frames in a batch. A large error on one frame costs more than a small error, which pushes the network toward the average correct steering.

Augmentation magnitudes. Shifts and rotations from augmentation are drawn from a normal distribution with zero mean. Its standard deviation is twice the standard deviation the authors measured for human drivers. This makes the augmented positions larger than typical human variation, so the network learns recovery from larger errors than it usually sees.

Convolution output size. For an input of width WW, a kernel of width KK, a stride SS and no padding, the output width is ⌊(W−K)/S⌋+1\lfloor (W - K)/S \rfloor + 1. The paper's strides are S=2S = 2 with K=5K = 5 in the first three layers, and S=1S = 1 with K=3K = 3 in the last two.

Model size. The paper reports that the network has about 27 million connections and about 250 thousand parameters. Much of the gap comes from weight sharing in the convolutional layers, where one kernel's weights are reused at every position in the image.

Autonomy. For a simulated drive, the authors count interventions, each costing six seconds, and compute

autonomy=(1−(number of interventions)⋅6 secondselapsed time [seconds])⋅100\text{autonomy} = \left(1 - \frac{(\text{number of interventions}) \cdot 6\ \text{seconds}}{\text{elapsed time [seconds]}}\right) \cdot 100

With 10 interventions in 600 seconds, the autonomy is (1−60/600)⋅100=90%(1 - 60/600) \cdot 100 = 90\%.

Results

Simulation. The authors test the network on prerecorded routes totalling about three hours and 100 miles in Monmouth County, New Jersey. The simulator uses the viewpoint transformation to show what the camera would see if the network were steering, and it records a virtual intervention when the car is more than one meter from the lane centre.

On-road. On a typical drive from the NVIDIA office in Holmdel to Atlantic Highlands, the car steers itself about 98% of the time. This figure excludes lane changes and turns from one road onto another. The authors also drove 10 miles on the Garden State Parkway, a multi-lane divided highway with on- and off-ramps, with no interventions.

Training data. As of March 28, 2016 the team had about 72 hours of driving, collected in clear, cloudy, foggy, snowy and rainy weather, by day and night, on highways, two-lane roads, residential streets, tunnels and unpaved roads. The conclusion describes the data as less than a hundred hours.

Inside the network. For an unpaved road, the activations of the first two feature-map layers clearly show the outline of the road. For a forest with no road, the activations look like noise. The authors present this as evidence that the network found road features on its own, from the steering signal alone.

Limits. The authors describe these as preliminary results. The viewpoint transformation assumes flat ground and distorts anything standing above the ground, such as cars, poles and buildings. The on-road figure excludes lane changes and turns. The authors state that more work is needed to improve the network's robustness, to verify robustness, and to improve visualisation. They also note that after end-to-end training it is not possible to separate the convolutional layers that extract features from the fully connected layers that act as a controller.

Reading guide

Read the sections in this order. Each one names the lessons that cover its prerequisites.

  • Section 1, Introduction. Needs convolutional neural networks, and the history of backpropagation for training them.
  • Section 2, Overview of DAVE-2. Needs curvature, since 1/r1/r is the curvature of the path, and behavior cloning for the supervised setup.
  • Section 3, Data collection. Plain description of the recording setup. No prerequisite beyond the floor.
  • Section 4, Network architecture. Needs convolution and fully connected networks.
  • Section 5, Training details. Needs mean squared error, data augmentation and stochastic gradient descent.
  • Section 6, Simulation. Plain description of the simulator, using the viewpoint transformation from Section 2.
  • Section 7, Evaluation. Needs only the definition of autonomy given in the Math section.
  • Section 7.3, Visualisation. Needs convolution to read the feature maps.
  • Section 8, Conclusions. No new prerequisites. For a related method that tackles the same drift problem by collecting data from the learner's own mistakes, see DAgger.

Check yourself

QuestionThe network outputs 1/r rather than the radius r. Why is this the better target?Show answer

A straight road has an infinite radius, so rr would blow up on straight segments and produce a singularity. The inverse 1/r1/r is zero on straight roads and passes smoothly through zero from left turns to right turns, so the target stays finite and changes smoothly across all driving situations.

QuestionIn a simulated drive of 800 seconds the car has 4 interventions. What is its autonomy?Show answer

Each intervention costs 6 seconds, so the lost time is 4×6=244 \times 6 = 24 seconds. The autonomy is (1−24/800)⋅100=(1−0.03)⋅100=97%(1 - 24/800) \cdot 100 = (1 - 0.03) \cdot 100 = 97\%.

QuestionA first convolutional layer has an input width of 31, a kernel width of 5 and a stride of 2, with no padding. What is the output width?Show answer

The formula gives ⌊(31−5)/2⌋+1=⌊26/2⌋+1=13+1=14\lfloor (31 - 5)/2 \rfloor + 1 = \lfloor 26/2 \rfloor + 1 = 13 + 1 = 14. The output is 14 columns wide.

QuestionWhy does the paper augment the training data with shifted and rotated views, and why is each shifted label set to steer back within two seconds?Show answer

Human driving data keeps the car near the lane centre, so the network never sees how to recover from a drift. Without recovery examples, small errors grow and the car leaves the road, as the paper notes. The augmented views put the car in off-centre positions, and labelling each one with the steering that returns the car within two seconds teaches the correct correction. The standard deviation of the shifts is twice that of human drivers, so the recovery examples cover larger errors than typical driving.

Sources

Read the full paper

Mariusz Bojarski, Davide Del Testa, Daniel Dworakowski et al., 2016. arXiv:1604.07316