1 of 56

Building a self driving car

by Tanay and Rohan

2 of 56

We wanted to create a machine that thinks and learns.

3 of 56

Inspiration: BoxCar2D

Except... AI is not generating vehicles.

4 of 56

Mundane tasks steal precious time.

5 of 56

But AI isn’t just about saving time; it’s about saving lives.

6 of 56

(also Tanay does 3D stuff, and Rohan finds 3D stuff magical. Rohan does Neural Network stuff, and Tanay finds Neural Network stuff magical)

7 of 56

The car and its world.

8 of 56

Meet the driver.

9 of 56

Who does the AI learn from?

humans

10 of 56

We drive the car (many times)

Features are computed from data

Features are paired with control states → training cases

Unity sends training cases to learning server

The Training Process

Neural Network learns

11 of 56

Unity sends computed features to server

Neural Network predicts control states

Server responds back to Unity

Car inherits suggested control states

Self-driving mode

12 of 56

Where does the learning, prediction and persistence occur?

a local Python HTTP server

13 of 56

Feature vectors/input

JSON

HTTP POST (REST) to localhost:8000/[get|send]DrivingData

Server prediction/training results computed

JSON

Server responds to client (Unity)

JSON decoded and action is taken

14 of 56

Performed every ~0.1 seconds (40 FPS). Latency of ~0.06 seconds.

15 of 56

Training Process

16 of 56

Collecting Input

17 of 56

:(

[51, 210.00, 31.31, 44, 62.52, 104, 20, 21, 33, 31, 67, 140, 93, 53, 81, 88, 86, 420, 21.41 310.33, 500.51, 20.17, 100.34, 140.67, 40.33, 510.29, 192.107, 12.433, 191.67, 124.15, 79.51, 31, 67, 140, 93, 53, 81, 88.51, 86, 420, 310.33, 500.51, 20.17, 100.34, 140.67, 1, 210.41, 24.2 31.31, 140.67, 201.41]

18 of 56

Feature Extraction

19 of 56

speed

Human eyes = “raycasts”

20 of 56

Computing Features

leftRightRatio

forwardDistance

21 of 56

Preparing Features

forwardDistance

leftRightRatio

speed

[0.51, 0.67, 0.33]

tuning - normalization & scaling

scaledForward

scaledLeftRightRatio

scaledSpeed

22 of 56

X: [ , , ]

y_motion: [ ]

y_steering:[ , , ]

scaledDistance

A Training Case (qualified)

scaledLeftRightRatio

scaledSpeed

isAccelerating

isTurningLeft

isTurningRight

isKeepingStraight

Binary control states: we change them to achieve a goal (eg. of driving well!)

23 of 56

X: [0.94, 0.55, 0.36]

y_motion: [1]

y_steering:[0, 0, 1]

Teaching the network: at a 0.94 scaledForward, 0.55 scaledLeftRightRatio, and a 0.36 scaledSpeed, the car is accelerating and keeping straight.

A Training Case (quantified)

24 of 56

~3000 training cases

and the neural�network will learn

25 of 56

But what is a neural network?

26 of 56

A supervised Machine Learning classification algorithm that maps (with weights) some real input X to probabilistically distributed outputs y. It is modelled after the human brain.

27 of 56

Example Time!

28 of 56

Architecture of ANN

Out1 + Out2 + … + Outm = 1 (normally)

Shallow vs. deep?

Multi-label vs. single label?

Number of hidden nodes?

Weight

Node (activity)

29 of 56

Activation Probabilistic Function - Sigmoid

- - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - -

Horizontal asymptotes at 0 and 1.

30 of 56

Feed Forward

Bias = +1

Activate each post-input node (eg. a1 and y1):

.

.

.

31 of 56

Car Motion

shouldAccelerate

[0.45]

[0]

32 of 56

Car Steering

shouldTurningLeft

shouldTurningRight

shouldKeepStraight

[0.02,

0.05,

0.93]

[0,

0,

1]

33 of 56

A measure of how good a neural net’s weights are is a cost function like this one. We want to minimize on this error.

This gets the average discrepancy (not really though - a bit more complex) between the actual output and the predicted output for the training cases.

34 of 56

To adjust its weights favorably, we “ride” down the derivatives to the global minimum cost point using gradient/hill descent.

J(θ)

θj

35 of 56

But gradient descent in Neural Networks is more complex than this. Each weight contributes to the overall error differently. We use a different complex algorithm called backpropagation.

36 of 56

37 of 56

We’re computing how much each weight contributes to the overall cost/error and hence updating each of these weights (till convergence) via the error’s partial derivatives with respect to each individual weight.

Basically…

38 of 56

And when we converge, we have a trained neural network which we can use to make predictions.

39 of 56

Quick overview of Neural Networks - fin.

40 of 56

We drive the car (many times)

Features are computed from data

Features are paired with control states

Unity sends training cases to learning server

The Training Process

Neural Network learns

41 of 56

  1. Initialize weights randomly (not to zero - which will prevent convergence)

  • Feed forward all training data and retrieve cost/error

  • Perform backpropagation to achieve optimum weights

  • You can now make predictions!

Neural Network Learning

42 of 56

92% accuracy for steering data, 96% accuracy for motion data.

43 of 56

Unity sends computed features to server

Neural Network predicts control states

Server responds back to Unity

Car inherits suggested control states

Self-driving mode

44 of 56

  1. “Activate” the network by forward feeding the input to predict on

  • Get output of control states with their probabilities

  • Convert probabilities to binary outputs

  • Set the car control states to these binary values

Neural Network Prediction

45 of 56

Documentation

46 of 56

Us Training the AI

47 of 56

It can brake!

48 of 56

It can turn!

49 of 56

Almost getting there...

50 of 56

The AI finishes! (with a catch)

51 of 56

Bug - braking training didn’t finish up to this documented point!

52 of 56

  • Choosing features that are relevant from a human perspective

  • Normalizing and scaling features

  • Choosing an appropriate neural network architecture - eg. no. of hidden nodes, no. of hidden layers, bias terms, etc.

  • Choosing backpropagation parameters - eg. learning rate, validation set size, momentum, max. epochs, etc.

5. Trained more and…. drove better (controls were wonky)!

How We Improved

53 of 56

  • Make car detect road edges instead of walls

  • Speed up neural network training (ARAC)

  • Fix braking!

Fixes

54 of 56

  • (Moving) obstacles

  • Evolution/reinforcement learning

  • Ability to drive backwards, coast (constant speed) or inherit a suggested speed

  • A hardware version!

  • Route embellishments and variables like stop signs

  • Other cars (traffic) following the neural network

Future

55 of 56

56 of 56

Thank you!