Multi-fault diagnosis method based on fusion wavelet convolution and window attention mechanism
By integrating wavelet convolution and window attention mechanism, the feature extraction and training convergence speed of bearing fault diagnosis model is improved, solving the shortcomings of traditional models in diagnostic accuracy and training time, and achieving more efficient fault diagnosis.
Patent Information
- Application Number
- CN202510286281.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-12
- Publication Date
- 2025-06-17
AI Technical Summary
Traditional deep learning models have problems such as long training time and low fault diagnosis accuracy in bearing fault diagnosis, which cannot meet the needs of industrial applications.
Using a multi-fault diagnosis method based on fusion wavelet convolution and window attention mechanism, the feature extraction capability and model training convergence speed are enhanced through improved wavelet transform convolution layer and Swin Transformer network architecture.
It has achieved improved the accuracy of fault diagnosis and shortened the convergence time of model training, and can effectively diagnose various single and composite faults, meeting the requirements of industrial applications.
Smart Images

Figure CN120162576A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of bearing fault diagnosis, and particularly to a multi-fault diagnosis method based on the fusion of wavelet convolution and window attention mechanism. Background Art
[0002] Bearings are important components of mechanical equipment. During long-term operation, faults such as fatigue damage, cracks, and erosion may occur. These faults are very likely to cause instability of the entire mechanical equipment, and further result in serious production accidents. Therefore, it is crucial to adopt effective fault diagnosis techniques to eliminate risks to ensure the safe and stable operation of mechanical equipment.
[0003] Traditional deep learning models face the following challenges when performing bearing fault diagnosis. On the one hand, due to the large amount of diagnostic data, the model training process takes a long time, and it is impossible to judge the fault category in time, which may lead to subsequent adverse effects. On the other hand, although relevant researchers have adopted relevant deep learning models for fault diagnosis, due to the simple model structure and weak feature extraction ability, the fault diagnosis accuracy is low and cannot meet the requirements of industrial applications. Therefore, it is urgent to solve. Summary of the Invention
[0004] To solve the problems of the existing technology, the present invention provides a multi-fault diagnosis method based on the fusion of wavelet convolution and window attention mechanism. The present invention effectively shortens the convergence time of the model training process on the premise of improving the fault diagnosis accuracy, and can effectively diagnose various single faults and compound faults to meet the requirements of industrial applications.
[0005] To achieve the above object, the present invention provides the following technical solutions: A multi-fault diagnosis method based on the fusion of wavelet convolution and window attention mechanism, comprising the following steps:
[0006] Data selection and preprocessing: Collect vibration data from a bearing data acquisition device, and perform one-dimensional data time-frequency domain processing to obtain a two-dimensional fault image. Optional methods include but are not limited to short-time Fourier transform, Fourier transform, wavelet transform, etc.;
[0007] Converting one-dimensional vibration data into a two-dimensional spectrogram can not only provide more comprehensive "time-frequency" information, but also make full use of the powerful feature extraction ability of deep learning models, thereby significantly improving the performance and robustness of fault diagnosis. This conversion has become one of the important technical means in the field of modern mechanical fault diagnosis. In the embodiment of the present invention, the Seoul National University deep groove ball bearing fault dataset used performs the operation of converting one-dimensional vibration data into a two-dimensional fault image by short-time Fourier transform (STFT).
[0008] Process of constructing the model: In each BasicLayer of the original Swin-T model, the original SwinTransformerBlock is connected in parallel with the improved WTConv Block, and both are used as the feature extraction part to further enhance the feature representation, making the model more effective in processing complex images;
[0009] Process of training the model: Divide the existing data, use the training set and validation set to train and validate the model, and optimize the model parameters using the gradient descent method until the cross-entropy loss in the validation process converges; The gradient descent method is implemented through the Adam optimizer in PyTorch to iteratively update the parameters in the Swin-T-WTCBN model;
[0010] Fault diagnosis process: Use the trained Swin-T-WTCBN model to classify the faults of the existing bearing fault data, evaluate the model performance through the accuracy rate and cross-entropy loss indicators, and determine the final fault category according to the output labels of the classified samples to achieve fault diagnosis.
[0011] According to the method described in any one of claims 1-6, the method is particularly applicable to the fault diagnosis of the bearing components of mechanical equipment, and can effectively diagnose the faults of the bearing components of mechanical equipment and eliminate risks in a timely manner, ensuring the safe and stable operation of mechanical equipment.
[0012] Beneficial effects: 1. The present invention integrates wavelet convolution and window attention mechanism, combines the improved wavelet transform convolutional layer and the Swin Transformer network architecture, can extract features more efficiently from the original fault image data, and improve the model training convergence speed and diagnosis accuracy rate.
[0013] 2. By setting the improved wavelet convolutional layer, the model training convergence speed is increased, thereby achieving the purpose of saving time costs and meeting the time requirements of industrial fault diagnosis.
[0014] 3. The parallel design of the WTConv Block and the Swin Transformer Block is proposed, which can further enhance the feature representation, making the model more effective in processing complex images and improving the bearing fault diagnosis accuracy rate. Description of the drawings
[0015] Figure 1 It is the structure diagram of the Swin-T-WTCBN model of the present invention;
[0016] Figure 2 It is the comparison diagram of the WTConv Block before and after improvement used in the present invention;
[0017] Figure 3Convergence graph of the loss function in the embodiment of the present invention;
[0018] Figure 4 Iteration graph of the diagnosis accuracy rate in the embodiment of the present invention;
[0019] Figure 5 Confusion matrix graph of the fault diagnosis results of the Swin-T-WTCBN model;
[0020] Figure 6 Case graph of converting one-dimensional vibration data into two-dimensional fault images in the embodiment of the present invention;
[0021] Figure 7 Flowchart of the method in the embodiment of the present invention. Specific implementation mode
[0022] The preferred embodiments of the present invention are introduced below with reference to the accompanying drawings of the specification to make its technical content clearer and easier to understand. The present invention can be embodied in many different forms of embodiments, and the protection scope of the present invention is not limited to the embodiments mentioned in the text.
[0023] Embodiment 1
[0024] Data selection and preprocessing process
[0025] The Seoul National University deep groove ball bearing fault dataset is selected for the research. After selecting the dataset, the two-dimensional array data is selected and the operation of converting the two-dimensional array into a two-dimensional image is performed.
[0026] Since the dataset itself already contains the pixel data of the two-dimensional image obtained by the short-time Fourier transform of the one-dimensional vibration data, this step only needs to map the two-dimensional pixel data array into a jpg image. When using other datasets, the following steps should be used for data preprocessing (taking the short-time Fourier transform as an example):
[0027] For a continuous-time signal x(t), its STFT is defined as:
[0028]
[0029] Where X(τ,f) is the STFT result at time point τ and frequency f, w(t) is the window function (usually the Kaiser window function), which is used to localize the time period of the signal, and j is the imaginary unit.
[0030] The mathematical expression of the Kaiser window function is as follows:
[0031]
[0032] Where I0 is the zero-order modified Bessel function, β is the shape parameter, which controls the main lobe width and side lobe attenuation of the window, and α=(N - 1) / 2, where N is the window length.
[0033] In practical applications, signals are usually discrete, so the discrete form of STFT is used
[0034]
[0035] where n and m are time indices, k is the frequency index, and N is the size of the FFT
[0036] Given a segment of original vibration data x[n], its STFT can be expressed as
[0037]
[0038] where k is the frequency index, l is the time frame index, and hop_size is the jump step between adjacent time frames, which is equal to the window size minus the overlap size
[0039] The finally generated spectrogram is a three-dimensional array with dimensions N spectrogram ×N freq ×N time , where N spectrogram represents the number of spectrograms, and N freq and N time are the dimensions of the frequency axis and the time axis respectively. After slicing and separating, N spectrogram two-dimensional arrays are finally obtained
[0040] The main reason for converting one-dimensional vibration data into two-dimensional spectrograms is that two-dimensional representations can better capture the "time-frequency" characteristics of signals and are more suitable for input into modern deep learning models such as CNN models, VIT models, and Swin Transformer models. In addition, in two-dimensional spectrograms, fault features often appear as specific textures or patterns, and deep learning models can learn richer features from these textures, thereby improving the accuracy of fault diagnosis. In contrast, the features of one-dimensional data may not be intuitive enough to be effectively captured by the model; two-dimensional spectrograms can naturally reflect the frequency changes at different time scales. In the case of compound fault scenarios, multiple faults may simultaneously affect different frequency ranges, and the spectrogram can clearly show the mutual relationship between these frequency components, but one-dimensional vibration data cannot achieve this result
[0041] Description of the dataset used: The original dataset contains a total of 32 fault categories, of which 11 are single fault categories and 21 are compound fault categories. Each category has 78 samples. The original data with a sampling rate of 8 kHz and a rotational speed of 600 is selected, with a total of 2496 sample pictures; the ratio of the number of training set samples: the number of validation set samples: the number of test set samples = 28:7:4
[0042] Model structure design
[0043] Based on the original SwinTransformer (Tiny) model, this invention connects the improved wavelet transform convolutional layer WTConvBlock and SwinTransformerBlock in parallel in the BasicLayer, and extracts image features by fusing wavelet convolution and window attention mechanism.
[0044] The original wavelet transform convolutional layer includes a basic convolutional layer, a wavelet transform layer, and an inverse wavelet transform layer; the improvement of this invention to the wavelet transform convolutional layer is adding a batch normalization layer after both the basic convolutional layer and the wavelet transform convolutional layer. Through the added batch normalization layer above, the wavelet transform convolutional layer can better process the input features, improve the performance of the model, and the convergence speed of the training process.
[0045] Among them, the basic convolution branch process is basic convolution, batch normalization, and scaling:
[0046] Step 1: Basic convolution
[0047] C base = Conv2D(x)
[0048] The output shape is C base ∈R B×C×H×W
[0049] Step 2:: Batch normalization and scaling
[0050] For each channel C ∈ {1, 2, …, C}, calculate:
[0051]
[0052] Normalize and apply learnable parameters:
[0053]
[0054] Among them, γ base,c , β base,c are the learnable parameters of the BN layer.
[0055] S base = s base,c ·BN base,c
[0056] Among them, s base,c is a learnable parameter.
[0057] Among them, the wavelet branch process is wavelet transform, wavelet convolution, batch normalization and scaling, and inverse wavelet transform:
[0058] Step 1: Wavelet transform
[0059] Let the input tensor be x ∈ RB×C×H×W , where B is the batch size, C is the number of channels, H×W is the spatial dimension, and the Haar wavelet is selected; apply the two-dimensional wavelet transform independently to each channel, and decompose it into 4 sub-bands:
[0060]
[0061] After rearrangement, the shape is (B, C×4, H / 2, W / 2).
[0062] Step 2: Wavelet convolution
[0063] C wavelet,i = Conv2D i (x wavelet,i )
[0064] The output shape is C wavelet,i ∈R B×4C×H′×W′ (In the present invention, i takes 1, but it is allowed to take values other than 1 for further improvement during use, so H′×W′ is used for subsequent representation).
[0065] Step 3: Batch normalization and scaling
[0066] For each channel d ∈ {1, 2, …, 4C}, calculate:
[0067]
[0068] Normalize and apply learnable parameters:
[0069]
[0070] where γ wavelet,i,d , β wavelet,i,d are the learnable parameters of the BN layer.
[0071] S wavelet,i = s wavelet,i,d ·BN wavelet,i,d
[0072] where S wavelet,i is a learnable parameter.
[0073] Step 4: Inverse wavelet transform
[0074] Recombine the 4 sub-bands into the original resolution
[0075]
[0076] where the residual connection formula
[0077] Let the output of the basic convolution be F base (x), and the output of the wavelet path be F wavelet (x), then the final output is
[0078] Output = F base (x) + F wavelet (x)
[0079] Among them, the cascading operation of the wavelet path:
[0080] The i-th level forward transform
[0081]
[0082] Among them For the next-level transform, It is saved after convolution, BN, and scaling.
[0083] The i-th level reverse recombination
[0084]
[0085] In the present invention, i takes 1, but it is allowed to take values other than 1 for further improvement during use.
[0086] Through step-by-step reverse recombination, multi-scale feature fusion is achieved, and finally the output of the improved wavelet transform convolutional layer is x output = x ∈ R B×(C×H×W) .
[0087] The improved wavelet transform convolutional layer WTConv Block and the Swin Transormer Block are in parallel at each BasicLayer. The shape of the feature map input to the wavelet transform convolutional layer is first converted from [B, H*W, C] to [B, C, H, W], and then converted from [B, C, H, W] to [B, H*W, C] after feature extraction by the wavelet transform convolutional layer, so as to match the output shape of the Swin Transformer Block and achieve residual connection. The specific model structure implementation is as Figure 1 And Figure 2 shown.
[0088] After processing the features in all layers, the global normalization layer is used to normalize the features. This layer processes the features at all positions, and the normalized features will be passed to the global average pooling layer. This layer will perform average pooling on each channel of the feature map, compressing the feature map from the shape of [B, H*W, C] to [B, C, 1]. Finally, a fully connected layer is used to map the output of the global average pooling layer to the number of classes. Thus, the model construction for the fault picture sample classification task is achieved.
[0089] Training stage
[0090] In the present invention, the gradient descent method in parameter update is implemented through the optimizer in PyTorch. Here, the Adam optimizer is used to complete this work. The Adam optimizer is a gradient-based optimization algorithm and is widely used in some deep learning algorithms. By iteratively looping through the model, the parameters in the model are updated through backpropagation until convergence. In this neural network, as the number of iterations increases, the loss function eventually tends to converge.
[0091] Acc and Loss are two common types of metric data in the training and validation phases. The accuracy Acc represents the proportion of the number of samples correctly predicted by the model to the total number of samples, and it is the most intuitive metric for evaluating the performance of a classification model; the cross-entropy loss Loss reflects the gap between the current prediction result of the model and the true label. During the training process, the model continuously adjusts the parameters by minimizing Loss; secondly, the change trend of Loss can reveal whether the model is effectively learning or whether there are overfitting / underfitting problems. When used in combination, they can comprehensively understand the performance of the model. The neural network method that combines wavelet convolution and window attention mechanism uses these two types of metric data to monitor the model training process and the quality change of the output results.
[0092] The accuracy Acc is the proportion of the number of samples correctly predicted by the model to the total number of samples. Suppose there are N samples, and the true label of each sample is y i (where i ranges from the set of classes {1, 2,..., C}), and the predicted label of the model is The accuracy is expressed as:
[0093]
[0094] where is the indicator function, which takes the value of 1 when and 0 otherwise.
[0095] The cross-entropy loss Loss measures the difference between the predicted probability distribution of the model and the true label distribution. Suppose there are N samples, and the true label y i of each sample is an integer, ranging from {0, 1,..., C - 1} (where C is the total number of classes). The predicted probability distribution of the model for the i-th sample is:
[0096]
[0097] For a single sample i, its true label under integer encoding is the integer y i , and the corresponding cross-entropy loss can be simplified to:
[0098]
[0099] For the entire dataset (containing N samples), the total cross-entropy loss is the average of the losses of all samples:
[0100]
[0101] Verification and comparative experiment stage
[0102] The comparative experiment is supplemented with three control groups, namely the CNN model, the SwinTransformer (Tiny) model (denoted as Swin-T), and the Swin-T fused with WTConv (before improvement) model (denoted as Swin-T-WTC). Keep the parameters in the training process consistent: learning rate 0.00005, weight decay 0.05, batch size 4, and no use of any pre-trained weights.
[0103] Explanation of the CNN model structure and parameters: Input a 224×224 image. The first convolutional layer has 3-channel input and 32-channel output, with a 3×3 convolutional kernel, a stride of 1, padding of 1, ReLU activation, and max pooling of 2×2; the second convolutional layer has 32-channel input and 64-channel output, with a 3×3 convolutional kernel, a stride of 1, padding of 1, ReLU activation, and max pooling of 2×2: the first fully connected layer has 197632 input features and 512 output features, with ReLU activation; the Dropout layer has a 50% dropout rate; the second fully connected layer has 512 input features and output features (32 classes), and directly outputs the prediction result.
[0104] During the iterative learning process of the model, the validation set is used generation by generation for validation operations to detect the performance of the model. The accuracy Acc and cross-entropy loss Loss of each model in the training process and validation process of each generation are statistically calculated. The specific statistical results are as Figure 3 and Figure 4 shown.
[0105] Finally, the previously divided test set data is used to test each model. The accuracy and average accuracy of each model under 5 tests on the test set are shown in Table 1.
[0106]
[0107] Table 1
[0108] The experimental results show that the Swin-T-WTCBN model performs better than other comparative models in all indicators, indicating that the parallel design of the WTConvBlock and SwinTransformer Block proposed in the present invention improves the correct rate of bearing fault diagnosis and is effective.
[0109] In principle, Swin Transformer reduces the computational complexity by introducing window partitioning and calculating self-attention independently within each window. This approach preserves the modeling ability of Transformer and can capture long-range dependencies and global context information. The wavelet convolutional layer WTConvBlock can decompose the input image into sub-bands of different frequencies, extracting local details and multi-scale features. Through the parallel structure, the model can fuse information at different levels, increasing its expressive power and making it more robust to noise and interference. Ultimately, the result is that the image classification performance is better than that of traditional structures.
[0110] Meanwhile, the cross-entropy convergence rate of the Swin-T-WTCBN model during training and validation is better than that of the Swin-T-WTC model, indicating that the method of improving the wavelet convolutional layer proposed in the present invention, i.e., adding batch normalization and scaling, is effective.
[0111] In principle, batch normalization improves the training efficiency and stability of the model by normalizing the input of each layer of the neural network. Since the features extracted by the wavelet convolutional layer have a large numerical range and complex distribution, this may lead to unstable gradients during the optimization process. The BN layer effectively alleviates this problem through normalization operations, enabling the model training process to converge faster. The final result is that the convergence rate of the Swin-T-WTCBN model is better than that of the Swin-T-WTC model.
[0112] In summary, the method of fusing wavelet convolution and window attention mechanism is effective and performs well, meeting the needs of industrial applications.
[0113] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. For those skilled in the art, it is obvious that the present invention is not limited to the details of the above-described exemplary embodiments, and without departing from the spirit or basic characteristics of the present invention, the present invention can be implemented in other specific forms. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-limiting. The scope of the present invention is defined by the appended claims rather than the above description. Therefore, all changes falling within the meaning and scope of the equivalent elements of the claims are intended to be embraced by the present invention. Any reference signs in the claims should not be construed as limiting the claims involved.
[0114] In addition, it should be understood that although this specification is described according to embodiments, not every embodiment only contains an independent technical solution. This narrative way of the specification is only for clarity. Those skilled in the art should regard the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.
Claims
1. A multi-fault diagnosis method based on fusion of wavelet convolution and window attention mechanism, characterized in that: The following steps are involved: Data selection and preprocessing: Collect two-dimensional array data from the Seoul University deep groove ball bearing fault data set and perform two-dimensional array data-to-image processing; Divide the dataset: Divide the generated image data into training set, validation set and training set, and label them according to the fault category; A neural network model integrating wavelet convolution and window attention mechanism is constructed, which is denoted as Swin-T-WTCBN model: the improved wavelet transform convolution layer WTConv Block and Swin Transformer Block are connected in parallel in BasicLayer, and image features are extracted by integrating wavelet convolution and window attention mechanism; Training the Swin-T-WTCBN model: using the gradient descent method to optimize the model parameters, training until the cross entropy of the verification process converges; Verification results: The trained Swin-T-WTCBN model is used to classify the divided test fault samples, and the model performance is evaluated by the classification accuracy.
2. The method according to claim 1, characterized in that The model architecture that integrates wavelet convolution and window attention mechanism can realize multi-scale extraction and enhancement of image features to improve model performance.
3. The method according to claim 1, characterized in that The model architecture that integrates wavelet convolution and window attention mechanism includes an improved wavelet transform convolution layer WTConv Block and the original SwinTransformerBlock, which are connected in parallel in BasicLayer. The wavelet convolution layer can capture image information of different scales and enhance the expressive ability of the model. The features after wavelet transformation are added to the original features to further enhance the feature representation, making the model more effective in processing complex images.
4. The method according to claim 1, characterized in that The gradient descent method is implemented through the Adam optimizer in PyTorch to iteratively update the parameters in the Swin-T-WTCBN model.
5. The method according to claim 1, characterized in that The original labels of the fault image samples contained in the test set are compared with the model classification output labels to determine what kind of fault the bearing has and the accuracy of the fault diagnosis, that is, to evaluate the performance of the model.
6. The method according to any one of claims 1 to 6, characterized in that The method is particularly suitable for fault diagnosis of bearing components of mechanical equipment, and can effectively diagnose faults of bearing components of mechanical equipment and eliminate risks in a timely manner, thereby ensuring safe and stable operation of the mechanical equipment.