A transformer fault diagnosis method and system introducing feature contrast learning
By introducing a transformer fault diagnosis method that incorporates bimodal feature encoding and supervised contrastive learning, the problem of uneven feature space distribution in existing technologies is solved, improving the accuracy and reliability of transformer fault diagnosis, especially the ability to identify a few fault categories, without consuming additional computational resources.
Patent Information
- Application Number
- CN202611291684.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-25
- Publication Date
- 2026-11-24
AI Technical Summary
Existing transformer fault diagnosis methods lack explicit constraints on feature space distribution, resulting in loose intra-class distribution of similar samples and blurred inter-class boundaries of dissimilar samples. Furthermore, under conditions of extreme data class imbalance, the feature representation of a few difficult fault categories is dominated by the majority class, making it difficult to improve recall.
A dual-modal feature encoding network is adopted, which combines cross-modal attention fusion and supervised contrastive learning. By establishing a shared contrastive learning space, DGA and PRPD feature maps are used to a unified low-dimensional contrastive learning space. Supervised contrastive loss is introduced to optimize the intra-class compactness and inter-class separability of the feature space, and a dynamic weight scheduling strategy is adopted to optimize model training.
It significantly improves the ability to identify difficult fault categories, enhances the diagnostic reliability and generalization ability of the model in complex power grid environments, while maintaining overall diagnostic accuracy, and requires no additional parameters or computation during the deployment phase.
Smart Images

Figure CN123159085A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of power equipment condition monitoring and fault diagnosis technology, specifically to a transformer fault diagnosis method and system that incorporates feature comparison learning. Background Technology
[0002] Power transformers are core equipment in power systems, and their operating status directly affects power supply reliability. DGA (Dissolved Gas Analysis) infers fault types by analyzing the concentration and ratio of characteristic dissolved gases in the oil, while PRPD (Partial Discharge Phase-Amplitude Distribution) maps reflect insulation status by recording the phase-amplitude distribution characteristics of partial discharges.
[0003] To overcome the limitations of single-modality methods, existing technologies extract two types of features using DGA and PRPD encoders respectively. A cross-modal attention mechanism, with DGA as the query and PRPD local features as the key and value, is employed to achieve inter-modal interaction. A gated enhancement module adaptively adjusts the contribution ratio of the fused features to the original DGA features, ultimately achieving classification and diagnosis of five types of transformer faults (normal, medium-low temperature overheating, high temperature overheating, low-energy discharge, and high-energy discharge). Experiments show that the above-mentioned fusion diagnosis method achieves significant improvements in overall accuracy and macroscopic recall compared to single-modality and simple splicing methods. However, due to the increasing complexity of transformer faults, the aforementioned fusion diagnosis method has the following drawbacks:
[0004] ① Existing fusion diagnostic methods only use classification loss for training, which lacks explicit constraints on the distribution of feature space, resulting in loose intra-class distribution of similar samples and blurred inter-class boundaries of dissimilar samples;
[0005] ② Existing fusion diagnostic methods cannot effectively capture the complex relationships between numerical and image data in the semantic space. Information from one modality cannot guide another modality to focus on more critical parts, resulting in models often only learning a rough joint distribution. Under conditions of extreme imbalance in data categories, the feature representations of a few difficult fault categories (such as high-temperature overheating and medium-low-temperature overheating) are dominated by the majority class, which is easily confused with adjacent categories in the feature space, thus resulting in limited improvement in the ability to distinguish between difficult and marginal fault categories. Summary of the Invention
[0006] The purpose of this invention is to provide a transformer fault diagnosis method that introduces feature contrast learning. This method aims to solve the technical problems in the prior art, which only uses classification loss for training and lacks explicit constraints on the distribution of feature space. These problems result in loose intra-class distribution of similar samples, blurred inter-class boundaries of dissimilar samples, and under conditions of extreme imbalance in data categories, the feature representation of a few difficult fault categories (such as high temperature overheating and medium-low temperature overheating) is dominated by the majority class, which is easy to be confused with adjacent categories in the feature space, making it difficult to further improve the recall rate.
[0007] The diagnostic method includes the following steps:
[0008] S1: Collect dissolved gas analysis (DGA) data and phase-resolved partial discharge (PRPD) map data of the transformer to be diagnosed, perform data preprocessing, sample pairing and labeling on the DGA data and PRPD map data, and construct a dual-modal training dataset;
[0009] S2: Establish a dual-modal feature encoding network, and use the DGA encoder to extract DGA global features, and use the PRPD encoder to extract PRPD map global features and PRPD map local feature sequences respectively;
[0010] S3: Establish a cross-modal attention fusion network, using DGA global features as query vectors and PRPD local feature sequences as keys and values for cross-modal attention calculation to obtain cross-modal fusion features. Then, use a gating enhancement module to fuse the cross-modal fusion features with DGA global features to obtain classification features.
[0011] S4: Establish PRPD projection head and DGA projection head respectively, map PRPD global features and DGA global features to a unified contrastive learning space to obtain normalized projection features;
[0012] S5: Establish a supervised feature contrastive learning model, construct a positive sample set and a negative sample set based on the sample labels, and use supervised contrastive loss to optimize the intra-class compactness and inter-class separability of normalized projected features;
[0013] S6: Establish a joint optimization model of classification loss and supervised contrastive loss, and complete model training by dynamically adjusting the weights of supervised contrastive loss;
[0014] S7: After training, delete the PRPD projection head and DGA projection head, and keep only the dual-modal coding network, cross-modal attention fusion network, gating enhancement module and classifier to complete the deployment of the transformer fault diagnosis model.
[0015] A further approach is that both the PRPD projection head and the DGA projection head described in S4 are constructed using a two-layer multilayer perceptron, mapping 128-dimensional global features to 64-dimensional projected features, and using L2 normalization to obtain a unit-length projection vector, so that the two modalities are mapped to a unified shared contrastive learning space.
[0016] A further approach is to use the supervised feature contrast learning model described in S5. During the learning process, any projection vector in the batch training samples is used as the anchor sample. Projection vectors with the same fault label as the anchor sample are used as the positive sample set, and projection vectors with different fault labels are used as the negative sample set. The shared feature space is optimized based on the supervised contrast loss function. The positive samples include samples of the same modality and class as well as samples of the same class of different modalities.
[0017] A further approach is to use the cosine similarity between normalized projection vectors to calculate the similarity of positive and negative samples in the supervised contrast loss described in S5. By increasing the similarity of positive samples and decreasing the similarity of negative samples, samples of the same class are clustered and samples of different classes are separated, thereby strengthening the semantic consistency between the DGA modality and the PRPD modality.
[0018] A further approach is that the joint optimization model of classification loss and supervised contrastive loss described in S6 uses the linear weighting of classification loss and supervised contrastive loss to form the total loss function, and adopts a phased dynamic weight scheduling strategy. In the early stage of training, only classification loss is used to train the model, and in the middle and later stages of training, the weight of supervised contrastive loss is gradually increased to ensure stable convergence of model training.
[0019] A further approach is to employ a two-stage joint training method for the model training described in S6, including:
[0020] In the first stage, the PRPD encoder convolutional backbone is frozen, and only the DGA encoder, cross-modal attention fusion module, gating enhancement module, classifier, and projector are trained.
[0021] The second phase involves lifting the complete network freeze and performing end-to-end joint fine-tuning of the entire network.
[0022] A further approach is to remove the supervised feature contrast learning projection branch during the deployment phase of the transformer fault diagnosis model described in S7, retaining only the dual-modal fault diagnosis backbone network. This ensures that the parameter scale, computational complexity, and inference time of the deployed model remain consistent with the basic dual-modal fusion model, thereby decoupling the training and deployment phases.
[0023] The present invention also provides a transformer fault diagnosis system incorporating feature contrast learning, the diagnosis system comprising:
[0024] The dual-modal data management module is used to collect dissolved gas analysis (DGA) data and phase-resolved partial discharge (PRPD) spectrum data of the transformer to be diagnosed, and to perform data preprocessing, sample pairing and labeling on the DGA data and PRPD spectrum data to construct a dual-modal training dataset.
[0025] The dual-modal feature representation module is used to establish a dual-modal feature encoding network, which extracts global features of DGA using the DGA encoder and extracts global features and local feature sequences of PRPD map using the PRPD encoder.
[0026] The cross-modal semantic fusion module is used to establish a cross-modal attention fusion network. It uses DGA global features as query vectors and PRPD local feature sequences as keys and values to perform cross-modal attention calculations to obtain cross-modal fusion features. Then, the gating enhancement module is used to fuse the cross-modal fusion features with DGA global features to obtain classification features.
[0027] The feature space collaborative optimization module is used to establish PRPD projection heads and DGA projection heads respectively, mapping PRPD global features and DGA global features to a unified contrastive learning space to obtain normalized projected features; a supervised feature contrastive learning model is established, constructing positive and negative sample sets based on sample labels, and using supervised contrastive loss to optimize the intra-class compactness and inter-class separation of normalized projected features; a joint optimization model of classification loss and supervised contrastive loss is established, and model training is completed by dynamically adjusting the weights of supervised contrastive loss.
[0028] The lightweight intelligent inference deployment module is used to delete the PRPD projection head and DGA projection head after training, retaining only the dual-modal coding network, cross-modal attention fusion network, gating enhancement module and classifier to complete the deployment of the transformer fault diagnosis model.
[0029] The present invention also provides an electronic device, comprising:
[0030] A processor and a memory for storing a computer program capable of running on the processor, wherein the processor, when running the computer program, implements the steps of the diagnostic method.
[0031] The present invention also provides a computer-readable storage medium storing an executable program, which, when executed by a processor, implements the steps of the diagnostic method.
[0032] The advantages of this invention compared to the prior art are as follows:
[0033] This invention provides a fault diagnosis method that, while maintaining the main structure of the cross-modal attention fusion network, establishes a shared contrastive learning space. Projection heads are added to both the DGA global features and PRPD global image features, mapping the features of both modalities to the shared low-dimensional contrastive learning space. This achieves a unified expression of DGA and PRPD features, improving the quality of dual-modal fusion. Furthermore, by adding projection branches and introducing supervised contrastive loss, the feature space distribution is explicitly optimized, thereby significantly improving the ability to identify difficult fault categories while maintaining overall diagnostic accuracy.
[0034] This invention employs a joint optimization mechanism of classification loss and supervised contrastive loss, and uses a dynamic weight scheduling strategy. By bringing similar samples closer together and dissimilar samples further apart in the contrastive learning space, it explicitly optimizes the intra-class compactness and inter-class separation of the feature space. This allows the model to prioritize learning stable classification boundaries in the early stages of training and gradually optimize the feature space structure in the later stages. Furthermore, the phased dynamic scheduling strategy of contrastive loss weights improves the model's training stability and final convergence performance.
[0035] This invention proposes a network structure that decouples the training and deployment phases. The supervised comparative learning module only participates in training and not inference. While improving fault diagnosis performance, it achieves zero additional parameters, zero additional computation, and zero additional inference latency in the deployment phase, which has good engineering application value.
[0036] This invention addresses extreme class imbalance scenarios by employing supervised contrastive learning and shared semantic space constraints to significantly improve the identification capabilities of a few fault categories, such as high temperature overheating, thereby enhancing the model's diagnostic reliability and generalization ability in complex power grid operating environments. Attached Figure Description
[0037] Figure 1 A flowchart of a transformer fault diagnosis method incorporating feature contrast learning, provided in an embodiment of the present invention;
[0038] Figure 2 A schematic diagram of a transformer fault diagnosis system incorporating feature contrast learning, provided in an embodiment of the present invention;
[0039] Figure 3 This is a schematic diagram of the cross-modal attention fusion network model provided in an embodiment of the present invention.
[0040] Figure 4 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present invention;
[0041] Figure captions: 10-Dual-modal data management module; 11-Dual-modal feature representation module; 12-Cross-modal semantic fusion module; 13-Feature space collaborative optimization module; 14-Lightweight intelligent inference deployment module; 20-Memory; 21-Processor. Detailed Implementation
[0042] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
[0043] Example 1
[0044] like Figure 1 As shown, an embodiment 1 of the present invention discloses a transformer fault diagnosis method that incorporates feature contrast learning. The diagnosis method includes the following steps:
[0045] S1: Collect dissolved gas analysis (DGA) data and phase-resolved partial discharge (PRPD) map data of the transformer to be diagnosed, perform data preprocessing, sample pairing and labeling on the DGA data and PRPD map data, and construct a dual-modal training dataset;
[0046] It should be noted that the collected DGA data includes the concentration characteristics of seven characteristic gases: hydrogen (H2), methane (CH4), ethane (C2H6), ethylene (C2H4), acetylene (C2H2), carbon monoxide (CO), and carbon dioxide (CO2), as well as the ratio characteristics of these three gases.
[0047] r1 reflects the relative trend between high-energy discharge and high-temperature thermal failure;
[0048] r2 reflects the relative trend of low-temperature pyrolysis and discharge activity;
[0049] r3 reflects the temperature change trend of thermal faults.
[0050] Here, ε is a local constant used to prevent the denominator from being zero.
[0051] By combining the concentrations of seven gases with the ratios of three gases, a 10-dimensional DGA input vector x is obtained. dga =[H2,CH4,C2H6,C2H4,C2H2,CO,CO2,r1,r2,r3].
[0052] The established sample labels include normal, medium and low temperature overheating, high temperature overheating, low energy discharge, and high energy discharge.
[0053] The training data is divided into a training set and a validation set according to a preset ratio. The training set is used for learning network parameters, and the validation set is used for evaluating model performance.
[0054] S2: Establish a dual-modal feature encoding network, and use the DGA encoder to extract DGA global features, and use the PRPD encoder to extract PRPD map global features and PRPD map local feature sequences respectively;
[0055] It should be noted that, in this embodiment, corresponding encoding networks are established for the two modalities respectively to achieve high-level semantic extraction of chemical information and partial discharge image information. The dual-modal feature encoding network includes a DGA encoder and a PRPD encoder.
[0056] The DGA encoder employs a two-layer multilayer perceptron (MLP) as its feature extraction network. Its input layer receives the aforementioned 10-dimensional DGA input vector x. dga .
[0057] The DGA encoder includes two layers of fully connected networks;
[0058] The first fully connected network is used to map the DGA input vector to a 64-dimensional hidden space, followed by layer normalization, ReLU activation function and Dropout regularization.
[0059] The second fully connected network maps the 64-dimensional features to a 128-dimensional feature space, followed by layer normalization, ReLU activation, and Dropout regularization. The output is a 128-dimensional DGA global feature vector f. dga This feature vector integrates all information about gas concentration and ratio, representing the chemical state of the fault.
[0060] The PRPD encoder uses a pre-trained EfficientNet-B0 convolutional neural network as its backbone. The input is: I∈R 224×224×3 After convolutional feature extraction, the feature map is obtained: F∈R H×W×C .
[0061] Where H and W represent spatial dimensions, and C represents the feature channel.
[0062] Two types of outputs are then generated. The first type is the PRPD global image feature f. img This refers to the 128-dimensional global semantic features of the image. It represents the overall visual features of the PRPD map and is the source of features for subsequent input to the PRPD projection head in this embodiment.
[0063] Local feature sequences as input to cross-modal attention module
[0064] The second category is the PRPD local feature sequence S. imgIt is a 128-dimensional local feature sequence of length N obtained by spatial flattening, that is, S img ={s1,s2,s3,⋯,s N}, where N represents the number of spatial locations, and S img ∈R 128 This serves as the input source for keys and values in the subsequent cross-modal attention module.
[0065] S3: Establish a cross-modal attention fusion network, using DGA global features as query vectors and PRPD local feature sequences as keys and values for cross-modal attention calculation to obtain cross-modal fusion features. Then, use a gating enhancement module to fuse the cross-modal fusion features with DGA global features to obtain classification features.
[0066] It should be noted that, in order to fully utilize the complementary information relationship between the two modalities, this embodiment employs a cross-modal attention mechanism to establish a bimodal fusion network. For example... Figure 2 As shown, specifically:
[0067] Using the global features of the DGA as the query vector: Q=f dga ; PRPD local feature sequence S img As key and value respectively: K=S img V=S img .
[0068] The results were obtained using multi-head attention calculations:
[0069] , where d is the feature dimension.
[0070] Obtain cross-modal fusion features f att The cross-modal attention mechanism can adaptively focus on key local regions in the PRPD map based on the fault characteristics of the DGA, thereby improving the information exchange capability between different modalities.
[0071] To further coordinate the contribution ratio between the original DGA information and the cross-modal fusion information, this embodiment sets up a gating enhancement module.
[0072] The cross-modal fusion features and the DGA global feature vector are concatenated in a dimensionality using a gated enhancement module to obtain the concatenated vector [f]. att ,f dga ]. Concatenate vector [f att ,f dga The input is fed into a gated augmentation network consisting of a fully connected layer and a sigmoid activation function, generating a g of gating coefficients with element values between 0 and 1. ;in, W is the Sigmoid activation function. gand b g The gating parameters are learnable; using the gating coefficients, the cross-modal fusion features f are... att and DGA global eigenvector f dga By performing element-wise weighted combination, the gated enhancement feature f is obtained. gate ,Right now:
[0073] , where ⊙ denotes element-wise multiplication;
[0074] Then the gating enhancement feature f gate With DGA global eigenvector f dga The data is then concatenated again to form the classification feature f most suitable for fault classification. cls That is, F cls =[f gate ;f dga ].
[0075] The classification features are input into a classifier for fault identification. The classifier includes:
[0076] ① Fully connected layer; ② Batch Normalization layer; ③ ReLU activation layer; ④ Dropout layer;
[0077] ⑤ Softmax classification layer. The final output is the probability P = [p1, p2, p3, p4, p5] corresponding to the five fault types, and p1 + p2 + p3 + p4 + p5 = 1. The fault category with the highest probability is taken as the final diagnosis result: y = argmax(P).
[0078] To ensure the model has stable classification capabilities, this embodiment uses a classification loss function to train the basic fusion network. The classification loss employs the Logit-Adjusted Cross Entropy (LA-CE) loss function. This loss function introduces prior probabilities of each class into the classification logits, making the loss function explicitly aware of the imbalanced distribution of the data, thereby reducing the classifier's bias towards the majority class to some extent.
[0079] For class c, the model's original output logit for class c is O. c The prior probability of the c-th sample in the training set is π. c The adjusted output is:
[0080] , where τ represents the temperature coefficient.
[0081] Adjusted logit ô c It is fed into the standard cross-entropy loss function for calculation.
[0082] ,in Classification loss L cls This is the average value of the cross-entropy loss of all samples within the batch.
[0083] The classification loss is mainly used to establish a stable fault classification boundary, providing a reliable foundation for subsequent feature space optimization.
[0084] S4: Establish PRPD projection head and DGA projection head respectively, map PRPD global features and DGA global features to a unified contrastive learning space to obtain normalized projection features;
[0085] It should be noted that although the basic fusion network can achieve information fusion between the DGA and PRPD modalities, its training objective consists only of classification loss and cannot directly constrain the deep feature space structure. Therefore, this embodiment adds a feature projection module, which includes a PRPD projection head and a DGA projection head. The two projection heads have identical structures, but their network parameters are not shared.
[0086] PRPD feature projection head:
[0087] The PRPD projection head receives the global image features f output by the PRPD encoder. img ∈R 128 The PRPD projector head consists of two multilayer perceptrons (MLPs).
[0088] The first layer maps the 128-dimensional input to a 128-dimensional hidden space, followed by the ReLU activation function. That is:
[0089] H img =ReLU(W1f img +b1), where the input dimension is 128 and the output dimension is 128.
[0090] The second layer maps the 128-dimensional hidden features to a 64-dimensional contrastive learning space. That is:
[0091] z img =W2f img +b2, the output dimension is set to 64 dimensions.
[0092] To eliminate the impact of differences in feature magnitudes between different samples, L2 normalization is performed on the output.
[0093] By constraining its magnitude to 1, we obtain the PRPD-normalized projection vector:
[0094] ;
[0095] Where Norm(·) represents the L2 normalization operation, This indicates the forward mapping of the PRPD projection head.
[0096] Finally, a PRPD projection vector of unit length is obtained. .
[0097] DGA projector head:
[0098] The DGA projector head receives the DGA global feature vector f output by the DGA encoder. dga ∈R 128 The DGA projector head also consists of two multilayer perceptrons (MLPs).
[0099] The first layer maps the 128-dimensional input to a 128-dimensional hidden space, followed by the ReLU activation function. That is:
[0100] H dga =ReLU(W3f dga +b3), where the input dimension is 128 and the output dimension is 128.
[0101] The second layer maps the 128-dimensional hidden features to a 64-dimensional contrastive learning space. That is:
[0102] z dga =W4f dga +b4, the output dimension is set to 64 dimensions.
[0103] To eliminate the impact of differences in feature magnitudes between different samples, L2 normalization is performed on the output.
[0104] By constraining its magnitude to 1, we obtain the DGA-normalized projection vector:
[0105] ;
[0106] Where Norm(·) represents the L2 normalization operation, This indicates the forward mapping of the PRPD projection head.
[0107] Finally, a PRPD projection vector of unit length is obtained. .
[0108] After completing the calculations for both projection heads, each training sample corresponds to two 64-dimensional projection vectors. and .
[0109] S5: Establish a supervised feature contrastive learning model, construct a positive sample set and a negative sample set based on the sample labels, and use supervised contrastive loss to optimize the intra-class compactness and inter-class separability of normalized projected features;
[0110] It should be noted that the supervised contrastive loss is applied to the output of the projection branch. Its function is to explicitly optimize the feature space distribution, so that samples with the same label cluster together in the contrastive learning space, while samples with different labels move away from each other.
[0111] Suppose a training batch contains B training samples. For each sample in the batch, after passing through the PRPD projection head and the DGA projection head, a total of 2B normalized projection vectors can be obtained. Let these 2B projection vectors be denoted as {z}. i} where i = 1, 2, ..., 2B. All projection vectors together form the supervised feature learning space. This shared space not only includes the relationship between samples of the same modality, but also establishes the consistency relationship between different modalities. Therefore, the DGA representation and PRPD representation corresponding to the same fault can gradually approach each other, achieving true cross-modal semantic unification.
[0112] For any projection vector z i As anchors, construct a set of positive samples P. i :
[0113] Positive sample set P i In the current batch, except for anchor point z i Besides itself, all other projected vectors that have the same fault label as the anchor point. Positive samples include:
[0114] Projection vectors of similar samples from the same modality (such as similar fault samples in the same modality).
[0115] Projection vectors of similar samples from another modality (such as the z-axis of a sample) img z with another sample with the same label dga (These are cross-modal positive sample pairs). This cross-modal positive sample pairing method can further shorten the distance between the same fault in the chemical feature space and the electrical feature space, and strengthen the semantic consistency between the two modes.
[0116] Negative sample set: the set of samples in the current batch excluding anchor point z. i All other projected vectors besides themselves have different labels and anchor points. By introducing cross-modal positive samples, the model learns not only category consistency but also modal consistency. This embodiment further establishes a common feature space between chemical and electrical information, thus effectively improving the quality of bimodal fusion.
[0117] For anchor point z i The supervised contrast loss design is defined as:
[0118] ;
[0119] in, To represent the anchor vector z i With a certain positive sample vector z p The inner product between the two vectors. Since all projected vectors have been L2 normalized, this inner product is equivalent to the cosine similarity between the two vectors.
[0120] τ' is the temperature coefficient for contrastive learning, used to adjust the smoothness of the similarity distribution. It is generally set to a small value, such as τ'=0.07, to make the model pay more attention to the difficult-to-distinguish positive and negative samples. |P i | indicates the size of the positive sample set.
[0121] The core mechanism of this loss function is to sum the similarity indices between the anchor point and all positive samples in the numerator, encouraging the maximization of similarity between positive sample pairs; and to sum the similarity indices between the anchor point and all samples (positive and negative samples) in the denominator, forcing the anchor point to have the smallest possible similarity to negative samples. Through this optimization mechanism of "bringing closer similar samples and pushing away dissimilar ones," the model can actively learn and construct a compact intra-class and separated inter-class feature space structure.
[0122] Supervisory comparison loss L throughout the entire batch con The average loss for all individual anchor points:
[0123] ;
[0124] This loss can improve the similarity of samples within the same class, reduce the similarity of samples from different classes, narrow the intra-class distance, widen the inter-class distance, improve the ability to distinguish difficult classes, and unify the semantic spaces of DGA and PRPD. Compared with ordinary cross-entropy training, supervised contrastive learning directly acts on the feature representation layer, thus significantly improving the quality of features learned by the network.
[0125] S6: Establish a joint optimization model of classification loss and supervised contrastive loss, and complete model training by dynamically adjusting the weights of supervised contrastive loss;
[0126] It should be noted that, in order to balance classification performance and feature learning ability, this embodiment establishes a joint objective of classification loss and supervised contrastive loss.
[0127] The total loss function L is defined as the sum of the classification loss L and the total loss function L. cls Compared with supervised loss L con Linear weighting yields L = L cls +λL con The classification loss guarantees the final classification accuracy; the supervised contrastive loss is responsible for optimizing the feature space; and λ is the weight coefficient of the contrastive loss, used to balance the relative importance of the two types of losses during training.
[0128] Considering that the model needs to establish a stable classification boundary in the early stages of training, applying strong contrast constraints too early may interfere with the normal convergence of the backbone classification path. Therefore, this embodiment adopts a phased dynamic λ scheduling strategy:
[0129] Training epochs 1-2: Set λ=0. At this point, the total loss degenerates into the classification loss L. cls The model primarily completes parameter initialization and adaptation and learns basic decision boundaries under the drive of the classification objective.
[0130] In training rounds 3 to 5: λ is gradually increased to a smaller value, such as λ = 0.01. At this point, the contrastive loss begins to play a constraining role, gently guiding the features towards a better spatial distribution.
[0131] After the 5th training epoch: λ is further increased to the target value, such as λ=0.02. At this point, the contrastive loss participates in joint training with full strength, giving full play to its ability to optimize the feature space structure and continuously promoting the clustering of similar classes and the separation of dissimilar classes.
[0132] This progressive weight scheduling strategy allows the network to focus on building stable classification capabilities in the initial training phase, and then smoothly shift the optimization focus to adjusting the feature space structure. Compared with fixed weight training, this avoids the mutual interference between the two types of loss in the early training stage, ensures the convergence stability of the entire training process, reduces gradient oscillations, improves the final convergence accuracy, and guarantees the quality of the final feature representation.
[0133] To further improve the identification ability of minority categories and boundary samples, this embodiment introduces a dynamic hard sample enhancement mechanism based on the supervised contrastive learning described above. For each anchor sample, a difficulty evaluation index is constructed based on its cosine similarity with positive and negative samples. Dissimilar samples with high similarity to the anchor are preferentially selected as hard negative samples, while samples with low similarity to the same category are selected as hard positive samples and given higher weight in the supervised contrastive loss calculation.
[0134] During training, the set of difficult samples is dynamically adjusted as the model parameters are updated, so that the network continues to focus on samples near the class boundary, further enhancing the ability to distinguish a few fault categories such as high temperature overheating and medium and low temperature overheating, while improving the model's generalization performance under complex working conditions.
[0135] To fully utilize the training results of existing basic fusion models, improve model convergence speed, and reduce the time and computational resource consumption caused by repeated training, this embodiment adopts a two-stage training strategy of "pre-training loading + joint fine-tuning". Specifically:
[0136] Pre-training weight loading phase;
[0137] Before training begins, all weight parameters of the pre-trained base fusion model are loaded as the initial parameters for the backbone network. The base fusion model includes a DGA encoder, a PRPD encoder, a cross-modal attention fusion module, a gating enhancement module, and a classifier. All of these modules are initialized with pre-trained weights.
[0138] Pre-trained weights enable the backbone network to possess good cross-modal fusion and classification capabilities, providing a high-quality starting point for subsequent joint fine-tuning. For the two newly added projection heads (PRPD and DGA), since they are not in the base fusion model, Xavier or He initialization methods are used, employing a random initialization strategy to randomly initialize the network parameters. The model parameters are then expressed as follows:
[0139] θ={θ backbone ,θ projection}, where θ backbone Based on the fusion model parameters, θ projection Add new projection head parameters.
[0140] Since the basic fusion network already possesses good fault classification capabilities, the overall training time can be significantly shortened.
[0141] Joint fine-tuning phase: includes the freeze training phase and the end-to-end joint fine-tuning phase.
[0142] Freeze training stage (freeze the backbone, adapt to the upper layer)
[0143] In the initial training phase, to avoid large gradient perturbations caused by randomly initialized projection heads affecting image feature learning, the parameters of the EfficientNet-B0 convolutional backbone network are first frozen. Frozen parameters include: the PRPD encoder convolutional backbone, Batch Normalization statistical parameters, and the bottom convolutional layers. These do not participate in gradient updates; only the upper-layer DGA encoder, cross-modal attention module, gating enhancement module, classifier, and the two newly added projection heads are trained. The parameters participating in training include: the DGA encoder, cross-modal attention module, gating enhancement module, classifier, PRPD projection head, and DGA projection head. The AdamW optimizer is used for parameter updates. The learning rate is set to... .
[0144] This phase lasts for several rounds (e.g., the first 5 epochs) and mainly completes projector learning, high-level fusion adaptation, and stable establishment of classification boundaries. The goal is to enable the randomly initialized projector and high-level fusion module to complete preliminary adaptation based on fixed image features, avoiding interference from the backpropagation of random noise output by the projector that could affect the pre-trained low-level image feature extraction capabilities.
[0145] End-to-end joint fine-tuning phase (unfreezing all parameters, end-to-end fine-tuning)
[0146] After completing the frozen training and once the projection head and high-level modules have largely converged, unfreeze all parameters of the EfficientNet-B0 backbone network. Perform end-to-end joint fine-tuning of the entire network, enabling the entire network to participate in backpropagation. A lower learning rate can be used at this stage. ; Update all parameters meticulously:
[0147] θ=θ backbone +θ projection Joint loss is continuously optimized: L=L cls +λL con The training continues until the model converges, enabling each stage of image feature extraction, cross-modal interaction, gated fusion, and contrastive learning projection to reach a globally optimal collaborative state.
[0148] The end-to-end joint fine-tuning stage can further optimize image features, enhance cross-modal fusion, further converge the shared feature space, further cluster difficult categories, and further improve overall diagnostic performance.
[0149] S7: After training, delete the PRPD projection head and DGA projection head, and keep only the dual-modal coding network, cross-modal attention fusion network, gating enhancement module and classifier to complete the deployment of the transformer fault diagnosis model.
[0150] It should be noted that after training is complete, the two projectors used for contrastive learning have internalized the knowledge of feature space optimization into the parameters of the backbone network. During model deployment and actual inference, the projection branches are completely deleted, retaining only the backbone network, namely the DGA encoder, PRPD encoder, cross-modal attention module, gating enhancement module, and classifier. Deleting the entire projection branch means removing all the PRPD projection head, DGA projection head, and supervised contrastive learning module added during training. Therefore, the deployed network is represented as: Model deploy =Model backbone In other words, since the projection branch has been removed, the number of parameters, computational cost, and inference speed of the deployed model are completely consistent with the basic fusion model. That is, the feature contrastive learning introduced in this embodiment only consumes additional computational resources to optimize the feature space during the training phase, and does not incur any additional overhead in practical applications. Furthermore, the projection branch only plays a role during the training phase and is completely removed after training. The number of parameters and inference speed of the deployed model are completely consistent with the basic fusion model, allowing for performance gains from algorithm improvements without upgrading hardware. This is highly suitable for online monitoring scenarios of power equipment where computational resources are limited.
[0151] The network inference process is as follows:
[0152] Input DGA data and PRPD map → Encode and extract features → Cross-modal attention fusion → Gated enhancement → Classifier output → Fault category.
[0153] No supervised contrastive learning computation is required throughout the inference process. Therefore, model parameters, inference time, memory usage, and computational complexity remain constant, achieving true zero extra inference cost. This characteristic makes it ideal for deployment in computationally limited scenarios such as online monitoring of power equipment, edge computing terminals, and embedded intelligent diagnostic devices.
[0154] To verify the effectiveness of the diagnostic method in this embodiment, experimental verification was conducted using actual collected transformer dual-mode fault data, and the results were compared with the basic fusion model under the same dataset partitioning and evaluation conditions. The dual-mode dataset used in the experiment contained 13,353 samples, categorized into five groups: normal (8,540 groups), medium-low temperature overheating (59 groups), high temperature overheating (246 groups), low-energy discharge (1,521 groups), and high-energy discharge (2,987 groups). The training and validation sets were partitioned in an 8:2 ratio. All experiments used the same data partitioning method and training parameters. Evaluation metrics included accuracy, macro-recall, macro-F1 score, recall for each category, and feature space separation. The comparative experimental results are shown in Tables 1, 2, and 3 below:
[0155] Model Accuracy / % Macro-Recall Macro-F1 Cross-modal attention fusion model 98.91 0.8185 0.8539 An improved model introducing FCL 98.76 0.8339 0.8495 change -0.15 +0.0154 -0.0044
[0156] Table 1 compares the overall performance of cross-modal attention fusion and the introduction of FCL.
[0157] Category Different Category Model Cross-modal attention fusion An improved model introducing FCL change normal 0.9971 0.9924 -0.0047 Medium and low temperature overheating 0.3333 0.3333 0.0000 High temperature overheating 0.7755 0.8571 +0.0816 Low-energy discharge 0.9901 0.9901 0.0000 High-energy discharge 0.9967 0.9967 0.0000
[0158] Table 2 compares the category recall rates of cross-modal attention fusion and improved models.
[0159] category Intraclass distance has no FCL Intraclass distance FCL Inter-class center distance has no FCL Inter-class center distance FCL Separation ratio without FCL Separation ratio FCL normal 0.0252 0.0786 1.0385 1.0140 41.2730 12.9018 Medium and low temperature overheating 0.6668 0.6064 0.9638 0.9704 1.4456 1.6003 High temperature overheating 0.4633 0.3270 1.1410 1.2040 2.4625 3.6816 Low-energy discharge 0.0661 0.0762 1.3539 1.3149 20.4848 17.2654 High-energy discharge 0.0896 0.1817 1.3792 1.3411 15.3914 7.3800 mean 0.2622 0.2540 1.1753 1.1689 16.2115 8.5658
[0160] Table 3 compares intraclass distance, interclass centroid distance, and separation ratio before and after FCL.
[0161] Overall performance comparison
[0162] Based on the data in Table 1, after introducing FCL, the diagnostic method disclosed in this embodiment maintains an accuracy of over 98%; the macro-recall on the validation set increases from 0.8185 to 0.8339, indicating that the model's comprehensive coverage of all categories has been improved. Meanwhile, the overall accuracy only decreases by about 0.15%, but still remains at a high level of 98.76%, meeting the requirements for engineering applications. This demonstrates that supervised contrastive learning primarily optimizes the difficult categories without significantly affecting the overall classification performance.
[0163] Performance improvements for difficult categories
[0164] According to the recall data for each category in Table 2, the recall rate of the high-temperature overheating category increased by more than 8 percentage points. This indicates that supervised contrastive loss effectively improved the representation quality of features in difficult categories. The recall rate of the medium- and low-temperature overheating category remained at 0.3333, mainly due to its small sample size (only 12 validation samples), making it difficult to achieve significant improvement through contrastive constraints, thus limiting the improvement. This demonstrates that the diagnostic method in this embodiment has better robustness for a minority of categories.
[0165] Feature space analysis
[0166] Table 3 shows the evaluation results after adding FCL, using intra-class distance, inter-class center distance, and separation ratio. Experimental results indicate that after adding supervised contrastive learning, the separation ratios for both medium- and low-temperature overheating categories and high-temperature overheating categories increased, especially for the high-temperature overheating category, which saw a significant increase from 2.4625 to 3.6816, an increase of nearly 50%. This is because supervised contrastive loss fundamentally narrows the distance between samples of the same class and widens the distance between samples of different classes, enabling the classifier to more accurately identify difficult samples.
[0167] Furthermore, the intra-class distance for the high-temperature overheating category decreased significantly, while the inter-class distance increased significantly, indicating that FCL effectively reduced the intra-class variability and increased the distance between it and other class centers. This demonstrates that supervised contrastive learning can effectively establish a high-quality feature space that is compact intra-class and separate inter-class. For the medium- and low-temperature overheating category, due to its limited sample size of only 12, the separation increased, but not significantly.
[0168] For most class samples, the role of FCL is not primarily reflected in further increasing the separation, but rather tends to re-divide the feature space resources to optimize the shape of the local thermal fault region, rather than further expanding the already significant boundaries between the classes.
[0169] Example 2
[0170] like Figure 3As shown, an embodiment 2 of the present invention also discloses a diagnostic system based on the diagnostic method described above. The diagnostic system includes:
[0171] The dual-modal data management module 10 is used to collect dissolved gas analysis (DGA) data and phase-resolved partial discharge (PRPD) map data of the transformer to be diagnosed, and to perform data preprocessing, sample pairing and labeling on the DGA data and PRPD map data to construct a dual-modal training dataset.
[0172] The dual-modal feature representation module 11 is used to establish a dual-modal feature encoding network, which extracts DGA global features using the DGA encoder and extracts PRPD map global features and PRPD map local feature sequences using the PRPD encoder.
[0173] The cross-modal semantic fusion module 12 is used to establish a cross-modal attention fusion network. It uses the DGA global features as the query vector and the PRPD local feature sequence as the key and value to perform cross-modal attention calculation to obtain cross-modal fusion features. Then, it uses the gating enhancement module to fuse the cross-modal fusion features with the DGA global features to obtain classification features.
[0174] The feature space co-optimization module 13 is used to establish PRPD projection heads and DGA projection heads respectively, map PRPD global features and DGA global features to a unified contrastive learning space to obtain normalized projection features; establish a supervised feature contrastive learning model, construct positive sample sets and negative sample sets according to sample labels, and use supervised contrastive loss to optimize the intra-class compactness and inter-class separation of normalized projection features; establish a joint optimization model of classification loss and supervised contrastive loss, and complete model training by dynamically adjusting the weight of supervised contrastive loss;
[0175] The lightweight intelligent inference deployment module 14 is used to delete the PRPD projection head and DGA projection head after training, retaining only the dual-modal coding network, cross-modal attention fusion network, gating enhancement module and classifier to complete the deployment of the transformer fault diagnosis model.
[0176] like Figure 4 As shown, Embodiment 2 of the present invention also provides an electronic device, which includes a memory 20, a processor 21, and computer instructions stored in the memory 20 and executable on the processor 21; when the processor 21 executes the instructions, it implements steps applied to the diagnostic method.
[0177] In some embodiments, the memory 20 in Embodiment 2 of the present invention may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory may be random access memory (RAM), which serves as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchlink DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The memory 20 of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0178] The processor 21 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 21 or by software instructions. The processor 21 can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this invention can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software modules can be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory 20, and the processor 21 reads the information in memory 20 and, in conjunction with its hardware, completes the steps of the above diagnostic method.
[0179] In some embodiments, the embodiments described herein can be implemented using hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described herein, or combinations thereof.
[0180] For software implementation, the techniques described herein can be achieved through modules (e.g., procedures, functions, etc.) that perform the functions described herein. The software code can be stored in memory and executed by a processor. The memory can be implemented within the processor or externally.
[0181] Another embodiment of the present invention provides a computer storage medium storing an executable program, which, when executed by a processor 21, can implement steps applied to a diagnostic method. For example, such as... Figure 1 One or more of the diagnostic methods shown.
[0182] In some embodiments, computer-readable storage media may include various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0183] It should be noted that the technical solutions described in the embodiments of the present invention can be combined arbitrarily without conflict.
[0184] Finally, it should be noted that the above description is only for specific embodiments of the present invention. However, the present invention is not limited to the specific embodiments described above. Equivalent modifications and substitutions made to the present invention by those skilled in the art are also within the scope of the present invention. Therefore, all equivalent changes and modifications made without departing from the spirit and scope of the present invention are covered within the scope of the present invention.
Claims
1. A transformer fault diagnosis method incorporating feature contrast learning, characterized in that: The diagnostic method includes the following steps: S1: Collect dissolved gas analysis (DGA) data and phase-resolved partial discharge (PRPD) map data of the transformer to be diagnosed, perform data preprocessing, sample pairing and labeling on the DGA data and PRPD map data, and construct a dual-modal training dataset; S2: Establish a dual-modal feature encoding network, and use the DGA encoder to extract DGA global features, and use the PRPD encoder to extract PRPD map global features and PRPD map local feature sequences respectively; S3: Establish a cross-modal attention fusion network, using DGA global features as query vectors and PRPD local feature sequences as keys and values for cross-modal attention calculation to obtain cross-modal fusion features. Then, use a gating enhancement module to fuse the cross-modal fusion features with DGA global features to obtain classification features. S4: Establish PRPD projection head and DGA projection head respectively, map PRPD global features and DGA global features to a unified contrastive learning space to obtain normalized projection features; S5: Establish a supervised feature contrastive learning model, construct a positive sample set and a negative sample set based on the sample labels, and use supervised contrastive loss to optimize the intra-class compactness and inter-class separability of normalized projected features; S6: Establish a joint optimization model of classification loss and supervised contrastive loss, and complete model training by dynamically adjusting the weights of supervised contrastive loss; S7: After training, delete the PRPD projection head and DGA projection head, and keep only the dual-modal coding network, cross-modal attention fusion network, gating enhancement module and classifier to complete the deployment of the transformer fault diagnosis model.
2. The transformer fault diagnosis method incorporating feature contrast learning according to claim 1, characterized in that: The PRPD projection head and DGA projection head described in S4 are both constructed using a two-layer multilayer perceptron, which maps 128-dimensional global features to 64-dimensional projected features and uses L2 normalization to obtain a unit-length projection vector, so that the two modalities are mapped to a unified shared contrastive learning space.
3. The transformer fault diagnosis method incorporating feature contrast learning according to claim 1, characterized in that: In the learning process using the supervised feature contrastive learning model described in S5, any projection vector in the batch training samples is used as the anchor sample. Projection vectors with the same fault label as the anchor sample are used as the positive sample set, and projection vectors with different fault labels are used as the negative sample set. The shared feature space is optimized based on the supervised contrastive loss function. The positive samples include samples of the same modality and class as well as samples of the same class of different modalities.
4. The transformer fault diagnosis method incorporating feature contrast learning according to claim 1, characterized in that: The supervised contrastive loss described in S5 uses the cosine similarity between normalized projection vectors to calculate the similarity of positive and negative samples. By increasing the similarity of positive samples and decreasing the similarity of negative samples, samples of the same class are clustered and samples of different classes are separated, and the semantic consistency between the DGA modality and the PRPD modality is strengthened.
5. The transformer fault diagnosis method incorporating feature contrast learning according to claim 1, characterized in that: The joint optimization model of classification loss and supervised contrastive loss described in S6 uses a linear weighted sum of classification loss and supervised contrastive loss to form the total loss function, and adopts a phased dynamic weight scheduling strategy. In the early stage of training, only classification loss is used to train the model, and in the middle and later stages of training, the weight of supervised contrastive loss is gradually increased to ensure stable convergence of model training.
6. The transformer fault diagnosis method incorporating feature contrast learning according to claim 1, characterized in that: The model training described in S6 employs a two-stage joint training approach, including: In the first stage, the PRPD encoder convolutional backbone is frozen, and only the DGA encoder, cross-modal attention fusion module, gating enhancement module, classifier, and projector are trained. The second phase involves lifting the complete network freeze and performing end-to-end joint fine-tuning of the entire network.
7. The transformer fault diagnosis method incorporating feature contrast learning according to claim 1, characterized in that: In the deployment phase of the transformer fault diagnosis model described in S7, the supervised feature comparison learning projection branch is removed, and only the dual-modal fault diagnosis backbone network is retained. This ensures that the parameter scale, computational complexity, and inference time of the deployed model are consistent with the basic dual-modal fusion model, thereby decoupling the training and deployment phases.
8. A transformer fault diagnosis system incorporating feature contrastive learning, characterized in that: The diagnostic system includes: The dual-modal data management module is used to collect dissolved gas analysis (DGA) data and phase-resolved partial discharge (PRPD) spectrum data of the transformer to be diagnosed, and to perform data preprocessing, sample pairing and labeling on the DGA data and PRPD spectrum data to construct a dual-modal training dataset. The dual-modal feature representation module is used to establish a dual-modal feature encoding network, which extracts global features of DGA using the DGA encoder and extracts global features and local feature sequences of PRPD map using the PRPD encoder. The cross-modal semantic fusion module is used to establish a cross-modal attention fusion network. It uses DGA global features as query vectors and PRPD local feature sequences as keys and values to perform cross-modal attention calculations to obtain cross-modal fusion features. Then, the gating enhancement module is used to fuse the cross-modal fusion features with DGA global features to obtain classification features. The feature space collaborative optimization module is used to establish PRPD projection heads and DGA projection heads respectively, mapping PRPD global features and DGA global features to a unified contrastive learning space to obtain normalized projected features; a supervised feature contrastive learning model is established, constructing positive and negative sample sets based on sample labels, and using supervised contrastive loss to optimize the intra-class compactness and inter-class separation of normalized projected features; a joint optimization model of classification loss and supervised contrastive loss is established, and model training is completed by dynamically adjusting the weights of supervised contrastive loss. The lightweight intelligent inference deployment module is used to delete the PRPD projection head and DGA projection head after training, retaining only the dual-modal coding network, cross-modal attention fusion network, gating enhancement module and classifier to complete the deployment of the transformer fault diagnosis model.
9. An electronic device, characterized in that, include: A processor and a memory for storing a computer program capable of running on the processor, wherein the processor, when running the computer program, implements the steps of the diagnostic method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The device contains an executable program that, when executed by a processor, implements the steps of the diagnostic method as described in any one of claims 1 to 7.
