Cross-working-condition bearing fault diagnosis method based on prototype domain alignment feature coding
Through the combination of self-attention encoder and hash encoder, the precise mapping and alignment of bearing fault diagnosis methods under complex operating conditions is achieved, which solves the problems of insufficient generalization performance and dependence on labeled data in the existing methods, and improves the accuracy and efficiency of bearing fault diagnosis.
Patent Information
- Application Number
- CN202510616704.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-14
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2045-05-14
AI Technical Summary
The existing bearing fault diagnosis methods are insufficient in complex high-dimensional systems, making it difficult to adapt to data distribution differences under different operating conditions, and relying on large-scale annotation of data leads to high costs.
The method based on prototype domain alignment feature coding is adopted. Through self-attention encoder and hash encoder, combined with the embedding layer, continuous wavelet transformation and composite loss function, the precise mapping and alignment of the source domain and target domain features are achieved, reducing the dependence of labeled data, and improving the diagnostic performance of the model under complex operating conditions.
It significantly improves the accuracy and robustness of bearing fault diagnosis, reduces data labeling costs, enhances the model's adaptability and generalization ability under complex operating conditions, and can accurately identify fault types under different operating conditions.
Smart Images

Figure CN120541740A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of bearing fault diagnosis, and in particular to a cross-working-condition bearing fault diagnosis method based on prototype domain alignment feature coding. Background Art
[0002] In today's industrial landscape, rotating machinery plays an indispensable role in many key sectors, including manufacturing and energy. Bearings, as core components of rotating machinery, have a significant impact on the reliability and stability of the entire equipment. Bearing failure can lead to unexpected equipment downtime, production process interruptions, and even serious safety incidents, resulting in significant economic losses. Therefore, achieving high-precision bearing fault diagnosis is crucial for ensuring smooth industrial operations, reducing operating costs, and ensuring personnel safety.
[0003] Traditional bearing fault diagnosis methods primarily rely on physical models and various signal processing techniques to analyze specific faulty components. However, these physical models are not universally applicable in complex, high-dimensional systems. With the continuous advancement of industrial technology and the increasing complexity and sophistication of rotating machinery, the limitations of traditional fault diagnosis methods are becoming increasingly prominent. In recent years, data-driven intelligent fault diagnosis methods have attracted significant attention from researchers due to their high accuracy and low reliance on prior knowledge.
[0004] Deep learning methods, with their powerful feature learning capabilities, have achieved remarkable results in bearing fault diagnosis. Convolutional neural networks (CNNs) can effectively process high-dimensional data and automatically extract fault features in graphical form. Recurrent neural networks (RNNs) and their variants, such as long-short-term memory networks (LSTMs), excel at processing time series data and can capture dynamic changes in bearing operating conditions. However, these deep learning methods typically assume that training and test data come from the same distribution. In real industrial scenarios, the distribution of bearing data under different operating conditions varies significantly, resulting in reduced generalization performance and difficulty meeting practical requirements.
[0005] In order to solve the distribution difference problem between different data domains, domain adaptation technology has emerged. It aims to narrow the gap between the data distribution of the source domain and the target domain, realize the transfer of knowledge from the source domain to the target domain, and provide an effective way for cross-working condition bearing fault diagnosis. Among the existing domain adaptation methods, (1) Methods based on metric learning: This type of method aims to achieve feature alignment by minimizing the statistical difference between the source domain and the target domain data, thereby promoting knowledge transfer. A typical example is the maximum mean difference (MMD), which narrows the gap between the data distribution of the two domains by calculating and minimizing the distance metric loss between the source domain and the target domain features. Its principle is to measure the difference between the two distributions in the reproducing kernel Hilbert space (RKHS), so that the features of the source domain and the target domain are more similar to a certain extent, thereby achieving domain adaptation. (2) Methods based on adversarial learning: Drawing on the idea of generative adversarial network (GAN), a domain discriminator is introduced to distinguish the source domain and target domain data, while forcing the feature extractor to generate domain invariant features. Taking the Domain Adversarial Neural Network (DANN) as an example, during the training process, the feature extractor strives to generate features that the domain discriminator cannot distinguish the source of, while the domain discriminator tries its best to distinguish whether the features come from the source domain or the target domain. Through this adversarial training, the feature difference between the source and target domains is reduced, and the generalization ability of the model is improved. However, both methods have the following defects: (1) When calculating the distribution difference, the metric learning method may ignore the association between the features and the fault labels, making it difficult to ensure the fine-grainedness of domain adaptation and prone to feature alignment errors; (2) When aligning the domain distribution, the adversarial learning method may lose the specific information of the target domain, affecting the performance of the diagnostic model in the target domain.
[0006] In summary, existing bearing fault diagnosis methods rely heavily on large amounts of labeled data, a process that requires significant human, material, and time investment, resulting in high costs. The diversity and variability of operating conditions also significantly increases the difficulty of collecting and labeling data for new operating conditions, making it difficult to obtain sufficient labeled data. Therefore, how to fully extract domain information from a small amount of labeled data, reduce the distribution differences in fault data under different operating conditions, and improve the generalization ability of fault diagnosis models for complex operating conditions are currently important technical challenges that need to be addressed. Summary of the Invention
[0007] To address these issues, the present invention provides a cross-operating-condition bearing fault diagnosis method based on prototype domain alignment feature encoding. This method accurately maps and aligns data feature spaces, effectively addressing the problem of data modal differences caused by varying operating conditions. This significantly improves the performance of the diagnostic model under complex operating conditions, providing a more reliable and efficient identification method for bearing fault diagnosis.
[0008] In order to achieve the above object, the present invention adopts the following technical solution: a cross-operating-condition bearing fault diagnosis method based on prototype domain alignment feature coding, comprising the following steps:
[0009] S1. Data collection and preprocessing:
[0010] S101. Data collection: Simulate the operating conditions of bearings in the laboratory, including operating conditions of different speeds, different loads, and fault types, collect bearing vibration signal data of all fault types under all operating conditions, and select different operating conditions to divide the collected bearing vibration signal data into source domain vibration signals x s (t) and target domain vibration signal x t (t); where the source domain vibration signal x s (t) including n s samples Target domain vibration signal x t (t) including n t samples Source domain vibration signal x s (t) Known working condition data for model training, with real fault type labels, total number of fault types cls, fault type label c; target domain vibration signal x t (t) For unknown working condition data used in cross-working condition testing, pseudo labels are inferred through source domain knowledge;
[0011] S102, data preprocessing: After the data collection is completed, the source domain vibration signal x s (t) and target domain vibration signal x t All samples of (t) are preprocessed using continuous wavelet transform and converted into source domain time-frequency features and target domain time-frequency features
[0012] S2. Build a bearing fault diagnosis model, which includes an embedding layer, a self-attention encoder, a hash encoder, and a feature classifier. and target domain time-frequency features Input the bearing fault diagnosis model for processing, which specifically includes the following steps:
[0013] S201, the source domain time-frequency features and target domain time-frequency features Through the embedding layer processing, we get the embedded sequence and
[0014] S202, using self-attention encoder to and Processing is performed to obtain the features f s and feature f t , where the source domain vibration signal x s (t)n s samples After being processed by the self-attention feature encoder, the features are obtained Recorded as Target domain vibration signal x t (t)n t samples After being processed by the self-attention feature encoder, the features are obtained Recorded as
[0015] S203, hash encoder processing: Use hash encoder to process the features respectively Encode and obtain the source domain relaxed hash code H s and the target domain relaxed hash code H t ;
[0016] S204, relax the source domain hash code H s and the target domain relaxed hash code H t Input feature classifier to output the probability of bearing fault type;
[0017] S3. Constructing a composite loss function The bearing fault diagnosis model built by training makes the composite loss function minimize, Defined as:
[0018]
[0019] in, is the cross entropy classification loss function, is the prototype contrast loss function, is the relationship preserving loss function, is the quantization loss function; α, β, γ and δ are trade-off parameters used to adjust In the composite loss function The relative importance of the two parameters is used to balance the model between different optimization objectives.
[0020] Furthermore, in step S102, the source domain vibration signal x s (t) is converted to For example, the conversion formula for continuous wavelet transform preprocessing is:
[0021]
[0022] Among them, a is the scale parameter and τ is the time translation parameter; is the wavelet basis function of wavelet transform, and t represents the sampling moment of the time series;
[0023] Target domain vibration signal x t(t) Also using wavelet transform, the time-frequency characteristics of the target domain are finally obtained
[0024] Furthermore, in step S201, the specific method of embedding layer processing is:
[0025] Source domain time-frequency features For example, the embedding layer processing specifically includes the following steps:
[0026] S2011, Data Reshaping: Converting source domain time-frequency features Evenly divided into N patches, satisfying N = H × W / P 2 , These patches are then rearranged into a sequence:
[0027]
[0028] in, represents the i-th patch (i=1,2,3,…,N), P is the side length of the patch, N is the number of patches, H, W, C are the time-frequency features of the source domain, respectively. The height, width and number of channels; reshape means rearrangement;
[0029] S2012, Linear Projection and Embedding: Use a learnable linear projection matrix to map the patch sequence into a high-dimensional embedding space to obtain an embedded sequence The specific form is shown in the formula:
[0030]
[0031] in, represents the embedding weight matrix, d is the embedding dimension;
[0032] S2013, calculate the position code: in order to preserve the absolute position information and relative position information of the patch, embed the sequence Added absolute position information E pos , using sine function and cosine function to alternately represent position information, using sine function and cosine function of different frequencies to generate position code, absolute position information E pos The calculation process is:
[0033] E (POS,2q+1) =cos(POS / 10000 2q / d )
[0034] E (POS,2q) =sin(POS / 10000 2q / d )
[0035] E pos =[E (POS,1),E (POS,2) ,E (POS,3) ,...,E (POS,N) ]
[0036] Among them, E is the position encoding matrix; POS represents the position index, representing In patch sequence q represents the dimension, even dimensions correspond to 2q, odd dimensions correspond to 2q+1; d represents the embedding dimension, (POS,q) represents the POS-th row and q-th column in the position encoding matrix P; N is the number of patches, 10000 is a constant chosen empirically;
[0037] S2014, add position encoding and classification tags: introduce a vector x class , used as feature representation to obtain the embedded sequence x class Obtained by the following formula:
[0038]
[0039] in, N is the number of patches and d is the embedding dimension.
[0040] Furthermore, in step S202, the self-attention encoder is composed of two sub-layers: a multi-head self-attention layer and an MLP feed-forward network. The multi-head self-attention layer has h attention heads. The specific processing steps of the self-attention encoder are as follows:
[0041] S2021, with the source domain vibration signal x s (t) as an example, the output sequence after processing by the embedding layer As the input of the self-attention feature encoder, Through the linear transformation corresponding to h attention heads, we get the query vector Q, key vector K and value vector V corresponding to h groups. For the query vector Q of the i-th attention head i , key vector K i , value vector V i , the calculation formulas are:
[0042]
[0043] Where h is the number of attention heads; are the weight matrices corresponding to the i-th attention head, i = 1, 2, 3, ..., h;
[0044] S2022, within the i-th attention head, the attention weights are calculated using the scaled dot product attention mechanism, and the value matrix is weighted summed according to these weights, as follows:
[0045]
[0046] Among them, Attention represents the attention mechanism operation, It's K i The transposed matrix, d k It's K i Dimension, softmax is an activation function that converts the input vector into a probability distribution;
[0047] S2023, concatenates the outputs of h attention heads according to the feature dimension, integrates the information captured by different heads to form a richer feature representation, and passes the linear transformation matrix W of the linear layer O Fusion is performed to obtain the final output of the multi-head attention mechanism The formula is as follows:
[0048]
[0049] in h is the number of attention heads, Concat(·) is the concatenation function, and W O is the linear transformation matrix;
[0050] S2024, the final output of the multi-head attention mechanism Perform layer normalization to obtain The formula is as follows:
[0051]
[0052] Where LN(·) represents layer normalization, μ and σ are The mean and standard deviation of , ε is the scaling parameter, which adjusts the scaling degree of the normalized data; ∈ is the offset parameter, which translates the scaled data;
[0053] S2025. Output the normalized multi-head attention With embedded sequence Residual connection to obtain fused features
[0054]
[0055] S2026, fused features Enter the multi-layer perceptron MLP to further extract features and get f s :
[0056]
[0057] S2027, source domain vibration signal x s (t)n s samples After processing steps S2021-S2026 respectively, the features are obtained Recorded as
[0058] Target domain vibration signal x t (t)n t samples After the same processing of steps S2021-S2026, the feature Recorded as
[0059] Furthermore, in step S2026, the formula for further feature extraction by the multi-layer perceptron MLP is:
[0060]
[0061] Among them, Dropout p (·) represents random dropout operation with probability p, represents the linear transformation of the first linear layer; K1, K2 are weight matrices, b is the bias vector, GELU(·) represents the application of Gaussian error linear unit activation function, and Linear(·) represents the linear transformation of the second linear layer.
[0062] Furthermore, in step S203, the processing method of the hash encoder specifically includes the following steps:
[0063] S2031, obtain the source domain relaxed hash code: by HashEncoder(·;θ hash ) for features Encode and generate the source domain relaxed hash code H s , for n s The relaxed hash code of the source domain vibration signal sample is:
[0064]
[0065] in, r is the length of the hash code;
[0066] S2032, obtain the target domain relaxed hash code: by HashEncoder(·; θ hash) Pair Features Encode and generate the target domain relaxed hash code
[0067] in, r is the length of the hash code.
[0068] Furthermore, in step S204, the feature classifier is composed of a first fully connected layer and a second fully connected layer to output the probability of the bearing fault type. The specific steps are as follows:
[0069] First, relax the hash code H in the source domain s Or the target domain relaxed hash code H t Represented as F, they are respectively used as the input of the feature classifier, first pass through the first fully connected layer, and then perform nonlinear transformation through the ReLU activation function to obtain z1, that is:
[0070] z1=ReLU(W1F+b1)
[0071] Among them, z1 represents the feature output of the first fully connected layer, F is H s or H t , W1 is the weight matrix of the first fully connected layer, b1 is the bias vector of the first fully connected layer;
[0072] Next, z1 is input into the second fully connected layer. The number of neurons in the second fully connected layer is determined according to the actual number of fault types cls. The output layer uses the Softmax function to map the input to the probability distribution of fault types:
[0073] G=Softmax(W2z1+b2)
[0074] Where W2 is the weight matrix of the second fully connected layer, b2 is the bias vector of the second fully connected layer, and G is a vector containing cls elements, each element represents the predicted probability of the corresponding fault type;
[0075] Finally, as the fault diagnosis result, the element with the highest probability is selected from the vector G. The index corresponding to this element represents the most likely bearing fault type predicted by the model, thereby achieving accurate judgment of the bearing fault type.
[0076] Furthermore, the cross entropy classification loss function in step S3 is Used to measure the difference between the model prediction results and the true label, cross entropy classification loss is based on the true label y of the sample ij And the model predicted probability p ij Calculation, the calculation formula is:
[0077]
[0078] Among them, n s is the number of source domain vibration signal samples, cls is the total number of fault types, log(·) is the logarithmic function, y ij Indicates the true label of the i-th sample belonging to the j-th fault type, p ijIt is the probability of predicting that the i-th sample belongs to the j-th fault type.
[0079] Furthermore, the prototype contrast loss function in step S3 is The specific calculation process is:
[0080] Step S301: Based on the fault type label c, calculate the prototype feature of the c-th fault type in the source domain vibration signal The calculation formula is:
[0081]
[0082] in, is the feature of the source domain vibration signal sample extracted by the self-attention encoder, is the indicator function, when Returns 1 if the condition is met, otherwise returns 0; n s represents the number of samples of the source domain vibration signal, and c corresponds to the fault type label;
[0083] Step S302: Perform normalization processing, that is Through each Normalize and uniformly scale their lengths to 1, thereby mapping all prototype features of the source domain vibration signal and the target domain vibration signal onto the same unit hypersphere, forming a domain-shared hypersphere plane space;
[0084] Step S303: Obtain pseudo labels for target domain vibration signal data In order to realize the transfer of source domain knowledge to target domain, the nearest source prototype method is used to assign pseudo labels to target data. Based on the prototype characteristics of each fault type Determine the pseudo label for the target domain vibration signal sample using the formula:
[0085]
[0086] in, represents the independent variable c that maximizes the function, cos(·) is used to calculate the cosine similarity, is the feature extracted by the self-attention encoder of the jth target domain vibration signal sample, j = 1, 2, ..., n t , It is the prototype feature of the cth type of fault in the source domain vibration signal;
[0087] Step S304: Calculate prototype features of target domain vibration signal: Calculate prototype features of target domain vibration signal based on pseudo labels of target domain vibration signal data. The formula is:
[0088]
[0089] Among them, n t Indicates the number of target domain vibration signal samples;
[0090] Step S305: Similarly, Perform normalization processing, that is
[0091] Step S306: Constructing a prototype contrast loss function To promote domain alignment and obtain uniform and conflict-free feature representations, The calculation formula is:
[0092]
[0093] in, is the prototype feature of the i-th fault in the target domain vibration signal, where i is the category index except the c-th fault type; exp(·) is the exponential function, log(·) is the logarithmic function, cls is the total number of fault types, and τ is the temperature parameter.
[0094] Furthermore, in step S3, the relationship preservation loss function and quantization loss function The specific calculation process is:
[0095] Step S307: Calculate the similarity matrix S based on the source domain fault type label s , similarity matrix S s Used to reflect the source domain vibration signal x s (t) Similarity relationship between samples based on source domain fault type labels;
[0096] Step S308: Use the source domain fault type label to guide hash learning: In order to constrain the source domain to relax the hash code H s Retain the sample similarity relationship and transform the source domain vibration signal x s (t) The similarity relationship between samples is integrated into hash learning, so that the similarity between hash codes can approach the sample similarity calculated based on the source domain fault type label, thereby retaining the similarity relationship of the source domain vibration signal samples in the hash code, which is calculated by the following formula:
[0097]
[0098] in, represents the relationship preservation loss function, η is the scaling factor, H s is the relaxed hash code of the source domain vibration signal sample; ||·|| F is the F norm, S sis the similarity matrix calculated based on the fault type of the source domain vibration signal samples, cos(·) is the cosine function;
[0099] Step S309, cross-domain relationship constraint: To achieve cross-domain knowledge transfer and ensure that similar features in the domain-shared hypersphere plane space generate similar hash codes, the formula is used:
[0100]
[0101] in, They are the source domain vibration signal x s (t) and target domain vibration signal x t (t) Feature representation after processing by the self-attention encoder, H s 、H t are the corresponding relaxed hash codes; cos(·) is the cosine function; through this constraint, the source domain vibration signal and the target domain vibration signal maintain consistency in feature representation and hash code generation, enhancing the cross-domain adaptability of the model;
[0102] Step S310, fusion relationship loss: the above two loss functions and Fusion is a relation-preserving loss function The formula is as follows:
[0103]
[0104] Among them, γ is the balance factor;
[0105] Step S311, quantization loss: In order to make the relaxed hash code close to the binary hash code, make the hash code more in line with the actual application requirements, improve the storage and retrieval efficiency, and thus improve the efficiency and accuracy of bearing fault diagnosis, a quantization loss function is defined. The formula is:
[0106]
[0107] Among them, B s 、B t are the binary hash codes of the source domain vibration signal and the target domain vibration signal, H s 、H t are the relaxed hash codes of the source domain vibration signal and the target domain vibration signal, respectively.
[0108] Compared with the prior art, the present invention has the following beneficial effects:
[0109] In view of the complex actual working conditions and diverse data characteristics, the present invention proposes a complex working condition bearing fault diagnosis method based on self-attention hash coding. The present invention adopts specific data preprocessing and embedding layer technology to give full play to the advantages of self-attention encoder in feature extraction, accurately capture the key features of bearing data under different working conditions, effectively overcome the challenges brought by data distribution differences, and provide reliable data support for fault diagnosis. At the same time, the prototype hash framework is introduced to carry out prototype comparative learning by constructing a domain-sharing unit hypersphere plane space, maximize the distance between prototypes of different categories, enhance the compactness of similar sample features, convert sample relationships into prototype relationships, and further improve the discriminative ability of features. By accurately realizing the mapping and alignment of data feature space, the present invention can properly solve the problem of data modal differences caused by changes in working conditions, thereby significantly improving the performance of the diagnostic model under complex working conditions, significantly improving the accuracy of cross-working condition bearing fault diagnosis, ensuring that the fault type can be accurately identified under different working conditions, and reducing the misjudgment rate.
[0110] At the same time, this invention reduces reliance on large-scale annotated data. Through efficient domain adaptation strategies, it fully utilizes small amounts of annotated source domain data and unannotated target domain data for model training and testing, reducing data annotation costs and improving the model's adaptability and generalization capabilities. This invention enhances the robustness of fault diagnosis models, enabling them to consistently output reliable diagnostic results in complex and changing industrial environments, despite noise interference and data fluctuations. BRIEF DESCRIPTION OF THE DRAWINGS
[0111] The drawings described herein are used to provide further understanding of the present invention and constitute a part of this application. The illustrative examples of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.
[0112] Figure 1 This is a flow chart of a complex working condition bearing fault diagnosis method based on self-attention hash coding according to the present invention;
[0113] Figure 2 This is the processing flow chart of the self-attention encoder;
[0114] Figure 3 This is the processing flow chart of the hash encoder;
[0115] Figure 4 The histogram of the diagnosis results of Case Western Reserve University (CWRU) under cross-work tasks. DETAILED DESCRIPTION
[0116] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments.
[0117] Reference Figure 1 , a cross-operating-condition bearing fault diagnosis method based on prototype domain alignment feature encoding, comprising the following steps:
[0118] S1. Data collection and preprocessing:
[0119] S101. Data collection: Simulate the operating conditions of bearings in the laboratory, including operating conditions of different speeds, different loads, and fault types, collect bearing vibration signal data of all fault types under all operating conditions, and select different operating conditions to divide the collected bearing vibration signal data into source domain vibration signals x s (t) and target domain vibration signal x t (t); where the source domain vibration signal x s (t) including n s samples Target domain vibration signal x t (t) including n t samples Source domain vibration signal x s (t) Known working condition data for model training, with real fault type labels, total number of fault types cls, fault type label c; target domain vibration signal x t (t) For unknown working condition data used in cross-working condition testing, pseudo labels are inferred through source domain knowledge;
[0120] S102, data preprocessing: After the data collection is completed, the source domain vibration signal x s (t) and target domain vibration signal x t All samples of (t) are preprocessed using continuous wavelet transform and converted into source domain time-frequency features and target domain time-frequency features Take the source domain vibration signal x s (t) is converted to For example, the conversion formula is:
[0121]
[0122] Among them, a is the scale parameter and τ is the time translation parameter; is the wavelet basis function of wavelet transform, and t represents the sampling moment of the time series;
[0123] Target domain vibration signal x t (t) Also using wavelet transform, the time-frequency characteristics of the target domain are finally obtained
[0124] S2. Build a bearing fault diagnosis model, which includes an embedding layer, a self-attention encoder, a hash encoder, and a feature classifier. and target domain time-frequency features Input the bearing fault diagnosis model for processing, which specifically includes the following steps:
[0125] S201, the source domain time-frequency features and target domain time-frequency features Through the embedding layer processing, we get the embedded sequence and The role of the embedding layer is to map the input data into a low-dimensional and dense vector space, thereby reducing the data dimension while retaining key information, reducing the amount of computation and model parameters. At the same time, in this space, semantically similar data points are also closer in distance, which helps the model better learn and capture data features. The specific method of the embedding layer is as follows:
[0126] Source domain time-frequency features For example, the embedding layer processing specifically includes the following steps:
[0127] S2011, Data Reshaping: Converting source domain time-frequency features Evenly divided into N patches of specific size, satisfying These patches are then rearranged into a sequence:
[0128]
[0129] in, represents the i-th patch (i = 1, 2, 3, ..., N), P is the side length of the patch, N is the number of patches, H, W, C are the source domain time-frequency features, respectively The height, width and number of channels; reshape means rearrangement;
[0130] S2012, Linear Projection and Embedding: Use a learnable linear projection matrix to map the patch sequence into a high-dimensional embedding space to obtain an embedded sequence The specific form is shown in the formula:
[0131]
[0132] in, represents the embedding weight matrix, d is the embedding dimension;
[0133] S2013, calculate the position code: in order to preserve the absolute position information and relative position information of the patch, embed the sequence Added absolute position information E pos , using sine function and cosine function to alternately represent position information, using sine function and cosine function of different frequencies to generate position code, absolute position information E pos The calculation process is:
[0134] E (POS,2q+1) =cos(POS / 10000 2q / d )
[0135] E (POS,2q) =sin(POS / 10000 2q / d )
[0136] E pos =[E (POS,1) ,E (POS,2) ,E (POS,3) ,...,E (POS,N) ]
[0137] Among them, E is the position encoding matrix; POS represents the position index, representing In patch sequence ; q represents the dimension, even dimensions correspond to 2q, odd dimensions correspond to 2q+1; d represents the embedding dimension, (POS,q) represents the POS-th row and q-th column in the position encoding matrix P; N is the number of patches, 10000 is a constant chosen empirically; cos(·) is the cosine function, and sin(·) is the sine function;
[0138] S2014, adding positional encoding and classification tags: introducing a learnable vector x class , used as feature representation to obtain the embedded sequence x class Obtained by the following formula:
[0139]
[0140] in, are all learnable parameters; N is the number of patches, and d represents the embedding dimension;
[0141] S202, using self-attention encoder to and Processing is performed to obtain the features f s and feature f t , where the source domain vibration signal x s (t)n s samples After being processed by the self-attention feature encoder, the features are obtained Recorded as Target domain vibration signal x t (t)n t samples After being processed by the self-attention feature encoder, the features are obtained Recorded as
[0142] Reference Figure 2 The self-attention encoder consists of two sub-layers: a multi-head self-attention layer and an MLP feed-forward network. After the output sequence of the embedding layer enters each sub-layer, it will first be normalized through layer normalization (LN) to stabilize the data distribution; then, the residual connection is used to directly fuse the sub-layer output with the input to prevent the gradient from disappearing and enhance feature transfer. Among them, the multi-head attention mechanism enables the model to focus on different parts of the input sequence in parallel in different representation subspaces, thereby capturing richer information. The MLP layer further mines and refines the features processed by the multi-head attention mechanism through nonlinear transformations, broadens or restores the feature dimensions, and introduces nonlinear factors. This enables the model to better learn complex feature relationships, improve its understanding and expression of input information, and be more compatible with other parts of the model, providing a higher-quality feature foundation for subsequent hash coding.
[0143] Among them, the multi-head self-attention layer has h attention heads, and the specific processing steps of the self-attention encoder are as follows:
[0144] S2021, with the source domain vibration signal x s (t) as an example, the output sequence after processing by the embedding layer As the input of the self-attention feature encoder, Through the linear transformation corresponding to h attention heads, we get the query vector Q, key vector K and value vector V corresponding to h groups. For the query vector Q of the i-th attention head i , key vector K i , value vector V i , the calculation formulas are:
[0145]
[0146] Where h is the number of attention heads; are the learnable weight matrices corresponding to the i-th attention head, i = 1, 2, 3, ..., h;
[0147] S2022, each attention head independently focuses on different feature subspaces of the input sequence, capturing the relationship between elements from different perspectives. Within the i-th attention head, the attention weights are calculated using the scaled dot product attention mechanism, and the value matrix is weighted summed according to these weights, as follows:
[0148]
[0149] Among them, Attention represents the attention mechanism operation, It's K i The transposed matrix, d k It's K iDimension, softmax is an activation function that converts the input vector into a probability distribution;
[0150] S2023, concatenates the outputs of h attention heads according to the feature dimension, integrates the information captured by different heads to form a richer feature representation, and passes the linear transformation matrix W of the linear layer O Fusion is performed to obtain the final output of the multi-head attention mechanism The formula is as follows:
[0151]
[0152] in h is the number of attention heads, Concat(·) is the concatenation function, and W O is a learnable linear transformation matrix;
[0153] S2024, the final output of the multi-head attention mechanism Perform layer normalization to obtain The formula is as follows:
[0154]
[0155] Where LN(·) represents layer normalization, μ and σ are The mean and standard deviation of , ε is a learnable scaling parameter that adjusts the scaling degree of the normalized data; ∈ is a learnable offset parameter that shifts the scaled data;
[0156] S2025. Output the normalized multi-head attention With embedded sequence Residual connection to obtain fused features
[0157]
[0158] S2026, fused features Enter the multi-layer perceptron MLP to further extract features and get f s :
[0159]
[0160] The multi-layer perceptron MLP further extracts features by the following steps:
[0161] 1) First linear layer processing: The input data first enters the first linear layer, which performs a linear transformation by multiplying it with the weight matrix, changing the dimension of the data and mapping the input features to the new feature space to achieve preliminary feature processing;
[0162] 2) Gaussian Error Linear Unit Processing: Data processed by the first linear layer enters the Gaussian Error Linear Unit (GELU). The GELU activation function introduces nonlinear factors. This function enables the model to learn more complex feature relationships, improves the model's expressiveness, and solves nonlinear problems that linear models cannot handle.
[0163] 3) Second linear layer processing: After being activated by the GELU activation function, the features enter the second linear layer again for a second linear transformation to further adjust the feature representation and explore more complex associations between features;
[0164] 4) Random deactivation: Perform random deactivation with probability p.
[0165] The formula for further feature extraction by the multi-layer perceptron MLP is:
[0166]
[0167] Among them, Dropout p (·) represents random dropout operation with probability p, represents the linear transformation of the first linear layer; K1, K2 are weight matrices, b is the bias vector, GELU(·) represents the application of Gaussian error linear unit activation function, and Linear(·) represents the linear transformation of the second linear layer;
[0168] S2027, source domain vibration signal x s (t)n s samples After processing steps S2021-S2026 respectively, the features are obtained Recorded as
[0169] Target domain vibration signal x t (t)n t samples After the same processing of steps S2021-S2026, the feature Recorded as
[0170] After completing the feature mining of the self-attention encoder, a feature representation with good discriminability is obtained. However, the original feature dimension is relatively high, which makes fast storage and retrieval challenging, and it is difficult to meet the actual requirements of bearing fault diagnosis for efficiency. Therefore, the hash encoder is introduced. This module is the core part of converting features into efficient diagnostic information. Through multi-step operations, it maps high-dimensional features into low-dimensional hash codes. This process significantly reduces the space occupied by data storage, greatly increases the data retrieval rate, and effectively improves the efficiency of fault diagnosis. It can quickly and accurately obtain effective diagnostic information, providing support for the timely location and resolution of bearing faults.
[0171] Reference Figure 3 , S203, hash encoder processing: use hash encoder to process the features Encode and obtain the source domain relaxed hash code H s and the target domain relaxed hash code H t ; The processing method of the hash encoder specifically includes the following steps:
[0172] S2031, obtain the source domain relaxed hash code: by HashEncoder(·;θ hash ) for features Encode and generate the source domain relaxed hash code H s , for n s The relaxed hash code of the source domain vibration signal sample is:
[0173]
[0174] in, r is the length of the hash code;
[0175] S2032, obtain the target domain relaxed hash code: by HashEncoder(·; θ hash ) for features Encode and generate the target domain relaxed hash code
[0176] in, r is the length of the hash code;
[0177] S204, relax the source domain hash code H s and the target domain relaxed hash code H t Input feature classifier, which consists of the first fully connected layer and the second fully connected layer to output the probability of bearing fault type. The specific content is as follows:
[0178] First, relax the hash code H in the source domain s Or the target domain relaxed hash code Ht Represented as F, they are respectively used as the input of the feature classifier, first pass through the first fully connected layer, and then perform nonlinear transformation through the ReLU activation function to obtain z1, that is:
[0179] z1=ReLU(W1F+b1)
[0180] Among them, z1 represents the feature output of the first fully connected layer, F is H s or H t , W1 is the weight matrix of the first fully connected layer, b1 is the bias vector of the first fully connected layer;
[0181] Next, z1 is input into the second fully connected layer. The number of neurons in the second fully connected layer is determined according to the actual number of fault types cls. The output layer uses the Softmax function to map the input to the probability distribution of fault types:
[0182] G=Softmax(W2z1+b2)
[0183] Where W2 is the weight matrix of the second fully connected layer, b2 is the bias vector of the second fully connected layer, and G is a vector containing cls elements, each element represents the predicted probability of the corresponding fault type;
[0184] Finally, as the fault diagnosis result, the element with the highest probability is selected from the vector G. The index corresponding to this element represents the most likely bearing fault type predicted by the model, thereby achieving accurate determination of the bearing fault type.
[0185] S3. Constructing a composite loss function The bearing fault diagnosis model built by training makes the composite loss function minimize, Defined as:
[0186]
[0187] in, is the cross entropy classification loss function, is the prototype contrast loss function, is the relationship preserving loss function, is the quantization loss function; α, β, γ and δ are trade-off parameters used to adjust In the composite loss function The relative importance of , so that the model can achieve a balance between different optimization objectives;
[0188] In step S3, the cross entropy classification loss function Used to measure the difference between the model prediction results and the true label, cross entropy classification loss is based on the true label y of the sampleij And the model predicted probability p ij Calculation, the calculation formula is:
[0189]
[0190] Among them, n s is the number of source domain vibration signal samples, cls is the total number of fault types, y ij Indicates the true label of the i-th sample belonging to the j-th fault type, p ij is the probability of predicting that the i-th sample belongs to the j-th fault type; log(·) is the logarithmic function;
[0191] In step S3, the prototype contrast loss function The specific calculation process is:
[0192] Step S301: Based on the fault type label c, calculate the prototype feature of the c-th fault type in the source domain vibration signal The calculation formula is:
[0193]
[0194] in, is the feature of the source domain vibration signal sample extracted by the self-attention encoder, is the indicator function, when Returns 1 if the condition is met, otherwise returns 0; n s represents the number of samples of the source domain vibration signal, and c corresponds to the fault type label;
[0195] Step S302: Perform normalization processing, that is Through each Normalize and uniformly scale their lengths to 1, thereby mapping all prototype features of the source domain vibration signal and the target domain vibration signal onto the same unit hypersphere, forming a domain-shared hypersphere plane space;
[0196] Step S303: Obtain pseudo labels for target domain vibration signal data In order to realize the transfer of source domain knowledge to target domain, the nearest source prototype method is used to assign pseudo labels to target data. Based on the prototype characteristics of each fault type Determine the pseudo label for the target domain vibration signal sample using the formula:
[0197]
[0198] in, represents the independent variable c that maximizes the function, cos(·) is used to calculate the cosine similarity, is the feature extracted by the self-attention encoder of the jth target domain vibration signal sample, j = 1, 2, ..., n t , It is the prototype characteristic of the cth type of fault in the vibration signal;
[0199] Step S304: Calculate prototype features of target domain vibration signal: Calculate prototype features of target domain vibration signal based on pseudo labels of target domain vibration signal data. The formula is:
[0200]
[0201] Among them, n t Indicates the number of target domain vibration signal samples;
[0202] Step S305: Similarly, Perform normalization processing, that is
[0203] Step S306: Constructing a prototype contrast loss function To promote domain alignment and obtain uniform and conflict-free feature representations, The calculation formula is:
[0204]
[0205] in, is the prototype feature of the i-th fault in the target domain vibration signal, where i is the category index except the c-th fault type; exp(·) is the exponential function, log(·) is the logarithmic function, cls is the total number of fault types, and τ is the temperature parameter.
[0206] By establishing a prototype contrastive learning loss function, the model successfully narrowed the gap between the source and target domains, obtaining uniform and conflict-free feature representations. This not only improves the model's ability to extract bearing fault features under different operating conditions, but also provides a more discriminative feature foundation for subsequent fault diagnosis tasks. This enables the model to more accurately distinguish different fault types when faced with complex and changing bearing operating data, laying a solid foundation for accurate fault diagnosis.
[0207] In step S3, the relationship preservation loss function and quantization loss function The specific calculation process is:
[0208] Step S307: Calculate the similarity matrix S based on the source domain fault type label s (known technology), similarity matrix S s Used to reflect the source domain vibration signal x s(t) Similarity relationship between samples based on source domain fault type labels;
[0209] Step S308: Use the source domain fault type label to guide hash learning: In order to constrain the source domain to relax the hash code H s Retain the sample similarity relationship and transform the source domain vibration signal x s (t) The similarity relationship between samples is integrated into hash learning, so that the similarity between hash codes can approach the sample similarity calculated based on the source domain fault type label, thereby retaining the similarity relationship of the source domain vibration signal samples in the hash code, which is calculated by the following formula:
[0210]
[0211] in, represents the relationship preservation loss function, η is the scaling factor, H s is the relaxed hash code of the source domain vibration signal sample; ||·|| F is the F norm, S s is the similarity matrix calculated based on the fault type of the source domain vibration signal samples; cos(·) is the cosine function;
[0212] F norm is Frobenius Norm.
[0213] Step S309, cross-domain relationship constraint: To achieve cross-domain knowledge transfer and ensure that similar features in the domain-shared hypersphere plane space generate similar hash codes, the formula is used:
[0214]
[0215] in They are the source domain vibration signal x s (t) and target domain vibration signal x t (t) Feature representation after processing by the self-attention encoder, H s 、H t are the corresponding relaxed hash codes; cos(·) is the cosine function; through this constraint, the source domain vibration signal and the target domain vibration signal maintain consistency in feature representation and hash code generation, enhancing the cross-domain adaptability of the model;
[0216] Step S310, fusion relationship loss: the above two loss functions and Fusion is a relation-preserving loss function By comprehensively considering the source domain label guidance and cross-domain relationship constraints, the model can better balance the information of the source domain and the target domain when learning the hash code. The formula for optimizing the hash code learning process is as follows:
[0217]
[0218] Among them, γ is the balance factor;
[0219] Step S311, quantization loss: In order to make the relaxed hash code close to the binary hash code, make the hash code more in line with the actual application requirements, improve the storage and retrieval efficiency, and thus improve the efficiency and accuracy of bearing fault diagnosis, a quantization loss function is defined. The formula is:
[0220]
[0221] Among them, B s 、B t are binary hash codes of the source domain vibration signal samples and the target domain vibration signal samples, respectively, H s 、H t are the relaxed hash codes of the source domain vibration signal samples and the target domain vibration signal samples, respectively.
[0222] During the training of the bearing fault diagnosis model, the composite loss function is first calculated based on the training sample data. Then, backpropagation is used to obtain the gradients of the corresponding relaxed hash codes with respect to all learnable parameters in the embedding layer, self-attention encoder, hash encoder, and feature classifier (known technique). Finally, the Adam (Adaptive Moment Estimation) optimizer is used to adaptively update these learnable parameters (known technique) according to the gradient direction to gradually minimize the composite loss function.
[0223] Composite loss function In the cross entropy classification loss function Push the model prediction results closer to the actual fault type, thereby improving the accuracy of diagnosis and enabling the model to accurately identify different fault states of the bearing. Promote the alignment of source domain vibration signals and target domain vibration signals, help the model obtain more discriminative feature representations, and enhance the ability to distinguish bearing fault characteristics under different working conditions. Ensure that the similarity between samples is preserved in the hash code, strengthen the model's ability to capture bearing fault characteristics under different working conditions, and assist cross entropy classification loss to more accurately determine the fault type. Quantified loss function This approach makes the relaxed hash code closer to the binary hash code, improving data storage efficiency while also accelerating the model's ability to match fault samples when processing large amounts of data. This optimizes the model's overall performance and indirectly improves the cross-entropy classification loss. During training, by adjusting the parameters α, β, γ, and δ, the model achieves a balance between different optimization objectives, comprehensively improving its performance in bearing fault diagnosis tasks.
[0224] The present invention divides the collected vibration signals into source domain vibration signals and target domain vibration signals, and pre-processes the collected data by using continuous wavelet transform (WT) as a time-frequency analysis method. The input data is then mapped to a low-dimensional and dense vector space through embedding layer processing, thereby reducing the data dimension while retaining key information, reducing the amount of calculation and model parameters. At the same time, in this space, data points with similar semantics are also closer in distance, which helps the model better learn and capture data features. The embedding layer processing introduces additional structural and semantic features to the data of the source domain vibration signal and the target domain vibration signal, which not only improves the expressive power of the source domain vibration signal and the target domain vibration signal data, but also enables the model to better capture and distinguish the feature differences and commonalities in the two domain data, enhances the model's ability to capture the features of data from different domains, and provides more effective data representation for subsequent fault diagnosis across the source domain vibration signal and the target domain vibration signal.
[0225] The data processed by the embedding layer is passed through the self-attention encoder to accurately capture the key features of the bearing data under different working conditions, so that subsequent hash learning can be carried out based on more representative features. They contain the key information of the source domain vibration signal and the target domain vibration signal samples, and will participate in the calculation of the prototype code of the source domain vibration signal and the target domain vibration signal, the generation of hash codes and the calculation of related loss functions.
[0226] After processing by the hash encoder, the generated hash code achieves efficient data compression and fast retrieval while preserving key data features. This not only significantly improves the efficiency of bearing fault diagnosis, enabling rapid location of faulty samples within large amounts of data, but also ensures diagnostic accuracy by maintaining similarity between samples. The hash encoder works closely with prototype contrastive learning to provide a complete and efficient solution for bearing fault diagnosis, effectively improving the model's performance in practical applications. A feature classifier is then used to output the probability of the bearing fault type.
[0227] Constructing a composite loss function During the training and optimization process of the bearing fault diagnosis model, multiple loss functions collaborate to drive model learning and achieve accurate fault diagnosis. Cross-entropy classification loss plays a central role in the model's classification task and, combined with other loss functions, effectively improves the performance of the bearing fault diagnosis model.
[0228] In order to verify the effectiveness of the method of the present invention, the following experiments were performed:
[0229] (I) A rolling bearing fault simulation test bench was used to accurately simulate three different speed conditions: 1000 rpm, 2000 rpm, and 3000 rpm. These were considered as three working conditions and represented as 0, 1, and 2. During the experiment, the rolling bearing was operated under these three different speed conditions, and four types of fault states were set, including rolling element fault, inner ring fault, outer ring fault, and mixed fault, in addition to normal operating conditions. Specific information is shown in Table 1:
[0230] Table 1 Rolling bearing speed operating conditions and fault status parameters
[0231]
[0232] Collect bearing vibration signals under different working conditions and divide them into source domain (training) and target domain (testing) samples. Select a certain working condition as the source domain sample: for example, the bearing vibration signal of working condition 0 is recorded as x s , including n s samples (covering 5 types of fault conditions). Select another working condition as the target domain sample, for example, the bearing vibration signal of working condition 1 or working condition 2 is recorded as x t (t), corresponding to n t samples (all belonging to the same 5 types of fault states, but with different working conditions resulting in data distribution differences). In order to solve the problem of insufficient model generalization ability caused by data distribution differences under different working conditions and to achieve efficient knowledge transfer for cross-working condition fault diagnosis, this paper designs 6 cross-working condition tasks under three different working conditions to evaluate the diagnostic accuracy of the model. ab To represent the task (a→b), we use Q ab To represent the cross-condition migration task. Among them, a and b are the subscripts representing different conditions, and → represents the migration direction. The meaning of this symbol is: the task of migrating from condition a (source domain condition, used for training) to condition b (target domain condition, used for testing). Specifically expressed as Q 01 , Q 02 , Q 10 , Q 12 , Q 20 , Q 21 Detailed information is shown in Table 2:
[0233] Table 2 Cross-domain task parameters of rolling bearing load conditions
[0234] Task Symbol Source domain conditions (training) Target domain conditions (test) Physical meaning <![CDATA[Q 01 ]]> 0 (1000 rpm) 1(2000 rpm) Low speed → medium speed <![CDATA[Q 02 ]]> 0 (1000 rpm) 2 (3000 rpm) Low speed → high speed <![CDATA[Q 10 ]]> 1(2000 rpm) 0 (1000 rpm) Medium speed → low speed <![CDATA[Q 12 ]]> 1(2000 rpm) 2 (3000 rpm) Medium speed → high speed <![CDATA[Q 20 ]]> 2 (3000 rpm) 0 (1000 rpm) High speed → low speed <![CDATA[Q 21 ]]> 2 (3000 rpm) 1(2000 rpm) High speed → medium speed
[0235] In order to prove the effectiveness of the recognition method (Proposed) of the present invention, five other models were used for comparison, namely Baseline (baseline model), JAN (joint adaptive network), MKMMD (multi-core maximum mean difference), CORAL (correlation alignment), and DANN (domain adversarial neural network). The experimental results are shown in Table 3. Table 3 comprehensively presents the fault diagnosis performance of the recognition method model (Proposed) of the present invention and multiple comparison models of Baseline, JAN, MKMMD, CORAL, and DANN under different tasks. It can be seen from Table 3 that the recognition method (Proposed) proposed by the present invention achieved the best diagnostic accuracy, significantly surpassing other comparison models. First of all, from the results of the average accuracy, the average accuracy of the model proposed by the present invention reached 96.49±0.07%, which is a significant lead compared with other models. Taking the most difficult task Q 02 Taking the diagnosis result of (the change in working conditions from low speed to high speed leads to large differences in vibration signal characteristics (such as frequency, amplitude, and noise), which makes it impossible to directly generalize the features learned by the model and easily induces negative transfer) as an example, the accuracy rate obtained by the Baseline method is only 74.55%, while with the help of the method proposed in the present invention, the accuracy rate is greatly improved to 94.25%, which greatly reduces the possibility of misjudgment. This result fully demonstrates that the cross-working condition bearing fault diagnosis method based on prototype domain alignment feature encoding proposed in the present invention has powerful capabilities and can effectively extract more discriminative features. Even in the face of complex and changeable working conditions, it can accurately identify the fault type of rolling bearing. In summary, in the problem of rolling bearing fault diagnosis under variable working conditions, the method proposed in the present invention provides a more efficient and accurate solution for this field by virtue of its excellent performance and high reliability. It is expected to play an important role in actual engineering applications and help improve the safety and stability of equipment operation.
[0236] Table 3 Diagnostic accuracy of rolling bearing fault simulation device data
[0237]
[0238] Second, we used a rolling element bearing dataset provided by Case Western Reserve University (CWRU), which is often used by researchers as a benchmark for testing diagnostic methods. This dataset contains four health states: normal (N), rolling element fault (RF), inner race fault (IF), and outer race fault (OF). Each fault has three different damage levels on the bearing: 0.007 inches, 0.014 inches, and 0.021 inches. Furthermore, the experimental platform was operated under four different load conditions: 0 horsepower, 1 horsepower, 2 horsepower, and 3 horsepower. The specific information is shown in Table 4:
[0239] Table 4 Rolling bearing load conditions and fault status parameters
[0240] Corner mark Working conditions Motor load Data characteristics 0 Working condition 0 0 horsepower No load, low vibration signal noise 1 Working condition 1 1 horsepower With light load, the vibration frequency and amplitude increase slightly 2 Working condition 2 2 horsepower Medium load, increased signal complexity 3 Working condition 3 3 horsepower Heavy load, more complex vibration characteristics and louder noise
[0241] Similar to the above experiment, when dividing the source domain vibration signal and target domain vibration signal samples, the vibration signal under a certain working condition is selected as the source domain training data, including n s Samples of different fault types and damage degrees are used to train the model to extract fault features that are not related to the load; signals under another working condition are selected as target domain test data, including n t Samples with different fault types and damage degrees are used to verify the diagnostic capability of the model under unknown load conditions.
[0242] In order to verify the migration ability of the model between asymmetric load conditions and solve the interference of signal complexity and noise level changes caused by load differences on fault diagnosis, 12 cross-condition migration tasks (denoted as T) were designed based on the vibration signals collected from CWRU bearing data under four different working conditions (covering different working scenarios, represented by 0, 1, 2, and 3 respectively). ab ), indicating that the model is trained under source domain operating condition a and identifies bearing fault samples under target domain operating condition b, covering all asymmetric operating condition combinations. Through cross-operating condition transfer tasks, the proposed method's feature generalization capability across load conditions is systematically evaluated to address the diagnostic challenges caused by load variations in real industrial scenarios. Specific task information is shown in Table 5:
[0243] Table 5 Cross-domain task parameters for rolling bearing speed conditions
[0244] Task Symbol Source domain conditions (training) Target domain conditions (test) Physical meaning <![CDATA[T 01 ]]> 0(0HP) 1(1HP) No load → Light load <![CDATA[T 02 ]]> 0(0HP) 2(2HP) No load → Medium load <![CDATA[T 03 ]]> 0(0HP) 3(3HP) No load → Heavy load <![CDATA[T 10 ]]> 1(1HP) 0(0HP) Light load → No load <![CDATA[T 12 ]]> 1(1HP) 2(2HP) Light load → Medium load <![CDATA[T 13 ]]> 1(1HP) 3(3HP) Light load → Heavy load <![CDATA[T 20 ]]> 2(2HP) 0(0HP) Medium load → No load <![CDATA[T 21 ]]> 2(2HP) 1(1HP) Medium load → Light load <![CDATA[T 23 ]]> 2(2HP) 3(3HP) Medium load → Heavy load <![CDATA[T 30 ]]> 3(3HP) 0(0HP) Heavy load → No load <![CDATA[T 31 ]]> 3(3HP) 1(1HP) Heavy load → Light load <![CDATA[T 32 ]]> 3(3HP) 2(2HP) Heavy load → Medium load
[0245] On the Case Western Reserve University (CWRU) dataset, the proposed method was compared with the Baseline, JAN, MKMMD, CORAL, and DANN methods, and the diagnostic accuracy in different cross-domain tasks was evaluated. The experimental results are respectively Figure 4 and Table 6 presents. Figure 4 It can be seen intuitively that in each cross-domain task, the diagnostic accuracy of the method of the present invention is in a leading position and is significantly higher than other comparison methods. As can be seen from Table 6, the diagnostic accuracy of the method of the present invention has obvious numerical advantages. From the perspective of the overall average accuracy, the method of the present invention is as high as 99.84±0.06%, which is significantly ahead of the highest MKMMD (94.76±0.72%) among other comparison methods. Secondly, in some more difficult tasks, such as task T 03(The working conditions range from no load to high load. High load may introduce stronger background noise or nonlinear vibration, resulting in a large difference between the signal characteristics and the source domain. The model needs to overcome a larger domain offset). The accuracy of the method of the present invention is 96.89±0.11%, while the lowest DANN is only 77.34±0.43%. These experimental results fully demonstrate that the method proposed in the present invention can more accurately identify faults in the cross-domain task of bearing fault diagnosis, and effectively improve the diagnostic accuracy. Its high accuracy and stability in different tasks have significant advantages over other existing methods, and have important application value and significance for actual bearing fault diagnosis.
[0246] Table 6 Diagnostic accuracy on the Case Western Reserve University (CWRU) dataset
[0247]
[0248] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Those skilled in the art will readily appreciate that the present invention is susceptible to various modifications and variations. Any modifications, equivalent substitutions, or improvements to the present invention are intended to fall within the scope of protection of the present invention.
Claims
1. A cross-operating bearing fault diagnosis method based on prototype domain alignment feature encoding, characterized by: The following steps are involved: S1. Data collection and preprocessing: S101. Data collection: Simulate the operating conditions of bearings in the laboratory, including operating conditions of different speeds, different loads, and fault types, collect bearing vibration signal data of all fault types under all operating conditions, and select different operating conditions to divide the collected bearing vibration signal data into source domain vibration signals x s (t) and target domain vibration signal x t (t); where the source domain vibration signal x s (t) including n s samples Target domain vibration signal x t (t) including n t samples Source domain vibration signal x s (t) Known working condition data for model training, with real fault type labels, total number of fault types cls, fault type label c; target domain vibration signal x t (t) For unknown working condition data used in cross-working condition testing, pseudo labels are inferred through source domain knowledge; S102, data preprocessing: After the data collection is completed, the source domain vibration signal x s (t) and target domain vibration signal x t All samples of (t) are preprocessed using continuous wavelet transform and converted into source domain time-frequency features and target domain time-frequency features S2. Build a bearing fault diagnosis model, which includes an embedding layer, a self-attention encoder, a hash encoder, and a feature classifier. and target domain time-frequency features Input the bearing fault diagnosis model for processing, which specifically includes the following steps: S201, the source domain time-frequency features and target domain time-frequency features Through the embedding layer processing, we get the embedded sequence and S202, using self-attention encoder to and Processing is performed to obtain the features f s and feature f t , where the source domain vibration signal x s (t)n s samples After being processed by the self-attention feature encoder, the features are obtained Recorded as Target domain vibration signal x t (t)n t samples After being processed by the self-attention feature encoder, the features are obtained Recorded as S203, hash encoder processing: Use hash encoder to process the features respectively Encode and obtain the source domain relaxed hash code H s and the target domain relaxed hash code H t ; S204, relax the source domain hash code H s and the target domain relaxed hash code H t Input feature classifier to output the probability of bearing fault type; S3. Constructing a composite loss function The bearing fault diagnosis model built by training makes the composite loss function minimize, Defined as: in, is the cross entropy classification loss function, is the prototype contrast loss function, is the relationship preserving loss function, is the quantization loss function; α, β, γ and δ are trade-off parameters used to adjust In the composite loss function The relative importance of the two parameters is used to balance the model between different optimization objectives.
2. A cross-operating-condition bearing fault diagnosis method based on prototype domain alignment feature coding according to claim 1, characterized in that: In step S102, the source domain vibration signal x s (t) is converted to For example, the conversion formula for continuous wavelet transform preprocessing is: Among them, a is the scale parameter and τ is the time translation parameter; is the wavelet basis function of wavelet transform, and t represents the sampling moment of the time series; Target domain vibration signal x t (t) Also using wavelet transform, the time-frequency characteristics of the target domain are finally obtained 3. The cross-operating-condition bearing fault diagnosis method based on prototype domain alignment feature coding according to claim 1 is characterized in that: In step S201, the specific method of embedding layer processing is: Source domain time-frequency features For example, the embedding layer processing specifically includes the following steps: S2011, Data Reshaping: Converting source domain time-frequency features Evenly divided into N patches, satisfying N = H × W / P 2 , These patches are then rearranged into a sequence: in, represents the i-th patch (i = 1, 2, 3, ..., N), P is the side length of the patch, N is the number of patches, H, W, C are the source domain time-frequency features, respectively The height, width and number of channels; reshape means rearrangement; S2012, Linear Projection and Embedding: Use a learnable linear projection matrix to map the patch sequence into a high-dimensional embedding space to obtain an embedded sequence The specific form is shown in the formula: in, represents the embedding weight matrix, d is the embedding dimension; S2013, calculate the position code: in order to preserve the absolute position information and relative position information of the patch, embed the sequence Added absolute position information E pos , using sine function and cosine function to alternately represent position information, using sine function and cosine function of different frequencies to generate position code, absolute position information E pos The calculation process is: AND (POS,2q+1) =cos(POS / 10000 2q / d ) AND (POS,2q) =sin(POS / 10000 2q / d ) AND pos =[And (POS,1) ,AND (POS,2) ,AND (POS,3) ,...,AND (POS,N) ] Among them, E is the position encoding matrix; POS represents the position index, representing In patch sequence ; q represents the dimension, even dimensions correspond to 2q, odd dimensions correspond to 2q+1; d represents the embedding dimension, (POS,q) represents the POS-th row and q-th column in the position encoding matrix P; N is the number of patches, 10000 is a constant chosen empirically; cos(·) is the cosine function, and sin(·) is the sine function; S2014, add position encoding and classification tags: introduce a vector x class , used as feature representation to obtain the embedded sequence x class Obtained by the following formula: in, N is the number of patches and d is the embedding dimension.
4. The cross-operating-condition bearing fault diagnosis method based on prototype domain alignment feature coding according to claim 1 is characterized in that: In step S202, the self-attention encoder is composed of two sub-layers: a multi-head self-attention layer and an MLP feed-forward network. The multi-head self-attention layer has h attention heads. The specific processing steps of the self-attention encoder are as follows: S2021, with the source domain vibration signal x s (t) as an example, the output sequence after processing by the embedding layer As the input of the self-attention feature encoder, Through the linear transformation corresponding to h attention heads, we get the query vector Q, key vector K and value vector V corresponding to h groups. For the query vector Q of the i-th attention head i , key vector K i , value vector V i , the calculation formulas are: Where h is the number of attention heads; are the weight matrices corresponding to the i-th attention head, i = 1, 2, 3, ..., h; S2022, within the i-th attention head, the attention weights are calculated using the scaled dot product attention mechanism, and the value matrix is weighted summed according to these weights, as follows: Among them, Attention represents the attention mechanism operation, It's K i The transposed matrix, d k It's K i Dimension, softmax is an activation function that converts the input vector into a probability distribution; S2023, concatenates the outputs of h attention heads according to the feature dimension, integrates the information captured by different heads to form a richer feature representation, and passes the linear transformation matrix W of the linear layer O Fusion is performed to obtain the final output of the multi-head attention mechanism The formula is as follows: in h is the number of attention heads, Concat(·) is the concatenation function, and W O is the linear transformation matrix; S2024, the final output of the multi-head attention mechanism Perform layer normalization to obtain The formula is as follows: Where LN(·) represents layer normalization, μ and σ are The mean and standard deviation of , ε is the scaling parameter, which adjusts the scaling degree of the normalized data; ∈ is the offset parameter, which translates the scaled data; S2025. Output the normalized multi-head attention With embedded sequence Residual connection to obtain fused features S2026, fused features Enter the multi-layer perceptron MLP to further extract features and get f s : S2027, source domain vibration signal x s (t)n s samples After processing steps S2021-S2026 respectively, the features are obtained Recorded as Target domain vibration signal x t (t)n t samples After the same processing of steps S2021-S2026, the feature Recorded as 5. The cross-operating-condition bearing fault diagnosis method based on prototype domain alignment feature coding according to claim 4 is characterized in that: In step S2026, the formula for further feature extraction by the multi-layer perceptron MLP is: Among them, Dropout p (·) represents random dropout operation with probability p, represents the linear transformation of the first linear layer; K1, K2 are weight matrices, b is the bias vector, GELU(·) represents the application of Gaussian error linear unit activation function, and Linear(·) represents the linear transformation of the second linear layer.
6. The cross-operating-condition bearing fault diagnosis method based on prototype domain alignment feature coding according to claim 1 is characterized in that: In step S203, the processing method of the hash encoder specifically includes the following steps: S2031, obtain the source domain relaxed hash code: by HashEncoder(·;θ hash ) for features Encode and generate the source domain relaxed hash code H s , for n s The relaxed hash code of the source domain vibration signal sample is: in, r is the length of the hash code; S2032, obtain the target domain relaxed hash code: by HashEncoder(·; θ hash ) for features Encode and generate the target domain relaxed hash code in, r is the length of the hash code.
7. The cross-operating-condition bearing fault diagnosis method based on prototype domain alignment feature coding according to claim 1 is characterized in that: In step S204, the feature classifier is composed of a first fully connected layer and a second fully connected layer to output the probability of the bearing fault type. The specific steps are as follows: First, relax the hash code H in the source domain s Or the target domain relaxed hash code H t Represented as F, they are respectively used as the input of the feature classifier, first pass through the first fully connected layer, and then perform nonlinear transformation through the ReLU activation function to obtain z1, that is: z1=ReLU(W1F+b1) Among them, z1 represents the feature output of the first fully connected layer, F is H s or H t , W1 is the weight matrix of the first fully connected layer, b1 is the bias vector of the first fully connected layer; Next, z1 is input into the second fully connected layer. The number of neurons in the second fully connected layer is determined according to the actual number of fault types cls. The output layer uses the Softmax function to map the input to the probability distribution of fault types: G=Softmax(W2z1+b2) Where W2 is the weight matrix of the second fully connected layer, b2 is the bias vector of the second fully connected layer, and G is a vector containing cls elements, each element represents the predicted probability of the corresponding fault type; Finally, as the fault diagnosis result, the element with the highest probability is selected from the vector G. The index corresponding to this element represents the most likely bearing fault type predicted by the model, thereby achieving accurate judgment of the bearing fault type.
8. The cross-operating-condition bearing fault diagnosis method based on prototype domain alignment feature coding according to claim 1 is characterized in that: The cross entropy classification loss function in step S3 Used to measure the difference between the model prediction results and the true label, cross entropy classification loss is based on the true label y of the sample ij And the model predicted probability p ij Calculation, the calculation formula is: Among them, n s is the number of source domain vibration signal samples, cls is the total number of fault types, y ij Indicates the true label of the i-th sample belonging to the j-th fault type, p ij It is the probability of predicting that the i-th sample belongs to the j-th fault type, and log(·) is the logarithmic function.
9. The cross-operating-condition bearing fault diagnosis method based on prototype domain alignment feature coding according to claim 1, characterized in that: The prototype contrast loss function in step S3 The specific calculation process is: Step S301: Based on the fault type label c, calculate the prototype feature of the c-th fault type in the source domain vibration signal The calculation formula is: in, is the feature of the source domain vibration signal sample extracted by the self-attention encoder, is the indicator function, when Returns 1 if the condition is met, otherwise returns 0; n s represents the number of samples of the source domain vibration signal, and c corresponds to the fault type label; Step S302: Perform normalization processing, that is Through each Normalize and uniformly scale their lengths to 1, thereby mapping all prototype features of the source domain vibration signal and the target domain vibration signal onto the same unit hypersphere, forming a domain-shared hypersphere plane space; Step S303: Obtain pseudo labels for target domain vibration signal data In order to realize the transfer of source domain knowledge to target domain, the nearest source prototype method is used to assign pseudo labels to target data. Based on the prototype characteristics of each fault type Determine the pseudo label for the target domain vibration signal sample using the formula: in, represents the independent variable c that maximizes the function, cos(·) is used to calculate the cosine similarity, is the feature extracted by the self-attention encoder of the jth target domain vibration signal sample, j = 1, 2, ..., n t , It is the prototype feature of the cth type of fault in the source domain vibration signal; Step S304: Calculate prototype features of target domain vibration signal: Calculate prototype features of target domain vibration signal based on pseudo labels of target domain vibration signal data. The formula is: Among them, n t Indicates the number of target domain vibration signal samples; Step S305: Similarly, Perform normalization processing, that is Step S306: Constructing a prototype contrast loss function To promote domain alignment and obtain uniform and conflict-free feature representations, The calculation formula is: in, is the prototype feature of the i-th fault in the target domain vibration signal, where i is the category index except the c-th fault type; exp(·) is the exponential function, log(·) is the logarithmic function, cls is the total number of fault types, and τ is the temperature parameter.
10. The cross-operating-condition bearing fault diagnosis method based on prototype domain alignment feature coding according to claim 1, characterized in that: In step S3, the relationship preservation loss function and quantization loss function The specific calculation process is: Step S307: Calculate the similarity matrix S based on the source domain fault type label s , similarity matrix S s Used to reflect the source domain vibration signal x s (t) Similarity relationship between samples based on source domain fault type labels; Step S308: Use the source domain fault type label to guide hash learning: In order to constrain the source domain to relax the hash code H s Retain the sample similarity relationship and transform the source domain vibration signal x s (t) The similarity relationship between samples is integrated into hash learning, so that the similarity between hash codes can approach the sample similarity calculated based on the source domain fault type label, thereby retaining the similarity relationship of the source domain vibration signal samples in the hash code, which is calculated by the following formula: in, represents the relationship preservation loss function, η is the scaling factor, H s is the relaxed hash code of the source domain vibration signal sample; ||·|| F is the F norm, S s is the similarity matrix calculated based on the fault type of the source domain vibration signal samples; cos(·) is the cosine function; Step S309, cross-domain relationship constraint: To achieve cross-domain knowledge transfer and ensure that similar features in the domain-shared hypersphere plane space generate similar hash codes, the formula is used: in They are the source domain vibration signal x s (t) and target domain vibration signal x t (t) Feature representation after processing by the self-attention encoder, H s 、H t are the corresponding relaxed hash codes; cos(·) is the cosine function; through this constraint, the source domain vibration signal and the target domain vibration signal maintain consistency in feature representation and hash code generation, enhancing the cross-domain adaptability of the model; Step S310, fusion relationship loss: the above two loss functions and Fusion is a relation-preserving loss function The formula is as follows: Among them, γ is the balance factor; Step S311, quantization loss: In order to make the relaxed hash code close to the binary hash code, make the hash code more in line with the actual application requirements, improve the storage and retrieval efficiency, and thus improve the efficiency and accuracy of bearing fault diagnosis, a quantization loss function is defined. The formula is: Among them, B s 、B t are the binary hash codes of the source domain vibration signal and the target domain vibration signal, H s 、H t are the relaxed hash codes of the source domain vibration signal and the target domain vibration signal, respectively.
Citation Information
Patent Citations
Variable working condition gearbox fault diagnosis method based on fusion feature extraction network
CN117272172A
Image retrieval method based on unsupervised domain adaptive hash
CN117874277A
Partial multi-modal Hash method based on fine-grained feature fusion
CN118981507A
Intelligent fault diagnosis method and system for ship propulsion shafting
CN119669854A
Cited By
Context-aware intelligent retrieval method suitable for multi-domain heterogeneous data
CN121301625A
Injection molding process fault diagnosis method based on domain generalization time sequence feature fusion
CN122442903A
Injection molding process fault diagnosis method based on domain generalization time sequence feature fusion
CN122442903B