# Lane following Learning Based on Semantic Segmentation with Chroma Key and Image Superposition
## 3 Materials and Methods
### Experimental Setup
#### 3.2.3 Learning to Drive  
For the task of learning steering control, a densely connected network (MLP) is used to process the features extracted by the Autoencoder rather than using an image as the input. The dataset for this task is collected while driving with the circuit placed in the target scenario.  
To build this driving model, only the encoder part of the Autoencoder is used, which extracts the characteristics and generates the latent vector from the captured image. This feature vector is used as the input of the MLP, which acts as a decision network. The target is the steering angle, which is represented as a linear value in the interval (\(-1\), +1). During training, the modification of the weights of the Encoder is disabled. The structure of the complete network is shown in Figure 7.  
The first set of data is obtained by following the route of the circuit in both directions. A total of 23,122 driving frames were captured as the result of driving about 6 min in each direction. This set (dataset DR1) is divided into two parts for training and for testing purposes. The images are later resized to either 320 \(\times\) 240 or 160 \(\times\) 120, depending on the needs of the used Autoencoder. More details of the distribution of the dataset are shown in Table 2.  
In the initial experiments, some problems were detected that could be attributed to the driving style. Therefore, a second dataset (DR2) is generated using a similar setup and distribution. In this case, a more precise driving style is used, keeping the model car close  
\begin{table}
\begin{tabular}{c c c c c c c c} \hline \hline
**Data Set** & **Size** & **Train Left** & **Train Right** & **Test Left** & **Test Right** & **Train Total** & **Test Total** \\ \hline DR1 & 640 \(\times\) 480 & 9.345 & 9.287 & 1.925 & 2.565 & 18.632 & 4.490 \\ DR2 & 640 \(\times\) 480 & 9.804 & 9.738 & 1.456 & 1.530 & 19.542 & 2.986 \\ DR3 & 640 \(\times\) 480 & - & - & 1.024 & 1.024 & - & 2.048 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Distribution of the frames in the datasets for the driving task. The images are later downsized to 320 \(\times\) 240 or 160 \(\times\) 120.  
Figure 7: Graphical representation of the complete driving network.  
to the outside line and trying to take turns smoothly. This allows it to more consistently keep both lines in the camera frame.  
To carry out a more precise final evaluation, a third dataset (DR3) is generated using a different circuit layout. A total of 1024 frames taken while driving in each direction are selected to obtain a balanced set.  
The characteristics and parameters of the used MLP are the following:  
* A set of five densely connected layers, each one with 512, 256, 128, 64, and 1 nodes.
* Each dense hidden layer is followed by a dropout layer with a parameter value of 0.2.
* A ReLU is the activation function for all the layers except for the output, which has a linear activation function.
* The output codifies the expected steering angle, which is represented as a continuous value in the interval (-1, 1).
* Training is performed with the Stochastic Gradient Descent with batch size of 32 and the Loss Function Mean Squared Error, which lasts for 100 epochs.  
Once the network has been trained, the model is transferred to the vehicle to test the operation. A constant minimum speed is set, and the driving model is started.