Bearing fault diagnosis method based on ViTCapsNet network for variable operating condition migration in noisy environment
By using ViTCapsNet network in a noisy environment combined with ViT attention mechanism and capsule network, the problem of difficulty in extracting fault characteristics and low model generalization ability in a noisy environment is solved, and accurate diagnosis and explanatory enhancement of bearing failures under different working conditions is achieved.
Patent Information
- Application Number
- CN202411681856.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-22
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2044-11-22
AI Technical Summary
In noisy environments, traditional bearing fault diagnosis methods are difficult to extract accurate fault characteristics, and the model generalization ability is low, so they cannot adapt to the diagnosis of operating conditions and new fault types.
The ViTCapsNet network is used to diagnose bearings faults by obtaining bearing vibration signals, adding Gaussian white noise for data enhancement, using continuous wavelet transformation to convert it into two-dimensional wavelet time-frequency images, and a ViT attention mechanism encoder and capsule network are constructed for fault diagnosis.
Effectively extracting features in a noisy environment improves the generalization ability and adaptability of the model, accurately diagnose bearing failures under different operating conditions, and enhances the interpretability of the diagnosis through Grad-CAM visualization.
Smart Images

Figure CN119202905B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to intelligent fault diagnosis technology, and in particular to a variable working condition migration bearing fault diagnosis method based on a ViTCapsNet network in a noisy environment. Background Art
[0002] Rotating machinery is the most widely used type of mechanical equipment in the field of mechanical engineering. At the same time, rotating machinery is also the part of mechanical equipment where failures occur most frequently. Bearings, as one of the core components of rotating machinery, are the parts where failures frequently occur. Nearly 40% of failures in mechanical equipment are caused by bearing failures. Therefore, it is very meaningful to conduct effective fault diagnosis of bearings.
[0003] The working environment of bearings is relatively complex and easily disturbed by noise. The characteristic vibration signals collected by the acceleration sensor will be disturbed by noise. When the noise increases to a certain extent, the characteristics of the fault impact of the vibration signal will be submerged by the messy noise, which makes intelligent fault diagnosis very difficult. In this case, fault diagnosis requires accurate fault characteristics to be extracted in a noisy environment to avoid the deterioration of bearing faults and affect the operating efficiency of the equipment.
[0004] In actual application scenarios, in addition to noise, there are often problems with changes in operating conditions or new types of faults. The feature distribution of the training set and the test set of traditional fault diagnosis methods is the same, resulting in low generalization and poor adaptability of the model. If a new type of fault is encountered, the historical training model cannot accurately diagnose and classify the fault under the new operating conditions. In order to adapt to the new operating conditions that are constantly generated, it is necessary to combine transfer learning to improve the generalization ability of the model, ensure the real-time nature of fault diagnosis, and ensure the safe and stable operation of the bearing. Summary of the invention
[0005] Purpose of the invention: The purpose of the present invention is to solve the deficiencies in the prior art and to provide a bearing fault diagnosis method with variable operating condition migration based on the ViTCapsNet network in a noisy environment.
[0006] Technical solution: The present invention provides a variable working condition migration bearing fault diagnosis method based on ViTCapsNet network in a noisy environment, comprising the following steps:
[0007] Step 1. First, obtain the bearing vibration signal at a sampling frequency of 25.6kHz; then add Gaussian white noise with different signal-to-noise ratios to the bearing vibration signal data set, and use the sliding window method to enhance the bearing vibration signal data after adding noise; then use continuous wavelet transform to transform the enhanced data into a two-dimensional wavelet time-frequency image, and divide all the two-dimensional wavelet time-frequency images into a training set and a test set (set the length of each sample to 784, and the overlapping data length to 300); when performing time-frequency transformation here, the wavelet basis can be set to "cmor3-3" to convert the nonlinear and non-stationary vibration signal into a two-dimensional wavelet time-frequency image, which can more accurately express the information of nonlinear and non-stationary signals;
[0008] Step 2: construct a ViTCapsNet network fault diagnosis model, and use the training set to train the ViTCapsNet network fault diagnosis model. The ViTCapsNet network fault diagnosis model includes two parts in sequence: an encoder module based on the ViT attention mechanism and a capsule network CapsNet;
[0009] Step 2.1: Construct an encoder module based on the ViT attention mechanism, input the two-dimensional wavelet time-frequency image obtained in step 1 into the trained encoder module, and extract global features (obtain global information). The specific method is as follows:
[0010] Step 2.1.1: Before inputting the encoder module, the two-dimensional time-frequency image is segmented through the Embeddings module, converted into a one-dimensional time series, and the learnable position code and class token are added to obtain the embedded sequence. ;
[0011] Step 2.1.2: First, the embedded sequence is calculated by a multi-head attention mechanism with multiple scaled dot product attention layers. The weights are assigned according to the similarity, and the weights are aggregated and superimposed to obtain ;
[0012] Then, we build a multi-layer perceptron (MLP) (extracting the weights obtained by the attention mechanism). The multi-layer perceptron (MLP) includes two fully connected (FC) layers. The first FC layer expands the original dimension to 4 times the original dimension and uses the GELU activation function to enhance the model's expressiveness. The second FC layer restores the dimension to the original dimension, which avoids overfitting problems caused by excessive complexity.
[0013] The present invention uses residual connection, LN layer and Dropout layer to connect the multi-head attention mechanism and MLP (the encoder is first normalized, then passes through the multi-head attention mechanism, passes through a dropout layer, and then the features of the input block are fused with the features after the dropout layer through the residual connection, and then normalized. After normalization, it is input to the MLP layer for full connection to form an independent encoder Encoder Block). The use of residual connection can solve the problem of gradient explosion, the LN layer can improve the robustness of the model, and the Dropout layer can improve the generalization ability of the model. Relying on the existing connection method can speed up the training speed of the model and improve the stability of the model operation;
[0014] Finally, the ViT attention mechanism encoder module is run 4 times in a loop to obtain global features. , the final result is converted into data as the input for the next step;
[0015] Step 2.2: Construct capsule networks CapsNets and use the dynamic routing mechanism of capsule networks to perform fault diagnosis and classification;
[0016] Step 3: Use the test set in step 1 to test the fault diagnosis effect of the ViTCapsNet network fault diagnosis model. After training, the internal weights and coupling coefficients of the ViTCapsNet network fault diagnosis model are fixed. Then, the diagnostic effect of the model is verified using data under other loads. A box plot and confusion matrix are drawn to compare the diagnosis with other models to show the performance of the ViTCapsNet network fault diagnosis model.
[0017] Step 4: Verify the diagnostic effect of the ViTCapsNet network fault diagnosis model under different noises. Perform multiple experiments under the same migration condition with different noises. Specifically, perform variable working condition migration experiments under SRN=5, perform comparative experiments with different noises under the migration condition of 0Nm to 2Nm, and draw violin plots and box plots to observe the effect of fault diagnosis.
[0018] Step 5: Introduce the gradient-weighted class activation heat map Grad-CAM to visualize the features extracted by the encoder module. The Grad-CAM method uses the maximum or minimum value in the final prediction result to calculate the reverse gradient of the input capsule network feature map, weighted multiply the feature map of each channel by the gradient of the corresponding channel, and then average pool the gradient to obtain a single heat map, which is used to display the focus area of the ViTCapsNet network fault diagnosis model for the prediction result.
[0019] Furthermore, the Gaussian white noise formula added in step 1 is as follows:
[0020] ;
[0021] In the above formula, the calculation formula of signal-to-noise ratio SNR is:
[0022] ;
[0023] in, , Represent the power of the original signal and the power of the noise respectively;
[0024] Finally, the vibration signal after adding Gaussian white noise With the original vibration signal The relationship is as follows: ;
[0025] The formula for continuous wavelet transform of the vibration signal after adding noise is as follows:
[0026] ;
[0027] In the formula, Represents the signal being analyzed With wavelet The similarity between the two, n is the time variable, is the scale parameter, is the displacement parameter.
[0028] Furthermore, in step 2.1.1, the Embeddings module converts the two-dimensional wavelet time-frequency image Linearly projecting into one-dimensional space, the specific method of generating patch tokens is:
[0029] Input 2D wavelet time-frequency image Divided into patches; these patches are then embedded by the embedding layer, setting the dimension of the embedded patch to 784 and setting the input to After the image is segmented by the Embeddings module, 49 patch tokens are obtained. At this time, a trainable positional encoding is added after the patch token sequence, and a class tag is added. To help the model identify the fault classification, get the input shape of the encoder module , after adding the class label and position encoding, we get the input of the encoder module , the formula is as follows:
[0030] ;
[0031] In the formula, ;
[0032] ;
[0033] Among them, (H, W) is the original two-dimensional wavelet time-frequency image The resolution ratio, C is the number of channels, is the size of each image block after segmentation, and N is the number of patches obtained after segmentation; Represents the class tag, Indicates patch token. represents the resulting two-dimensional matrix, representing the embedding of the positional encoding.
[0034] Furthermore, the encoder module includes a multi-head attention mechanism, an MLP layer, a residual connection, a normalized LN layer, and a Dropout layer. The embedded sequence input encoder module finally outputs the global feature after processing. ; The specific process is:
[0035] For one-dimensional embedded sequences, each scaled dot product attention including the multi-head attention mechanism first calculates the dot product of Query and Key, and then divides it by the scaling factor , then multiply it by Value, and finally calculate the weight through the Softmax function, and then multiply it by the value of Value. The formula is as follows:
[0036] ;
[0037] ;
[0038] In the formula, is the dimension of the input matrix vector;
[0039] The multi-head attention mechanism independently learns to obtain h groups of different linear mapping projections to transform Query, Key and Value, and then passes them into the attention mechanism for processing. Finally, the features are fused. The formula is as follows: ;
[0040] In the formula, represents a linear projection of multiple attention heads in series;
[0041] ;
[0042] In the formula, , , Represents input embeddings that obtain different queries, keys, and values through different linear projections;
[0043] Residual connection can simplify the network in multi-layer network training. The LN layer can ensure the stability of feature distribution and accelerate the convergence of the model. The formula is as follows:
[0044] ;
[0045] The above-mentioned Input the multi-layer perceptron MLP. In the first fully connected layer, MLP uses the GELU activation function to enhance the attention mechanism, retaining the part with larger attention weight and suppressing the part with smaller attention weight, so that valuable fault classification information can be better retained. The formula of the GELU activation function is as follows:
[0046] ;
[0047] The Dropout layer removes redundant information, reduces the complexity of the model, and prevents overfitting. The above is one of the four blocks. The four blocks need to be stacked in a loop to finally obtain the global features. .
[0048] Furthermore, the capsule network of step 2.2 includes a primary capsule layer and a digital capsule layer, and the primary capsule and the digital capsule transmit the weight information between the features through a dynamic routing mechanism; the primary capsule layer converts the obtained global features into Perform two-dimensional convolution to convert into multiple primary capsules. The digital capsule layer extracts local features and spatial information for fault diagnosis. The specific method is as follows:
[0049] First, build the primary capsule layer, and transform the global features Converted to the primary capsule layer, the length of each capsule is 16;
[0050] Second, set the l Layer r The output vector of a capsule is recorded as , and set the transformation matrix , using the transformation matrix To connect the first layer r Capsules and l +1st floor j The formula is as follows:
[0051] , ;
[0052] The result of linear transformation is processed by dynamic routing mechanism Process it and get l +1st floor j The total number of capsules , the formula is as follows: ;
[0053] In the formula, is the coupling coefficient determined by the dynamic routing iteration process, and the capsule r The sum of the coupling coefficients with all capsules in the l+1th layer is 1, Through The calculation is determined as follows:
[0054] ; ;
[0055] In the formula, It's a capsule r Should be coupled to the capsule j The prior probability of , its initial value is 0;
[0056] Finally, a custom nonlinear function Squash is used to ensure the length of the capsule. Compress between 0 and 1 while keeping the direction of the vector unchanged. The formula is as follows:
[0057] ;
[0058] In the formula represents the output vector of the capsule, express norm;
[0059] In the dynamic routing mechanism, It can be learned and updated together with other weights. Its value depends on the direction and size of the primary capsule and the digital capsule. The formula is as follows:
[0060] ;
[0061] if and The larger the product of, the stronger the local connection between the features, and the greater the coupling coefficient in the dynamic path. will increase accordingly, so that As it increases, the longer the capsule is, the better it can represent the fault category;
[0062] Due to the multi-classification problem to be dealt with, the predicted value output by the capsule network must be converted into probability. The Softmax function is used for multi-classification and the output is converted into probability. The formula is as follows:
[0063] .
[0064] The capsule network of the present invention uses a dynamic routing mechanism to calculate the weight value between the primary capsule and the digital capsule to determine whether the information is important, retain the important information, and discard the unimportant information. Specifically, if the predicted vector has a large vector product with the output of the upper layer vector, more fault features can be learned through top-down feedback to increase the coupling coefficient of the upper layer capsule and reduce the coupling coefficient of other capsules; on the contrary, when the predicted value is small, the calculated value is close to 0, and the next step of calculation cannot be performed.
[0065] Furthermore, when the ViTCapsNet network fault diagnosis model is trained and tested in step 3, in order to obtain the error between the true value and the predicted value, the loss function used is the cross entropy loss function, and the formula is as follows:
[0066] .
[0067] Furthermore, step 5 uses the gradient weighted class activation heat map Grad-CAM to visualize the attention method used, and the formula for obtaining the gradient is as follows:
[0068]
[0069]
[0070] In the formula, represents the classification probability corresponding to category c obtained by forward propagation, Indicates the kth channel on the entire layer A. Features, Represents the gradient information obtained by the specific feature map corresponding to category c. The purpose of this process is to perform global average pooling on the obtained gradient information to obtain important weights ;
[0071] Finally, the obtained gradient weights are weighted summed and then passed Output, the formula is as follows:
[0072] .
[0073] Beneficial effects: The present invention effectively enhances the ability to extract features, so that the model can effectively extract important information from the features after adding noise; at the same time, under the constraint of the same noise, the model can still accurately perform fault diagnosis when the working conditions change; finally, the Grad-CAM method in visual analysis technology is introduced to visualize the effective information extracted by the model, thereby enhancing the internal interpretability of intelligent fault diagnosis. BRIEF DESCRIPTION OF THE DRAWINGS
[0074] Figure 1It is the overall flow chart of the present invention;
[0075] Figure 2 It is a specific flow chart of each part in the ViTCapsNet network of the present invention;
[0076] Figure 3 The ViTCapsNet network structure diagram of the present invention;
[0077] Figure 4 This is a diagram showing the visualization principle of Grad-CAM in the embodiment;
[0078] Figure 5 This is the fault diagnosis effect of variable working condition in the same noise environment in the embodiment;
[0079] Figure 6 It is the confusion matrix under different models in the case of 0Nm-2Nm migration under the same noise condition in the embodiment;
[0080] Figure 7 Grad-CAM is used to visualize different models in the same noise environment in the embodiment;
[0081] Figure 8 This is a comparative experiment under different noise conditions under the same migration conditions in the embodiment;
[0082] Fig. 9 The confusion matrix of different models with SRN=2 under the same migration condition in the embodiment;
[0083] Fig.10 It is a visual display of different models under the same migration situation in the embodiment. DETAILED DESCRIPTION
[0084] The technical solution of the present invention is described in detail below, but the protection scope of the present invention is not limited to the embodiments.
[0085] like Figure 1 and Figure 2 As shown, the variable working condition migration bearing fault diagnosis method based on ViTCapsNet network in a noisy environment of the present invention comprises the following steps:
[0086] Step 1: First, obtain the bearing vibration signal at a sampling frequency of 25.6kHz; then add Gaussian white noise with different signal-to-noise ratios to the bearing vibration signal data set, and use the sliding window method to enhance the bearing vibration signal data after adding noise; then use continuous wavelet transform to transform the enhanced data into a two-dimensional wavelet time-frequency image, and divide all the two-dimensional wavelet time-frequency images into a training set and a test set;
[0087] Step 2: construct a ViTCapsNet network fault diagnosis model, and use the training set to train the ViTCapsNet network fault diagnosis model. The ViTCapsNet network fault diagnosis model includes two parts in sequence: an encoder module based on the ViT attention mechanism and a capsule network CapsNet;
[0088] Step 2.1: Construct an encoder module based on the ViT attention mechanism, input the two-dimensional wavelet time-frequency image obtained in step 1 into the trained encoder module, and extract global features. The specific method is as follows:
[0089] Step 2.1.1: Before inputting the encoder module, the two-dimensional time-frequency image is segmented through the Embeddings module, converted into a one-dimensional time series, and the learnable position code and class token are added to obtain the embedded sequence. ;
[0090] Step 2.1.2: First, the embedded sequence is calculated through a multi-head attention mechanism with multiple scaled dot product attention layers The weights are assigned based on the similarity between the features, and the weights of each feature are aggregated and superimposed;
[0091] Then, a multi-layer perceptron (MLP) is built. The multi-layer perceptron (MLP) includes two fully connected layers. The first FC layer expands the original dimension to 4 times the original dimension, and the second FC layer restores the dimension to the original dimension.
[0092] Finally, the Encoder module is run four times in a loop to obtain the global features. ;
[0093] Step 2.2: Construct a capsule network CapsNet and use the dynamic routing mechanism of the capsule network to perform fault diagnosis and classification;
[0094] Step 3: Use the test set in step 1 to test the fault diagnosis effect of the ViTCapsNet network fault diagnosis model. The internal weights and coupling coefficients of the trained ViTCapsNet network fault diagnosis model are fixed, and its diagnostic effect is verified using real data.
[0095] Step 4: Verify the diagnostic effect of the ViTCapsNet network fault diagnosis model under different noises. Perform multiple experiments under different noises under the same migration conditions, and draw violin plots and box plots to observe the effect of fault diagnosis.
[0096] Step 5: Introduce the gradient-weighted class activation heat map Grad-CAM to visualize the features extracted by the encoder module, such as Figure 4 shown.
[0097] The Gaussian white noise formula added in step 1 of this embodiment is as follows:
[0098] ;
[0099] The calculation formula of signal-to-noise ratio SNR is:
[0100] ;
[0101] in, , Represent the power of the original signal and the power of the noise respectively;
[0102] Finally, the vibration signal after adding Gaussian white noise With the original vibration signal The relationship is as follows: ;
[0103] The formula for continuous wavelet transform of the vibration signal after adding noise is as follows:
[0104] ;
[0105] In the formula, Represents the signal being analyzed With wavelet The similarity between the two, n is the time variable, is the scale parameter, is the displacement parameter.
[0106] like Figure 3 As shown, in step 2.1.1 of the embodiment, the Embeddings module converts the two-dimensional wavelet time-frequency image Linearly projecting into one-dimensional space, the specific method of generating patch tokens is:
[0107] Input 2D wavelet time-frequency image Divided into patches; these patches are then embedded by the embedding layer, setting the dimension of the embedded patch to 784 and setting the input to After the image is segmented by the Embeddings module, 49 patch tokens are obtained. At this time, a trainable positional encoding is added after the patch token sequence, and a class tag is added. To help the model identify the fault classification, get the input shape of the encoder module , after adding the class label and position encoding, we get the input of the encoder module , the formula is as follows: ;
[0108] In the formula, ;
[0109] ;
[0110] Among them, (H, W) is the original two-dimensional wavelet time-frequency image The resolution ratio, C is the number of channels, is the size of each image block after segmentation, and N is the number of patches obtained after segmentation; Represents the class tag, Indicates patch token. represents the resulting two-dimensional matrix, representing the embedding of the positional encoding.
[0111] like Figure 2 As shown in FIG. 1 , the encoder module of this embodiment includes a multi-head attention mechanism, an MLP layer, a residual connection, a normalized LN layer, and a Dropout layer. The embedded sequence input encoder module finally outputs the global feature after processing. ; The specific process is:
[0112] For one-dimensional embedded sequences , including the various scaled dot product attentions of the multi-head attention mechanism. First, the dot product of Query and Key is calculated, and then divided by the scaling factor , then multiply it by Value, and finally calculate the weight through the Softmax function, and then multiply it by the value of Value. The formula is as follows:
[0113] ;
[0114] ;
[0115] Where is the dimension of the input matrix vector; the multi-head attention mechanism independently learns to obtain h groups of different linear mapping projections to transform Query, Key and Value, and then passes them into the attention mechanism for processing, and finally fuses the features. The formula is as follows: ;
[0116] In the formula, represents a linear projection of multiple attention heads in series;
[0117] ;
[0118] In the formula, , , Represents input embeddings that obtain different queries, keys, and values through different linear projections;
[0119] Residual connection can simplify the network in multi-layer network training. The LN layer can ensure the stability of feature distribution and accelerate the convergence of the model. The formula is as follows: ;
[0120] The above-mentioned Input the multi-layer perceptron MLP. In the first fully connected layer, MLP uses the GELU activation function to enhance the attention mechanism, retaining the part with larger attention weight and suppressing the part with smaller attention weight, so that valuable fault classification information can be better retained. The formula of the GELU activation function is as follows:
[0121] ;
[0122] The Dropout layer removes redundant information, reduces the complexity of the model, and prevents overfitting. The above is one of the four blocks. The four blocks need to be stacked in a loop to finally obtain the global features. .
[0123] The capsule network in step 2.2 includes a primary capsule layer and a digital capsule layer. The primary capsule and the digital capsule transmit the weight information between the features through a dynamic routing mechanism. The primary capsule layer converts the global features into Perform two-dimensional convolution to convert into multiple primary capsules. The digital capsule layer extracts local features and spatial information for fault diagnosis. The specific method is as follows:
[0124] First, build the primary capsule layer, and transform the global features Converted to the primary capsule layer, the length of each capsule is 16;
[0125] Second, set the l Layer r The output vector of a capsule is recorded as , and set the transformation matrix , using the transformation matrix To connect the first layer r Capsules and l +1st floor j The formula is as follows:
[0126] , ;
[0127] The result of linear transformation is processed by dynamic routing mechanism Process it and get l +1st floor jThe total number of capsules , the formula is as follows: ;
[0128] In the formula, is the coupling coefficient determined by the dynamic routing iteration process, and the capsule r The sum of the coupling coefficients with all capsules in the l+1th layer is 1, Through The calculation is determined as follows:
[0129] ; ;
[0130] In the formula, It's a capsule r Should be coupled to the capsule j The prior probability of , its initial value is 0;
[0131] Finally, a custom nonlinear function Squash is used to ensure the length of the capsule. Compress between 0 and 1 while keeping the direction of the vector unchanged. The formula is as follows:
[0132] ;
[0133] In the formula represents the output vector of the capsule, express norm;
[0134] In the dynamic routing mechanism, It can be learned and updated together with other weights. Its value depends on the direction and size of the primary capsule and the digital capsule. The formula is as follows:
[0135] ;
[0136] Due to the multi-classification problem to be dealt with, the predicted value output by the capsule network needs to be converted into probability. The Softmax function is used for multi-classification and the output is converted into probability. The formula is as follows:
[0137] .
[0138] When the ViTCapsNet network fault diagnosis model is trained and tested in step 3 of the embodiment, in order to obtain the error between the true value and the predicted value, the loss function used is the cross entropy loss function, and the formula is as follows:
[0139] .
[0140] like Figure 4As shown, step 5 of this embodiment uses the gradient weighted class activation heat map Grad-CAM to visualize the attention method used, and the formula for obtaining the gradient is as follows:
[0141]
[0142]
[0143] In the formula, represents the classification probability corresponding to category c obtained by forward propagation, Indicates the first k On the channel Features, Represents the gradient information obtained by the specific feature map corresponding to category c. The purpose of this process is to perform global average pooling on the obtained gradient information to obtain important weights ;
[0144] Finally, the obtained gradient weights are weighted summed and then passed Output, the formula is as follows:
[0145] .
[0146] The present invention combines the ViT module with the capsule network, which not only extracts the global features in the original image, but also captures the features of the local space. It can use the unique dynamic routing mechanism of the capsule network to increase the generalization of the network model, and can use the Grad-CAM method to perform regional enhancement display on the area paid attention to by the encoder model, so that the regional location of the feature extracted by the encoder model can be clearly seen, thereby increasing the interpretability of fault diagnosis. In Grad-CAM, the reverse gradient method is used to obtain the reverse gradient of the feature map after feature reshaping for the final prediction value, and then the reverse gradient is weightedly summed with the original feature map to obtain an interpretable class labeling heat map.
[0147] This embodiment uses the vibration, acoustic, temperature and motor current data sets of rotating motors under different load conditions for fault diagnosis provided by KAIST, and selects the variable load condition data to verify the proposed method in a noisy environment.
[0148] The following four working condition migration experiments were conducted in an environment with SNR=5, namely 0Nm to 2Nm, 0Nm to 4Nm, 2Nm to 4Nm and 2Nm to 0Nm. Experiments were conducted in four conditions respectively, using CapsNet, PAMCapsNet and CAMCapsNet as comparison models. The results are as follows Figure 5As shown, the network model of the technical solution of the present invention is more accurate than other existing models. Figure 5 The left picture in the first row shows the 0Nm-2Nm fault diagnosis effect under 75-105 noise conditions. Figure 5 The first row on the right shows the 0Nm-4Nm fault diagnosis effect under 90-100 noise conditions. Figure 5 The left picture in the second row shows the 2Nm-4Nm fault diagnosis effect under the 58-105 noise condition. Figure 5 The second right picture in the middle shows the 2Nm-4Nm fault diagnosis effect under 80-100 noise conditions. Taking the first group of migration experiments as an example, the confusion matrix is used to observe the results of each model fault diagnosis. Figure 6 As shown, Figure 6 The confusion matrix of different models under the same noise condition of 0Nm-2Nm migration (the first row left picture, the first row right picture, the second row left picture and the second row right picture are CapsNet, ViTCapsNet, PAMCapsNet, CAMCapsNet respectively). Figure 6 It can be found from the confusion matrix in that the classification capabilities of the other three models for the last category of the seven types of faults are relatively low.
[0149] To further explain the cause of this situation and increase the interpretability of fault diagnosis, the Grad-CAM method is used to perform gradient weighted visualization of the attention mechanism in the ViTCapsNet, PAMCapsNet, and CAMCapsNet network models. The results are shown in Figure 2. Figure 7 As shown, Figure 7 Grad-CAM is used to visualize different models in the same noise environment (the first row left picture, the first row right picture, the second row left picture and the second row right picture are CapsNet, ViTCapsNet, PAMCapsNet, CAMCapsNet respectively). The visualized results of the present invention are stronger than those of other models, which shows that the proposed network model is better than other models.
[0150] Under the same migration working conditions, a comparative test with different noises was conducted. Gaussian white noise with signal-to-noise ratios of 2, 4, 6, and 8 was added to the original data to simulate the noise in the working environment. CapsNet, PAMCapsNet, and CAMCapsNet were used as comparison models to test the fault diagnosis effect of the ViTCapsNet network model under the noise background. Figure 8 As shown, Figure 8 It can be seen from the comparative experiments under the same migration conditions and different noises that the diagnostic effect of the technical solution of the present invention is much higher than that of other models. Figure 8 The first row on the left, Figure 8 The first row on the right, Figure 8 The second row on the left, Figure 8The second right picture in the middle row shows the effect when SRN is 2, 4, 6, and 8 respectively.
[0151] To explain the results in different noise environments, take SRN = 2dB as an example and observe the specific classification results of diagnosis through the confusion matrix. The confusion matrix is as follows: Fig. 9 As shown (the first row left picture, the first row right picture, the second row left picture and the second row right picture are CapsNet, ViTCapsNet, PAMCapsNet, CAMCapsNet respectively), Fig. 9 This is the confusion matrix of different models with SRN=2 under the same migration condition. By observing the confusion matrix, we know that the existing CapsNet network, PAMCapsNet network, and CAMCapsNet network have errors in the 6th category respectively.
[0152] To further explore the cause of the error, the Grad-CAM method is used to perform gradient weighted visualization of the capsule input features, such as Fig.10 As shown in the figure (the first row left picture, the first row right picture, the second row left picture and the second row right picture are CapsNet, ViTCapsNet, PAMCapsNet, CAMCapsNet respectively), the visualization effects of different models under different migration conditions are demonstrated. It can be seen that the visualization effect of Grad-CAM used in the present invention is stronger than other models. It can be seen that under the same noise condition, the present invention is stronger than other attention models.
Claims
1. A variable operating condition migration bearing fault diagnosis method based on ViTCapsNet network in a noisy environment, characterized in that: The following steps are involved: Step 1: First, obtain the bearing vibration signal at a sampling frequency of 25.6kHz; then add Gaussian white noise with different signal-to-noise ratios to the bearing vibration signal data set, and use the sliding window method to enhance the bearing vibration signal data after adding noise; then use continuous wavelet transform to transform the enhanced data into a two-dimensional wavelet time-frequency image, and divide all the two-dimensional wavelet time-frequency images into a training set and a test set; Step 2: construct a ViTCapsNet network fault diagnosis model, and use the training set to train the ViTCapsNet network fault diagnosis model. The ViTCapsNet network fault diagnosis model includes two parts in sequence: an encoder module based on the ViT attention mechanism and a capsule network CapsNet; Step 2.1: Construct an encoder module based on the ViT attention mechanism, input the two-dimensional wavelet time-frequency image obtained in step 1 into the trained encoder module, and extract global features. The specific method is as follows: Step 2.1.1: Before inputting the encoder module, the two-dimensional time-frequency image is segmented through the Embeddings module, converted into a one-dimensional time series, and the learnable position code and class token are added to obtain the embedded sequence. ; Step 2.1.2: First, the embedded sequence is calculated by a multi-head attention mechanism with multiple scaled dot product attention layers. The weights are assigned according to the similarity, and the weights are aggregated and superimposed to obtain ; Then, a multi-layer perceptron (MLP) is built. The multi-layer perceptron (MLP) includes two fully connected layers. The first FC layer expands the original dimension to 4 times the original dimension, and the second FC layer restores the dimension to the original dimension. Finally, the Encoder module is run four times in a loop to obtain the global features. ; Step 2.2: Construct a capsule network CapsNet, use the capsule network to capture local features between features, and then perform fault diagnosis and classification based on the extracted local features; Step 3: Use the test set in step 1 to test the fault diagnosis effect of the ViTCapsNet network fault diagnosis model. The internal weights and coupling coefficients of the trained ViTCapsNet network fault diagnosis model are fixed, and its diagnostic effect is verified using real data. Step 4: Verify the diagnostic effect of the ViTCapsNet network fault diagnosis model under different noises. Perform multiple experiments under different noises under the same migration conditions, and draw violin plots and box plots to observe the effect of fault diagnosis. Step 5: Introduce the gradient-weighted class activation heat map Grad-CAM to visualize the features extracted by the encoder module.
2. The variable operating condition migration bearing fault diagnosis method based on ViTCapsNet network in a noisy environment according to claim 1 is characterized in that: The Gaussian white noise formula added in step 1 is as follows: ; The calculation formula of signal-to-noise ratio SNR is: ; in, , Represent the power of the original signal and the power of the noise respectively; Finally, the vibration signal after adding Gaussian white noise The original vibration signal The relationship is as follows: ; The formula for continuous wavelet transform of the vibration signal after adding noise is as follows: ; In the formula, Represents the signal being analyzed With wavelet The similarity between the two, n is the time variable, is the scale parameter, is the displacement parameter.
3. The variable operating condition migration bearing fault diagnosis method based on ViTCapsNet network in a noisy environment according to claim 1 is characterized in that: In step 2.1.1, the Embeddings module converts the two-dimensional wavelet time-frequency image Linearly projecting into one-dimensional space, the specific method of generating patch tokens is: Input 2D wavelet time-frequency image Divided into patches; these patches are then embedded by the embedding layer, setting the dimension of the embedded patch to 784 and setting the input to After the image is segmented by the Embeddings module, 49 patch tokens are obtained. At this time, a trainable positional encoding is added after the patch token sequence, and a class tag is added. To help the model identify the fault classification, get the input shape of the encoder module , after adding the class label and position encoding, we get the input of the encoder module , the formula is as follows: ; In the formula, ; ; Among them, (H, W) is the original two-dimensional wavelet time-frequency image The resolution ratio, C is the number of channels, is the size of each image block after segmentation, and N is the number of patches obtained after segmentation; Represents the class tag, Indicates patchtoken, represents the resulting two-dimensional matrix, representing the embedding of the positional encoding.
4. The variable operating condition migration bearing fault diagnosis method based on ViTCapsNet network in a noisy environment according to claim 1 is characterized in that: The encoder module includes a multi-head attention mechanism, an MLP layer, a residual connection, a normalized LN layer, and a Dropout layer. The embedded sequence input encoder module is processed and finally outputs the global feature ; The specific process is: For one-dimensional embedded sequences, each scaled dot product attention including the multi-head attention mechanism first calculates the dot product of Query and Key, and then divides it by the scaling factor , then multiply it by Value, and finally calculate the weight through the Softmax function, and then multiply it by the value of Value. The formula is as follows: ; ; In the formula, is the dimension of the input matrix vector; The multi-head attention mechanism is learned independently h Different linear mapping projections are used to transform Query, Key and Value, and then they are passed into the attention mechanism for processing. Finally, the features are fused. The formula is as follows: ; In the formula, represents a linear projection of multiple attention heads in series; ; In the formula, , , Represents input embeddings that are transformed into different queries, keys, and values through different linear projections; Residual connection simplifies the network in multi-layer network training. The LN layer ensures the stability of feature distribution and accelerates the convergence of the model. The formula is as follows: ; The income Input the multi-layer perceptron MLP. In the first fully connected layer, MLP uses the GELU activation function to enhance the attention mechanism. The GELU activation function formula is as follows: ; Redundant information is removed through the Dropout layer, and the Block stack is repeated 4 times to finally obtain the global features. .
5. The variable operating condition migration bearing fault diagnosis method based on ViTCapsNet network in a noisy environment according to claim 1 is characterized in that: The capsule network in step 2.2 includes a primary capsule layer and a digital capsule layer. The primary capsule and the digital capsule transmit weight information between features through a dynamic routing mechanism. The primary capsule layer converts the obtained global features into Perform two-dimensional convolution to convert into multiple primary capsules. The digital capsule layer extracts local features and spatial information for fault diagnosis. The specific method is as follows: First, build the primary capsule layer, and transform the global features Converted to the primary capsule layer, the length of each capsule is 16; Second, set the l Layer r The output vector of a capsule is recorded as , and set the transformation matrix , using the transformation matrix To connect the first layer r Capsules and l +1st floor j The formula is as follows: , ; The result of linear transformation is processed by dynamic routing mechanism Process it and get l +1st floor j The total number of capsules , the formula is as follows: ; In the formula, is the coupling coefficient determined by the dynamic routing iteration process, and the capsule r With l The sum of the coupling coefficients between all capsules in the +1 layer is 1, Through The calculation is determined as follows: ; ; In the formula, It's a capsule r Should be coupled to the capsule j The prior probability of , its initial value is 0; Finally, a custom nonlinear function Squash is used to ensure the length of the capsule. Compress between 0 and 1 while keeping the direction of the vector unchanged. The formula is as follows: ; In the formula represents the output vector of the capsule, express norm; In the dynamic routing mechanism, It can be learned and updated together with other weights. Its value depends on the direction and size of the primary capsule and the digital capsule. The formula is as follows: ; Due to the multi-classification problem to be dealt with, the predicted value output by the capsule network needs to be converted into probability. The Softmax function is used for multi-classification and the output is converted into probability. The formula is as follows: 。 6. The variable operating condition migration bearing fault diagnosis method based on ViTCapsNet network in a noisy environment according to claim 1 is characterized in that: When the ViTCapsNet network fault diagnosis model is trained and tested in step 3, in order to obtain the error between the true value and the predicted value, the loss function used is the cross entropy loss function, and the formula is as follows: 。 7. The variable operating condition migration bearing fault diagnosis method based on ViTCapsNet network in a noisy environment according to claim 1 is characterized in that: Step 5 uses the gradient weighted class activation heat map Grad-CAM to visualize the attention method used, and the formula for obtaining the gradient is as follows: ; ; In the formula, represents the classification probability corresponding to category c obtained by forward propagation, Indicates the kth channel on the entire layer A. Features, Represents the gradient information obtained by the specific feature map corresponding to category c. The purpose of this process is to perform global average pooling on the obtained gradient information to obtain important weights ; Finally, the obtained gradient weights are weighted summed and then passed Output, the formula is as follows: 。
Citation Information
Patent Citations
Aviation bearing fault diagnosis method based on depth migration graph convolutional network under fluctuation working condition
CN115563553A
Induction motor infrared image fault diagnosis method based on double-flow attention convolution
CN118411562A