## 3 A Design of the Lightweight Autonomous Vehicle Self-Diagnosis (LAVS)
### A Design of an In-Vehicle Diagnosis Module (In-VDM)
#### 3.3.2 A Design of a Neural Network Vehicle-Diagnosis Sub-Module (NNVS)  
After the RPS diagnoses parts of a vehicle, the NNVS learns a neural network model using the result of the RPS and diagnoses the total condition of the vehicle by using the learned neural network model. Figure 12 shows an example of the input and output of the NNVS. The RPS result represents a probability value. However, it exists between \(-1\) and \(1\) because the probability value is multiplied by \(-1\) when the RPS determines that the part is abnormal. For example, in Table 3, the value of the engine condition for the RPS is \(0.251\), and because the engine has been diagnosed as faulty, \(-0.251\) is delivered to the NNVP. Table 3 is used as an input to the NNVP in Figure 12. Algorithm 2 represents the process by which the NNVS learns neural networks. \begin{table}
\begin{tabular}{c c c c c c c} \hline
**Parts** & **Engine** & **Light** & **Steering** & **Transmission** & \(\ldots\) & **Break** \\ \hline
**RPS result** & \(-0.251\) & \(0.992\) & \(0.687\) & \(-0.451\) & \(\ldots\) & \(0.876\) \\ \hline \end{tabular}
\end{table} 
Table 3: The results that the random-forest part-diagnosis sub-module (RPS) delivered to the neural network vehicle-diagnosis sub-module (NNVS). Figure 12: A process of the total diagnosis using the NNVS. ```
Input : Training data I, O I I = result of RPS n = the number of input nodes y = training data initialize: weight Z [3][][] : for(int i = 0; i<n; i++){ for(int j = 0; j<15; j++){  Z [0][i][j] = sqrt(random(0,3)/n+15); } } for(int i = 0; i<15; i++){ for(int j = 0; j<15; j++){  Z[1][i][j] = sqrt(random(0,3)/30); } } for(int i = 0; i<15; i++){  Z[2][i][j] = sqrt(random(0,3)/16); } } \(\text{Emax}=0.03\); E = 900; NET = 0; H[2][15] = 0; O = 0; while(E>Emax){ for(int i = 0; i<15; i++){ for(int j=0; j<n; j++){  NET = NET + I[j]*Z[0][j][i];  }  H[0][i] = tanh(NET);  NET = 0; } for(k = 1; k<3; k++){ for(int i = 0; i<15; i++){ for(int j = 0; j<15; j++){  NET = NET + H[k-1][j]*Z[k][j][i];  }  H[k][i] = tanh(NET);  NET = 0; } }  for(int i = 0; i<15; i++){  NET = NET + H[2][i] * Z[3][i][0];  }  O = tanh(NET); E = pow((o-y),2); Update_weights(Z, E); } end
```  
**Algorithm 2** The learning process of the NNVS
The NNVS uses the results of the RPS as an input, which indicates the condition of vehicle parts. That is, the number of the NNVS input nodes is equal to the number of the RPS outputs. The number of The NNVS output nodes is 1. Formula (12) represents the set of inputs in the NNVS, I.  
\[\text{I}=\{i_{1},\ i_{2},\ldots,\ i_{n}\}. \tag{12}\]  
Here, \(n\) is the number of parts diagnosed by the RPS. The NNVS generates a neural network model consisting of three hidden layers. Formula (13) represents the nodes of the hidden layers and Formula (14) represents a weight that connects the adjacent node. \[\text{H}=\big{\{}\text{h}_{1}^{1},\ \text{h}_{2}^{1},\text{h}_{3}^{1},\text{h}_{4 }^{1},\text{h}_{5}^{1},\ \ldots,\ \text{h}_{15}^{3}\big{\}}, \tag{13}\]  
\[\text{Z}=\ \big{\{}\text{z}_{1,\ 1}^{1},\ \text{z}_{1,\ 2}^{1},\text{z}_{1,\ 3}^{1}, \text{z}_{1,\ 4}^{1},\text{z}_{1,\ 5}^{1},\ \ldots,\ \text{z}_{15,\ 15}^{3}\big{\}}. \tag{14}\]  
The weights are initialized using the Xavier initialization [25]. Formula (15) represents the weights that are initialized using the Xavier initialization. \[\text{z}_{y,k}^{\text{x}}=\sqrt{\frac{random(0,3)}{p_{in}+p_{out}}}, \tag{15}\]  
Here, \(p_{in}\) represents the number of nodes in the input layer connected to \(Z\) and \(p_{out}\) the number of nodes in the output layer connected to \(Z\). The NNVS uses tanh as an activation function for accurate and quick computation, and the mean squared error as a loss function. Formula (16) represents tanh and (17) mean squared error. \[tanh(x)=\frac{e^{2x}-1}{e^{2x}+1}, \tag{16}\]  
\[E(y,\ d)=(\text{y}-\text{d})^{2}. \tag{17}\]  
In Formula (17), d means the training data, and y means the result of a neural network model. The NNVS is learned based on back-propagation and uses gradient descent to change the weight.