Transform neural network and method for detecting motor based on SE attention mechanism
By combining the MFCC module, the fully connected module, the Transformer model, and the SE module, and utilizing the channel attention mechanism of the SE attention mechanism, the problem of low accuracy in motor sound detection is solved, and efficient and accurate classification of motor anomaly detection is achieved.
Patent Information
- Application Number
- CN202511574266.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-31
- Publication Date
- 2025-11-28
- 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 anomaly detection, 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 utilize the channel attention mechanism of the SE module to suppress redundant and noisy information and improve feature representation capabilities.
Without increasing computational overhead, the robustness and generalization ability of the model are improved, and the accuracy of abnormal motor sound detection is significantly enhanced.
Smart Images

Figure CN121031671A_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: 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.
[0012] The further technical scheme is that the hidden layer dimension of the Transformer model is n_mfcc.
[0013] The further technical scheme is that 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.
[0014] The further technical scheme is that the binary classification module is a binary classification full connection layer with a dimension of (n_mfcc, 2).
[0015] 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, 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); Step S202: the full connection output features are obtained through the Transformer model to obtain a Transformer feature matrix with a shape of (n_frame, n_mfcc); Step S203: the Transformer feature matrix is obtained 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 the time dimension to obtain SE global features with a shape of (1, n_mfcc); Step S205: obtaining a classification result of normal or abnormal based on the SE global feature binary classification.
[0016] Further technical solutions are as follows: in the step S1, n_frame is the frame number of the MFCC Fourier transform, and n_mfcc is the number of MFCC mel frequency cepstrum coefficients.
[0017] Further technical solutions are as follows: the step S203 includes the following steps, Step S2031: obtaining a global mean feature with a shape of (1, n_mfcc) based on the average of the Transformer feature matrix in the time dimension; Step S2032: the global mean feature sequentially passes through the first fully connected layer and the second fully connected layer to generate channel attention weights with a shape of (1, n_mfcc); Step S2033: multiplying the channel attention weights with the Transformer feature matrix frame by frame to obtain an SE feature matrix with a shape of (n_frame, n_mfcc) after weighting.
[0018] The above technical solutions have the following beneficial effects: A Transformer neural network for detecting a motor based on an SE attention mechanism includes an MFCC module, a fully connected 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 fully connected layer, a second fully connected 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. The Transformer model and the SE module etc. are used to improve the feature expression capability, suppress redundant and noise information, reduce invalid calculation, improve the robustness and generalization capability of the model without increasing the calculation overhead, and thus effectively improve the precision of abnormal sound detection.
[0019] A method for detecting a motor, according to the above Transformer neural network for detecting a motor based on an SE attention mechanism, includes a step S1 of feature extraction and a step S2 of Transformer classification. In the step S2, a Transformer feature matrix is obtained as an SE feature matrix with a shape of (n_frame, n_mfcc) through an SE module, the feature expression capability is improved, redundant and noise information is suppressed, invalid calculation is reduced, the robustness and generalization capability of the model are improved without increasing the calculation overhead, and thus the precision of abnormal sound detection is effectively improved. BRIEF DESCRIPTION OF DRAWINGS
[0020] Figure 1 is a principle block diagram of the present application. DETAILED DESCRIPTION
[0021] The technical solutions in the embodiments of the present application will be clearly and completely described 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 creative work, fall within the scope of protection of the present application.
[0022] In the following description, many specific details are set forth in order to provide a thorough understanding of the present application. However, the present application can be practiced without the specific details, other than those described herein, and it is understood that the present application is not limited to the embodiments described herein and can be practiced with or without other apparatuses, systems, structures, methodologies, procedures, components, materials and so on. Therefore, the present application is not limited to the specific embodiments disclosed below. Embodiment 1
[0023] As shown in Figure 1 The present application discloses a Transformer neural network based on SE attention mechanism for detecting motor, which comprises MFCC module, full connection module, Transformer model, SE module, average module and binary classification module connected in sequence, the SE module comprises average layer of SE module, first full connection layer, second full connection layer and weighting layer, the average layer of SE module, the first full connection layer of SE module, the second full connection layer of SE module and the weighting layer of SE module are connected in sequence, the output end of the Transformer model is connected with the average layer of SE module, the output end of the Transformer model is connected with the weighting layer of SE module, and the weighting layer of SE module is connected with the average module.
[0024] The MFCC module is used for inputting motor sound time domain signal, and the binary classification module is used for outputting classification result of motor normal or abnormal.
[0025] The full connection layer output feature with the shape of (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 the 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 layer of the 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.
[0026] The SE module is a lightweight 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.
[0027] The SE module is a structure that introduces an attention mechanism, which is used to weight 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 the shape of (n_frame, n_mfcc). A copy of the feature matrix is input into the average layer of the SE module, and after being averaged, 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 the shape of (n_frame, n_mfcc) after weighting. Embodiment 2
[0028] The application discloses a method for detecting a motor based on an SE attention mechanism, which comprises the following steps: Step S1: feature extraction.
[0029] 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.
[0030] Step S2: Transformer classification.
[0031] Step S201: input the feature matrix with a shape of (n_frame, n_mfcc) into a full connection module to extract shallow features and obtain full connection output features with a same shape (n_frame, n_mfcc).
[0032] 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).
[0033] 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).
[0034] The execution process of the SE module is described in detail as follows.
[0035] 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).
[0036] 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.
[0037] 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.
[0038] 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).
[0039] 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).
[0040] The experimental data in this experiment uses an industrial measured data set, which places the motor parts in a test box, i.e., 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 an 8:2 ratio.
[0041] The measured data set in this experiment has 1000 normal samples and 360 abnormal samples. The training set contains 70% of normal samples and abnormal samples; the validation set contains 15% of normal samples and abnormal samples; and the test set contains 15% of normal samples and abnormal samples.
[0042] The optimizer used in this training is Adam, the learning rate is equal to 0.0001, the number of iterations epoch is 100, and 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.
[0043] In feature extraction: n_frame=5, n_mfcc=32.
[0044] In the Transformer classification: num_heads=2, num_layers=2.
[0045] 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.
[0046] 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%.
[0047] 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%.
[0048] Table 1: Experimental data table
[0049] 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%.
[0050] 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 abnormal sound detection.
Claims
1. A Transformer neural network for detecting motors based on SE attention mechanism, characterized in that: It includes an MFCC module, a fully connected module, a Transformer model, an SE module, an averaging module, and a binary classification module connected in sequence. The SE module includes an averaging layer, a first fully connected layer, a second fully connected layer, and a weighted layer connected in sequence. The Transformer model is connected to the averaging layer and the weighted layer respectively. The weighted layer is connected to the averaging module. The MFCC module is used to input the time-domain signal of the motor sound. The binary classification module is used to output the classification result of whether the motor is normal or abnormal.
2. The Transformer neural network for motor detection based on SE attention mechanism according to claim 1, characterized in that: The hidden layer dimension of the Transformer model is n_mfcc.
3. The Transformer neural network for motor detection based on SE attention mechanism according to claim 1, characterized in that: The first fully connected layer has dimensions of (n_mfcc, n_mfcc / 2), and the second fully connected layer has dimensions of (n_mfcc / 2, n_mfcc). The activation function in the second fully connected layer is the Sigmoid activation function.
4. The Transformer neural network for motor detection based on SE attention mechanism according to claim 1, characterized in that: The binary classification module is a fully connected binary classification layer with dimension (n_mfcc, 2).
5. A method for detecting a motor, comprising the Transformer neural network for motor detection based on the SE attention mechanism according to any one of claims 1 to 4, characterized in that: The process includes steps S1: feature extraction and S2: Transformer classification. Step S1, feature extraction, involves obtaining the time-domain signal of the motor sound, extracting frequency-domain features using MFCC features, and obtaining a feature matrix of shape (n_frame, n_mfcc). Step S2, Transformer classification, includes the following steps... Step S201: Extract shallow features based on the feature matrix of shape (n_frame, n_mfcc) to obtain fully connected output features of shape (n_frame, n_mfcc); Step S202: The fully connected output features are processed by the Transformer model to obtain a Transformer feature matrix with shape (n_frame, n_mfcc); Step S203: The Transformer feature matrix is processed by the SE module to obtain an SE feature matrix with shape (n_frame, n_mfcc); Step S204: The SE feature matrix is averaged over the time dimension to obtain the SE global features of shape (1, n_mfcc); Step S205: Obtain the classification result of normal or abnormal based on the global features of SE.
6. The method for detecting a motor according to claim 5, characterized in that: In step S1, n_frame is the number of frames in the MFCC Fourier transform, and n_mfcc is the number of MFCC Mel frequency cepstral coefficients.
7. The method for detecting a motor according to claim 5, characterized in that: Step S203 includes the following steps. Step S2031: Based on the average of the Transformer feature matrix over the time dimension, obtain the global mean feature with shape (1, n_mfcc); Step S2032: The global mean features are sequentially passed through the first fully connected layer and the second fully connected layer to generate channel attention weights of shape (1, n_mfcc); Step S2033: Multiply the channel attention weights with the Transformer feature matrix frame by frame to obtain a weighted SE feature matrix with shape (n_frame, n_mfcc).
Citation Information
Patent Citations
Transform and SE-based magnetic shoe defect detection method
CN115496738A
Image classification system and method based on lightweight LA Transform network
CN115984620A
Method for detecting motor based on Transform model of UMAP
CN119622609A
Multilayer feature fusion Transform neural network and method for detecting motor
CN119940417A
Rotary machinery fault diagnosis method based on PyramidNet and Transform
CN120781152A