Cross-condition bearing fault diagnosis method based on prototype domain alignment feature coding
By combining self-attention encoders and hash encoders, accurate mapping and alignment of bearing fault diagnosis models under different operating conditions are achieved, solving the problem of data distribution differences in complex high-dimensional systems, improving diagnostic accuracy and robustness, and reducing annotation costs.
Patent Information
- Application Number
- CN202510616704.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-14
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2045-05-14
AI Technical Summary
Existing bearing fault diagnosis methods lack generalization performance in complex high-dimensional systems, struggle to adapt to differences in data distribution under different operating conditions, and rely on large-scale labeled data, resulting in high costs.
A prototype domain-aligned feature encoding method is adopted. By combining self-attention encoder and hash encoder with embedding layer, continuous wavelet transform and composite loss function, the source domain and target domain features are accurately mapped and aligned, reducing the dependence on labeled data and improving the diagnostic performance of the model under complex conditions.
It significantly improves the accuracy and robustness of bearing fault diagnosis, reduces data annotation costs, can accurately identify fault types under complex working conditions, and enhances the model's adaptability and generalization ability.
Smart Images

Figure CN120541740B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of bearing fault diagnosis technology, and in particular to a cross-condition bearing fault diagnosis method based on prototype domain aligned feature encoding. Background Technology
[0002] In today's industrial sector, rotating machinery plays an indispensable role in many key industries such as manufacturing and energy. As a core component of rotating machinery, the operating condition of bearings directly affects the reliability and stability of the entire equipment. Bearing failure can lead to unexpected equipment shutdowns, production disruptions, and even serious safety accidents, resulting in significant economic losses. Therefore, achieving high-precision bearing fault diagnosis is crucial for ensuring the smooth operation of industrial production, 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, in complex, high-dimensional systems, the versatility of these physical models is limited. With continuous innovation in industrial technology, the structures of rotating machinery are becoming increasingly complex and precise, highlighting the limitations of traditional fault diagnosis methods. In recent years, data-driven intelligent fault diagnosis methods have attracted significant attention from researchers due to their high accuracy and low dependence on prior knowledge.
[0004] Deep learning methods, with their powerful feature learning capabilities, have achieved significant results in bearing fault diagnosis. Convolutional Neural Networks (CNNs) can effectively process high-dimensional data and automatically extract image-based fault features; Recurrent Neural Networks (RNNs) and their variants, such as Long Short-Term Memory (LSTM) networks, 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 testing data come from the same distribution. In real-world industrial scenarios, the distribution of bearing data varies significantly under different operating conditions, leading to decreased generalization performance of the models and making it difficult to meet practical needs.
[0005] To address the issue of distribution differences between different data domains, domain adaptation techniques have emerged. These techniques aim to narrow the gap between the data distributions of the source and target domains, enabling knowledge transfer from the source to the target domain and providing an effective approach for cross-condition bearing fault diagnosis. Among existing domain adaptation methods, (1) methods based on metric learning: These methods aim to achieve feature alignment by minimizing the statistical differences between the source and target domain data, thereby promoting knowledge transfer. A typical example is Maximum Mean Difference (MMD), which narrows the gap between the data distributions of the two domains by calculating and minimizing the distance metric loss between the features of the source and target domains. Its principle is to measure the difference between the two distributions in the Regenerative Kernel Hilbert Space (RKHS), making the features of the source and target domains more similar to some extent, thus achieving domain adaptation. (2) Methods based on adversarial learning: Drawing on the idea of Generative Adversarial Networks (GANs), a domain discriminator is introduced to distinguish between the source and target domain data, while forcing the feature extractor to generate domain-invariant features. Taking Domain Adversarial Neural Networks (DANNs) as an example, during training, the feature extractor strives to generate features that the domain discriminator cannot distinguish, 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 differences between the source domain and the target domain are reduced, and the generalization ability of the model is improved. However, both methods have the following drawbacks: (1) When calculating the distribution difference, the metric learning method may ignore the correlation between the features and the fault label, making it difficult to guarantee the fine granularity of domain adaptation and easily leading to feature alignment errors; (2) In the process of aligning the domain distribution, the adversarial learning method may lose 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 heavily rely on large-scale labeled data. The labeling process requires significant investment of manpower, resources, and time, resulting in high costs. The diversity and variability of operating conditions also greatly increase 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 limited labeled data, reduce the differences in fault data distribution under different operating conditions, and improve the generalization ability of fault diagnosis models for complex operating conditions are important technical challenges that urgently need to be addressed. Summary of the Invention
[0007] To address the aforementioned issues, the present invention aims to provide a cross-condition bearing fault diagnosis method based on prototype domain aligned feature encoding. This invention accurately maps and aligns the data feature space, effectively resolving data modal differences caused by variations in 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] To achieve the above objectives, the present invention adopts the following technical solution: a cross-condition bearing fault diagnosis method based on prototype domain aligned feature encoding, comprising the following steps:
[0009] S1. Data Acquisition and Preprocessing:
[0010] S101. Data Acquisition: Simulate bearing operating conditions in the laboratory, including different speeds, loads, and fault types. Collect bearing vibration signal data for all fault types under all operating conditions, and divide the collected bearing vibration signal data into source domain vibration signals x under different operating conditions. s (t) and the vibration signal in the target domain x t (t); where the source domain vibration signal x s (t) includes n s Sample Target domain vibration signal x t (t) includes n t Sample Source domain vibration signal x s (t) Known operating condition data used for model training, labeled with actual fault types, total number of fault types cls, fault type label c; target domain vibration signal x t (t) Unknown operating condition data used for cross-condition testing, pseudo-labels inferred through source domain knowledge;
[0011] S102. Data Preprocessing: After data acquisition, the source domain vibration signal x is preprocessed. s (t) and the vibration signal in the target domain x t All samples of (t) are preprocessed using continuous wavelet transform to convert them into source domain time-frequency features. and target domain time-frequency features
[0012] S2. Construct a bearing fault diagnosis model, which includes an embedding layer, a self-attention encoder, a hash encoder, and a feature classifier, to integrate the source domain time-frequency features. and target domain time-frequency features The input bearing fault diagnosis model is processed, specifically including the following steps:
[0013] S201, Source domain time-frequency characteristics and target domain time-frequency features The embedded sequences are obtained by processing them through the embedding layer. and
[0014] S202, Using a self-attention encoder to respectively... and The features f are obtained through processing. s and feature f t Among them, the source domain vibration signal x s n of (t) s Sample The features are obtained by processing them separately through a self-attention feature encoder. Recorded as Target domain vibration signal x t n of (t) t Sample The features are obtained by processing them separately through a self-attention feature encoder. Recorded as
[0015] S203, Hash Encoder Processing: A hash encoder is used to process the features separately. Encode to obtain the source domain relaxed hash code H s and target domain relaxed hash code H t ;
[0016] S204, convert the source domain relaxation hash code H s and target domain relaxed hash code H t Input the feature classifier to output the probability of bearing failure type;
[0017] S3. Constructing a composite loss function The bearing fault diagnosis model built through training makes the composite loss function minimize, Defined as:
[0018]
[0019] in, It is the cross-entropy classification loss function. It is a prototype-contrast loss function. It is the relation-preserving loss function. This is the quantization loss function; α, β, γ, and δ are trade-off parameters used to adjust... In the composite loss function The relative importance of each factor allows the model to achieve a balance among different optimization objectives.
[0020] Furthermore, in step S102, the source domain vibration signal x s (t) is converted to For example, the transformation formula for preprocessing continuous wavelet transform is:
[0021]
[0022] Where a is the scale parameter and τ is the time shift parameter; These are the wavelet basis functions of the wavelet transform, where t represents the sampling time of the time series;
[0023] Target domain vibration signal x t(t) Similarly, using wavelet transform, the time-frequency features of the target domain are finally obtained.
[0024] Furthermore, in step S201, the specific method for the embedding layer processing is as follows:
[0025] Source domain time-frequency characteristics For example, the embedding layer processing specifically includes the following steps:
[0026] S2011, Data Reshaping: Reconstructing Source Domain Time-Frequency Features Divide the area into N patches evenly, satisfying N = H × W / P 2 , Then rearrange these patches into a sequence:
[0027]
[0028] in, Let P represent the i-th patch (i = 1, 2, 3, ..., N), where P is the side length of the patch, N is the number of patches, and H, W, and C represent the time-frequency characteristics of the source domain, respectively. Height, width, and number of channels; reshape indicates rearrangement;
[0029] S2012, Linear Projection and Embedding: Using a learnable linear projection matrix, the patch sequence is mapped to a high-dimensional embedding space to obtain the embedded sequence. See the formula for the specific form:
[0030]
[0031] in, This represents the embedding weight matrix, where d is the embedding dimension;
[0032] S2013, Calculate position encoding: In order to preserve the absolute and relative position information of the patch, for the embedded sequence Added absolute position information E pos The system uses sine and cosine functions to alternately represent position information, and uses sine and cosine functions of different frequencies to generate position codes. The absolute position information E pos The calculation process is as follows:
[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] Where E is the position encoding matrix; POS represents the position index, indicating... In patch sequence The position; 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 row and q column in the position encoding matrix P; N is the number of patches, 10000 is a constant chosen based on experience;
[0037] S2014, Adding Location Encoding and Classification Labels: Introducing a vector x class This is used as a feature representation to obtain the embedded sequence. x class Obtain it using the formula below:
[0038]
[0039] in, N represents the number of patches, and d represents the embedding dimension.
[0040] Furthermore, in step S202, the self-attention encoder consists of two sub-layers: a multi-head self-attention layer and an MLP feedforward 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, using the source domain vibration signal x s Taking (t) as an example, the output sequence after processing by the embedding layer As input to the self-attention feature encoder, After linear transformations corresponding to h attention heads, h sets of query vectors Q, key vectors K, and value vectors V are obtained. For the query vector Q of the i-th attention head... i Key vector K i Value vector V i The calculation formulas are as follows:
[0042]
[0043] Where h is the number of attention heads; These are the weight matrices corresponding to the i-th attention head, i = 1, 2, 3, ..., h;
[0044] In 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 and summed based on these weights, as shown in the following formula:
[0045]
[0046] Where Attention represents the attention mechanism operation. It is K i The transpose of d k It is K i In terms of dimensions, softmax is an activation function that transforms the input vector into a probability distribution;
[0047] S2023 concatenates the outputs of h attention heads along the feature dimension, integrating the information captured by different heads to form a richer feature representation, and then applies a linear transformation matrix W to the linear layer. O By fusing the results, the final output of the multi-head attention mechanism is obtained. The formula is as follows:
[0048]
[0049] in h is the number of attention heads, Concat(·) is the concatenation function, and W O It is a linear transformation matrix;
[0050] S2024, the final output of the multi-head attention mechanism Layer normalization is performed to obtain The formula is as follows:
[0051]
[0052] Where LN(·) represents layer normalization, and μ and σ are respectively The mean and standard deviation are given by ε, which is the scaling parameter that adjusts the scaling of the normalized data; ∈ is the offset parameter that shifts the scaled data.
[0053] S2025, Normalize the multi-head attention output With embedded sequence Residual connections are used to obtain the fused features.
[0054]
[0055] S2026, Features after fusion The feature is further extracted by a multilayer perceptron (MLP) to obtain f. s :
[0056]
[0057] S2027, Source Domain Vibration Signal x s n of (t) s Sample After processing through steps S2021-S2026 respectively, the features are obtained. Recorded as
[0058] Target domain vibration signal x t n of (t) t Sample After the same processing steps S2021-S2026, the features are obtained. Recorded as
[0059] Furthermore, in step S2026, the formula for further feature extraction by the multilayer perceptron (MLP) is as follows:
[0060]
[0061] Dropout p (·) indicates a random deactivation operation with probability p. denoted as the linear transformation of the first linear layer; K1 and K2 are weight matrices, b is the bias vector, GELU(·) denotes the application of the Gaussian error linear unit activation function, and Linear(·) denotes the linear transformation of the second linear layer.
[0062] Furthermore, in step S203, the hash encoder processing method specifically includes the following steps:
[0063] S2031. Obtain the source domain relaxed hash code: by hash encoder HashEncoder(·θ) hash ) for features Encode the source domain to generate a relaxed hash code H. s For n s The relaxation hash code for each source domain vibration signal sample is:
[0064]
[0065] in, r is the length of the hash code;
[0066] S2032. Obtain the relaxed hash code of the target domain: by hash encoder HashEncoder(·θ) hash) Features Encode the target domain to generate a relaxed hash code.
[0067] in, r is the length of the hash code.
[0068] Furthermore, in step S204, the feature classifier consists of a first fully connected layer and a second fully connected layer, which outputs the probability of bearing failure type. The specific steps are as follows:
[0069] First, using the source domain relaxed hash code H s Or target domain relaxed hash code H t Let F be the input to the feature classifier. The input first passes through a fully connected layer, then undergoes a non-linear transformation using the ReLU activation function to obtain z1, i.e.:
[0070] z1 = ReLU(W1F + b1)
[0071] Where z1 represents the feature output of the first fully connected layer, and F is the feature output of H. s or H t W1 is the weight matrix of the first fully connected layer, and 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 based on 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 representing 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 determination of the bearing fault type.
[0076] Furthermore, the cross-entropy classification loss function in step S3 Cross-entropy classification loss is used to measure the difference between the model's predicted results and the true labels. Based on the true label y of the sample ij and model predicted probability p ij The calculation formula is as follows:
[0077]
[0078] Where, n s y is the number of source domain vibration signal samples, cls is the total number of fault types, log(·) is the logarithmic function, and y ij p represents the true label of the i-th sample belonging to the j-th fault type. ijIt predicts the probability that the i-th sample belongs to the j-th fault type.
[0079] Furthermore, the prototype contrastive loss function in step S3 The specific calculation process is as follows:
[0080] Step S301: Based on the fault type label c, calculate the prototype features of the c-th fault type in the source domain vibration signal. The calculation formula is:
[0081]
[0082] in, These are the features extracted from the source domain vibration signal samples by the self-attention encoder. For indicator functions, when Returns 1 if the condition is true, otherwise returns 0; n s The number of samples representing the source domain vibration signal, and c corresponds to the fault type label;
[0083] Step S302, for Perform normalization processing, that is By each Normalization scales its length 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 vibration signal data in the target domain. To achieve the transfer of knowledge from the source domain to the target domain, the nearest source prototype method is used to assign pseudo-labels to the target data. Based on the prototype characteristics of each fault type The formula for determining pseudo-labels for vibration signal samples in the target domain is:
[0085]
[0086] in, Let c be the independent variable that makes the function reach its maximum value. cos(·) is used to calculate the cosine similarity. These are the features extracted from the j-th target domain vibration signal sample by the self-attention encoder, where j = 1, 2, ..., n t , It is a prototype feature of the c-th type of fault in the source domain vibration signal;
[0087] Step S304: Calculate the prototype features of the target domain vibration signal: Based on the pseudo-labels of the target domain vibration signal data, calculate the prototype features of the target domain vibration signal. The formula is:
[0088]
[0089] Where, n t Indicates the number of vibration signal samples in the target domain;
[0090] Step S305, similarly, for Perform normalization processing, that is
[0091] Step S306: Construct the prototype contrastive loss function To promote domain alignment and obtain uniform and class-conflicting feature representations, The calculation formula is:
[0092]
[0093] in, is the prototype feature of the i-th type of fault in the vibration signal of the target domain, where i is the category index other than the c-th type of fault; 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 relation-preserving loss function and quantization loss function The specific calculation process is as follows:
[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 relationships between samples based on source domain fault type labels;
[0096] Step S308: Guide hash learning using source domain fault type labels: In order to constrain the source domain relaxed hash code H s Preserving sample similarity, the source domain vibration signal x s (t) The similarity between samples is incorporated into hash learning, so that the similarity between hash codes can approximate the sample similarity calculated based on the source domain fault type label, thus preserving the similarity between source domain vibration signal samples in the hash code, which is calculated by the following formula:
[0097]
[0098] in, This represents the relation-preserving loss function, where η is the scaling factor, and H... s It is the relaxed hash code of the source domain vibration signal sample; ||·|| F Let S be the F-norm. sIt is a similarity matrix calculated based on the fault type of the source domain vibration signal samples, and cos(·) is a cosine function;
[0099] Step S309, Cross-Domain Relationship Constraints: To achieve cross-domain knowledge transfer and ensure that similar features in the domain-shared hypersphere generate similar hash codes, the following formula is used:
[0100]
[0101] in, These are the source domain vibration signals x s (t) and the vibration signal in the target domain x t (t) Feature representation after processing by the self-attention encoder, H s H t These 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, thereby enhancing the cross-domain adaptability of the model;
[0102] Step S310, Fusion Relationship Loss: Combine the above two loss functions and Fusion into relation-preserving loss function The formula is as follows:
[0103]
[0104] Where γ is the balance factor;
[0105] Step S311, Quantization Loss: To make the relaxed hash code approximate the binary hash code, making the hash code more in line with practical application requirements, improving storage and retrieval efficiency, and thus improving 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 These are the binary hash codes of the source domain vibration signal and the target domain vibration signal, respectively, H s H t These are the relaxation hash codes of the source domain vibration signal and the target domain vibration signal, respectively.
[0108] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0109] This invention proposes a bearing fault diagnosis method based on self-attention hashing encoding for complex operating conditions, addressing the challenges posed by diverse data characteristics. The invention employs specific data preprocessing and embedding layer techniques, leveraging the advantages of self-attention encoders in feature extraction to accurately capture key features of bearing data under different operating conditions. This effectively overcomes the challenges posed by data distribution differences, providing reliable data support for fault diagnosis. Simultaneously, a prototype hashing framework is introduced. By constructing a domain-shared unit hypersphere, prototype comparison learning is conducted to maximize the distance between prototypes of different categories, enhancing the feature compactness of similar samples and transforming sample relationships into prototype relationships, further improving the discriminative power of features. By accurately mapping and aligning the data feature space, this invention effectively solves the problem of data modality differences caused by varying operating conditions, thereby significantly improving the performance of the diagnostic model under complex operating conditions, significantly increasing the accuracy of cross-condition bearing fault diagnosis, ensuring accurate identification of fault types under different operating conditions, and reducing the false positive rate.
[0110] Meanwhile, this invention reduces reliance on large-scale labeled data. Through an efficient domain adaptation strategy, it fully utilizes a small amount of labeled source domain data and unlabeled target domain data for model training and testing, reducing data labeling costs and improving the model's adaptability and generalization ability. This invention enhances the robustness of fault diagnosis models, enabling them to consistently output reliable diagnostic results even in complex and ever-changing industrial environments, despite noise interference and data fluctuations. Attached Figure Description
[0111] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate the invention and are used to explain it, but do not constitute an undue limitation of the invention.
[0112] Figure 1 This is a flowchart of a bearing fault diagnosis method for complex operating conditions based on self-attention hash coding according to the present invention.
[0113] Figure 2 This is a flowchart of the self-attention encoder process.
[0114] Figure 3 This is a flowchart of the hash encoder's processing flow.
[0115] Figure 4 This is a histogram of diagnostic results from Case Western Reserve University (CWRU) under cross-condition tasks. Detailed Implementation
[0116] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.
[0117] Reference Figure 1 A cross-condition bearing fault diagnosis method based on prototype domain aligned feature encoding includes the following steps:
[0118] S1. Data Acquisition and Preprocessing:
[0119] S101. Data Acquisition: Simulate bearing operating conditions in the laboratory, including different speeds, loads, and fault types. Collect bearing vibration signal data for all fault types under all operating conditions, and divide the collected bearing vibration signal data into source domain vibration signals x under different operating conditions. s (t) and the vibration signal in the target domain x t (t); where the source domain vibration signal x s (t) includes n s Sample Target domain vibration signal x t (t) includes n t Sample Source domain vibration signal x s (t) Known operating condition data used for model training, labeled with actual fault types, total number of fault types cls, fault type label c; target domain vibration signal x t (t) Unknown operating condition data used for cross-condition testing, pseudo-labels inferred through source domain knowledge;
[0120] S102. Data Preprocessing: After data acquisition, the source domain vibration signal x is preprocessed. s (t) and the vibration signal in the target domain x t All samples of (t) are preprocessed using continuous wavelet transform to convert them into source domain time-frequency features. and target domain time-frequency features Using the source domain vibration signal x s (t) is converted to For example, the conversion formula is:
[0121]
[0122] Where a is the scale parameter and τ is the time shift parameter; These are the wavelet basis functions of the wavelet transform, where t represents the sampling time of the time series;
[0123] Target domain vibration signal x t (t) Similarly, using wavelet transform, the time-frequency features of the target domain are finally obtained.
[0124] S2. Construct a bearing fault diagnosis model, which includes an embedding layer, a self-attention encoder, a hash encoder, and a feature classifier, to integrate the source domain time-frequency features. and target domain time-frequency features The input bearing fault diagnosis model is processed, specifically including the following steps:
[0125] S201, Source domain time-frequency characteristics and target domain time-frequency features The embedded sequences are obtained by processing them through the embedding layer. and The role of the embedding layer is to map the input data to a low-dimensional and dense vector space, thereby reducing data dimensionality, computational cost, and model parameters while preserving key information. Simultaneously, in this space, semantically similar data points are closer in distance, helping the model to better learn and capture data features. The specific methods of the embedding layer are as follows:
[0126] Source domain time-frequency characteristics For example, the embedding layer processing specifically includes the following steps:
[0127] S2011, Data Reshaping: Reconstructing Source Domain Time-Frequency Features Divide the area evenly into N patches of a specific size, satisfying the following conditions: Then rearrange these patches into a sequence:
[0128]
[0129] in, Let P represent the i-th patch (i = 1, 2, 3, ..., N), where P is the side length of the patch, N is the number of patches, and H, W, and C represent the time-frequency characteristics of the source domain, respectively. Height, width, and number of channels; reshape indicates rearrangement;
[0130] S2012, Linear Projection and Embedding: Using a learnable linear projection matrix, the patch sequence is mapped to a high-dimensional embedding space to obtain the embedded sequence. See the formula for the specific form:
[0131]
[0132] in, This represents the embedding weight matrix, where d is the embedding dimension;
[0133] S2013, Calculate position encoding: In order to preserve the absolute and relative position information of the patch, for the embedded sequence Added absolute position information E pos The system uses sine and cosine functions to alternately represent position information, and uses sine and cosine functions of different frequencies to generate position codes. The absolute position information E pos The calculation process is as follows:
[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] Where E is the position encoding matrix; POS represents the position index, indicating... In patch sequence The position; 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 row and q column in the position coding matrix P; N is the number of patches, 10000 is a constant chosen based on experience; cos(·) is the cosine function, sin(·) is the sine function;
[0138] S2014, Adding positional encoding and classification labels: Introducing a learnable vector x class This is used as a feature representation to obtain the embedded sequence. x class Obtain it using the formula below:
[0139]
[0140] in, All are learnable parameters; N is the number of patches, and d represents the embedding dimension;
[0141] S202, Using a self-attention encoder to respectively... and The features f are obtained through processing. s and feature f t Among them, the source domain vibration signal x s n of (t) s Sample The features are obtained by processing them separately through a self-attention feature encoder. Recorded as Target domain vibration signal x t n of (t) t Sample The features are obtained by processing them separately through a self-attention feature encoder. Recorded as
[0142] Reference Figure 2 The self-attention encoder consists of two sub-layers: a multi-head self-attention layer and an MLP feedforward network. After the output sequence of the embedding layer enters each sub-layer, it is first normalized using layer normalization (LN) to stabilize the data distribution. Then, residual connections are used to directly fuse the sub-layer output with the input, preventing gradient vanishing and enhancing feature propagation. The multi-head attention mechanism allows the model to focus on different parts of the input sequence in parallel across 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, broadening or restoring feature dimensions and introducing nonlinear factors. This enables the model to better learn complex feature relationships, improve its understanding and expression of input information, and better integrate with other parts of the model, providing a higher-quality feature foundation for subsequent hash encoding.
[0143] 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, using the source domain vibration signal x s Taking (t) as an example, the output sequence after processing by the embedding layer As input to the self-attention feature encoder, After linear transformations corresponding to h attention heads, h sets of query vectors Q, key vectors K, and value vectors V are obtained. For the query vector Q of the i-th attention head... i Key vector K i Value vector V i The calculation formulas are as follows:
[0145]
[0146] Where h is the number of attention heads; These are the learnable weight matrices corresponding to the i-th attention head, i = 1, 2, 3, ..., h;
[0147] In S2022, each attention head independently focuses on different feature subspaces of the input sequence, capturing the relationships between elements from different perspectives. Within the i-th attention head, a scaled dot product attention mechanism is used to calculate attention weights, and the value matrix is weighted and summed based on these weights, as shown in the following formula:
[0148]
[0149] Where Attention represents the attention mechanism operation. It is K i The transpose of d k It is K iIn terms of dimensions, softmax is an activation function that transforms the input vector into a probability distribution;
[0150] S2023 concatenates the outputs of h attention heads along the feature dimension, integrating the information captured by different heads to form a richer feature representation, and then applies a linear transformation matrix W to the linear layer. O By fusing the results, the final output of the multi-head attention mechanism is obtained. The formula is as follows:
[0151]
[0152] in h is the number of attention heads, Concat(·) is the concatenation function, and W O It is a learnable linear transformation matrix;
[0153] S2024, the final output of the multi-head attention mechanism Layer normalization is performed to obtain The formula is as follows:
[0154]
[0155] Where LN(·) represents layer normalization, and μ and σ are respectively The mean and standard deviation of the data, ε is a learnable scaling parameter that adjusts the scaling of the normalized data; ∈ is a learnable offset parameter that shifts the scaled data.
[0156] S2025, Normalize the multi-head attention output With embedded sequence Residual connections are used to obtain the fused features.
[0157]
[0158] S2026, Features after fusion The feature is further extracted by a multilayer perceptron (MLP) to obtain f. s :
[0159]
[0160] The further feature extraction by the Multilayer Perceptron (MLP) includes the following steps:
[0161] 1) First linear layer processing: The input data first enters the first linear layer, where it undergoes a linear transformation by multiplying with the weight matrix, changing the dimension of the data and mapping the input features to a new feature space, thus achieving the initial processing of the features;
[0162] 2) Gaussian error linear unit processing: The data processed by the first linear layer enters the Gaussian error linear unit. The nonlinear factor is introduced through the Gaussian error linear unit GELU activation function. Through this function, the model can learn more complex feature relationships, improve the model's expressive ability, and solve nonlinear problems that linear models cannot handle.
[0163] 3) Second linear layer processing: The features activated by the GELU activation function enter the second linear layer again for a second linear transformation to further adjust the feature representation and uncover more complex relationships between features;
[0164] 4) Random deactivation: Perform random deactivation operation with probability p.
[0165] The formula for further feature extraction using a Multilayer Perceptron (MLP) is as follows:
[0166]
[0167] Dropout p (·) indicates a random deactivation operation with probability p. denoted as the linear transformation of the first linear layer; K1, K2 are weight matrices, b is the bias vector, GELU(·) denotes the application of the Gaussian error linear unit activation function, and Linear(·) denotes the linear transformation of the second linear layer;
[0168] S2027, Source Domain Vibration Signal x s n of (t) s Sample After processing through steps S2021-S2026 respectively, the features are obtained. Recorded as
[0169] Target domain vibration signal x t n of (t) t Sample After the same processing steps S2021-S2026, the features are obtained. Recorded as
[0170] After feature mining using a self-attention encoder, highly discriminative feature representations are obtained. However, the high dimensionality of the original features poses challenges for rapid storage and retrieval, making it difficult to meet the efficiency requirements of actual bearing fault diagnosis. Therefore, a hash encoder is introduced. This module, as the core part of transforming features into efficient diagnostic information, maps high-dimensional features to low-dimensional hash codes through multi-step operations. This process significantly reduces data storage space, greatly improves data retrieval speed, and effectively enhances fault diagnosis efficiency, enabling the rapid and accurate acquisition of effective diagnostic information, thus supporting the timely location and resolution of bearing faults.
[0171] Reference Figure 3 S203, Hash Encoder Processing: A hash encoder is used to process the features separately. Encode to obtain the source domain relaxed hash code H s and target domain relaxed hash code H t The hash encoder's processing method specifically includes the following steps:
[0172] S2031. Obtain the source domain relaxed hash code: by hash encoder HashEncoder(·θ) hash ) for features Encode the source domain to generate a relaxed hash code H. s For n s The relaxation hash code for each source domain vibration signal sample is:
[0173]
[0174] in, r is the length of the hash code;
[0175] S2032. Obtain the relaxed hash code of the target domain: by hash encoder HashEncoder(·θ) hash ) for features Encode the target domain to generate a relaxed hash code.
[0176] in, r is the length of the hash code;
[0177] S204, convert the source domain relaxation hash code H s and target domain relaxed hash code H t The input feature classifier, consisting of a first fully connected layer and a second fully connected layer, outputs the probability of bearing fault types, as detailed below:
[0178] First, using the source domain relaxed hash code H s Or target domain relaxed hash code Ht Let F be the input to the feature classifier. The input first passes through a fully connected layer, then undergoes a non-linear transformation using the ReLU activation function to obtain z1, i.e.:
[0179] z1 = ReLU(W1F + b1)
[0180] Where z1 represents the feature output of the first fully connected layer, and F is the feature output of H. s or H t W1 is the weight matrix of the first fully connected layer, and 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 based on 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 representing 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 through training makes the composite loss function minimize, Defined as:
[0186]
[0187] in, It is the cross-entropy classification loss function. It is a prototype-contrast loss function. It is the relation-preserving loss function. This is the quantization loss function; α, β, γ, and δ are trade-off parameters used to adjust... In the composite loss function The relative importance of each factor allows the model to achieve a balance among different optimization objectives;
[0188] In step S3, the cross-entropy classification loss function Cross-entropy classification loss is used to measure the difference between the model's predicted results and the true labels. Based on the true label y of the sampleij and model predicted probability p ij The calculation formula is as follows:
[0189]
[0190] Where, n s y is the number of vibration signal samples in the source domain, cls is the total number of fault types, and y is the number of vibration signal samples in the source domain. ij p represents the true label of the i-th sample belonging to the j-th fault type. ij It predicts the probability 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 as follows:
[0192] Step S301: Based on the fault type label c, calculate the prototype features of the c-th fault type in the source domain vibration signal. The calculation formula is:
[0193]
[0194] in, These are the features extracted from the source domain vibration signal samples by the self-attention encoder. For indicator functions, when Returns 1 if the condition is true, otherwise returns 0; n s The number of samples representing the source domain vibration signal, and c corresponds to the fault type label;
[0195] Step S302, for Perform normalization processing, that is By each Normalization scales its length 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 vibration signal data in the target domain. To achieve the transfer of knowledge from the source domain to the target domain, the nearest source prototype method is used to assign pseudo-labels to the target data. Based on the prototype characteristics of each fault type The formula for determining pseudo-labels for vibration signal samples in the target domain is:
[0197]
[0198] in, Let c be the independent variable that makes the function reach its maximum value. cos(·) is used to calculate the cosine similarity. These are the features extracted from the j-th target domain vibration signal sample by the self-attention encoder, where j = 1, 2, ..., n t , It is a prototype feature of the c-th type of fault in the vibration signal;
[0199] Step S304: Calculate the prototype features of the target domain vibration signal: Based on the pseudo-labels of the target domain vibration signal data, calculate the prototype features of the target domain vibration signal. The formula is:
[0200]
[0201] Where, n t Indicates the number of vibration signal samples in the target domain;
[0202] Step S305, similarly, for Perform normalization processing, that is
[0203] Step S306: Construct the prototype contrastive loss function To promote domain alignment and obtain uniform and class-conflicting feature representations, The calculation formula is:
[0204]
[0205] in, is the prototype feature of the i-th type of fault in the vibration signal of the target domain, where i is the category index other than the c-th type of fault; 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 class-conflict-free feature representations. This not only improved the model's ability to extract bearing fault features under different operating conditions but also provided 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 varied bearing operating data, laying a solid foundation for precise fault diagnosis.
[0207] In step S3, the relation-preserving loss function and quantization loss function The specific calculation process is as follows:
[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 relationships between samples based on source domain fault type labels;
[0209] Step S308: Guide hash learning using source domain fault type labels: In order to constrain the source domain relaxed hash code H s Preserving sample similarity, the source domain vibration signal x s (t) The similarity between samples is incorporated into hash learning, so that the similarity between hash codes can approximate the sample similarity calculated based on the source domain fault type label, thus preserving the similarity between source domain vibration signal samples in the hash code, which is calculated by the following formula:
[0210]
[0211] in, This represents the relation-preserving loss function, where η is the scaling factor, and H... s It is the relaxed hash code of the source domain vibration signal sample; ||·|| F Let S be the F-norm. s It is a similarity matrix calculated based on the fault type of the source domain vibration signal samples; cos(·) is the cosine function;
[0212] The F-norm is also known as the Frobenius Norm.
[0213] Step S309, Cross-Domain Relationship Constraints: To achieve cross-domain knowledge transfer and ensure that similar features in the domain-shared hypersphere generate similar hash codes, the following formula is used:
[0214]
[0215] in These are the source domain vibration signals x s (t) and the vibration signal in the target domain x t (t) Feature representation after processing by the self-attention encoder, H s H t These 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, thereby enhancing the cross-domain adaptability of the model;
[0216] Step S310, Fusion Relationship Loss: Combine the above two loss functions and Fusion into relation-preserving loss function By comprehensively considering source domain label guidance and cross-domain relationship constraints, the model can better balance the information from the source and target domains when learning hash codes. The optimized formula for the hash code learning process is as follows:
[0217]
[0218] Where γ is the balance factor;
[0219] Step S311, Quantization Loss: To make the relaxed hash code approximate the binary hash code, making the hash code more in line with practical application requirements, improving storage and retrieval efficiency, and thus improving 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 These are the binary hash codes of the source domain vibration signal sample and the target domain vibration signal sample, respectively, H. s H t These are the relaxed hash codes of the source domain vibration signal sample and the target domain vibration signal sample, respectively.
[0222] In the training process 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 (a well-known technique). Finally, the Adam (Adaptive Moment Estimation) optimizer is used to adaptively update these learnable parameters according to the gradient direction (a well-known technique) to gradually minimize the composite loss function.
[0223] Composite loss function In the middle, the cross-entropy classification loss function This aims to improve diagnostic accuracy by pushing model predictions closer to actual fault types, enabling the model to accurately identify different bearing fault states. Prototype-based comparison loss function. This promotes feature alignment between source and target domain vibration signals, helping the model obtain more discriminative feature representations and enhancing its ability to distinguish bearing fault characteristics under different operating conditions. Relationship-preserving loss function. This ensures that the similarity between samples is preserved in the hash code, enhancing the model's ability to capture bearing fault characteristics under different operating conditions and assisting cross-entropy classification loss in more accurately determining the fault type. Quantization loss function. This approach encourages relaxed hash codes to approximate binary hash codes, improving data storage efficiency and accelerating the model's matching speed for fault samples when processing large amounts of data. This optimizes the overall model performance and indirectly enhances the effectiveness of cross-entropy classification loss. During training, adjusting parameters such as α, β, γ, and δ allows the model to achieve a balance among different optimization objectives, comprehensively improving its performance in bearing fault diagnosis tasks.
[0224] This invention divides the acquired vibration signals into source domain vibration signals and target domain vibration signals. It preprocesses the acquired data using continuous wavelet transform (WT) as a time-frequency analysis method. Furthermore, through an embedding layer, the input data is mapped to a low-dimensional and dense vector space, thereby reducing data dimensionality, computational load, and model parameters while retaining key information. Simultaneously, semantically similar data points are closer in distance within this space, aiding the model in better learning and capturing data features. The embedding layer introduces additional structural and semantic features into both the source and target domain vibration signals, enhancing their individual expressive power and enabling the model to better capture and distinguish the feature differences and commonalities between the two domains. This strengthens the model's ability to capture features from different domains, providing a more effective data representation for subsequent fault diagnosis across the source and target domains.
[0225] The data processed by the embedding layer is accurately captured by the self-attention encoder to capture the key features of bearing data under different working conditions, so that subsequent hash learning can be based on more representative features. These features contain key information of source domain vibration signal and target domain vibration signal samples, and will participate in the calculation of source domain vibration signal and target domain vibration signal prototype code, hash code generation and related loss function calculation.
[0226] After processing by the hash encoder, the generated hash code retains key data features while achieving efficient data compression and fast retrieval. This not only significantly improves the efficiency of bearing fault diagnosis, making it possible to quickly locate fault samples in large amounts of data, but also ensures diagnostic accuracy by maintaining the similarity relationship 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. Then, a feature classifier is used to output the probability of bearing fault types.
[0227] Constructing a composite loss function In the training and optimization process of the bearing fault diagnosis model, multiple loss functions work together to promote model learning and achieve accurate fault diagnosis. Among them, cross-entropy classification loss plays a core role in the model's classification task, and when combined with other loss functions, it effectively improves the performance of the bearing fault diagnosis model.
[0228] To verify the effectiveness of the method of the present invention, the following experiments were conducted:
[0229] (I) A rolling bearing failure simulation test bench was used to accurately simulate three different speed conditions: 1000 rpm, 2000 rpm, and 3000 rpm, which were represented as three operating conditions, denoted as 0, 1, and 2, respectively. During the experiment, the rolling bearing was operated under these three different speed conditions, and four types of failure states were set, including rolling element failure, inner ring failure, outer ring failure, and mixed failure, as well as normal operation. Specific information is shown in Table 1.
[0230] Table 1. Rolling Bearing Speed, Operating Conditions, and Fault Status Parameters
[0231]
[0232] Bearing vibration signals under different operating conditions are collected and divided into source domain (training) and target domain (test) samples. A specific operating condition is selected as the source domain sample: for example, the bearing vibration signal under operating condition 0 is denoted as x. s , containing n s One sample (covering 5 types of fault states). Another operating condition is selected as the target domain sample, for example, the bearing vibration signal of operating condition 1 or operating condition 2 is denoted as x. t (t), corresponding to n t The sample consists of five fault states, but the data distribution varies due to different operating conditions. To address the insufficient generalization ability of the model caused by the difference in data distribution under different operating conditions and to achieve efficient knowledge transfer for cross-operating condition fault diagnosis, this invention designs six cross-operating condition tasks under three different operating conditions to evaluate the diagnostic accuracy of the model. Q is used... ab To represent the task (a→b), use Q. ab This symbol represents a cross-condition migration task. Here, 'a' and 'b' represent different condition indices, and '→' indicates the migration direction. The symbol signifies a task that migrates from condition a (source domain condition, used for training) to condition b (target domain condition, used for testing). Specifically, it is represented 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 for rolling bearing load conditions
[0234] Task Symbol Source domain operating conditions (training) Target domain operating 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] To demonstrate the effectiveness of the proposed identification method, five other models were compared: Baseline, JAN (Joint Adaptive Network), MKMMD (Multi-kernel Maximum Mean Difference), CORAL (Correlation Alignment), and DANN (Domain Adversarial Neural Network). The experimental results are shown in Table 3, which comprehensively presents the fault diagnosis performance of the proposed identification method model against Baseline, JAN, MKMMD, CORAL, and DANN on different tasks. Table 3 shows that the proposed identification method achieves the best diagnostic accuracy, significantly outperforming other comparative models. Firstly, considering the average accuracy, the proposed model achieves an average accuracy of 96.49 ± 0.07%, a significant lead over other models. Taking the most difficult task Q… 02 Taking the diagnostic results of a bearing fault diagnosis under varying operating conditions (such as low-speed to high-speed operation leading to significant differences in vibration signal characteristics (e.g., frequency, amplitude, noise) as an example, the accuracy obtained using the baseline method was only 74.55%, while the accuracy was significantly improved to 94.25% using the method proposed in this invention, greatly reducing the possibility of misjudgment. This result fully demonstrates that the cross-condition bearing fault diagnosis method based on prototype domain aligned feature encoding proposed in this invention has powerful capabilities, effectively extracting more discriminative features, and accurately identifying the fault type of rolling bearings even in the face of complex and changing operating conditions. In summary, the method proposed in this invention provides a more efficient and accurate solution for the problem of rolling bearing fault diagnosis under varying operating conditions, thanks to its superior performance and high reliability. It is expected to play an important role in practical engineering applications, helping to improve the safety and stability of equipment operation.
[0236] Table 3. Diagnostic accuracy of rolling bearing fault simulation device data.
[0237]
[0238] II. A rolling bearing dataset provided by Case Western Reserve University (CWRU) was used, which is often used by researchers as a standard for testing diagnostic methods. This dataset contains four health states: normal (N), rolling element failure (RF), inner ring failure (IF), and outer ring failure (OF). Each failure is assigned three different damage levels on the bearing: 0.007 inches, 0.014 inches, and 0.021 inches. The experimental platform was operated under four different load conditions: 0 hp, 1 hp, 2 hp, and 3 hp. Specific information is shown in Table 4.
[0239] Table 4 Load Condition and Fault Status Parameters of Rolling Bearings
[0240] Subscript Operating conditions motor load Data characteristics 0 Operating condition 0 0 horsepower No load, low vibration signal noise 1 Operating Condition 1 1 horsepower Under light load, the vibration frequency and amplitude increase slightly. 2 Operating Condition 2 2 horsepower Medium load, increased signal complexity 3 Operating Condition 3 3 horsepower Heavy loads result in more complex vibration characteristics and greater noise.
[0241] Similar to the experiments described above, when dividing the source domain vibration signal and target domain vibration signal samples, vibration signals under a certain working condition were selected as the source domain training data, containing n... s Samples of different fault types and damage degrees are used to train the model to extract load-independent fault features; signals under another operating condition are selected as the target domain test data, containing n t Samples with different fault types and damage levels were used to verify the model's diagnostic capabilities under unknown load conditions.
[0242] To verify the model's ability to migrate between asymmetric load conditions and to address the interference of signal complexity and noise level variations caused by load differences on fault diagnosis, 12 cross-load condition migration tasks (denoted as T) were designed based on vibration signals collected from CWRU bearing data under four different operating conditions (covering different working scenarios, represented by 0, 1, 2, and 3 respectively). ab The expression indicates that the model is trained under source domain condition a and identifies bearing fault samples under target domain condition b, covering all asymmetric condition combinations. Through a cross-condition transfer task, the feature generalization ability of the method of this invention under cross-load conditions is systematically evaluated to address the diagnostic challenges caused by load changes in real-world industrial scenarios. Specific task information is shown in Table 5.
[0243] Table 5 Rolling Bearing Speed Operating Condition Cross-Domain Task Parameter Table
[0244] Task Symbol Source domain operating conditions (training) Target domain operating conditions (test) Physical meaning <![CDATA[T 01 ]]> 0 (0HP) 1 (1 HP) 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 (1 HP) 0 (0HP) Light load → No load <![CDATA[T 12 ]]> 1 (1 HP) 2 (2HP) Light load → Medium load <![CDATA[T 13 ]]> 1 (1 HP) 3 (3HP) Light load → Heavy load <![CDATA[T 20 ]]> 2 (2HP) 0 (0HP) Medium load → No load <![CDATA[T 21 ]]> 2 (2HP) 1 (1 HP) 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 (1 HP) Heavy load → Light load <![CDATA[T 32 ]]> 3 (3HP) 2 (2HP) Heavy load → Medium load
[0245] The proposed method was compared with Baseline, JAN, MKMMD, CORAL, and DANN methods on the Case Western Reserve University (CWRU) dataset, and the diagnostic accuracy was evaluated in different cross-domain tasks. Experimental results are presented as follows: Figure 4 And as presented in Table 6. From Figure 4 It can be intuitively seen that in each cross-domain task, the diagnostic accuracy of the method of this invention is in a leading position, significantly higher than other comparative methods. Table 6 shows that the diagnostic accuracy of the method of this invention has a clear numerical advantage. In terms of the overall average accuracy, the method of this invention reaches 99.84±0.06%, significantly outperforming the highest among the comparative methods, MKMMD (94.76±0.72%). Furthermore, in some more difficult tasks, such as task T… 03(In a scenario where the operating condition changes from no load to high load, and high load may introduce stronger background noise or nonlinear vibrations, leading to a large difference between the signal characteristics and the source domain, the model needs to overcome a larger domain shift.) The accuracy of the method proposed in this invention is 96.89±0.11%, while the lowest accuracy of DANN is only 77.34±0.43%. These experimental results fully demonstrate that the method proposed in this invention can more accurately identify faults and effectively improve diagnostic accuracy in bearing fault diagnosis across different tasks. Its high accuracy and stability under different tasks have significant advantages over other existing methods, and it has important application value and significance for practical bearing fault diagnosis.
[0246] Table 6 shows the 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 invention. Various modifications and variations can be made to the invention by those skilled in the art. Any modifications, equivalent substitutions, or improvements made to the present invention should be included within the scope of protection of the present invention.
Claims
1. A cross-condition bearing fault diagnosis method based on prototype domain aligned feature encoding, characterized in that, Includes the following steps: S1. Data Acquisition and Preprocessing: S101. Data Acquisition: Simulate bearing operating conditions in the laboratory, including different speeds, loads, and fault types. Collect bearing vibration signal data for all fault types under all operating conditions, and divide the collected bearing vibration signal data into source domain vibration signals x under different operating conditions. s (t) and the vibration signal in the target domain x t (t); where the source domain vibration signal x s (t) includes n s Sample Target domain vibration signal x t (t) includes n t Sample Source domain vibration signal x s (t) Known operating condition data used for model training, labeled with actual fault types, total number of fault types cls, fault type label c; target domain vibration signal x t (t) Unknown operating condition data used for cross-condition testing, pseudo-labels inferred through source domain knowledge; S102. Data Preprocessing: After data acquisition, the source domain vibration signal x is preprocessed. s (t) and the vibration signal in the target domain x t All samples of (t) are preprocessed using continuous wavelet transform to convert them into source domain time-frequency features. and target domain time-frequency features S2. Construct a bearing fault diagnosis model, which includes an embedding layer, a self-attention encoder, a hash encoder, and a feature classifier, to integrate the source domain time-frequency features. and target domain time-frequency features The input bearing fault diagnosis model is processed, specifically including the following steps: S201, Source domain time-frequency characteristics and target domain time-frequency features The embedded sequences are obtained by processing them through the embedding layer. and S202, Using a self-attention encoder to respectively... and The features f are obtained through processing. s and feature f t Among them, the source domain vibration signal x s n of (t) s Sample The features are obtained by processing them separately through a self-attention feature encoder. Recorded as Target domain vibration signal x t n of (t) t Sample The features are obtained by processing them separately through a self-attention feature encoder. Recorded as S203, Hash Encoder Processing: A hash encoder is used to process the features separately. Encode to obtain the source domain relaxed hash code H s and target domain relaxed hash code H t ; S204, convert the source domain relaxation hash code H s and target domain relaxed hash code H t Input the feature classifier to output the probability of bearing failure type; S3. Constructing a composite loss function The bearing fault diagnosis model built through training makes the composite loss function minimize, Defined as: in, It is the cross-entropy classification loss function. It is a prototype-contrast loss function. It is the relation-preserving loss function. This is the quantization loss function; α, β, γ, and δ are trade-off parameters used to adjust... In the composite loss function The relative importance of each factor allows the model to achieve a balance among different optimization objectives.
2. The cross-condition bearing fault diagnosis method based on prototype domain aligned feature encoding as described in claim 1, characterized in that, In step S102, the source domain vibration signal x s (t) is converted to For example, the transformation formula for preprocessing continuous wavelet transform is: Where a is the scale parameter and τ is the time shift parameter; These are the wavelet basis functions of the wavelet transform, where t represents the sampling time of the time series; Target domain vibration signal x t (t) Similarly, using wavelet transform, the time-frequency features of the target domain are finally obtained.
3. The cross-condition bearing fault diagnosis method based on prototype domain aligned feature encoding as described in claim 1, characterized in that, In step S201, the specific method for the embedding layer processing is as follows: Source domain time-frequency characteristics For example, the embedding layer processing specifically includes the following steps: S2011, Data Reshaping: Reconstructing Source Domain Time-Frequency Features Divide the area into N patches evenly, satisfying N = H × W / P 2 , Then rearrange these patches into a sequence: in, Let P represent the i-th patch (i = 1, 2, 3, ..., N), where P is the side length of the patch, N is the number of patches, and H, W, and C represent the time-frequency characteristics of the source domain, respectively. Height, width, and number of channels; reshape indicates rearrangement; S2012, Linear Projection and Embedding: Using a learnable linear projection matrix, the patch sequence is mapped to a high-dimensional embedding space to obtain the embedded sequence. See the formula for the specific form: in, This represents the embedding weight matrix, where d is the embedding dimension; S2013, Calculate position encoding: In order to preserve the absolute and relative position information of the patch, for the embedded sequence Added absolute position information E pos The system uses sine and cosine functions to alternately represent position information, and uses sine and cosine functions of different frequencies to generate position codes. The absolute position information E pos The calculation process is as follows: 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) ] Where E is the position encoding matrix; POS represents the position index, indicating... In patch sequence The position; 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 row and q column in the position coding matrix P; N is the number of patches, 10000 is a constant chosen based on experience; cos(·) is the cosine function, sin(·) is the sine function; S2014, Adding Location Encoding and Classification Labels: Introducing a vector x class This is used as a feature representation to obtain the embedded sequence. x class Obtain it using the formula below: in, N represents the number of patches, and d represents the embedding dimension.
4. The cross-condition bearing fault diagnosis method based on prototype domain aligned feature encoding as described in claim 1, characterized in that, In step S202, the self-attention encoder consists of two sub-layers: a multi-head self-attention layer and an MLP feedforward network. The multi-head self-attention layer has h attention heads. The specific processing steps of the self-attention encoder are as follows: S2021, using the source domain vibration signal x s Taking (t) as an example, the output sequence after processing by the embedding layer As input to the self-attention feature encoder, After linear transformations corresponding to h attention heads, h sets of query vectors Q, key vectors K, and value vectors V are obtained. For the query vector Q of the i-th attention head... i Key vector K i Value vector V i The calculation formulas are as follows: Where h is the number of attention heads; These are the weight matrices corresponding to the i-th attention head, i = 1, 2, 3, ..., h; In 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 and summed based on these weights, as shown in the following formula: Where Attention represents the attention mechanism operation. It is K i The transpose of d k It is K i In terms of dimensions, softmax is an activation function that transforms the input vector into a probability distribution; S2023 concatenates the outputs of h attention heads along the feature dimension, integrating the information captured by different heads to form a richer feature representation, and then applies a linear transformation matrix W to the linear layer. O By fusing the results, the final output of the multi-head attention mechanism is obtained. The formula is as follows: in h is the number of attention heads, Concat(·) is the concatenation function, and W O It is a linear transformation matrix; S2024, the final output of the multi-head attention mechanism Layer normalization is performed to obtain The formula is as follows: Where LN(·) represents layer normalization, and μ and σ are respectively The mean and standard deviation are given by ε, which is the scaling parameter that adjusts the scaling of the normalized data; ∈ is the offset parameter that shifts the scaled data. S2025, Normalize the multi-head attention output With embedded sequence Residual connections are used to obtain the fused features. S2026, Features after fusion The feature is further extracted by a multilayer perceptron (MLP) to obtain f. s : S2027, Source Domain Vibration Signal x s n of (t) s Sample After processing through steps S2021-S2026 respectively, the features are obtained. Recorded as Target domain vibration signal x t n of (t) t Sample After the same processing steps S2021-S2026, the features are obtained. Recorded as 5. The cross-condition bearing fault diagnosis method based on prototype domain aligned feature encoding as described in claim 4, characterized in that, In step S2026, the formula for further feature extraction by the Multilayer Perceptron (MLP) is as follows: Dropout p (·) indicates a random deactivation operation with probability p. denoted as the linear transformation of the first linear layer; K1 and K2 are weight matrices, b is the bias vector, GELU(·) denotes the application of the Gaussian error linear unit activation function, and Linear(·) denotes the linear transformation of the second linear layer.
6. The cross-condition bearing fault diagnosis method based on prototype domain aligned feature encoding as described in claim 1, characterized in that, In step S203, the hash encoder processing method specifically includes the following steps: S2031. Obtain the source domain relaxed hash code: by hash encoder HashEncoder(·θ) hash ) for features Encode the source domain to generate a relaxed hash code H. s For n s The relaxation hash code for each source domain vibration signal sample is: in, r is the length of the hash code; S2032. Obtain the relaxed hash code of the target domain: by hash encoder HashEncoder(·θ) hash ) for features Encode the target domain to generate a relaxed hash code. in, r is the length of the hash code.
7. The cross-condition bearing fault diagnosis method based on prototype domain aligned feature encoding as described in claim 1, characterized in that, In step S204, the feature classifier consists of a first fully connected layer and a second fully connected layer, which outputs the probability of bearing failure type. The specific steps are as follows: First, using the source domain relaxed hash code H s Or target domain relaxed hash code H t Let F be the input to the feature classifier. The input first passes through a fully connected layer, then undergoes a non-linear transformation using the ReLU activation function to obtain z1, i.e.: z1 = ReLU(W1F + b1) Where z1 represents the feature output of the first fully connected layer, and F is the feature output of H. s or H t W1 is the weight matrix of the first fully connected layer, and 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 based on 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 representing 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 determination of the bearing fault type.
8. The cross-condition bearing fault diagnosis method based on prototype domain aligned feature encoding as described in claim 1, characterized in that, The cross-entropy classification loss function in step S3 Cross-entropy classification loss is used to measure the difference between the model's predicted results and the true labels. Based on the true label y of the sample ij and model predicted probability p ij The calculation formula is as follows: Where, n s y is the number of vibration signal samples in the source domain, cls is the total number of fault types, and y is the number of vibration signal samples in the source domain. ij p represents the true label of the i-th sample belonging to the j-th fault type. ij It is the probability that the i-th sample belongs to the j-th fault type, and log(·) is the logarithmic function.
9. The cross-condition bearing fault diagnosis method based on prototype domain aligned feature encoding as described in claim 1, characterized in that, The prototype contrast loss function in step S3 The specific calculation process is as follows: Step S301: Based on the fault type label c, calculate the prototype features of the c-th fault type in the source domain vibration signal. The calculation formula is: in, These are the features extracted from the source domain vibration signal samples by the self-attention encoder. For indicator functions, when Returns 1 if the condition is true, otherwise returns 0; n s The number of samples representing the source domain vibration signal, and c corresponds to the fault type label; Step S302, for Perform normalization processing, that is By each Normalization scales its length 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 vibration signal data in the target domain. To achieve the transfer of knowledge from the source domain to the target domain, the nearest source prototype method is used to assign pseudo-labels to the target data. Based on the prototype characteristics of each fault type The formula for determining pseudo-labels for vibration signal samples in the target domain is: in, Let c be the independent variable that makes the function reach its maximum value. cos(·) is used to calculate the cosine similarity. These are the features extracted from the j-th target domain vibration signal sample by the self-attention encoder, where j = 1, 2, ..., n t , It is a prototype feature of the c-th type of fault in the source domain vibration signal; Step S304: Calculate the prototype features of the target domain vibration signal: Based on the pseudo-labels of the target domain vibration signal data, calculate the prototype features of the target domain vibration signal. The formula is: Where, n t Indicates the number of vibration signal samples in the target domain; Step S305, similarly, for Perform normalization processing, that is Step S306: Construct the prototype contrastive loss function To promote domain alignment and obtain uniform and class-conflicting feature representations, The calculation formula is: in, is the prototype feature of the i-th type of fault in the vibration signal of the target domain, where i is the category index other than the c-th type of fault; 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-condition bearing fault diagnosis method based on prototype domain aligned feature encoding as described in claim 1, characterized in that, In step S3, the relation preservation loss function and quantization loss function The specific calculation process is as follows: 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 relationships between samples based on source domain fault type labels; Step S308: Guide hash learning using source domain fault type labels: In order to constrain the source domain relaxed hash code H s Preserving sample similarity, the source domain vibration signal x s (t) The similarity between samples is incorporated into hash learning, so that the similarity between hash codes can approximate the sample similarity calculated based on the source domain fault type label, thus preserving the similarity between source domain vibration signal samples in the hash code, which is calculated by the following formula: in, This represents the relation-preserving loss function, where η is the scaling factor, and H... s It is the relaxed hash code of the source domain vibration signal sample; ||·|| F Let S be the F-norm. s It is a 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 Constraints: To achieve cross-domain knowledge transfer and ensure that similar features in the domain-shared hypersphere generate similar hash codes, the following formula is used: in These are the source domain vibration signals x s (t) and the vibration signal in the target domain x t (t) Feature representation after processing by the self-attention encoder, H s H t These 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, thereby enhancing the cross-domain adaptability of the model; Step S310, Fusion Relationship Loss: Combine the above two loss functions and Fusion into relation-preserving loss function The formula is as follows: Where γ is the balance factor; Step S311, Quantization Loss: To make the relaxed hash code approximate the binary hash code, making the hash code more in line with practical application requirements, improving storage and retrieval efficiency, and thus improving the efficiency and accuracy of bearing fault diagnosis, a quantization loss function is defined. The formula is: Among them, B s B t These are the binary hash codes of the source domain vibration signal and the target domain vibration signal, respectively, H s H t These are the relaxation hash codes of the source domain vibration signal and the target domain vibration signal, respectively.