Transformer neural network and method for detecting motor based on SE attention mechanism
By introducing the SE attention mechanism into the Transformer neural network, combined with MFCC and fully connected modules, the classification accuracy of motor sound detection is improved, the problem of information redundancy in motor sound detection of the Transformer model is solved, and more efficient abnormal sound detection is achieved.
Patent Information
- Application Number
- CN202511574266.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-31
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2045-10-31
AI Technical Summary
The classification accuracy of motor sound detection is low. Existing Transformer models have information redundancy when processing motor sound, resulting in insufficient classification accuracy.
We employ a Transformer neural network based on the SE attention mechanism. By combining the MFCC module, the fully connected module, the Transformer model, the SE module, the averaging module, and the binary classification module, we introduce the SE module to suppress redundant and noisy information, thereby improving feature representation ability and model robustness.
With almost no increase in computational overhead, the accuracy of abnormal motor sound detection is significantly improved, and the model's generalization ability and robustness are enhanced.
Smart Images

Figure CN121031671B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of motor testing, and particularly relates to a Transformer neural network based on an SE attention mechanism for detecting a motor and a method. BACKGROUND
[0002] Motors are important electromechanical devices in modern production and life, and are of great significance to the smooth progress of industrial processes and the safe operation of equipment. However, the produced motors are prone to abnormal conditions, leading to faults and thus safety hazards. Rapidly detecting abnormal equipment can reduce the number of defective products and prevent damage from spreading. The sound of motor operation can be used to determine whether the motor is normal or abnormal. For manual detection, manual detection of abnormal sound and other characteristics will greatly occupy human and material resources, but machine recognition of abnormal equipment can reduce the loss of human and economic resources.
[0003] Common machine learning models for motor sound classification include RNN, CNN and Transformer. Compared with traditional neural networks such as RNN and CNN, Transformer has significant advantages in processing sequence data, such as sound and text, mainly in the following aspects.
[0004] 1. Self-attention mechanism Self-Attention enables it to focus on all positions in the entire sequence, overcoming the disadvantages of RNN and CNN in long-distance dependence.
[0005] 2. Strong parallel computing capability and faster training speed.
[0006] 3. Efficient inference, lower demand for computing resources.
[0007] Due to these advantages, Transformer has been widely used in speech recognition, sound classification and dialogue language large models such as ChatGPT and DeepSeek.
[0008] However, when Transformer performs classification, the last layer often contains a large number of sequence features, which can easily lead to information redundancy and thus limit the classification accuracy.
[0009] Therefore, the low classification accuracy of motor sound detection is a technical problem to be solved. SUMMARY
[0010] The present application provides a Transformer neural network based on an SE attention mechanism for detecting a motor and a method, which solves the technical problem of low classification accuracy of motor sound detection.
[0011] To solve the above technical problems, the technical scheme adopted by the present application is as follows:
[0012] A Transformer neural network based on SE attention mechanism for detecting motors, comprising an MFCC module, a full connection module, a Transformer model, an SE module, an average module and a binary classification module connected in sequence, the SE module comprising an average layer, a first full connection layer, a second full connection layer and a weighting layer connected in sequence, the Transformer model being connected with the average layer and the weighting layer respectively, the weighting layer being connected with the average module, the MFCC module being used for inputting motor sound time domain signals, and the binary classification module being used for outputting classification results of motor normality or abnormality.
[0013] Further technical solutions are as follows: the hidden layer dimension of the Transformer model is n_mfcc.
[0014] Further technical solutions are as follows: the dimension of the first full connection layer is (n_mfcc, n_mfcc / 2), the dimension of the second full connection layer is (n_mfcc / 2, n_mfcc), and the activation function in the second full connection layer adopts a Sigmoid activation function.
[0015] Further technical solutions are as follows: the binary classification module is a binary classification full connection layer with a dimension of (n_mfcc, 2).
[0016] A method for detecting motors, according to the above Transformer neural network based on SE attention mechanism for detecting motors, comprising steps S1: feature extraction and step S2: Transformer classification, in the step S1, the feature extraction step comprises obtaining a time domain signal of motor sound, extracting MFCC features to frequency domain features, and obtaining a feature matrix with a shape of (n_frame, n_mfcc); in the step S2, the Transformer classification step comprises the following steps,
[0017] Step S201: shallow layer features are extracted based on the feature matrix with a shape of (n_frame, n_mfcc) to obtain full connection output features with a shape of (n_frame, n_mfcc);
[0018] Step S202: the full connection output features are subjected to the Transformer model to obtain a Transformer feature matrix with a shape of (n_frame, n_mfcc);
[0019] Step S203: the Transformer feature matrix is subjected to the SE module to obtain an SE feature matrix with a shape of (n_frame, n_mfcc);
[0020] Step S204: the SE feature matrix is averaged in the time dimension to obtain an SE global feature with a shape of (1, n_mfcc);
[0021] Step S205: a classification result of normal or abnormal is obtained based on the SE global feature binary classification.
[0022] Further technical solutions are that in the step S1, n_frame is the number of MFCC Fourier transform frames, and n_mfcc is the number of MFCC mel frequency cepstrum coefficients.
[0023] Further technical solutions are that the step S203 includes the following steps,
[0024] Step S2031: based on the Transformer feature matrix, the average in the time dimension is obtained to obtain a global mean feature with a shape of (1, n_mfcc);
[0025] Step S2032: the global mean feature sequentially passes through a first full connection layer and a second full connection layer to generate channel attention weights with a shape of (1, n_mfcc);
[0026] Step S2033: the channel attention weights are multiplied with the Transformer feature matrix frame by frame to obtain an SE feature matrix with a shape of (n_frame, n_mfcc) after weighting.
[0027] The beneficial effects produced by the above technical solutions are that:
[0028] A Transformer neural network based on an SE attention mechanism for detecting a motor includes an MFCC module, a full connection module, a Transformer model, an SE module, an average module, and a binary classification module connected in sequence, the SE module includes an average layer, a first full connection layer, a second full connection layer, and a weighting layer connected in sequence, the Transformer model is connected with the average layer and the weighting layer respectively, the weighting layer is connected with the average module, the MFCC module is used for inputting a motor sound time domain signal, and the binary classification module is used for outputting a classification result of normal or abnormal of the motor. Through the Transformer model and the SE module, the feature expression ability is improved, the redundant and noise information is suppressed, the invalid calculation is reduced, the robustness and the generalization ability of the model are improved without increasing the calculation overhead, and thus the precision of abnormal sound detection is effectively improved.
[0029] A method for detecting a motor according to the above-mentioned Transformer neural network for detecting a motor based on an SE attention mechanism, comprising steps S1: feature extraction and S2: Transformer classification, in step S2, the Transformer feature matrix obtains an SE feature matrix with a shape of (n_frame, n_mfcc) through an SE module, which improves the feature expression capability, suppresses redundant and noise information, reduces invalid calculation, improves the robustness and generalization ability of the model without increasing the calculation overhead, and thus effectively improves the precision of abnormal sound detection. BRIEF DESCRIPTION OF DRAWINGS
[0030] Figure 1 is a principle block diagram of the present application. DETAILED DESCRIPTION
[0031] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. The following description of at least one exemplary embodiment is actually only illustrative, but not as any limitation on the present application and its application or use. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative efforts fall within the scope of protection of the present application.
[0032] In the following description, many specific details are set forth in order to provide a thorough understanding of the present application, but the present application can also be implemented in other ways different from those described herein, and those skilled in the art can make similar generalizations without departing from the connotation of the present application, therefore the present application is not limited to the specific embodiments disclosed below. Embodiment 1
[0033] As Figure 1 shown, the present application discloses a Transformer neural network for detecting a motor based on an SE attention mechanism, comprising an MFCC module, a full connection module, a Transformer model, an SE module, an average module and a binary classification module connected in sequence, the SE module comprises an average layer of the SE module, a first full connection layer, a second full connection layer and a weighting layer of the SE module, the average layer of the SE module, the first full connection layer of the SE module, the second full connection layer of the SE module and the weighting layer of the SE module are connected in sequence, the output end of the Transformer model is connected with the average layer of the SE module, the output end of the Transformer model is connected with the weighting layer of the SE module, and the weighting layer of the SE module is connected with the average module.
[0034] The MFCC module is used for inputting a motor sound time domain signal, and the binary classification module is used for outputting a classification result of a normal or abnormal motor.
[0035] The full connection layer output feature with shape (n_frame, n_mfcc) is input into the Transformer module. Since the Transformer structure itself does not have position information, the feature matrix is added with sinusoidal position encoding before input, so as to explicitly represent the relative position information of each frame (frame) in the sequence. Subsequently, the feature added with position encoding is input into the Transformer module with a multi-head self-attention mechanism with num_heads=2 and a layer stacking structure with num_layers=2. In each Transformer module, a feedforward neural network, a residual connection and a layer normalization structure are included, and the feedforward neural network keeps the input and output dimensions consistent. The residual connection is used to retain the original feature information and alleviate the gradient vanishing problem, and the layer normalization is used to stabilize the network training process, thereby improving the convergence performance and feature expression ability of the model.
[0036] The SE module is a light-weight channel attention mechanism, which can adaptively adjust the importance of different channels through global information compression (Squeeze) and channel weight recalibration (Excitation). The introduction of the SE module in the Transformer for anomaly sound detection can: first, highlight key acoustic features and improve feature expression ability; second, suppress redundant and noisy information and reduce invalid calculations; third, it can also improve the robustness and generalization ability of the model without increasing the computational overhead, thereby effectively improving the accuracy of anomaly sound detection.
[0037] The SE module is a structure that introduces an attention mechanism, which weights the input features to enhance the frame or channel information that needs to be focused on. The feature matrix output by the Transformer module has a shape of (n_frame, n_mfcc). A copy of the feature matrix is input into the average layer of the SE module, and after average processing, it is sequentially input into the first full connection layer and the second full connection layer of the SE module to generate channel attention weights. Subsequently, the original Transformer feature matrix and the obtained channel attention weights are jointly input into the weighting layer of the SE module. The weighting layer performs frame-by-frame weighting processing on the Transformer feature matrix to obtain an SE feature matrix with a shape of (n_frame, n_mfcc) after weighting. Embodiment 2
[0038] The application discloses a method for detecting a motor based on an SE attention mechanism.
[0039] Step S1: feature extraction.
[0040] The time-domain signal of the motor sound is extracted into a frequency domain feature by an MFCC module to obtain a feature matrix with a shape of (n_frame, n_mfcc). The MFCC module is Mel-Frequency Cepstral Coefficients, n_frame is the number of MFCC Fourier transform frames, and n_mfcc is the number of MFCC mel-frequency cepstral coefficients.
[0041] Step S2: Transformer classification.
[0042] Step S201: input the feature matrix with a shape of (n_frame, n_mfcc) into a full connection module to extract shallow features to obtain full connection output features with a same shape of (n_frame, n_mfcc).
[0043] Step S202: input the full connection output features into a Transformer model with num_layers layers to obtain a Transformer feature matrix with a shape of (n_frame, n_mfcc). The hidden layer dimension of the Transformer model is n_mfcc, and the number of heads is num_heads. Since the Transformer is essentially a sequence-to-sequence structure, and the hidden layer dimension is consistent with the input dimension, the output is still a Transformer feature matrix with a shape of (n_frame, n_mfcc).
[0044] Step S203: input the Transformer feature matrix with a shape of (n_frame, n_mfcc) output by the Transformer model into an SE module to obtain an SE feature matrix with a shape of (n_frame, n_mfcc).
[0045] The execution process of the SE module is described in detail as follows.
[0046] Step S2031: the average layer of the SE module takes the average of the Transformer feature matrix with a shape of (n_frame, n_mfcc) output by the Transformer model in the time dimension to obtain a global mean feature with a shape of (1, n_mfcc).
[0047] Step S2032: The global mean feature sequentially passes through the first fully connected layer of the SE module and the second fully connected layer of the SE module, to generate channel attention weights in the shape of (1, n_mfcc), the dimension of the first fully connected layer of the SE module is (n_mfcc, n_mfcc / 2), and the dimension of the second fully connected layer of the SE module is (n_mfcc / 2, n_mfcc), and the activation function in the second fully connected layer of the SE module adopts a Sigmoid activation function.
[0048] Step S2033: The weighting layer of the SE module multiplies the channel attention weights with the (n_frame, n_mfcc) shape of the Transformer feature matrix output by the Transformer model frame by frame, to obtain an SE feature matrix in the shape of (n_frame, n_mfcc) after weighting.
[0049] Step S204: The average module takes the average of the SE feature matrix in the shape of (n_frame, n_mfcc) in the time dimension, to obtain the final SE global feature in the shape of (1, n_mfcc).
[0050] Step S205: The SE global feature is input into the binary classification module to output the classification result of the motor being normal or abnormal, and the binary classification module is a binary classification fully connected layer with a dimension of (n_mfcc, 2).
[0051] The experimental data in this experiment adopts an industrial measured data set, the motor parts are placed in a test box, that is, the data is collected in a background noise-free environment, and the processed data is divided into a training set and a test set according to a ratio of 8:2.
[0052] The measured data set in this experiment has 1000 normal samples and 360 abnormal samples. The training set contains 70% of the normal samples and abnormal samples; the validation set contains 15% of the normal samples and abnormal samples; and the test set contains 15% of the normal samples and abnormal samples.
[0053] The optimizer used in this training is Adam, the learning rate is equal to 0.0001, the number of iterations epoch is 100, the batch data size Batch Size is 64, the data of the training set is used to train the model, the model with the highest accuracy is saved according to the data of the validation set, and the test set data is used to compare the advantages and disadvantages of the model.
[0054] In feature extraction: n_frame=5, n_mfcc=32.
[0055] In the Transformer classification: num_heads=2, num_layers=2.
[0056] Since the training of machine learning has contingency, five repeated experiments are done to prove the superiority of the SE attention mechanism based Transformer industrial motor equipment anomaly detection method using SE module. The SE attention mechanism based Transformer industrial motor equipment anomaly detection method without using SE module: directly input the feature matrix of Transformer into the average module.
[0057] Referring to Table 1, the accuracy of the five experiments of the SE attention mechanism based Transformer industrial motor equipment anomaly detection method without using SE module is: 96%, 95.8%, 96.1%, 96.2%, 95.9%. The average of the five experimental results is: 96%.
[0058] The accuracy of the five experiments of the SE attention mechanism based Transformer industrial motor equipment anomaly detection method using SE module is: 96.3%, 96.6%, 96.0%, 96.4%, 96.2%. The average of the five experimental results is: 96.3%.
[0059] Table 1: Experimental data table
[0060]
[0061] The experimental results show that the SE attention mechanism based Transformer industrial motor equipment anomaly detection method using SE module and the SE attention mechanism based Transformer industrial motor equipment anomaly detection method without using SE module are compared, the accuracy of the SE attention mechanism based Transformer industrial motor equipment anomaly detection method using SE module is 96.3%, and the accuracy of the SE attention mechanism based Transformer industrial motor equipment anomaly detection method without using SE module is 96%.
[0062] Therefore, the SE module can highlight the key acoustic features, improve the feature expression ability, suppress redundant and noise information, and effectively improve the accuracy of anomaly sound detection.
Claims
1. A method of detecting an electric machine, characterized by: The Transformer neural network for detecting the motor based on the SE attention mechanism comprises steps S1: feature extraction and S2: Transformer classification, The Transformer neural network comprises an MFCC module, a full connection module, a Transformer model, an SE module, an average module and a binary classification module connected in sequence, the SE module comprises an average layer, a first full connection layer, a second full connection layer and a weighting layer connected in sequence, the Transformer model is connected with the average layer and the weighting layer respectively, the weighting layer is connected with the average module, the MFCC module is used for inputting a motor sound time domain signal, and the binary classification module is used for outputting a classification result of motor normality or abnormality; In the step S1, the feature extraction comprises obtaining a time domain signal of a motor sound, extracting MFCC features to frequency domain features, and obtaining a feature matrix with a shape of (n_frame, n_mfcc); in the step S2, the Transformer classification comprises the following steps, Step S201: shallow layer features are extracted based on the feature matrix with the shape of (n_frame, n_mfcc) to obtain full connection output features with a shape of (n_frame, n_mfcc); Step S202: the full connection output features pass through the Transformer model to obtain a Transformer feature matrix with a shape of (n_frame, n_mfcc); Step S203: the Transformer feature matrix passes through the SE module to obtain an SE feature matrix with a shape of (n_frame, n_mfcc); Step S204: the SE feature matrix is averaged in a time dimension to obtain SE global features with a shape of (1, n_mfcc); Step S205: binary classification is performed based on the SE global features to obtain a classification result of normality or abnormality.
2. The method of detecting an electric machine of claim 1, wherein: The hidden layer dimension of the Transformer model is n_mfcc.
3. The method of detecting an electric machine of claim 1, wherein: The dimension of the first full connection layer is (n_mfcc, n_mfcc / 2), and the dimension of the second full connection layer is (n_mfcc / 2, n_mfcc), and the activation function in the second full connection layer adopts a Sigmoid activation function.
4. The method of detecting an electric machine of claim 1, wherein: The binary classification module is a binary classification full connection layer with a dimension of (n_mfcc, 2).
5. The method of detecting an electric machine of claim 1, wherein: In the step S1, n_frame is the number of MFCC Fourier transform frames, and n_mfcc is the number of MFCC mel frequency cepstrum coefficients.
6. The method of detecting an electric machine of claim 1, wherein: The step S203 comprises the following steps, Step S2031: global mean features with a shape of (1, n_mfcc) are obtained by averaging the Transformer feature matrix in a time dimension; Step S2032: the global mean features pass through the first full connection layer and the second full connection layer in sequence to generate channel attention weights with a shape of (1, n_mfcc); Step S2033: multiply the channel attention weight with the Transformer feature matrix frame by frame to obtain an SE feature matrix with a shape of (n_frame, n_mfcc) after weighting.
Citation Information
Patent Citations
Transform and SE-based magnetic shoe defect detection method
CN115496738A
Multilayer feature fusion Transform neural network and method for detecting motor
CN119940417A