# Road Segmentation and Environment Labeling for Autonomous Vehicles
## 3 System Design
### Clustering--Block B  
The K-means is one of the unsupervised learning algorithms used to classify a given data set through a certain number of clusters, when \(k=\{k_{1},k_{2},k_{3},........,\ k_{c}\}\) with \(c\) cluster centers. The distance between the cluster center and the data points is calculated as follows:  
\[D_{i}^{(j)}=\|z_{i}^{(j)}-c_{j}\|^{2} \tag{4}\]  
By updating the centroid for each set of \(j\), \(l\) is the length of the data in the cluster. \[c_{j}=\frac{\sum_{p=0}^{l-1}z_{j}^{p}}{l} \tag{5}\]  
The objective function of the clustering algorithm is given below. \[z_{j}=min\sum_{j=1}^{k}\sum_{i=1}^{n}\|z_{i}^{(j)}-c_{j}\|^{2} \tag{6}\]  
The latent-vector \(z_{i}\) is clustered to \(z_{k}\) with \(C_{j}\) as the cluster center using a K-means algorithm, where \(k\) represents the number of clusters. The pseudo labeling of clusters is explained in Algorithm 1. ```
\(k\)\(\leftarrow\) Number of Clusters  Initialize cluster centroids \(\ C_{j}=\{C_{1},C_{2},C_{3},......,C_{k}\}\)  Initialize label \(L_{j}=\{L_{1},L_{2},L_{3},....,L_{k}\}\)  inputData \(\leftarrow\)\([z_{0}\,z_{1}z_{2}]\)\(\
eq\)\(z\) vector reduced to 3 dimension  clustered latent vector \(z_{k}=\{[L_{j}\,z_{j}]\}\)  repeat  CreateClusters (\(C_{j}\), inputData) \(z_{j}\)\(\leftarrow\)\([]\) for i in range(0, inputDataLength) do \(L_{j}^{i}\)\(\leftarrow\)\(\text{FindCentroid}(inputData_{i},\ C_{j})\) \(z_{j}^{i}\)\(\leftarrow\)\(inputData_{i}\) \(z_{k}\).append(\(z_{j}\,l_{j}^{i}\)) Return \(z_{k}\)  FindCentroid(\(inputData_{i},\ C_{j}\)) \(L\)\(\leftarrow\)\(\emptyset\)\(C^{t}\)\(\leftarrow\)\([]\) for j in range(1, \(k\)) do \(C^{t}\).append(\(\|inputData_{i}^{(j)}-C_{j}\|^{2}\)) \(\
eq\)Equation (4) \(L\)\(\leftarrow\)\(\text{Indexof}(\min(C^{t}))\) Return \(L\)  UpdateClusterCentroid(\(C_{j},z_{j}\))  for j in range(1, \(k\)) do \(1\) = Length(\(z_{j}\)) \(\
eq\) Length of Cluster data \(C[j]=\frac{\sum_{p=0}^{l-1}z_{j}^{p}}{l}\)\(\
eq\) Equation (5) \(C_{j}\).append(\(C[j]\)) until the stopping criteria Result: clustered latent vector \(z_{k}\)
```  
**Algorithm 1**K-Means Clustering Algorithm  
``` \(k\)\(\leftarrow\) Number of Clusters  Initialize cluster centroids \(\ C_{j}=\{C_{1},C_{2},C_{3},....,C_{k}\}\)  Initialize label \(L_{j}=\{L_{1},L_{2},L_{3},....,L_{k}\}\)  inputData \(\leftarrow\)\([z_{0}\,z_{1}z_{2}]\)\(\
eq\)\(z\) vector reduced to 3 dimension  clustered latent vector \(z_{k}=\{[L_{j}\,z_{j}]\}\)  repeat  CreateClusters (\(C_{



### Decoded Output--Block C

The decoder learns to recreate the data points from the latent space. From the clustered latent-vector \(z_{k}\), the decoder \(f\) parameterized with \(\varnothing\) learned to reconstruct the point cloud input \(x^{\prime}\) that is similar to vector \(x\). \[x^{\prime}=f_{\varnothing}(g_{\varnothing}(x)) \tag{7}\]

The decoding network is similar to the encoder but with different weight, bias, and activation functions as follows:

\[x^{\prime}=\sigma^{\prime}\big{(}W^{\prime}z_{k}+b^{\prime}\big{)} \tag{8}\]

where \(x^{\prime}\) is the reconstructed vector, \(z_{k}\) is the clustered latent vector as shown in Equation (5), \(W^{\prime}\) is the weight matrix of size \(m\times n\), \(b^{\prime}\) is the bias of size \(m\), and \(\sigma^{\prime}\) is the ReLU activation function. The loss function used to train the AE network through the standard BPN procedure can then be written in terms of these network functions, as given below. \[Loss(\varnothing,\theta)=\frac{1}{n}\sum_{i=1}^{n}\big{(}x_{i}\ -f_{ \varnothing}(g_{\varnothing}(x_{i}))\big{)}^{2} \tag{9}\]

The decoder is similar to the encoder structure, where the input layer is taken over by the latent attributes, as shown in Figure 3. The model is fitted using the efficient Adam version of the stochastic gradient descent [48] to minimize the mean squared error, given that reconstruction is a classification problem. ### Automated Labeling--Block D

The clustered dataset \(z_{k}\) in the latent space is mapped back to the input dataset \(x_{k}\).