## 4 Intelligent Algorithm Model for Determination of the Axle Temperature Alarm Level
### Optimization of the Axle Temperature Alarm-Level AdamW-Based Discriminator Model  
In the former process of determination of the axle temperature alarm level, only the prediction and evaluation of axle temperature alarm levels are conducted. At this stage, the model acquires the probability values associated with various levels of alarm grades through three main steps. Firstly, useful information is extracted through the transformer model, and after passing through a fully connected layer, the output 0 is obtained. The shape of 0 is (Batch, 3, 4). After that, the maximum sequence corresponding to the predictions from the second dimension 0 is extracted (from right to left, where the rightmost is the first dimension), resulting in the prediction results in Pr with a shape of (Batch, 4). Finally, Pr is normalized along the first dimension to obtain the probability values of the model's judgments at various alarm levels of the input data. In this step, the indicators used for model parameter iteration include the model-predicted probabilities of axle temperature alarm levels and the corresponding cross-entropy loss function values for the real alarm levels. To optimize the existing loss function, the value of the cross-entropy loss function is therefore included between the predicted probability of axle temperature states based on the detection station judgment and the true axle temperature state labels. Consequently, for the output of the transformer module in the model, two distinct fully connected layers are required to extract the probabilities of each axle temperature alarm level and the probabilities of the axle temperature states for the three detection stations, as shown in Figure 8.  
Due to the sequential nature of detection at detection stations, the input feature vector of the current detection station to the model should only interact with the features obtained from previous detection stations through the attention mechanism (i.e., interaction with the features obtained from subsequent detection stations should not occur). It is hence crucial to optimize the multi-head attention mechanism in the alarm-level discrimination  
Figure 8: Input to the new prediction stage model. Figure 7: Input to the prediction stage model. by incorporating the masked multi-head attention mechanism. The loss function at this point can be calculated through the following formula:  
\[L=\sum_{n=1}^{N}-\log(y_{i}^{(n)})+\omega\sum_{n=1}^{N}-\lambda_{1}\log(p_{1}^{(n )})-\lambda_{2}\log(p_{2}^{(n)})-\lambda_{3}\log(p_{3}^{(n)}) \tag{16}\]  
In Equation (6), the first term on the right-hand side signifies the loss caused by the prediction of axle temperature alarm levels for the current batch of feature data, whereas the remaining terms denote the loss caused by the axle temperature states of the three detection stations. In addition, \(\omega\) represents the proportion of the axle temperature state prediction to the total loss. The factors \(\lambda_{1}\), \(\lambda_{2}\), and \(\lambda_{3}\) denote the weights of the entire axle temperature state loss pertinent to the first, second, and third detection stations, respectively, while \(p_{1}^{(n)}\), \(p_{2}^{(n)}\), and \(p_{3}^{(n)}\) represent the model output probabilities associated with the correct axle temperature states for the first, second, and third detections. It should be herein emphasized that, in the case of a train just starting up or restarting (when the sequence length is less than 3 and the missing parts are replaced with vectors all set to \(-2\)), the corresponding loss should be removed. The iteration curves for the training and validation sets at \(\lambda_{1}\), \(\lambda_{2}\), and \(\lambda_{3}\) (corresponding to 1, 3, and 9) are presented in Figure 9.  
The plotted results in Figure 9 reveal that, when the number of iterations reaches 4000, the validation loss and training loss become almost stabilized. At this stage, the accuracy of the training set reaches 87.8% and the accuracy of the validation set touches 90.9%.