Unbalanced sample fault diagnosis method and device based on SMOTE and improved generative adversarial network, and electronic equipment
Through the SMOTE algorithm and the improved generative adversarial network, combined with self-attention mechanism and layer normalization, the diagnostic performance degradation caused by unbalanced fault data is solved, and the accuracy of fault diagnosis and model performance is improved.
Patent Information
- Application Number
- CN202411232777.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-04
- Publication Date
- 2025-01-03
AI Technical Summary
The existing technology is difficult to effectively process unbalanced fault data, resulting in the performance of deep learning networks deteriorating in fault diagnosis, especially in fault diagnosis of mechanical equipment, data in health status dominates, and there is less fault data, resulting in a tendency of classifiers. In most categories, it affects the accuracy of diagnosis.
Some fault samples are synthesized using the SMOTE algorithm, and an improved generative adversarial network is built, self-attention mechanism and layer normalization are introduced, the number and diversity of fault samples are enhanced, and distribution characteristics are learned by generating the adversarial network model to generate high-quality balance. Samples were diagnosed.
It effectively reduces the imbalance ratio, enables the generative adversarial network model to learn more distributed characteristics, improves the accuracy of fault diagnosis and model performance, and significantly improves the diagnostic ability under imbalance samples.
Smart Images

Figure CN119250131A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of mechanical engineering automation, and relates to an unbalanced sample fault diagnosis method, device and electronic equipment based on SMOTE and an improved generative adversarial network. Background Art
[0002] In the modern society with the development of science and technology, high-tech products are more and more widely used in aviation, aerospace and other industries, but their manufacturing process is inseparable from the mechanical processing manufacturing industry. CNC machine tools can process precision components of various shapes with their own characteristics, and have become the core of the mechanical processing manufacturing industry. Due to the harsh processing environment of CNC machine tools, the frequency of failure of their parts is very high, so it is necessary to diagnose the faults of CNC machine tool parts.
[0003] With the rapid expansion of the industrial Internet, the massive data generated by large and complex mechanical equipment can be easily collected. Effective fault diagnosis technology can avoid significant losses caused by faults and ensure the safety and reliability of mechanical equipment by timely detecting faults. Since traditional fault diagnosis methods have difficulty in processing multi-source and heterogeneous equipment fault data, data-driven fault diagnosis methods have received widespread attention. However, most of the research on data-driven fault diagnosis is based on balanced training data, that is, the number of samples in different categories is similar. However, in actual engineering, a large number of mechanical equipment are in a healthy state, and the fault state only accounts for a small part of their life cycle, which results in most of the data actually collected being normal, with only a small amount of fault data. This data imbalance will cause the classifier to tend to the majority class, resulting in a decline in its performance, which seriously affects the accuracy of fault diagnosis. At present, most of the research on data-driven fault diagnosis is based on balanced training data, that is, there are the same number of samples in different categories. For example, the patent number is CN202410931759.5, and the patent entitled "Planetary Gearbox Fault Diagnosis Method and Device Based on Improved Loss Function" submitted by Zhang Jian proposes a method for fault diagnosis of planetary gearboxes. However, in actual engineering, most mechanical equipment works in a healthy state, and the fault state only accounts for a small part of its life cycle, resulting in most of the data actually collected being normal, with only a small amount of fault data. This data imbalance makes the training of deep learning networks pay more attention to majority class samples, and the feature learning of minority class samples is incomplete, thereby deteriorating the ability to fit training samples, which seriously affects the accuracy of fault diagnosis. Therefore, there is an urgent need for an unbalanced sample fault diagnosis method, device and electronic device based on SMOTE and an improved generative adversarial network. Summary of the invention
[0004] The purpose of the present invention is to overcome the defects of the prior art and provide an imbalanced sample fault diagnosis method, device and electronic device based on SMOTE and improved generative adversarial network, which can solve the problem that the diagnostic model will focus on the classification of majority class samples under sample imbalance, resulting in its performance degradation.
[0005] To solve the above problems, the present invention adopts the following technical solutions.
[0006] The present invention provides an unbalanced sample fault diagnosis method, device and electronic device based on SMOTE and improved generative adversarial network, comprising the following steps:
[0007] S1, fault sample preprocessing stage: use SMOTE to synthesize some fault samples to increase the number and diversity of fault samples;
[0008] S2, fault sample generation stage: construct a generative adversarial network, introduce the self-attention mechanism and layer normalization into it, input the fault samples synthesized by SMOTE and the collected fault samples into the improved generative adversarial network to enhance the fault samples;
[0009] S3, fault diagnosis stage: input the enhanced balanced samples into the diagnosis model to output the diagnosis results.
[0010] Specifically, in step S1, the process of synthesizing some fault samples using SMOTE includes:
[0011] First, we set the imbalance ratio of synthetic samples to real samples and determine the number of samples synthesized using SMOTE. Then, we randomly select a minority class sample x from the minority class sample set X. i , calculate the other samples in the minority class sample set X to x i The Euclidean distance of x is calculated and the k-nearest neighbor algorithm is used to search for x i The nearest neighbor samples of j ; Then according to the interpolation formula at x i and x j Interpolate between to get the synthetic sample x new ; Finally, repeat the above steps to obtain enough synthetic samples; the interpolation formula is:
[0012] x new =x i +rand(0,1)*(x j -x i )
[0013] Where rand(0,1) represents a random number between 0 and 1.
[0014] Specifically, in step S2, the process of constructing a generative adversarial network includes:
[0015] S2.1.1. Input the noise z that obeys the Gaussian distribution into the generator G, so that it generates a set of false samples G(z);
[0016] S2.1.2. Input G(z) and the real sample x into the discriminator D to determine whether the input data is a real sample;
[0017] S2.1.3. Through the gradient information fed back by the discriminator D, the generator G will try its best to learn the distribution of real samples and generate false samples that are very close to the real samples to deceive the discriminator D, while the discriminator D will also try its best to prevent itself from being deceived;
[0018] S2.1.4, the generator G and the discriminator D alternately iterate and optimize the parameters until the discriminator D cannot determine whether the input data is a real sample. At this time, the final objective function of the generative adversarial network is:
[0019]
[0020] Where x~P data Indicates that the real sample x obeys the probability distribution P data , z~P z Indicates that the noise z follows the prior distribution P z , E represents mathematical expectation, and D(x) represents the output of the discriminator D;
[0021] S2.1.5. In order to solve the problem of unstable training of generative adversarial networks, Wasserstein distance is used instead of JS divergence and KL divergence:
[0022]
[0023] Where sup represents the minimum upper bound, ||f|| L ≤1 means that the function f(x) satisfies 1-Lipschitz continuity;
[0024] S2.1.6. In order to solve the problem of gradient vanishing and gradient exploding in the generative adversarial network, the gradient penalty strategy is used instead of weight clipping. At this time, the loss function of the discriminant model is:
[0025]
[0026] in represents a random sample, ζ obeys a uniform distribution in the interval [0,1], λ represents a penalty factor, and ▽ represents a gradient operator.
[0027] Specifically, in step S2, the process of introducing the self-attention mechanism in the generative adversarial network includes:
[0028] S2.2.1. The feature map x after convolution mapping is converted into feature space f, g, h through linear mapping, which are called Query, Key, and Value respectively, as shown below:
[0029] f(x)=W f x
[0030] g(x)=W g x
[0031] h(x)=W h x
[0032] in are all weight matrices, which are constantly updated during the training process. C is the input channel. is the output channel;
[0033] S2.2.2.2. Calculate the attention score s using the transposed f and g i,j , usually calculated using dot multiplication:
[0034] s i,j =f T g
[0035] Where T represents transpose;
[0036] S2.2.3, apply the softmax function to normalize and get α i,j :
[0037]
[0038] Among them, the subscript i,j indicates the model's attention to the i-th position when synthesizing the j-th region;
[0039] S2.2.4. Calculate the output o of the self-attention layer j :
[0040] v(x i )=W v x i
[0041]
[0042] in It is related to W f ,W g ,W h The weight matrix is also constantly updated;
[0043] S2.2.5. In order to ensure the quality of the self-attention layer output, the output o j After linear transformation, the final output is as follows:
[0044] yi =γo j +x i
[0045] Where γ is the scale parameter, x i is the input vector.
[0046] Furthermore, in step S2, the specific process of introducing layer normalization in the generative adversarial network includes:
[0047] S2.3.1. Calculate the mean μ of the lth layer l and variance σ l :
[0048]
[0049] Where H is the number of neurons in a layer, is the i-th neuron in the l-th layer;
[0050] S2.3.2. Calculate the normalized value
[0051]
[0052] Where ε represents a very small number;
[0053] S2.3.3. The normalized value Perform a linear transformation:
[0054]
[0055] Where β is the translation variable.
[0056] The present invention provides an unbalanced sample fault diagnosis device based on SMOTE and improved generative adversarial network, comprising:
[0057] The preprocessing module is used to synthesize some fault samples using SMOTE to enhance the number and diversity of fault samples. First, the imbalance ratio after combining the synthetic samples with the real samples is set to determine the number of samples synthesized using SMOTE. Then, a minority class sample x is randomly selected from the minority class sample set X. i , calculate the other samples in the minority class sample set X to x i The Euclidean distance of x is calculated and the k-nearest neighbor algorithm is used to search for x i The nearest neighbor samples of j ; Then according to the interpolation formula at x i and x j Interpolate between to get the synthetic sample x new ; Finally, repeat the above steps to obtain enough synthetic samples; the interpolation formula is: x new=x i +rand(0,1)*(x j -x i ), where rand(0,1) represents a random number between 0 and 1;
[0058] The generation module is used to construct a generative adversarial network, and introduces the self-attention mechanism and layer normalization into it, and inputs the fault samples synthesized by SMOTE and the collected fault samples into the improved generative adversarial network for fault sample enhancement; wherein, the process of constructing the generative adversarial network includes: inputting the noise z obeying the Gaussian distribution into the generator G, so that it generates a set of false samples G(z); inputting G(z) and the real sample x into the discriminator D to judge whether the input data is a real sample; through the gradient information fed back by the discriminator D, the generator G will learn the distribution of the real sample as much as possible, and generate false samples that are very close to the real sample to deceive the discriminator D, and the discriminator D will also try to prevent itself from being deceived; the generator G and the discriminator D alternately iterate and optimize the parameters until the discriminator D cannot judge whether the input data is a real sample. At this time, the final objective function of the generative adversarial network is: x~P data Indicates that the real sample x obeys the probability distribution P data , z~P z Indicates that the noise z follows the prior distribution P z , E represents mathematical expectation, D(x) represents the output of the discriminator D; in order to solve the problem of unstable training of generative adversarial networks, Wasserstein distance is used instead of JS divergence and KL divergence: sup represents the minimum upper bound, ||f|| L ≤1 means that the function f(x) satisfies 1-Lipschitz continuity. In order to solve the problem of gradient vanishing and gradient exploding in the generative adversarial network, the gradient penalty strategy is used instead of weight clipping. At this time, the loss function of the discriminant model is:
[0059] represents a random sample, ζ follows a uniform distribution in the interval [0,1], λ represents a penalty factor, and ▽ represents a gradient operator;
[0060] The diagnosis module is used to input the enhanced balanced samples into the diagnosis model to output the diagnosis results.
[0061] An electronic device of the present invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the method, device and electronic device for diagnosing unbalanced samples based on SMOTE and improved generative adversarial network are implemented as described above.
[0062] A non-transitory computer-readable storage medium of the present invention stores a computer program thereon, and when the computer program is executed by a processor, the method, device and electronic device for diagnosing unbalanced sample faults based on SMOTE and an improved generative adversarial network as described above are implemented.
[0063] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0064] 1. The present invention introduces the SMOTE algorithm to synthesize some fault samples, uses the generative adversarial network model to further enhance the fault samples, reduces the imbalance ratio through the SMOTE algorithm, and enables the generative adversarial network model to learn more distribution features, thereby further enhancing the ability of the generative adversarial network model to generate samples.
[0065] 2. The present invention introduces self-attention mechanism and layer normalization, improves the generative adversarial network model, and solves the problem of unbalanced fault diagnosis by generating high-quality samples.
[0066] 3. The present invention adopts a more comprehensive evaluation framework to evaluate the quality of samples generated by the proposed method from different aspects, such as sample similarity, fault diagnosis accuracy under different balance rates, and quantitative indicators between two samples. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] Figure 1 It is a flowchart of an embodiment of the imbalanced sample fault diagnosis method, device and electronic device based on SMOTE and improved generative adversarial network of the present invention.
[0068] Figure 2 It is an overall framework of an imbalanced sample fault diagnosis method, device and electronic device based on SMOTE and improved generative adversarial network of the present invention.
[0069] Figure 3a It is the time domain signal of the real fault data of the present invention.
[0070] Figure 3b It is the time domain signal of the generated data of the present invention.
[0071] Figure 4a It is the frequency domain signal of the real fault data of the present invention.
[0072] Figure 4b It is the frequency domain signal of the generated data of the present invention. DETAILED DESCRIPTION
[0073] The present invention provides an unbalanced sample fault diagnosis method, device and electronic device based on SMOTE and improved generative adversarial network, including: firstly, using SMOTE to synthesize some fault samples to enhance the number and diversity of fault samples; then constructing a generative adversarial network, and introducing a self-attention mechanism and layer normalization therein, inputting the fault samples synthesized by SMOTE and the collected fault samples into the improved generative adversarial network for fault sample enhancement; finally, inputting the enhanced balanced samples into the diagnosis model to output the diagnosis result. The present invention can effectively solve the problem that the diagnosis model will focus on the classification of the majority class samples under sample imbalance, resulting in its performance degradation, and its fault diagnosis accuracy is high, and it has broad application prospects.
[0074] The present invention will be further described in detail below in conjunction with the accompanying drawings.
[0075] Figure 1 is a flow chart of an embodiment of the imbalanced sample fault diagnosis method, device and electronic device based on SMOTE and improved generative adversarial network of the present invention, such as Figure 1 As shown, the method of this embodiment includes the following steps:
[0076] S1, fault sample preprocessing stage: use SMOTE to synthesize some fault samples to increase the number and diversity of fault samples;
[0077] S2, fault sample generation stage: construct a generative adversarial network, introduce the self-attention mechanism and layer normalization into it, input the fault samples synthesized by SMOTE and the collected fault samples into the improved generative adversarial network to enhance the fault samples;
[0078] S3, fault diagnosis stage: input the enhanced balanced samples into the diagnosis model to output the diagnosis results;
[0079] According to step S1, using SMOTE to synthesize some fault samples to enhance the number and diversity of fault samples specifically includes:
[0080] S1.1. Determine the number of synthetic samples: Set the imbalance ratio after combining synthetic samples with real samples, and determine the number of samples synthesized using SMOTE;
[0081] S1.2. Synthetic sample: Randomly select a minority class sample x from the minority class sample set X i , calculate the other samples in the minority class sample set X to x i The Euclidean distance of x is calculated and the k-nearest neighbor algorithm is used to search for x i The nearest neighbor samples of j ; Next, according to the interpolation formula, i and x jInterpolate between to get the synthetic sample x new ; Finally, repeat the above steps to obtain enough synthetic samples. In the implementation of the SMOTE algorithm, three nearest neighbor samples (k=3) were selected for interpolation, which is based on the experimental results of data distribution and the common choice in the literature. The size of the k value directly affects the balance between the diversity of synthetic samples and model performance. A smaller k value can prevent the synthetic samples from being overly biased towards the original minority class samples while maintaining the diversity of the data; the interpolation formula is:
[0082] x new =x i +rand(0,1)*(x j -x i )
[0083] Here rand(0,1) represents a random number between 0 and 1. This avoids the situation where the generated samples are too close to the original samples, helps to enhance the diversity of the generated samples, and ensures that the samples are more widely distributed.
[0084] In the embodiment of the present invention, a bearing data set of Case Western Reserve University in the United States is selected. The test equipment consists of a 2-horsepower motor, a torque sensor, a power tester and an electronic controller. The test bearing is an SKF6205 deep groove ball bearing with a sampling frequency of 12kHz. Single-point faults (inner ring fault, outer ring fault and rolling element fault) are introduced into the test bearing by electrospark machining, and the fault sizes are 0.1778mm, 0.3556mm and 0.5334mm respectively, plus the normal state, for a total of ten states. Each state contains 550 samples, 500 of which are randomly selected as training sets, and the remaining 50 are used as test sets. Each sample contains 1024 data points. In order to simulate the data imbalance scenario, four groups of experiments are designed, namely, groups A, B, C, and D. In the experiment of group A, the imbalance ratio is set to 1:100, that is, there are 5 samples for each fault state and 500 samples for the normal state. The imbalance ratios of groups B and C are set to 1:50 and 1:25, respectively. Group D is the same as Group A, except that data augmentation is not used. See Table 1 for detailed data division.
[0085] Table 1 Experimental data division
[0086]
[0087] According to step S2, a generative adversarial network is constructed, and a self-attention mechanism and layer normalization are introduced therein. The specific steps of inputting the fault samples synthesized by SMOTE and the collected fault samples into the improved generative adversarial network for fault sample enhancement include:
[0088] S2.1, build a generative adversarial network;
[0089] The construction of the generative adversarial network in this step specifically includes:
[0090] S2.1.1. Input the noise z that obeys the Gaussian distribution into the generator G, so that it generates a set of false samples G(z);
[0091] S2.1.2. Input G(z) and the real sample x into the discriminator D to determine whether the input data is a real sample;
[0092] S2.1.3. Through the gradient information fed back by the discriminator D, the generator G will try its best to learn the distribution of real samples and generate false samples that are very close to the real samples to deceive the discriminator D, while the discriminator D will also try its best to prevent itself from being deceived;
[0093] S2.1.4, the generator G and the discriminator D alternately iterate and optimize the parameters until the discriminator D cannot determine whether the input data is a real sample. The generator consists of 4 convolutional layers and 2 fully connected layers. The number of filters in each convolutional layer is 64, 128, 256 and 512 respectively. Leaky ReLU is used as the activation function, which can effectively prevent the gradient disappearance problem. The discriminator consists of 3 convolutional layers and 1 fully connected layer. The output layer uses the Sigmoid activation function for binary classification. At this time, the final objective function of the generative adversarial network is:
[0094]
[0095] Where x~P data Indicates that the real sample x obeys the probability distribution P data , z~P z Indicates that the noise z follows the prior distribution P z , E represents mathematical expectation, and D(x) represents the output of the discriminator D;
[0096] S2.1.5. In order to solve the problem of unstable training of generative adversarial networks, Wasserstein distance is used instead of JS divergence and KL divergence:
[0097]
[0098] Where sup represents the minimum upper bound, ||f|| L ≤1 means that the function f(x) satisfies 1-Lipschitz continuity;
[0099] S2.1.6. In order to solve the problem of gradient vanishing and gradient exploding in the generative adversarial network, the gradient penalty strategy is used instead of weight clipping. At this time, the loss function of the discriminant model is:
[0100]
[0101] in represents a random sample, ζ obeys a uniform distribution in the interval [0,1], λ represents a penalty factor, and ▽ represents a gradient operator.
[0102] S2.2, introduce self-attention mechanism in generative adversarial network;
[0103] The step of introducing the self-attention mechanism in the generative adversarial network specifically includes:
[0104] S2.2.1. The feature map x after convolution mapping is converted into feature space f, g, h through linear mapping, which are called Query, Key, and Value respectively, as shown below:
[0105] f(x)=W f x
[0106] g(x)=W g x
[0107] h(x)=W h x
[0108] in are all weight matrices, which are constantly updated during the training process. C is the input channel. is the output channel;
[0109] S2.2.2.2. Calculate the attention score s using the transposed f and g i,j , usually calculated using dot multiplication:
[0110] s i,j =f T g
[0111] Where T represents transpose;
[0112] S2.2.3, apply the softmax function to normalize and get α i,j :
[0113]
[0114] Among them, the subscript i,j indicates the model's attention to the i-th position when synthesizing the j-th region;
[0115] S2.2.4. Calculate the output o of the self-attention layer j :
[0116] v(x i )=W v x i
[0117]
[0118] in It is related to W f ,W g ,W h The weight matrix is also constantly updated;
[0119] S2.2.5. In order to ensure the quality of the self-attention layer output, the output o j After linear transformation, the final output is as follows:
[0120] y i =γo j +x i
[0121] Where γ is the scale parameter, x i is the input vector.
[0122] S2.3. In order to further capture the global features of the sample, the self-attention mechanism (SA mechanism) is introduced into the generator structure of the generative adversarial network. This mechanism converts the input feature map into Query, Key and Value through linear mapping, calculates the attention score using the inner product between them, and normalizes it through the Softmax function, thereby achieving global attention to the input features;
[0123] The step of introducing layer normalization in the generative adversarial network specifically includes:
[0124] S2.3.1. Calculate the mean μ of the lth layer l and variance σ l :
[0125]
[0126] Where H is the number of neurons in a layer, is the i-th neuron in the l-th layer;
[0127] S2.3.2. Calculate the normalized value
[0128]
[0129] Where ε represents a very small number;
[0130] S2.3.3. The normalized value Perform a linear transformation:
[0131]
[0132] Where β is the translation variable.
[0133] In an embodiment of the present invention, SMOTE and an improved generative adversarial network (GAN) are used to optimize the fault diagnosis model. Specifically, the SMOTE algorithm is first used to synthesize some fault samples to enhance the number and diversity of samples, and then a generative adversarial network is constructed, in which a self-attention mechanism is introduced. In the process of implementing the self-attention mechanism, the generator's attention to global features is gradually increased by controlling the proportional parameter γ, thereby ensuring that the global features of the generated samples are fully learned. The initial γ value is set to 0 and gradually increases as the training progresses. In order to overcome the shortcomings of batch normalization in small-batch sample training, layer normalization (LN) is used instead of batch normalization (BN). LN can normalize the neurons in each layer without relying on the batch size, effectively speeding up the convergence speed of the model while ensuring the stability of the model in small-batch training. The fault samples synthesized by SMOTE and the collected fault samples are input into the improved generative adversarial network for sample enhancement, and finally the enhanced balanced samples are input into the diagnosis model to output the diagnosis results. Among them, the overall framework results are as follows Figure 2 shown.
[0134] In the embodiment of the present invention, in order to prove the effectiveness of the improved generative adversarial network, a qualitative comparison is made between the time domain and frequency domain of the real fault data and the generated samples, as shown in Figures 3 and 4. It can be seen that although there is a small deviation between the real data and the generated samples, the overall trend is consistent and a certain diversity is maintained.
[0135] In the embodiment of the present invention, in order to prove the effectiveness of SMOTE and the improved generative adversarial network (GAN) model, the traditional GAN, ACGAN, and WGAN-GP models are used to diagnose the unbalanced samples, and the diagnosis results are shown in Table 2. Under three different groups of experiments A, B, and C, the SMOTE and improved GAN models used in the present invention have the highest accuracy, especially in the C group experiment, the accuracy of the three comparison methods is 82.6%, 81.5%, and 81.2%, respectively, while the accuracy of the adopted SMOTE and improved GAN models is 92.4%. The experiments show that the method has significant advantages in diagnostic accuracy, adaptability and robustness of the model, and plays an important role in engineering practice.
[0136] Table 2 Fault diagnosis results of four methods in bearing data set
[0137]
Claims
1. A method, device and electronic device for fault diagnosis of imbalanced samples based on SMOTE and improved generative adversarial network, characterized in that: The following steps are involved: S1, fault sample preprocessing stage: use SMOTE to synthesize some fault samples to increase the number and diversity of fault samples; S2, fault sample generation stage: construct a generative adversarial network, introduce the self-attention mechanism and layer normalization into it, input the fault samples synthesized by SMOTE and the collected fault samples into the improved generative adversarial network to enhance the fault samples; S3, fault diagnosis stage: input the enhanced balanced samples into the diagnosis model to output the diagnosis results.
2. According to claim 1, a method, device and electronic device for unbalanced sample fault diagnosis based on SMOTE and improved generative adversarial network, characterized in that: In step S1, the process of synthesizing some fault samples using SMOTE includes: First, we set the imbalance ratio of synthetic samples to real samples and determine the number of samples synthesized using SMOTE. Then, we randomly select a minority class sample x from the minority class sample set X. i , calculate the other samples in the minority class sample set X to x i The Euclidean distance of x is calculated and the k-nearest neighbor algorithm is used to search for x i The nearest neighbor samples of j ; Then according to the interpolation formula at x i and x j Interpolate between to get the synthetic sample x new ; Finally, repeat the above steps to obtain enough synthetic samples; the interpolation formula is: x new =x i +rand(0,1)*(x j -x i ) Where rand(0,1) represents a random number between 0 and 1.
3. The method, device and electronic device for diagnosing imbalanced sample faults based on SMOTE and improved generative adversarial network according to claim 1, characterized in that: In step S2, the specific process of constructing a generative adversarial network includes: S2.1.
1. Input the noise z that obeys the Gaussian distribution into the generator G, so that it generates a set of false samples G(z); S2.1.
2. Input G(z) and the real sample x into the discriminator D to determine whether the input data is a real sample; S2.1.
3. Through the gradient information fed back by the discriminator D, the generator G will try its best to learn the distribution of real samples and generate false samples that are very close to the real samples to deceive the discriminator D, while the discriminator D will also try its best to prevent itself from being deceived; S2.1.4, the generator G and the discriminator D alternately iterate and optimize the parameters until the discriminator D cannot determine whether the input data is a real sample. At this time, the final objective function of the generative adversarial network is: Where x~P data Indicates that the real sample x obeys the probability distribution P data , z~P z Indicates that the noise z follows the prior distribution P z , E represents mathematical expectation, and D(x) represents the output of the discriminator D; S2.1.
5. In order to solve the problem of unstable training of generative adversarial networks, Wasserstein distance is used instead of JS divergence and KL divergence: Where sup represents the minimum upper bound, ||f|| L ≤1 means that the function f(x) satisfies 1-Lipschitz continuity; S2.1.
6. In order to solve the problem of gradient vanishing and gradient exploding in the generative adversarial network, the gradient penalty strategy is used instead of weight clipping. At this time, the loss function of the discriminant model is: in represents a random sample, ζ follows a uniform distribution in the interval [0,1], λ represents a penalty factor, Represents the gradient operator.
4. The method, device and electronic device for diagnosing imbalanced sample faults based on SMOTE and improved generative adversarial network according to claim 1, characterized in that: In step S2, the specific process of introducing the self-attention mechanism in the generative adversarial network includes: S2.2.
1. The feature map x after convolution mapping is converted into feature space f, g, h through linear mapping, which are called Query, Key, and Value respectively, as shown below: f(x)=W f x g(x)=W g x h(x)=W h x in are all weight matrices, which are constantly updated during the training process. C is the input channel. is the output channel; S2.2.2.
2. Calculate the attention score s using the transposed f and g i,j , usually calculated using dot multiplication: s i,j =f T g Where T represents transpose; S2.2.3, apply the softmax function to normalize and get α i,j : Among them, the subscript i,j indicates the model's attention to the i-th position when synthesizing the j-th region; S2.2.
4. Calculate the output o of the self-attention layer j : v(x i )=W v x i in It is related to W f ,W g ,W h The weight matrix is also constantly updated; S2.2.
5. In order to ensure the quality of the self-attention layer output, the output o j After linear transformation, the final output is as follows: y i =γo j +x i Where γ is the scale parameter, x i is the input vector.
5. The method for fault diagnosis of imbalanced samples based on SMOTE and improved generative adversarial network according to claim 1, characterized in that: In step S2, layer normalization is introduced into the generative adversarial network, and the specific process includes: S2.3.
1. Calculate the mean μ of the lth layer l and variance σ l : Where H is the number of neurons in a layer, is the i-th neuron in the l-th layer; S2.3.
2. Calculate the normalized value Where ε represents a very small number; S2.3.
3. The normalized value Perform a linear transformation: Where β is the translation variable.
6. A device for fault diagnosis of imbalanced samples based on SMOTE and improved generative adversarial network, characterized in that: include: The preprocessing module is used to synthesize some fault samples using SMOTE to enhance the number and diversity of fault samples. First, the imbalance ratio after combining the synthetic samples with the real samples is set to determine the number of samples synthesized using SMOTE. Then, a minority class sample x is randomly selected from the minority class sample set X. i , calculate the other samples in the minority class sample set X to x i The Euclidean distance of x is calculated and the k-nearest neighbor algorithm is used to search for x i The nearest neighbor samples of j ; Then according to the interpolation formula at x i and x j Interpolate between to get the synthetic sample x new ; Finally, repeat the above steps to obtain enough synthetic samples; the interpolation formula is: x new =x i +rand(0,1)*(x j -x i ), where rand(0,1) represents a random number between 0 and 1; The generation module is used to construct a generative adversarial network, and introduces the self-attention mechanism and layer normalization into it, and inputs the fault samples synthesized by SMOTE and the collected fault samples into the improved generative adversarial network for fault sample enhancement; wherein, the process of constructing the generative adversarial network includes: inputting the noise z obeying the Gaussian distribution into the generator G, so that it generates a set of false samples G(z); inputting G(z) and the real sample x into the discriminator D to judge whether the input data is a real sample; through the gradient information fed back by the discriminator D, the generator G will learn the distribution of the real sample as much as possible, and generate false samples that are very close to the real sample to deceive the discriminator D, and the discriminator D will also try to prevent itself from being deceived; the generator G and the discriminator D alternately iterate and optimize the parameters until the discriminator D cannot judge whether the input data is a real sample. At this time, the final objective function of the generative adversarial network is: x~P data Indicates that the real sample x obeys the probability distribution P data , z~P z Indicates that the noise z follows the prior distribution P z , E represents mathematical expectation, D(x) represents the output of the discriminator D; in order to solve the problem of unstable training of generative adversarial networks, Wasserstein distance is used instead of JS divergence and KL divergence: sup represents the minimum upper bound, ||f|| L ≤1 means that the function f(x) satisfies 1-Lipschitz continuity. In order to solve the problem of gradient vanishing and gradient exploding in the generative adversarial network, the gradient penalty strategy is used instead of weight clipping. At this time, the loss function of the discriminant model is: represents a random sample, ζ follows a uniform distribution in the interval [0,1], λ represents a penalty factor, represents the gradient operator; The diagnosis module is used to input the enhanced balanced samples into the diagnosis model to output the diagnosis results.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method, device and electronic device for diagnosing unbalanced sample faults based on SMOTE and improved generative adversarial network as described in any one of claims 1 to 5 are implemented.
8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method, device and electronic device for diagnosing unbalanced sample faults based on SMOTE and improved generative adversarial network as described in any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Bearing fault detection method and device under sample imbalance condition
CN113255078A
Bearing unbalance fault diagnosis method based on generated data fusion
CN115510965A
BCTGAN data expansion method for extreme unbalanced data fault diagnosis
CN118277839A
Mechanical fault intelligent diagnosis method under class unbalanced dataset
WO2023044979A1
Cited By
Vacuum pump fault diagnosis method for fusion reactor strong electromagnetic environment
CN120062102A
A Fault Diagnosis Method for Vacuum Pumps in the Strong Electromagnetic Environment of Fusion Reactors
CN120062102B
