# Weigh-in-Motion Method Based on Modular Sensor System and Axle Recognition with Neural Networks
## 3 Results and Discussion in Axle Recognition
### Test Set Results  
Experimental analysis shows that a single Transformer encoder can extract the key information of the weighing signal, but the output signal cannot be calculated for the number of axles, the axle loads, and gross vehicle weight. Therefore, the GRU is necessary to decode the local information and obtain an ideal output. In addition, RNN and LSTM models were considered and compared when selecting GRU models. To verify the accuracy of the axle recognition model based on Transformer-GRU, we used the test set for evaluation on a GTX 1080 Ti GPU. The input was the weighing signal, the output was the time series of the same length as the input, and the output was binarized to obtain the 0-1 sequence. By post-processing the 0-1 sequence, we can calculate the number of segments of consecutive class 1 to obtain the number of axles. All the evaluation index metrics were calculated based on the number of axles. A total of 1853 vehicles were included in the test set. The confusion matrices of the Transformer-GRU model are listed in Table 1. The distribution of vehicle types and the corresponding recognition performance under the Transformer-GRU model are listed in Table 2.  
Figure 5: Training and validation loss trends. The test set data simulated the number and proportion of vehicle types traveling through the highway toll station in a day, and appropriately increased the number of rare vehicles. Among them, the accuracy of all the vehicles reached 0.9951, the number of two-axle vehicles and six-axle vehicles was the largest, and the precision, recall, and F1-score all exceeded 0.99. In addition, vehicles with more than 6 axles were more susceptible to the influence of other vehicle types because of their lower number, with three false positives and two false negatives, but the precision, recall, and F1-score all exceeded 0.9. According to the confusion matrix, the false positives and false negatives were mainly caused by having one axle less or one axle more due to the recognition probability of a real axle being too low and the recognition probability of interference being too high, respectively. Models based on Transformer-RNN, Transformer-LSTM, and Transformer-GRU were executed on a PC for comparative testing. The comparison of accuracy, training time with 200 epochs on a small dataset that contains 1134 vehicles, and average inference time for a vehicle among the three models are presented in Table 3.  
As shown in Table 3, the sequence-to-sequence model based on Transformer-GRU exhibited the best performance on the test set with an accuracy of 99.51%. The Transformer-RNN model exhibited the worst performance with an accuracy of 75.07%. Compared with the Transformer-RNN model, the accuracy of the Transformer-LSTM model was improved by 19.84%. Furthermore, the RNN model had limited ability to process long sequences, which led to the loss of axle information and unsatisfactory recognition results. The introduction of the gating mechanism in the LSTM and GRU models can effectively solve \begin{table}
\begin{tabular}{c c c c c c} \hline \hline \multirow{2}{*}{**Predicted Class**} & \multicolumn{5}{c}{**Actual Class**} \\ \cline{2-6}  & **2-Axle** & **3-Axle** & **4-Axle** & **5-Axle** & **6-Axle** \\ \hline
2-axle & 999 & 0 & 0 & 0 & 0 \\
3-axle & 1 & 109 & 0 & 0 & 0 \\
4-axle & 0 & 1 & 155 & 1 & 1 & 1 \\
5-axle & 0 & 0 & 0 & 53 & 0 & 0 \\
6-axle & 0 & 0 & 0 & 0 & 500 & 1 \\ More than 6-axle & 0 & 0 & 0 & 0 & 3 & 28 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: The confusion matrices of the Transformer-GRU model. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Vehicle Type** & **Number** & **Precision** & **Recall** & **F1-Score** & **Accuracy** \\ \hline
2-axle & 1000 & 1.0000 & 0.9990 & 0.9995 & \\
3-axle & 110 & 0.9909 & 0.9909 & 0.9909 & \\
4-axle & 155 & 0.9748 & 1.0000 & 0.9872 & \\
5-axle & 54 & 1.0000 & 0.9815 & 0.9907 & \\
6-axle & 504 & 0.9980 & 0.9921 & 0.9950 & \\ More than 6-axle & 30 & 0.9032 & 0.9333 & 0.9180 & \\ \hline \hline \end{tabular}
\end{table}