A lightweight vit fault diagnosis method combined with multi-scale convolution
By combining multi-scale depthwise separable convolutions and lightweight ViT networks, the real-time and accuracy problems of bearing fault diagnosis on terminals with limited computing power are solved, achieving fast and accurate fault diagnosis.
Patent Information
- Application Number
- CN202410257383.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-07
- Publication Date
- 2026-11-03
- Estimated Expiration
- 2044-03-07
AI Technical Summary
Existing technologies struggle to achieve efficient and accurate bearing fault diagnosis on terminals with limited computing power. Traditional methods are inefficient, and the computational complexity of deep learning methods limits real-time execution.
A lightweight ViT fault diagnosis method based on multi-scale convolution is proposed. It extracts signal features through a multi-scale depthwise separable convolutional network and combines it with a lightweight ViT network for self-attention feature extraction and classification, thereby reducing computational burden and adapting to environments with limited computing power.
This technology enables rapid and accurate bearing fault diagnosis on terminal devices with limited computing resources, improving diagnostic efficiency and reliability, and adapting the model to applications and products with varying resource usage. This allows for fast and accurate bearing fault diagnosis on terminals with limited computing power, improving diagnostic efficiency and reliability, adapting to different computing speeds and resource usage, and enhancing the model's accuracy and noise resistance.
Smart Images

Figure CN118051823B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a bearing fault diagnosis method, which is a lightweight ViT fault diagnosis method that combines multi-scale convolution. Background Technology
[0002] In industrial production, bearings are crucial components, and their fault diagnosis is essential for ensuring stable and efficient equipment operation. However, in real-world applications, the computing power of the terminal computer limits the computation time for large models, making it difficult to meet the real-time requirements in practical applications. This presents new challenges for bearing signal diagnosis.
[0003] Traditional bearing fault diagnosis methods, such as frequency domain analysis, time domain analysis, and wavelet analysis, can extract features from bearing signals, but their efficiency and accuracy suffer significantly when processing terminal devices with limited computing power. With the rapid development of deep learning technology, more and more researchers are attempting to apply deep learning to improve the performance of bearing fault diagnosis. Deep learning methods, by automatically extracting signal features, can accurately detect and diagnose bearing faults in complex data.
[0004] Nevertheless, the computational limitations of terminals remain a significant challenge. Traditional methods are often inefficient when dealing with large deep learning models, and while deep learning methods possess good robustness and accuracy, their complexity makes real-time execution difficult under limited computing power. In recent years, numerous research teams have begun exploring how to effectively apply deep learning-based bearing fault diagnosis methods under conditions of limited terminal computing power.
[0005] To address the limitations of computing power, developing bearing fault diagnosis methods suitable for environments with limited computing resources is particularly important. Bearing fault diagnosis is crucial for ensuring the safety and efficiency of industrial production; therefore, improving the efficiency and reliability of fault diagnosis is an urgent problem to be solved.
[0006] In view of this, this invention proposes a lightweight ViT fault diagnosis method combining multi-scale convolution. This method aims to optimize the model structure, reduce computational burden, and maintain high accuracy to adapt to terminal environments with limited computing power, thereby achieving fast and accurate bearing fault diagnosis. Summary of the Invention
[0007] This invention addresses the problems of large model parameter count, computational load, and long computation time in existing technologies by providing a lightweight ViT fault diagnosis method that combines multi-scale convolution.
[0008] The technical solution adopted in this invention is as follows: A lightweight ViT fault diagnosis method combining multi-scale convolution, the steps of which are:
[0009] 1) Collect bearing vibration signals: Use an accelerometer to collect signals emitted by bearings with different fault types during rotation. That is, collect the signal for each type of fault over a period of time. If there are t types of faults, then collect t segments of signals.
[0010] 2) Data augmentation: Use the moving window method to increase the number of samples.
[0011] The sliding window method is used to augment the data, assuming the signal length is L. signal The sliding step size is s, and the sample length is L. sample For the i-th type of fault, the number of samples that can be generated is n. i As shown in equation (1):
[0012]
[0013] Calculate the number of samples that can be generated for each data segment, and then divide the samples as shown in Equation (2):
[0014]
[0015] Among them, Singnal i Indicates the i-th type of fault signal. This represents the j-th sample of the i-th type of fault signal.
[0016] 3) Generate corresponding datasets based on different signal-to-noise ratios: Divide the data obtained in 2) into samples to obtain the original dataset, and then generate six datasets with different noise conditions: signal-to-noise ratios of -2, 0, 2, 4, 6, and no noise.
[0017] 3.1) Add noise to the obtained dataset to generate six datasets with signal-to-noise ratios of -2, 0, 2, 4, 6, and no noise, respectively; the specific operation of adding noise is shown in equation (3), with the sample For example:
[0018]
[0019] Where noise represents the generated noise, and random represents the randomly generated noise. Tensors with the same dimensions that conform to a standard normal distribution have a signal-to-noise ratio (SNR).
[0020] 3.2) Normalize the noisy dataset, transforming the values into a normal distribution with a mean of 0 and a variance of 1:
[0021] 3.2.1) Calculate the mean and standard deviation of the data, as shown in formula (4):
[0022]
[0023] in, for The mean, for The standard deviation of , where ∑· represents the summation of the element values of the tensor;
[0024] 3.2.2) Standardize the data using formula (5):
[0025]
[0026] in, Samples of the original signal. This is the standardized sample.
[0027] 4) Design and construct a lightweight ViT fault diagnosis model that combines multi-scale convolution: Use a multi-scale depthwise separable convolutional network to extract signal features and transform the original signal samples into embedding vectors so that the original signals can be processed later; then, use a lightweight ViT network to obtain the self-attention values between each embedding vector, thereby extracting feature vectors in the global receptive field; finally, input the output features of the lightweight ViT network into the classifier to calculate the fault category.
[0028] 4.1) Design and construct a multi-scale separable convolutional network: The normalized signal... The input multi-scale separable convolutional layer extracts features, and the specific design is as follows:
[0029] 4.1.1) Depthwise Convolution: Depthwise convolution pairs C in Each input channel is convolved sequentially. The dimension of the feature space is changed by using different convolution kernels and strides. In the following description, INP is used to represent the feature tensor of the input multi-scale depthwise separable convolutional network. Taking the ci-th channel feature of the input INP as an example, the depthwise convolution formula is expressed as shown in Equation (6).
[0030]
[0031] Where t1 represents the number of steps the convolution kernel has taken, pd represents the number of bounding box paddings, s represents the kernel stride, and K represents the kernel size in the depthwise convolution process. f represents the depthwise convolution kernel. DWC The value at the k-th position, This represents the value at position (t1-1)×s+k) of the input INP. This represents the result of depthwise convolution calculation at step t1 of the convolution kernel;
[0032] 4.1.2) Pointwise convolution: Enables cross-channel feature extraction without changing the feature map size; pointwise convolution connected after depthwise convolution is used to change the number of feature channels, by setting C. out A convolutional kernel of size 1 is used for cross-channel computation, thereby converting the feature channel output into C. out One, of which C out The number of output channels is represented by . Taking the coth output channel as an example, the point convolution formula is shown in equation (7):
[0033]
[0034] in, This represents the result of the point convolution at step t2. F represents a convolution kernel of size 1. DWC This represents the depthwise convolution result in 4.1.1). This represents the value at position t2 of the ci channel in the depthwise convolution;
[0035] 4.1.3) Construct depthwise separable convolutional blocks and design detailed network parameters: Each block contains depthwise separable convolutional layers, max pooling layers, activation functions, and dropout layers; the specific process is shown in equation (8):
[0036] DWC_B(ipt)=DP(LeakyReLU(MP(DWC(ipt)))) (8)
[0037] Where DWC_B represents the output of the current depthwise separable convolutional block, DWC represents the depthwise separable convolutional layer, MP represents the max pooling layer, DP represents the dropout layer, and LeakyReLU represents the LeakyReLU activation function, as shown in equation (9):
[0038] LeakyReLU(x) = max(αx,x) (9)
[0039] Where max represents the maximum value function, and α is a hyperparameter, which is set to 0.01 in this invention;
[0040] The multi-scale depthwise separable convolutional network is composed of depthwise separable convolutional blocks with different parameters. The specific network structure is shown in Equation (10):
[0041]
[0042] Where DWC_W1(ipt) and DWC_W2(ipt) represent two different depthwise separable convolutional paths, and DWC_B represents depthwise separable convolutional blocks with different parameters; the specific parameter settings are as follows: DWC_B1 has 1 input channel, 8 output channels, kernel size 9, stride 4, padding 4, and max pooling stride 4; DWC_B2 has 8 input channels, 16 output channels, kernel size 1, stride 1, padding 0, and no max pooling layer; DWC_B3 has 16 input channels, kernel size 1, stride 1, padding 0, and no max pooling layer; DWC_B3 has 16 input channels, kernel size 1, stride 1, padding 0, and no max pooling layer; DWC_B2 has 16 input channels, kernel size 1, stride 1, padding 0, and no max pooling layer. Input channel 16, output channel 16, kernel size 1, stride 1, padding 0, max pooling stride 5; DWC_B4 Input channel 1, output channel 8, kernel size 5, stride 2, padding 2, max pooling stride 2; DWC_B5 Input channel 8, output channel 16, kernel size 5, stride 2, padding 2, max pooling stride 2; DWC_B6 Input channel 16, output channel 16, kernel size 1, stride 1, padding 0, max pooling stride 5;
[0043] For input data with a sample size of 1200, the feature size after passing through a multi-scale residual convolutional network is 16×15.
[0044] 4.2) Design and Construction of a Lightweight ViT Network: The output features DWC_N(ipt) of the multi-scale separable convolutional network are transposed, exchanging the last two dimensions of the features. Then, the transposed features are used as input to the lightweight ViT network. The specific design steps are as follows:
[0045] 4.2.1) Generating Patch Embedding: Transpose DWC_N(ipt) to obtain the patch, and then perform a linear transformation on the patch to obtain the patch embedding; the transpose process is shown in equation (11):
[0046] DWC_N(ipt)[a,b]=DWC_N(ipt)[b,a] (11)
[0047] Where DWC_N(ipt)[a,b] represents the data in the a-th row and b-th column of DWC_N(ipt), and DWC_N(ipt)[b,a] represents the data in the b-th row and a-th column of DWC_N(ipt);
[0048] The linear transformation process is shown in equation (12):
[0049] Patch_emb = DWC_N(ipt) T ·W p (12)
[0050] Wherein, DWC_N(ipt) T W represents the transpose of DWC_N(ipt). p Represents the linear transformation weight matrix;
[0051] 4.2.2) Generate embedding vector: Concatenate a learnable classification token of the same size as the patch vector before the patch sequence, then generate a learnable position embedding, and add the position embedding to the patch embedding; the process is shown in equation (13):
[0052] Emb=Concat(cls_token,Patch)+pos (13)
[0053] Where Concat(·) represents the vector concatenation function, cls_token represents the classification token, and pos represents the position embedding;
[0054] 4.2.3) Multi-head self-attention mechanism layer: The multi-head self-attention mechanism can extract features from multiple different perspectives and obtain long-distance dependency information;
[0055] First, the query vector Q, key vector K, and value vector V are obtained through linear transformation, as shown in equation (14):
[0056]
[0057] Among them, Q h K h V h Let Q represent the query vector, K represent the key vector, and V and W represent the value vectors of the h-th group, respectively. h Q W h K and W h V Let H represent the weight matrix of the western linear transformation, and let H represent the number of heads, which is set to 2 in this invention;
[0058] Next, the dot product of the query vector and the key vector is calculated to obtain the attention value, and the attention value is normalized using the softmax function to obtain the attention weight; as shown in Equation (15):
[0059]
[0060] Where, d k Indicates the size of the key vector dimension. The scaling factor represents the size of the dot product; by introducing The model assigns different weights to each embedding vector, which strengthens the model's focus on important features while weakening the influence of unimportant features;
[0061] Next, the result of Equation (15) is linearly transformed to obtain the final output of the multi-head attention mechanism; the calculation process is shown in Equation (16):
[0062]
[0063] Among them, W O Represents the linear transformation weight matrix;
[0064] Finally, the calculation results are layer normalized and residually connected with the input to complete the calculation part of the multi-head self-attention mechanism, as shown in Equation (17):
[0065] Emb′=MSA(LN(Emb))+Emb (17)
[0066] Where LN(·) represents layer normalization;
[0067] 4.2.4) Feedforward network layer: Consists of two linear layers and a nonlinear activation function, used to increase the model's nonlinear processing capability and feature representation capability; the calculation process is shown in equation (18):
[0068]
[0069] in, Let represent the weight matrix of the fully connected layer. The linear transformation inflation rate is set to 3. GELU(·) represents the GELU activation function, and the calculation formula is shown in equation (19).
[0070]
[0071] Finally, the calculation results are normalized and residually connected to the input to complete the feedforward network layer; this process is shown in equation (20):
[0072] Encoder out =MLP(LN(Emb′))+Emb′ (20)
[0073] Among them, Encoder out This represents the output characteristics of the feedforward network layer.
[0074] 4.3) Design and construct the classifier: The classifier classifies the extracted features and consists of a linear transformation layer and a softmax function; the calculation process of the linear transformation part is shown in equation (21):
[0075]
[0076] in, Encoder out The classification token in the first vector, W cls Represents the weight matrix;
[0077] Then, the probability of the current sample being a certain fault type can be obtained by processing the linear transformation result with the softmax function. The fault probability calculation formula is shown in equation (22):
[0078]
[0079] Among them, y class represents the i-th value of y, i.e., the probability of the i-th class, and CLASS represents the total number of classes.
[0080] 5) Train and test the model designed in 4) using test datasets with different levels of noise to verify the model's performance;
[0081] The designed model was trained and tested using datasets with different levels of noise, with accuracy and cross-entropy loss as the evaluation criteria; the accuracy calculation formula is shown in equation (23):
[0082]
[0083] Where, num right num represents the number of correctly classified samples in the dataset. all Let represent the total number of samples in the dataset. The formula for calculating the cross-entropy loss is shown in equation (24):
[0084]
[0085] Among them, sample i p(sample) represents the i-th sample in the dataset. i ) represents the label value of the sample, q(sample) i ) represents the value predicted by the model.
[0086] 6) Fault diagnosis: Collect acceleration signals generated in the actual industrial production environment, use the model obtained in step 4) to perform fault diagnosis, and classify the fault signal types.
[0087] The beneficial effects of this invention are as follows: The invention primarily designs and implements a lightweight ViT fault diagnosis method combining multi-scale convolution. Addressing the problem that terminal machines with limited computing power cannot promptly compute results when faced with large models in real-world scenarios, a multi-scale depthwise separable convolution is designed for feature extraction and patch partitioning. This multi-scale depthwise separable convolution replaces traditional convolution to reduce the number of parameters and computational load. Furthermore, a lightweight ViT network is used to further reduce computational burden. Experiments are conducted on a prepared dataset using the designed method to verify the accuracy and efficiency of the proposed method. Attached Figure Description
[0088] Figure 1It is the overall flowchart;
[0089] Figure 2 This is a diagram of a multi-scale separable convolutional network model;
[0090] Figure 3 This is a diagram of a lightweight ViT network model;
[0091] Figure 4 This is a comparison chart of the accuracy and loss value of the designed model under different signal-to-noise ratio datasets. Detailed Implementation
[0092] 1) Collect bearing vibration signals: Use an accelerometer to collect signals emitted by bearings with different fault types during rotation. That is, collect the signal for each type of fault over a period of time. If there are t types of faults, then collect t segments of signals.
[0093] 2) Data augmentation: Use the moving window method to increase the number of samples.
[0094] The sliding window method is used to augment the data, assuming the signal length is L. signal The sliding step size is s, and the sample length is L. sample For the i-th type of fault, the number of samples that can be generated is n. i As shown in equation (1):
[0095]
[0096] Calculate the number of samples that can be generated for each data segment, and then divide the samples as shown in Equation (2):
[0097]
[0098] Among them, Singnal i Indicates the i-th type of fault signal. This represents the j-th sample of the i-th type of fault signal.
[0099] 3) Generate corresponding datasets based on different signal-to-noise ratios: Divide the data obtained in 2) into samples to obtain the original dataset, and then generate six datasets with different noise conditions: signal-to-noise ratios of -2, 0, 2, 4, 6, and no noise.
[0100] 3.1) Add noise to the obtained dataset to generate six datasets with signal-to-noise ratios of -2, 0, 2, 4, 6, and no noise, respectively; the specific operation of adding noise is shown in equation (3), with the sample For example:
[0101]
[0102] Where noise represents the generated noise, and random represents the randomly generated noise. Tensors with the same dimensions that conform to a standard normal distribution have a signal-to-noise ratio (SNR).
[0103] 3.2) Normalize the noisy dataset, transforming the values into a normal distribution with a mean of 0 and a variance of 1:
[0104] 3.2.1) Calculate the mean and standard deviation of the data, as shown in formula (4):
[0105]
[0106] in, for The mean, for The standard deviation of , where ∑· represents the summation of the element values of the tensor;
[0107] 3.2.2) Standardize the data using formula (5):
[0108]
[0109] in, Samples of the original signal. This is the standardized sample.
[0110] 4) Design and construct a lightweight ViT fault diagnosis model that combines multi-scale convolution: Use a multi-scale depthwise separable convolutional network to extract signal features and transform the original signal samples into embedding vectors so that the original signals can be processed later; then, use a lightweight ViT network to obtain the self-attention values between each embedding vector, thereby extracting feature vectors in the global receptive field; finally, input the output features of the lightweight ViT network into the classifier to calculate the fault category.
[0111] 4.1) Design and construct a multi-scale separable convolutional network: The normalized signal... The input multi-scale separable convolutional layer extracts features, and the specific design is as follows:
[0112] 4.1.1) Depthwise Convolution: Depthwise convolution pairs C in Each input channel is convolved sequentially. The dimension of the feature space is changed by using different convolution kernels and strides. In the following description, INP is used to represent the feature tensor of the input multi-scale depthwise separable convolutional network. Taking the ci-th channel feature of the input INP as an example, the depthwise convolution formula is expressed as shown in Equation (6).
[0113]
[0114] Where t1 represents the number of steps the convolution kernel has taken, pd represents the number of bounding box paddings, s represents the kernel stride, and K represents the kernel size in the depthwise convolution process. f represents the depthwise convolution kernel. DWC The value at the k-th position, This represents the value at position (t1-1)×s+k) of the input INP. This represents the result of depthwise convolution calculation at step t1 of the convolution kernel;
[0115] 4.1.2) Pointwise convolution: Enables cross-channel feature extraction without changing the feature map size; pointwise convolution connected after depthwise convolution is used to change the number of feature channels, by setting C. out A convolutional kernel of size 1 is used for cross-channel computation, thereby converting the feature channel output into C. out One, of which C out The number of output channels is represented by . Taking the coth output channel as an example, the point convolution formula is shown in equation (7):
[0116]
[0117] in, This represents the result of the point convolution at step t2. F represents a convolution kernel of size 1. DWC This represents the depthwise convolution result in 4.1.1). This represents the value at position t2 of the ci channel in the depthwise convolution;
[0118] 4.1.3) Construct depthwise separable convolutional blocks and design detailed network parameters: Each block contains depthwise separable convolutional layers, max pooling layers, activation functions, and dropout layers; the specific process is shown in equation (8):
[0119] DWC_B(ipt)=DP(LeakyReLU(MP(DWC(ipt)))) (8)
[0120] Where DWC_B represents the output of the current depthwise separable convolutional block, DWC represents the depthwise separable convolutional layer, MP represents the max pooling layer, DP represents the dropout layer, and LeakyReLU represents the LeakyReLU activation function, as shown in equation (9):
[0121] LeakyReLU(x) = max(αx,x) (9)
[0122] Where max represents the maximum value function, and α is a hyperparameter, which is set to 0.01 in this invention;
[0123] The multi-scale depthwise separable convolutional network is composed of depthwise separable convolutional blocks with different parameters. The specific network structure is shown in Equation (10):
[0124]
[0125] Where DWC_W1(ipt) and DWC_W2(ipt) represent two different depthwise separable convolutional paths, and DWC_B represents depthwise separable convolutional blocks with different parameters; the specific parameter settings are as follows: DWC_B1 has 1 input channel, 8 output channels, kernel size 9, stride 4, padding 4, and max pooling stride 4; DWC_B2 has 8 input channels, 16 output channels, kernel size 1, stride 1, padding 0, and no max pooling layer; DWC_B3 has 16 input channels, kernel size 1, stride 1, padding 0, and no max pooling layer; DWC_B3 has 16 input channels, kernel size 1, stride 1, padding 0, and no max pooling layer; DWC_B2 has 16 input channels, kernel size 1, stride 1, padding 0, and no max pooling layer. Input channel 16, output channel 16, kernel size 1, stride 1, padding 0, max pooling stride 5; DWC_B4 Input channel 1, output channel 8, kernel size 5, stride 2, padding 2, max pooling stride 2; DWC_B5 Input channel 8, output channel 16, kernel size 5, stride 2, padding 2, max pooling stride 2; DWC_B6 Input channel 16, output channel 16, kernel size 1, stride 1, padding 0, max pooling stride 5;
[0126] For input data with a sample size of 1200, the feature size after passing through a multi-scale residual convolutional network is 16×15.
[0127] 4.2) Design and Construction of a Lightweight ViT Network: The output features DWC_N(ipt) of the multi-scale separable convolutional network are transposed, exchanging the last two dimensions of the features. Then, the transposed features are used as input to the lightweight ViT network. The specific design steps are as follows:
[0128] 4.2.1) Generating Patch Embedding: Transpose DWC_N(ipt) to obtain the patch, and then perform a linear transformation on the patch to obtain the patch embedding; the transpose process is shown in equation (11):
[0129] DWC_N(ipt)[a,b]=DWC_N(ipt)[b,a] (11)
[0130] Where DWC_N(ipt)[a,b] represents the data in the a-th row and b-th column of DWC_N(ipt), and DWC_N(ipt)[b,a] represents the data in the b-th row and a-th column of DWC_N(ipt);
[0131] The linear transformation process is shown in equation (12):
[0132] Patch_emb = DWC_N(ipt) T ·Wp (12)
[0133] Wherein, DWC_N(ipt) T W represents the transpose of DWC_N(ipt). p Represents the linear transformation weight matrix;
[0134] 4.2.2) Generate embedding vector: Concatenate a learnable classification token of the same size as the patch vector before the patch sequence, then generate a learnable position embedding, and add the position embedding to the patch embedding; the process is shown in equation (13):
[0135] Emb=Concat(cls_token,Patch)+pos (13)
[0136] Where Concat(·) represents the vector concatenation function, cls_token represents the classification token, and pos represents the position embedding;
[0137] 4.2.3) Multi-head self-attention mechanism layer: The multi-head self-attention mechanism can extract features from multiple different perspectives and obtain long-distance dependency information;
[0138] First, the query vector Q, key vector K, and value vector V are obtained through linear transformation, as shown in equation (14):
[0139]
[0140] Among them, Q h K h V h Let Q represent the query vector, K represent the key vector, and V and W represent the value vectors of the h-th group, respectively. h Q W h K and W h V Let H represent the weight matrix of the western linear transformation, and let H represent the number of heads, which is set to 2 in this invention;
[0141] Next, the dot product of the query vector and the key vector is calculated to obtain the attention value, and the attention value is normalized using the softmax function to obtain the attention weight; as shown in Equation (15):
[0142]
[0143] Where, d k Indicates the size of the key vector dimension. The scaling factor represents the size of the dot product; by introducing The model assigns different weights to each embedding vector, which strengthens the model's focus on important features while weakening the influence of unimportant features;
[0144] Next, the result of Equation (15) is linearly transformed to obtain the final output of the multi-head attention mechanism; the calculation process is shown in Equation (16):
[0145]
[0146] Among them, W O Represents the linear transformation weight matrix;
[0147] Finally, the calculation results are layer normalized and residually connected with the input to complete the calculation part of the multi-head self-attention mechanism, as shown in Equation (17):
[0148] Emb′=MSA(LN(Emb))+Emb (17)
[0149] Where LN(·) represents layer normalization;
[0150] 4.2.4) Feedforward network layer: Consists of two linear layers and a nonlinear activation function, used to increase the model's nonlinear processing capability and feature representation capability; the calculation process is shown in equation (18):
[0151]
[0152] in, Let represent the weight matrix of the fully connected layer. The linear transformation inflation rate is set to 3. GELU(·) represents the GELU activation function, and the calculation formula is shown in equation (19).
[0153]
[0154] Finally, the calculation results are normalized and residually connected to the input to complete the feedforward network layer; this process is shown in equation (20):
[0155] Encoder out =MLP(LN(Emb′))+Emb′ (20)
[0156] Among them, Encoder out This represents the output characteristics of the feedforward network layer.
[0157] 4.3) Design and construct the classifier: The classifier classifies the extracted features and consists of a linear transformation layer and a softmax function; the calculation process of the linear transformation part is shown in equation (21):
[0158]
[0159] in, Encoder out The classification token in the first vector, W cls Represents the weight matrix;
[0160] Then, the probability of the current sample being a certain fault type can be obtained by processing the linear transformation result with the softmax function. The fault probability calculation formula is shown in equation (22):
[0161]
[0162] Among them, y class represents the i-th value of y, i.e., the probability of the i-th class, and CLASS represents the total number of classes.
[0163] 5) Train and test the model designed in 4) using test datasets with different levels of noise to verify the model's performance;
[0164] The designed model was trained and tested using datasets with different levels of noise, with accuracy and cross-entropy loss as the evaluation criteria; the accuracy calculation formula is shown in equation (23):
[0165]
[0166] Where, num right num represents the number of correctly classified samples in the dataset. all Let represent the total number of samples in the dataset. The formula for calculating the cross-entropy loss is shown in equation (24):
[0167]
[0168] Where samplei represents the i-th sample in the dataset, p(sample i ) represents the label value of the sample, q(sample) i ) represents the value predicted by the model.
[0169] 6) Fault diagnosis: Collect acceleration signals generated in the actual industrial production environment, use the model obtained in step 4) to perform fault diagnosis, and classify the fault signal types.
[0170] Example 1:
[0171] I. Theoretical basis of the present invention:
[0172] 1. Depthwise Separable Convolution (DSC)
[0173] In traditional convolutional neural networks, convolutional layers extract features by sliding multiple convolutional kernels across the input feature map, a process involving numerous multiplication and addition operations. As model depth and complexity increase, the computational cost and number of parameters for this standard convolutional operation grow rapidly, limiting the model's application in resource-constrained environments. Depthwise separable convolution aims to alleviate this limitation by breaking down this complex operation into simpler sub-operations.
[0174] Depthwise separable convolution is an efficient type of convolution that breaks down the standard convolution operation into depthwise convolution and pointwise convolution, thus significantly reducing the computational complexity and number of parameters in the model. This approach is particularly popular in deep learning applications on mobile and embedded devices, where computing resources and storage capacity are often limited. The computational process of depthwise separable convolution is detailed below, and its effectiveness in reducing computational cost and parameter count is analyzed.
[0175] First, in depthwise convolution, each input channel is independently convolved with its corresponding kernel. This means that if the input feature map has M channels, there will be M kernels, each with a size of K×K×1. Therefore, this step does not change the number of channels; it only extracts features in the spatial dimension.
[0176] Then, pointwise convolutions use 1×1 kernels to convolve over the output of depthwise convolutions, aiming to combine features from different input channels and potentially change the number of channels in the output feature map. If the goal is to output N channels, N 1×1 kernels will be used.
[0177] To compare the efficiency of depthwise separable convolution with that of traditional convolution, we will analyze their computational cost and parameter count. In traditional convolution, if the size of the input feature map is D... F ×D F If the number of channels is M, the kernel size is K×K, and the number of output channels is N, then the number of parameters is K×K×M×N, and the computational cost (number of multiplication and addition operations) is D. F ×D F ×K×K×M×N. In depthwise separable convolution, the number of parameters in depthwise convolution is K×K×M, and the computational cost is D. F ×D F The number of parameters in a point convolution is ×K×K×M, and the computational cost is D. F ×D F The total number of parameters is K×K×M+M×N, and the total computational cost is D. F ×D F×M×(K×K+N). Therefore, the number of parameters and computational cost of traditional convolution are K×K×N / K×K+N times that of separable convolution.
[0178] 2. Multi-head self-attention mechanism
[0179] In natural language processing tasks, capturing dependencies between elements within a sequence is crucial. Self-attention mechanisms achieve this by calculating the dependency weights of each element in the sequence on other elements. Multi-head self-attention mechanisms further extend this concept, allowing the model to learn information in parallel across different representation subspaces, thereby improving the model's ability to capture complex dependencies. The computational process of multi-head self-attention is detailed below.
[0180] First, for a size of The input is mapped through a linear transformation to multiple sets of query, key, and value vectors, with each set of vectors corresponding to the Q-value of each head. i K i V i .
[0181] Next, attention weights are calculated for each head separately, and the weights are multiplied by the values. The result combined with the attention weights is expressed as:
[0182]
[0183] Where softmax(·) represents the softmax function, d k This indicates the dimension of the Ki vector.
[0184] Then, the outputs of all the heads are concatenated and linearly transformed to obtain the final output of the multi-investment attention mechanism:
[0185] MultiHead(X)=Concat(O1,O2,…,O h W o
[0186] Where h represents the number of heads, W o This represents the weights for the linear transformation.
[0187] Multi-head self-attention enhances a model's ability to capture complex dependencies within a sequence by learning representations of the input sequence in parallel across different subspaces. Its design allows the model to capture information in different representation subspaces, improving its expressive power and learning efficiency. This mechanism has been widely adopted in the Transformer architecture, significantly advancing the field of natural language processing.
[0188] II. Implementation process of the technical solution of the present invention:
[0189] 1. Collect bearing vibration signals: Use an accelerometer to collect signals emitted by bearings with different fault types during rotation. That is, collect the signal for a period of time for each type of fault. There are 9 types of faults and 1 type of normal signal, and a total of 10 signal segments are collected.
[0190] 2. Data Augmentation: The number of samples is increased using the moving window method. The moving window size is set to 1200, the sample length is set to 1200, and each class of data contains 60 training samples and 40 test samples. There is no overlap between the training set and the test set.
[0191] 3. Generate corresponding datasets based on different signal-to-noise ratios: Divide the data obtained in 2) into samples to obtain the original dataset, and then generate six datasets with different noise conditions: signal-to-noise ratios of -2, 0, 2, 4, 6, and no noise.
[0192] 4. The neural network was trained using the dataset, and the results for each dataset, namely the accuracy and loss value, were recorded. The results are shown in Table 1. As can be seen from Table 1, the method designed in this invention can accurately identify the fault type under noise-free conditions. Although the accuracy decreases slightly when the signal-to-noise ratio is 6, 4, 2, 0, or -2, it still maintains a high accuracy, demonstrating the effectiveness and noise resistance of this method. Figure 2 , Figure 3 The curves show the changes in accuracy and loss value as the signal-to-noise ratio changes.
[0193] Table 1 Comparison of Accuracy and Loss Values under Different Noise Conditions
[0194]
[0195] This invention aims to propose an effective fault diagnosis method, namely a lightweight ViT fault diagnosis method combining multi-scale convolution. First, this method uses multi-scale depthwise separable convolution for feature extraction. Compared to traditional convolution, depthwise separable convolution reduces the number of parameters and computational cost, helping to accelerate model computation and reduce resource consumption. Simultaneously, using a multi-scale approach for feature extraction improves the model's resilience and robustness. Then, the designed lightweight ViT network is used to perform feature extraction that integrates global information, thereby improving the accuracy of the diagnostic model.
[0196] Experimental results show that the diagnostic model designed in this invention has higher accuracy and noise resistance than the original ViT method. The comparison results are shown in Table 3.
[0197] Table 2 Comparison of Accuracy and Resilience with the Original ViT Model
[0198]
[0199] Experimental results show that the proposed lightweight ViT fault diagnosis method combining multi-scale convolution is effective and can be widely applied in practical applications.
Claims
1. A lightweight ViT fault diagnosis method combining multi-scale convolution, characterized in that, The steps are as follows: Step 1) Collect bearing vibration signals: Use an accelerometer to collect signals emitted by bearings with different fault types during rotation. That is, collect the signal for each type of fault over a period of time. If there are t types of faults, then collect t segments of signals. Step 2) Data augmentation: Increase the number of samples using the moving window method; Step 3) Generate corresponding datasets based on different signal-to-noise ratios: Divide the data obtained in step 2) into samples to obtain the original dataset, and then generate datasets for six different noise conditions with signal-to-noise ratios of -2, 0, 2, 4, 6 and no noise respectively. Step 4) Design and build a lightweight ViT fault diagnosis model that combines multi-scale convolution: Use a multi-scale depthwise separable convolutional network to extract signal features and transform the original signal samples into embedding vectors so that the original signals can be processed later; then, use a lightweight ViT network to obtain the self-attention values between each embedding vector, thereby extracting feature vectors in the global receptive field. Finally, the output features of the lightweight ViT network are input into the classifier to calculate the fault category; Step 4.1) Design and construct a multi-scale separable convolutional network: The normalized signal... The input multi-scale separable convolutional layer extracts features, and the specific design is as follows: Step 4.1.1) Depthwise Convolution: Depthwise convolution pairs Each input channel is convolved sequentially. The dimensionality of the feature space is varied by using different convolution kernels and strides, as will be discussed later. This represents the feature tensor input to a multi-scale depthwise separable convolutional network, used as input. No. Taking the features of a single channel as an example, the depthwise convolution formula is expressed as shown in equation (6). (6) in, This indicates the number of steps the convolution kernel has taken. Indicates the number of border padding elements. Indicates the stride of the convolution kernel. This indicates the kernel size in the depthwise convolution process. Represents depthwise convolution kernel No. The value at each position, Indicates input No. The value of the position, Indicates the convolution kernel number 1 The results of depthwise convolution calculation are then performed. Step 4.1.2) Pointwise convolution: Enables cross-channel feature extraction without changing the feature map size; pointwise convolution connected after depthwise convolution is used to change the number of feature channels, by setting... A convolutional kernel of size 1 is used for cross-channel computation, thereby transforming the feature channel output into... One, of which Indicates the number of output channels, starting with the first channel. Taking one output channel as an example, the point convolution formula is shown in equation (7): (7) in, Represents the point convolution. The result of the step, This represents a convolution kernel of size 1. This represents the depthwise convolution result in step 4.1.1). Represents depthwise convolution aisle The value of the position; Step 4.1.3) Construct depthwise separable convolutional blocks and design detailed network parameters: Each block contains depthwise separable convolutional layers, max pooling layers, activation functions, and dropout layers; the specific process is shown in Equation (8): (8) in, This represents the output of the separable convolutional block at the current depth. This indicates a depthwise separable convolutional layer. This represents the max pooling layer, and DP represents the dropout layer. Let LeakyReLU be the activation function, as shown in equation (9): (9) in, This represents the function that takes the maximum value. This is a hyperparameter, set to 0.01; Multi-scale depthwise separable convolutional networks are composed of depthwise separable convolutional blocks with different parameters. The specific network structure is shown in Equation (10): (10) in, and These represent two depthwise separable convolutional paths. This indicates depthwise separable convolutional blocks with different parameters; the specific parameters are set as follows: Input channel 1, output channel 8, kernel size 9, stride 4, padding 4, max pooling stride 4; Input channels: 8; Output channels: 16; Kernel size: 1; Stride size: 1; Padding: 0; No max pooling layers. Input channel 16, output channel 16, kernel size 1, stride 1, padding 0, max pooling stride 5; Input channel 1, output channel 8, kernel size 5, stride 2, padding 2, max pooling stride 2; Input channels: 8; Output channels: 16; Kernel size: 5; Convolution stride: 2; Padding: 2; Max pooling stride:
2. Input channel 16, output channel 16, kernel size 1, stride 1, padding 0, max pooling stride 5; For input data with a sample size of 1200, the feature size after passing through the multi-scale residual convolutional network is 16×15; Step 4.2) Design and construct a lightweight ViT network: Utilize the output features of a multi-scale separable convolutional network Perform a transpose operation, swapping the last two dimensions of the features; then, use the transposed features as input to the lightweight ViT network. The specific design steps are as follows: Step 4.2.1) Generate patch embedding: Perform a transpose operation to obtain a patch, and then perform a linear transformation on the patch to obtain the patch embedding; the transpose process is shown in equation (11): (11) in, express No. Line 1 The data in the column, express No. Line 1 Column data; The linear transformation process is shown in equation (12): (12) in, express The transpose of the matrix, Represents the linear transformation weight matrix; Step 4.2.2) Generate embedding vector: Concatenate a learnable classification token of the same size as the patch vector before the patch sequence, then generate a learnable position embedding, and add the position embedding to the patch embedding; the process is shown in equation (13): (13) in, This represents a vector concatenation function. Indicates a category token. Indicates positional embedding; Step 4.2.3) Multi-head self-attention mechanism layer: The multi-head self-attention mechanism can extract features from multiple different perspectives and obtain long-distance dependency information; First, the query vector is obtained through linear transformation. key vector value vector The specific process is shown in equation (14): (14) in, , , They represent the first Group query vector key vector value vector , , and Represents the weight matrix of the western linear transformation. The number of the first item is set to 2; Next, the dot product of the query vector and the key vector is calculated to obtain the attention value, and the attention value is normalized using the softmax function to obtain the attention weight; as shown in Equation (15): (15) in, Indicates the size of the key vector dimension. The scaling factor represents the size of the dot product; by introducing The model assigns different weights to each embedding vector, which strengthens the model's focus on important features while weakening the influence of unimportant features. Next, the result of Equation (11) is linearly transformed to obtain the final output of the multi-head attention mechanism; the calculation process is shown in Equation (16): (16) in, Represents the linear transformation weight matrix; Finally, the calculation results are layer normalized and residually connected with the input to complete the calculation part of the multi-head self-attention mechanism, as shown in Equation (17): (17) in, Representation layer normalization; Step 4.2.4) Feedforward network layer: Consists of two linear layers and a nonlinear activation function, used to increase the model's nonlinear processing capability and feature representation capability; the calculation process is shown in equation (18): (18) in, , This represents the weight matrix of the fully connected layer, and the linear transformation inflation rate is set to 3. Let represent the GELU activation function, and its calculation formula is shown in equation (19): (19) Finally, the calculation results are normalized and residually connected to the input to complete the feedforward network layer; this process is shown in equation (20): (20) in, This represents the output features of the feedforward network layer; Step 4.3) Design and construct the classifier: The classifier classifies the extracted features and consists of a linear transformation layer and a softmax function; the calculation process of the linear transformation part is shown in Equation (21): (21) in, express The category token in the first vector. Represents the weight matrix; Then, by applying the softmax function to the linear transformation result, the probability of the current sample belonging to a certain fault type can be obtained. The formula for calculating the fault probability is: (22) in, express The The value, that is, the first value. The probability of a class Indicates the total number of categories; Step 5) Train and test the model designed in Step 4) using test datasets with different levels of noise to verify the model's performance; Step 6) Fault diagnosis: Collect acceleration signals generated in the actual industrial production environment, use the model obtained in step 4) to perform fault diagnosis, and classify the fault signal types.
2. The lightweight ViT fault diagnosis method combining multi-scale convolution as described in claim 1, characterized in that, In step 2): The sliding window method is used to augment the data, assuming the signal length is... The sliding step size is The sample length is Then for the first Class of faults, number of samples that can be generated As shown in equation (1): (1) Calculate the number of samples that can be generated for each data segment, and then divide the samples as shown in Equation (2): (2) in, express Type 1 fault signal, Indicates the first The first type of fault signal One sample.
3. The lightweight ViT fault diagnosis method combining multi-scale convolution as described in claim 1, characterized in that, In step 3): Step 3.1) Add noise to the obtained dataset to generate six datasets with signal-to-noise ratios of -2, 0, 2, 4, 6, and no noise, respectively; the specific operation of adding noise is shown in equation (3): (3) in, For the generated noise, For randomly generated and Tensors with the same dimensions and conforming to a standard normal distribution have an SNR (signal-to-noise ratio). Step 3.2) Normalize the noisy dataset, transforming the values into a normal distribution with a mean of 0 and a variance of 1: Step 3.2.1) Calculate the mean and standard deviation of the data, as shown in formula (4): (4) in, for The mean, for standard deviation This represents the summation of the element-values of a tensor. Step 3.2.2) Standardize the data using formula (5): (5) in, Samples of the original signal. This is the standardized sample.
4. The lightweight ViT fault diagnosis method combining multi-scale convolution as described in claim 1, characterized in that, In step 5): The designed model was trained and tested using datasets with different levels of noise, with accuracy and cross-entropy loss as the evaluation criteria; the accuracy calculation formula is shown in equation (23): Where, num right num represents the number of correctly classified samples in the dataset. all Let represent the total number of samples in the dataset. The formula for calculating the cross-entropy loss is shown in equation (24): in, Represents the first in the dataset One sample, This represents the label value of the sample. This represents the value predicted by the model.
