Building a self driving car
by Tanay and Rohan
We wanted to create a machine that thinks and learns.
Inspiration: BoxCar2D
Except... AI is not generating vehicles.
Mundane tasks steal precious time.
But AI isn’t just about saving time; it’s about saving lives.
(also Tanay does 3D stuff, and Rohan finds 3D stuff magical. Rohan does Neural Network stuff, and Tanay finds Neural Network stuff magical)
The car and its world.
Meet the driver.
Who does the AI learn from?
humans
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
Unity sends computed features to server
Neural Network predicts control states
Server responds back to Unity
Car inherits suggested control states
Self-driving mode
Where does the learning, prediction and persistence occur?
a local Python HTTP server
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
Performed every ~0.1 seconds (40 FPS). Latency of ~0.06 seconds.
Training Process
Collecting Input
:(
[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]
Feature Extraction
speed
Human eyes = “raycasts”
Computing Features
leftRightRatio
forwardDistance
Preparing Features
forwardDistance
leftRightRatio
speed
[0.51, 0.67, 0.33]
tuning - normalization & scaling
scaledForward
scaledLeftRightRatio
scaledSpeed
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!)
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)
~3000 training cases
and the neural�network will learn
But what is a neural network?
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.
Example Time!
Architecture of ANN
Out1 + Out2 + … + Outm = 1 (normally)
Shallow vs. deep?
Multi-label vs. single label?
Number of hidden nodes?
Weight
Node (activity)
Activation Probabilistic Function - Sigmoid
- - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - -
Horizontal asymptotes at 0 and 1.
Feed Forward
Bias = +1
Activate each post-input node (eg. a1 and y1):
.
.
.
Car Motion
shouldAccelerate
[0.45]
[0]
Car Steering
shouldTurningLeft
shouldTurningRight
shouldKeepStraight
[0.02,
0.05,
0.93]
[0,
0,
1]
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.
To adjust its weights favorably, we “ride” down the derivatives to the global minimum cost point using gradient/hill descent.
J(θ)
θj
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.
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…
And when we converge, we have a trained neural network which we can use to make predictions.
Quick overview of Neural Networks - fin.
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
Neural Network Learning
92% accuracy for steering data, 96% accuracy for motion data.
Unity sends computed features to server
Neural Network predicts control states
Server responds back to Unity
Car inherits suggested control states
Self-driving mode
Neural Network Prediction
Documentation
Us Training the AI
It can brake!
It can turn!
Almost getting there...
The AI finishes! (with a catch)
Bug - braking training didn’t finish up to this documented point!
5. Trained more and…. drove better (controls were wonky)!
How We Improved
Fixes
Future
Thank you!