# TSViT: A Time Series Vision Transformer for Fault Diagnosis of Rotating Machinery
## 4 Experimental Results and Evaluation
### Results  
Table 4 lists the utilized parameters for the TSViT model. The batch size was set to 32, 100, and 100, and the number of epochs was set 200, 200, and 50 during the training, based on the different sizes of the PBR, CWRU, and XJTU datasets, respectively. The optimizer was Adam. The learning rate was set to 0.0001. The trial was repeated 10 times under each condition to eliminate randomness. Figure 6 presents the training flow. Figure 5: Time domain waveforms of vibration signal samples in the XJTU dataset (**a**) Cage (**b**) Inner race (**c**) Outer race (**d**) Composite. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Types** & **Marks** & **Label** & **Training** & **Test** \\ \hline Cage & F0 & 0 & 6822 & 1706 \\ Inner race & F1 & 1 & 19,392 & 4848 \\ Outer race & F2 & 2 & 32,486 & 8122 \\ Composite & F3 & 3 & 31,948 & 7988 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: XJTU dataset. Figures 7-12 depict the downward trend of the loss function and the upward trend of recognition accuracy in the PBR, CWRU, and XJTU datasets, respectively. Figure 7a,b present the changes in losses during the first 35 epochs on the PBR training and test sets, respectively. The values of the loss function fluctuate due to random initialization, and the losses drop rapidly on both the training and test sets in the early stages of training. However, after 30 epochs, the boxes become flat, and the deviation range of the outliers gradually shrinks. This indicates that the losses tend to stabilize. Both losses are close to 0 after 30 epochs. Figure 7c presents the downward trends in the average loss throughout the 10 trials on both training and test sets. After the initial few epochs, the losses on both the training set and test set remain consistent. Both losses stabilize at 0 in the middle and late stages of training. \begin{table}
\begin{tabular}{c c c} \hline
**Name** & **Description** & **Value** \\ \hline \(L\) & the length of vibration signal & 2048 \\ \hline \multirow{3}{*}{\(L_{p}\)} & patch size & \\  & the width of the convolution kernel & 32 \\  & the stride of the convolution & \\ \hline \multirow{3}{*}{\(m\)} & the dimension of patch embedding & \\  & the number of output channels of the & \\  & convolution & \\ \hline \(h\) & the number of head in MSA & 8 \\ \hline \(d_{MLP}\) & the dimension of linear transformation in MLP & 768 \\ \hline \(B\) & the number of blocks in transformer encoder & 8 \\ \hline \multirow{3}{*}{\(d_{e}\)} & dropout probability in transformer encoder & \\  & (MSA, MLP) & 0.1 \\ \hline \(d_{p}\) & dropout probability after position embedding & 0.1 \\ \hline \end{tabular}
\end{table} 
Table 4: The parameters in TSViT. Figure 6: The training flow of the TSViT. Figure 7(a),b present the changes in the two accuracies in the initial 35 epochs. The accuracies fluctuate and rise rapidly on both the training and test sets in the early stages of training. However, after 30 epochs, the boxes become flat and the deviation range of the outliers gradually shrinks, indicating that both accuracies tend to stabilize. Both accuracies approach 100% after 30 epochs. Figure 7(c) presents the upward trends in the average accuracy throughout the 10 trials on both the training and test sets. After the initial few epochs, the two accuracies remain consistent. Both accuracies stabilize at 100% in the middle and late stages of training, indicating that the model performs well and fits perfectly. The maximum accuracy of the optimal model (MaxAcc), the accuracy of the minimum optimal model (MinAcc), and the average accuracy of the optimal model (AvgAcc) are all 100% in the 10 tests. The results on the CWRU dataset, as presented in Figures 9 and 10, are similar to the results on the PBR dataset. The two losses and accuracies gradually stabilize after only 10 epochs because the CWRU dataset is much larger than the PBR dataset. With 10 tests on the CWRU test set, the MaxAcc is 100%, the MinAcc is 99.96%, and the AvgAcc is 99.99%.