## 4 DNN Optimal Predictor
### Design and Training of the DNN  
The DNN structure used in this section is shown in Figure 11.  
Figure 10: Statistics of the optimal terminal time of sample trajectories.  
Figure 9: Distribution of the sample trajectories.  
The input layer of the DNN contains 7 neuron units, which represent the current position components, velocity components, and mass of the vehicle, respectively. The output layer contains 1 unit representing the estimation of \(t_{\text{opt}}\). Each unit in the network structure is essentially a nonlinear function that describes the mapping relationship between input and output. The number of hidden layers, the number of units in each layer, and the activation function are all hyperparameters of the DNN, which need to be determined by optimizing the network structure. Define a loss function in the form of mean squared error (MSE) as follows:  
\[\sigma_{\text{MSE}}=\frac{\sum\limits_{i=1}^{n}\left(t_{i,\text{opt}}-\hat{t}_ {i,\text{opt}}\right)^{2}}{n} \tag{19}\]  
where \(n\) is the number of samples input for each training, \(t_{i,\text{opt}}\) and \(\hat{t}_{i,\text{opt}}\) are the true values and estimated values of the optimal terminal time, respectively. Similarly, in order to measure the error of the network, an error function in the form of mean absolute error (MAE) is defined:  
\[\sigma_{\text{MAE}}=\frac{\sum\limits_{i=1}^{n}\left|t_{i,\text{opt}}-\hat{t}_ {i,\text{opt}}\right|}{n} \tag{20}\]  
The Bayesian regularized backpropagation algorithm is selected to train the DNN, and the method updates the weights and biases according to the Levenberg-Marquardt optimization algorithm. Bayesian regularization minimizes the linear combination of squared errors and weights and modifies the linear combination to give a network that generalizes well after training. The neural network hyperparameters are shown in Table 3:  
The variation of the training set and the test set's MSE with the training epochs is shown in Figure 12:  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Parameter** & **Amount** & **Parameter** & **Amount** \\ \hline Number of hidden layers & 2 & Training ratio & 85\% \\ Number of hidden layer units & 30 & Test ratio & 15\% \\ Activation function & Sigmoid & Maximum epochs & 1000 \\ \hline \hline \end{tabular}
\end{table}
Table 3: Setting of the DNN’s hyperparameters.  
Figure 11: Structure of the DNN.  
It can be found that the MSE decreases monotonically with the epoch. When the epoch reaches 1000, the MSE of the training set reaches the minimum, and \(\sigma_{\text{MSE}}=4.8\times 10^{-4}\) s\({}^{2}\). The MSE of the training set and the test set are highly coincident, indicating that the generalization ability of the net is good, and there is no overfitting in the training results.  
After training, the distribution of the network error is plotted, as shown in Figure 13.  
It can be found that the DNN constructed in this paper can accurately predict the optimal terminal time according to the current state. The MAE is 11.6 ms, and the prediction errors of most samples (99.11%) do not exceed 0.1 s. The specific results are shown in Table 4.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Parameter** & **Amount** & **Parameter** & **Amount** \\ \hline Mean square error (MSE) & \(4.8074\times 10^{-4}\) s\({}^{2}\) & Mean absolute error (MAE) & 11.6 ms \\ MSE of the training set & \(4.8001\times 10^{-4}\) s\({}^{2}\) & Maximum error & 0.3921 s \\ MSE of the test set & \(4.8488\times 10^{-4}\) s\({}^{2}\) & Minimum error & \(-0.4530\) s \\ \hline \hline \end{tabular}
\end{table}
Table 4: Statistics of training results.  
Figure 12: Visualization of the training process.  
Figure 13: Statistics of the DNN errors.