# Weigh-in-Motion Method Based on Modular Sensor System and Axle Recognition with Neural Networks
## 2 Materials and Methods  
### The Method of Transformer-GRU Model  
Axle recognition is an important part of the WIM system, which is used to obtain the number of axles and the time points of entering and exiting platforms for each axle to obtain the gross vehicle weight. At present, most whole-vehicle-load WIM systems need to add axle recognition devices in the traveling direction, which increases the cost. Furthermore, the traditional peak detection algorithm [14, 15] is easily influenced by interference signals, and the filtering and denoising processing [16, 17] can affect the phase of the signal, leading to inadequate accuracy in detecting the start and end weighing time points. At present, deep neural networks have been successfully applied in Electrocardiography signal peak seeking and power quality disturbance signal recognition. Therefore, this study uses a deep neural network to accomplish the task of axle recognition. In this paper, an axle recognition algorithm based on Transformer-GRU is proposed to identify the axle directly by reasoning the weighing signal from the WIM sensors, which does not require axle recognition devices, reduces the cost, and enhances the system's reliability. The architecture of the Transformer includes encoders and decoders, and realizes efficient information processing through a self-attention mechanism and fully connected layer. The self-attention mechanism enables the model to flexibly capture long-term dependencies in the input sequence, while multi-head self-attention allows the model to focus on information in parallel across different subspaces, thus efficiently processing long sequence data. Furthermore, the residual connection and layer normalization techniques in the model enhance stability and can better analyze the key information of the weighing signal. However, they may not fully capture the sequential local information in the sequence [18]. To overcome this limitation, a GRU decoder was used to reconstruct the original sequence order. By introducing reset gates and update gates [19], the GRU provides the network with more flexibility to selectively forget or retain previous information. The reset gate determines which history information can be discarded, while the update gate regulates how the hidden state is updated using the candidate hidden state, which incorporates both historical information and the current time step data. GRU solves the problem of gradient disappearance in traditional recurrent neural networks (RNNs) by gating mechanism. Compared with Long Short Term Memory (LSTM), the GRU has a simpler structure and easier convergence. In this paper, we propose a sequence-to-sequence model-based Transformer-GRU to generate 0-1 sequences for axle recognition and time positioning. Figure 1 shows the overall architecture of the proposed sequence-to-sequence model, which consists of an input layer, a Transformer encoder, a GRU decoder, and an output layer. The input layer is mainly responsible for preprocessing the original data, including the vehicle entering and exiting platforms weighing signals collected by the WIM sensors. After standardization and labeling, we can obtain the input sequence \([x_{1},x_{2},\ldots,x_{n}]\) and label sequence for the model. The input sequence is fed into the Transformer encoder layer, which first embeds the input sequence and adds it with the positional encoding. Then, it is fed into the encoder, which is usually stacked with multiple independent coding layers. In this paper, we use a straightforward one-layer structure. The encoder layer consists of a multi-head self-attention mechanism and a fully connected feedforward network. A residual connection is adopted around the two sub-layers, and the activation value of each layer is normalized. Finally, a feature sequence with the same dimension as the input signal is obtained through the fully connected layer. The feature sequence is sent to the hidden layer in the GRU decoder.