Skip to content

codeXLinkX/Behavioral-Cloning

Repository files navigation

Behavioral Cloning

Writeup Template

You can use this file as a template for your writeup if you want to submit it as a markdown file, but feel free to use some other method and submit a pdf if you prefer.


Behavioral Cloning Project

The goals / steps of this project are the following:

  • Use the simulator to collect data of good driving behavior
  • Build, a convolution neural network in Keras that predicts steering angles from images
  • Train and validate the model with a training and validation set
  • Test that the model successfully drives around track one without leaving the road
  • Summarize the results with a written report

Rubric Points

Here I will consider the rubric points individually and describe how I addressed each point in my implementation.


Files Submitted & Code Quality

1. Submission includes all required files and can be used to run the simulator in autonomous mode

My project includes the following files:

  • model.py containing the script to create and train the model
  • drive.py for driving the car in autonomous mode
  • model.h5 containing a trained convolution neural network
  • writeup_report.md or writeup_report.pdf summarizing the results

2. Submission includes functional code

Using the Udacity provided simulator and my drive.py file, the car can be driven autonomously around the track by executing

python drive.py model.h5

3. Submission code is usable and readable

The model.py file contains the code for training and saving the convolution neural network. The file shows the pipeline I used for training and validating the model, and it contains comments to explain how the code works.

Model Architecture and Training Strategy

1. An appropriate model architecture has been employed

My model consists of a convolution neural network that has 3 convolutional layers with 5x5 filter sizes and depths between 24 and 48 and 2 convolutional layers with 3x3 filter sizes and depths between 64 and 64.

The model includes RELU layers to introduce nonlinearity, and the data is normalized in the model using a Keras lambda layer (code line 55).

2. Attempts to reduce overfitting in the model

The model was trained and validated on different data sets to ensure that the model was not overfitting. The model was tested by running it through the simulator and ensuring that the vehicle could stay on the track.

To reduce overfitting, I used 2 dropout layers, one with 0.25 rate after Convolution2D layers, and another with 0.5 rate after 3 fully connected layers.

3. Model parameter tuning

The model used an adam optimizer, so the learning rate was not tuned manually.

4. Appropriate training data

Training data was chosen to keep the vehicle driving on the road. I used a combination of center lane driving, recovering from the left and right sides of the road and driving on the opposite way of the track.

For details about how I created the training data, see the next section.

Model Architecture and Training Strategy

1. Solution Design Approach

My first step was to use a convolution neural network model similar to the NVIDIA architecture.

In order to gauge how well the model was working, I split my image and steering angle data into a training and validation set. I found that my first model had a low mean squared error on the training set but a high mean squared error on the validation set. This implied that the model was overfitting.

To combat the overfitting, I modified the model so that it would have more convolutional and fully-connected layers.

The final step was to run the simulator to see how well the car was driving around track one. There were a few spots where the vehicle fell off the track to improve the driving behavior in these cases, I recorded more data where I was recovering the car from the edge.

At the end of the process, the vehicle is able to drive autonomously around the track without leaving the road.

2. Final Model Architecture

The final model architecture (model.py lines 63-92) consisted of a convolution neural network with the following layers and layer sizes:


Layer (type) Output Shape Param # Connected to

====================================================================================================

cropping2d_1 (Cropping2D) (None, 65, 320, 3) 0 cropping2d_input_1[0][0]


lambda_1 (Lambda) (None, 65, 320, 3) 0 cropping2d_1[0][0]


convolution2d_1 (Convolution2D) (None, 31, 158, 24) 1824 lambda_1[0][0]


convolution2d_2 (Convolution2D) (None, 14, 77, 36) 21636 convolution2d_1[0][0]


convolution2d_3 (Convolution2D) (None, 5, 37, 48) 43248 convolution2d_2[0][0]


convolution2d_4 (Convolution2D) (None, 3, 35, 64) 27712 convolution2d_3[0][0]


convolution2d_5 (Convolution2D) (None, 1, 33, 64) 36928 convolution2d_4[0][0]


dropout_1 (Dropout) (None, 1, 33, 64) 0 convolution2d_5[0][0]


flatten_1 (Flatten) (None, 2112) 0 dropout_1[0][0]


dense_1 (Dense) (None, 100) 211300 flatten_1[0][0]


dense_2 (Dense) (None, 40) 4040 dense_1[0][0]


dense_3 (Dense) (None, 16) 656 dense_2[0][0]


dropout_2 (Dropout) (None, 16) 0 dense_3[0][0]


dense_4 (Dense) (None, 10) 170 dropout_2[0][0]


dense_5 (Dense) (None, 1) 11 dense_4[0][0]

====================================================================================================

Total params: 347,525 Trainable params: 347,525 Non-trainable params: 0

3. Creation of the Training Set & Training Process

To capture good driving behavior, I first recorded two laps on track one using center lane driving.

I then recorded the vehicle recovering from the left side and right sides of the road back to center so that the vehicle would learn to come back to the center.

Then I repeated this process on track two in order to get more data points.

To augment the data sat, I also flipped images and angles thinking that this would give the model more data to learn how to handle the edges of the road and different curvatures of the road.

I used the center, right and left cameras all together. I also added correction amounts to left and right cameras. You can see the camera angles here:

| image1 | | image2 || image3 | |:--:| |:--:| |:--:| | Center || Left | | Right |

Before I used these images, I cropped them to focus on the road:

| image4 | | image5 || image6 | |:--:| |:--:| |:--:| | Center || Left | | Right |

After the collection process, I had about 80000 data points.

I finally randomly shuffled the data set and put 20% of the data into a validation set.

I used this training data for training the model. The validation set helped determine if the model was over or under fitting. The ideal number of epochs was 2 since it wasn't improving more after 2. I used an adam optimizer so that manually training the learning rate wasn't necessary.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages