A method for identifying power quality disturbances based on self-supervised contrastive learning
By generating views of power quality disturbance signals using a self-supervised contrastive learning method, building a pre-trained model and performing fine-tuning, the problems of insufficient data labeling and difficult feature selection in power quality disturbance identification are solved. This enables efficient and accurate power quality disturbance identification and real-time early warning, and enhances the power grid's anti-disturbance capability.
Patent Information
- Application Number
- CN202510838362.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-23
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2045-06-23
AI Technical Summary
Existing power quality disturbance identification technology relies on a large amount of labeled data, which has problems such as insufficient data labeling and difficulty in feature selection. In addition, the model training requires large computational complexity and poor real-time performance, making it difficult to meet the real-time monitoring needs of the power system.
A self-supervised contrastive learning method is adopted to generate views of power quality disturbance signals through strong enhancement and weak enhancement. A pre-trained model of the encoder, time comparison module and context comparison module is constructed, and fine-tuning is performed using a small amount of labeled data to realize the identification of power quality disturbances.
It effectively solves the problems of insufficient data labeling and feature selection, improves the generalization and real-time performance of the model, and can accurately identify power quality disturbances, reduce fault risks, and ensure stable operation of the power grid.
Smart Images

Figure CN120372254B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of power quality disturbance analysis and identification, and in particular to a power quality disturbance identification method based on self-supervised comparative learning. Background Art
[0002] Currently, the monitoring and identification of power quality disturbances primarily rely on traditional methods based on feature extraction and machine learning. These methods typically extract key time-domain or frequency-domain features from a large amount of collected power quality data and use a pre-set classification model to identify the type of disturbance. Common techniques include Fourier transform, wavelet transform, machine learning-based classification, and deep learning. The Fourier transform method, for example, converts power quality signals into frequency-domain signals through a fast Fourier transform (FFT) to identify harmonic components. While this method is effective for detecting harmonic problems, it has limited ability to identify complex, non-periodic disturbances. The wavelet transform provides local information in the time and frequency domains, making it suitable for analyzing transient disturbances. While the wavelet transform can effectively analyze transient power quality disturbances such as voltage sags and flicker, it is computationally complex and performs poorly when processing highly non-stationary signals. Classification methods based on machine learning: such as support vector machines (SVM), decision trees, and K-nearest neighbor algorithms (KNN). These methods are usually used to process extracted feature data for disturbance classification. Such methods usually rely on manually designed features and a large amount of training data, but have certain limitations in feature selection and the generalization ability of classification models. Deep learning methods: In recent years, deep learning has been increasingly widely used in the identification of power quality disturbances. Through deep learning models such as convolutional neural networks (CNN) and recurrent neural networks (RNN), features can be automatically learned from the original signal, thereby improving the accuracy of recognition. However, deep learning models usually require the use of a large amount of labeled data to train the model, and the training process is computationally intensive and has poor real-time performance, making it difficult to meet the power system's needs for real-time monitoring of power quality disturbances.
[0003] Therefore, while current power quality disturbance identification technology has made some progress, most machine learning and deep learning methods require large amounts of labeled data to train the models. However, in the power quality disturbance identification process, the acquisition cost of labeled data is high, and many disturbance types are relatively rare, resulting in an unbalanced dataset and difficulty in ensuring model training results. Furthermore, disturbance signals detected at different locations in the power grid play a vital role in the construction of power quality disturbance identification models, but this has not been considered in previous technologies.
[0004] Therefore, how to design a power quality disturbance identification method to solve the problems of insufficient data labeling and feature selection in traditional power quality disturbance identification methods is a technical problem that needs to be solved urgently. Summary of the Invention
[0005] In view of the above analysis, an embodiment of the present invention aims to provide a power quality disturbance identification method based on self-supervised contrastive learning to solve the problems of insufficient data labeling and feature selection in traditional power quality disturbance identification methods.
[0006] The present invention discloses a method for identifying power quality disturbances based on self-supervised contrastive learning, the method comprising:
[0007] Perform strong enhancement and weak enhancement on each power quality disturbance signal sample in the unlabeled sample set, and obtain the corresponding strong enhancement view and weak enhancement view;
[0008] A power quality disturbance pre-training model based on self-supervised contrastive learning is trained using the strong enhancement view and the weak enhancement view of each power quality disturbance signal sample; the power quality disturbance pre-training model includes an encoder, a time comparison module and a context comparison module in sequence;
[0009] Extract the encoder and its parameters from the trained power quality disturbance pre-trained model, connect a fully connected layer to the output of the extracted encoder, and build a power quality disturbance identification model; use the labeled sample set to perform classification and prediction training on the power quality disturbance identification model;
[0010] The power quality disturbance identification model trained by classification prediction is used to identify the power quality disturbance of real-time power quality disturbance signal.
[0011] On the basis of the above solution, the present invention also makes the following improvements:
[0012] Furthermore, the training is based on a power quality disturbance pre-training model based on self-supervised contrastive learning, and each training is performed:
[0013] The encoder extracts features from the strongly enhanced view and the weakly enhanced view of each power quality disturbance signal sample in the same training batch, and obtains corresponding feature vectors;
[0014] The feature vectors of the strong and weak enhanced views are input into the temporal contrast module, which performs the unsupervised cross-view prediction task, outputs the context vector, and calculates the temporal contrast loss.
[0015] The context vector is input into the context contrast module to perform self-supervised contrastive learning and calculate the context contrast loss;
[0016] The overall loss is obtained based on the time contrast loss and the context contrast loss. The model parameters are updated according to the overall loss. The training is repeated until the end condition is met to obtain a pre-trained model that has been trained.
[0017] Furthermore, performing the cross-view prediction task under unsupervised conditions includes:
[0018] In the time comparison module, an autoregressive model is used to summarize the parts of the feature vectors of the strong and weak enhanced views that are no longer than the preset time t into corresponding context vectors.
[0019] The context vectors of strong and weak augmented views are used to perform unsupervised cross-view prediction tasks.
[0020] Furthermore, the unsupervised cross-view prediction task refers to: using the context vector of the strongly enhanced view To predict the weakly enhanced view in the future time step potential representation of , using the context vector of the weakly enhanced view To predict the strong enhanced view in the future time step potential representation of .
[0021] Furthermore, the temporal contrast loss corresponding to the strong enhanced view and the weak enhanced view 、 Respectively expressed as:
[0022] (1)
[0023] (2)
[0024] in, represents a nonlinear layer, log represents a logarithmic function, and K represents the total step size for predicting future time steps. represents the set of negative samples in a training batch, Indicates the weight of positive and negative samples to enhance view similarity; is the weakly enhanced view of the current signal sample to be learned in the future time step The potential representation of , used as positive sample; is a strongly enhanced view of the current signal sample to be learned in the future time step The potential representation of , used as positive sample; A latent representation that represents a strongly enhanced view of all other samples in the same batch except the positive samples, used as negative samples; The latent representation that represents the weakly enhanced view of all other samples in the same batch except the positive samples is used as negative samples.
[0025] Furthermore, positive and negative samples enhance the view similarity weight Expressed as:
[0026] (3)
[0027] (4)
[0028] in, Indicates bandwidth parameter; represents the strongly enhanced view of the current signal sample to be learned, Represents a weakly enhanced view of samples other than the positive samples in the same batch.
[0029] Furthermore, the context contrast loss Expressed as:
[0030] (5)
[0031] in, Indicates the sample size of the power quality disturbance signal samples in a training batch; Indicates the The context vector of each view, The context vector of another augmented view from the same input signal sample, are considered as positive sample pairs; the remaining samples from other input signal samples in the same batch The context vector is Negative samples are defined as ; Indicates calculating the cosine similarity of two elements; represents the indicator function; Represents the temperature parameter.
[0032] Furthermore, the overall loss Expressed as:
[0033] (6)
[0034] in, 、 Represent the weights of temporal contrast loss and contextual contrast loss respectively.
[0035] Furthermore, the power quality disturbance identification model is trained for classification and prediction using the labeled sample set, and the following operations are performed:
[0036] Each power quality disturbance signal sample in the labeled sample set is used as the input of the power quality disturbance identification model, and the disturbance label of the corresponding power quality disturbance signal sample is used as the prediction output of the power quality disturbance identification model. The power quality disturbance identification model is subjected to classification prediction training to obtain the power quality disturbance identification model after classification prediction training.
[0037] Furthermore, the power quality disturbance identification model trained by classification prediction is used to identify the power quality disturbance of the real-time power quality disturbance signal and perform:
[0038] The collected real-time power quality disturbance signal is directly input into the power quality disturbance identification model after classification prediction training, and the power quality disturbance identification model predicts and outputs the disturbance identification result of the real-time power quality disturbance signal.
[0039] Compared with the prior art, the present invention can achieve at least one of the following beneficial effects:
[0040] The power quality disturbance identification method based on self-supervised contrastive learning proposed in the present invention first constructs a pre-trained model based on the self-supervised contrastive learning strategy, and then uses a small amount of power quality disturbance labeled data to perform fine-tuning to achieve the identification of power quality disturbances. Therefore, the contrastive learning strategy can mine the pattern information of the disturbance signal through the contrastive learning strategy without clear labels, thereby effectively solving the problems of insufficient data labeling and feature selection in traditional methods. The power quality disturbance identification model constructed based on the pre-trained model can accurately identify power quality disturbances, can give early warnings and take appropriate control measures, enhance the anti-disturbance capability of the power grid, reduce the failure risk of the power system, and ensure the stable operation of the power grid.
[0041] Specifically, this method first generates two different enhanced views of a power quality disturbance signal based on strong and weak enhancement methods; then, a time comparison module is proposed to explore the time domain characteristics of the power quality disturbance signal using an autoregressive model, and a cross-view prediction task is constructed; secondly, a context comparison module is constructed to maximize the consistency of the autoregressive model, and a power quality disturbance pre-training model is obtained through multiple training; finally, the pre-trained model is fine-tuned using a small amount of labeled power quality disturbance data to obtain a power quality disturbance identification model, thereby realizing the identification of power quality disturbances.
[0042] In summary, this method can overcome the problems of low accuracy, reliance on large amounts of labeled data, and poor real-time performance in existing technologies. By proposing a strong enhancement algorithm based on time-frequency domain feature retrieval, the generalization ability and feature discriminability of the self-supervised contrastive learning pre-trained model are significantly improved. Compared with traditional enhancement strategies such as random noise injection and extreme cropping, this method achieves targeted replacement of data enhancement by finding samples with similar disturbance features. The generated enhanced samples retain the core characteristics of power quality while introducing reasonable diversity, avoiding the problem of disturbance feature destruction caused by excessive modification in traditional strong enhancement methods. Through this method, efficient, accurate, and real-time identification of power quality disturbances can be achieved, data annotation costs can be reduced, and the generalization ability and adaptability of the model can be improved, thereby providing strong technical support for the safe and stable operation of power systems, the development of smart grids, and the improvement of power quality.
[0043] In the present invention, the above-mentioned technical solutions can be combined with each other to achieve more preferred combinations. Other features and advantages of the present invention will be described in the following description, and some advantages will become apparent from the description or be learned through practice of the present invention. The objectives and other advantages of the present invention can be realized and obtained through the contents particularly pointed out in the description and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The accompanying drawings are only used for the purpose of illustrating specific embodiments and are not to be considered as limiting the present invention. Like reference symbols denote like components throughout the accompanying drawings.
[0045] Figure 1 A flowchart of a method for identifying power quality disturbances based on self-supervised contrastive learning provided by an embodiment of the present invention;
[0046] Figure 2 A schematic diagram of a power quality disturbance identification method based on self-supervised contrastive learning provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0047] The preferred embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, and are not used to limit the scope of the present invention.
[0048] A specific embodiment of the present invention discloses a method for identifying power quality disturbances based on self-supervised contrastive learning. The flow chart of the method is as follows: Figure 1 As shown, the schematic diagram is as follows Figure 2 shown.
[0049] Step S1: performing strong enhancement and weak enhancement on each power quality disturbance signal sample in the unlabeled sample set to obtain a corresponding strong enhancement view and weak enhancement view.
[0050] In this embodiment, strong enhancement and weak enhancement are both relatively broad terms. In actual application, a variety of enhancement methods can be used to enhance the data of the power quality disturbance signal sample. Preferably, in this embodiment, weak enhancement adopts the strategy of jitter, scale and adding noise. Strong enhancement takes into account the characteristics of power quality disturbance and adopts the time-frequency domain feature retrieval strategy to achieve strong enhancement. For example, the power quality disturbance signal sample , Indicates the length of the power quality disturbance signal sample. The strong enhancement view and weak enhancement view of 、 .
[0051] Specifically, in this embodiment, the strong enhancement considers the characteristics of power quality disturbance and generates a strong enhancement view by using time-frequency domain feature retrieval. , the specific implementation process is described as follows.
[0052] Calculate the time-frequency domain feature vector of each power quality disturbance signal sample in the unlabeled sample set. Specifically, for the power quality disturbance signal sample , calculate its key feature vectors in the time-frequency domain, including: root mean square , extreme , total harmonic distortion .
[0053] (1)
[0054] (2)
[0055] (3)
[0056] in, is the xth harmonic component.
[0057] Therefore, the time-frequency domain key feature vector of each power quality disturbance signal sample is expressed as .
[0058] Calculate the Euclidean distance between the time-frequency domain key feature vectors of each power quality disturbance signal sample in the unlabeled sample set and other power quality disturbance signal samples, and select B power quality disturbance signal samples whose Euclidean distance is less than the preset value to form a candidate set. , from the candidate set Randomly select one power quality disturbance signal sample as the strong enhancement view, that is, .
[0059] Step S2: Using the strong enhancement view and weak enhancement view of each power quality disturbance signal sample to train the power quality disturbance pre-training model based on self-supervised contrastive learning (i.e. Figure 2 The self-supervised contrastive learning pre-training model in the embodiment of the present invention is a self-supervised contrastive learning pre-training model in the embodiment of the present invention); the power quality disturbance pre-training model includes an encoder, a time comparison module and a context comparison module in sequence.
[0060] Specifically, in step S2, the following operations are performed for each training.
[0061] Step S21: the encoder performs feature extraction on the strongly enhanced view and the weakly enhanced view of each power quality disturbance signal sample in the same training batch to obtain corresponding feature vectors.
[0062] Specifically, in each training process, this embodiment uses an encoder constructed by a convolutional neural network Feature extraction is performed on the strong enhancement view and weak enhancement view of each power quality disturbance signal sample respectively, and the feature vectors of the corresponding strong enhancement view and weak enhancement view are obtained as the corresponding potential embedding representation.
[0063] In this embodiment, the enhanced view , weakly enhanced view The corresponding eigenvector 、 Respectively expressed as:
[0064] (4)
[0065] (5)
[0066] in, , , Q represents the total number of time steps, Q is less than the length of the power quality disturbance signal sample .
[0067] Step S22: Input the feature vectors of the strong enhanced view and the weak enhanced view into the temporal contrast module, perform the cross-view prediction task under unsupervised conditions, output the context vector and calculate the temporal contrast loss.
[0068] Specifically, in this embodiment, the time contrast module uses the autoregressive model contrast loss function to extract the time features in the latent space, takes part of the feature vectors as the input of the Transformer model, obtains the context vectors of the strong enhancement view and the weak enhancement view respectively, and uses the context vector to predict the feature vector of the future power quality disturbance signal, thereby constructing an unsupervised cross-view prediction task and constructing the time contrast loss based on the cross-view prediction results.
[0069] Step S221: In the time comparison module, the autoregressive model is used to summarize the parts of the feature vectors of the strong enhanced view and the weak enhanced view that are not greater than the preset time t into corresponding context vectors.
[0070] Preferably, in the unsupervised cross-view prediction task proposed in this embodiment, the Transformer model is used as an autoregressive model. Specifically, the feature vector of the strongly enhanced view is A vector consisting of all elements in the sequence that are not greater than the preset time t As the input of the autoregressive model, the autoregressive model predicts the context vector of the output strong enhanced view ; Weakly enhance the eigenvector A vector consisting of all elements in the sequence that are not greater than the preset time t As the input of the autoregressive model, the autoregressive model predicts the context vector of the weakly enhanced view .
[0071] Step S222: Using the context vectors of the strong enhancement view and the weak enhancement view, perform the cross-view prediction task under unsupervised conditions.
[0072] Since both the strong enhancement view and the weak enhancement view are the results of data processing on the original power quality disturbance signal samples, they are the same source signals and have the feasibility of cross-view prediction. Specifically, the context vector of the strong enhancement view is used to To predict the weakly enhanced view in the future time step potential representation of , using the context vector of the weakly enhanced view To predict the strong enhanced view in the future time step potential representation of .
[0073] In the unsupervised cross-view prediction task proposed in this embodiment, the temporal contrast loss corresponding to the strongly enhanced view and the weakly enhanced view is 、 Respectively expressed as:
[0074] (6)
[0075] (7)
[0076] in, represents a nonlinear layer, log represents a logarithmic function, and K represents the total step size for predicting future time steps. Represents a set of negative samples in a training batch, including samples other than positive samples; Indicates the weight of positive and negative samples to enhance view similarity; is the weakly enhanced view of the current signal sample to be learned in the future time step The potential representation of , used as positive sample; is a strongly enhanced view of the current signal sample to be learned in the future time step The potential representation of , used as positive sample; A latent representation that represents the strongly enhanced views of samples other than the positive samples in the same batch, used as negative samples; The latent representations representing the weakly enhanced views of samples other than the positive samples in the same batch are used as negative samples.
[0077] It should be noted that since this framework does not require the use of perturbation labels to train model parameters, it is necessary to construct prediction tasks to allow the model parameters to be correctly updated. This embodiment constructs a cross-view prediction task and uses the above-mentioned loss function to evaluate the completion of the task. The lower the calculation results of the two loss functions become during the training process, the better the model parameters are learned. The two loss functions are used to guide the parameter training of the encoder, time comparison module, and context comparison module. Preferably, this embodiment improves the calculation of the time comparison loss and adds a weight for measuring the similarity of samples after strong and weak enhancement. The larger the weight, the greater the proportion of this sample in the process of calculating the similarity of negative samples. Therefore, through the weight mechanism, the model can pay more attention to negative samples that are more similar to the current sample.
[0078] Positive and negative samples enhance view similarity weights It is obtained by calculating the Euclidean similarity between the strongly enhanced view of the signal sample to be learned and the weakly enhanced views of all other samples in the same batch except the positive sample. Expressed as:
[0079] (8)
[0080] in, It can be calculated as follows:
[0081] (9)
[0082] in, represents the bandwidth parameter, which is used to control the width of the Gaussian function; represents the strongly enhanced view of the current signal sample to be learned, Represents a weakly enhanced view of samples other than the positive samples in the same batch.
[0083] This embodiment constructs these two loss functions and updates the model parameters by gradient descent to guide the implementation of self-supervised learning.
[0084] Step S23: Input the context vector into the context contrast module, perform self-supervised contrastive learning and calculate the context contrast loss.
[0085] Specifically, the context vectors of the strong and weak enhanced views are input into the context contrast module for self-supervised contrastive learning, and the context contrast loss is calculated.
[0086] During the specific implementation process, the context vectors of the strongly enhanced view and the weakly enhanced view are used to predict the context vector of the other view through a nonlinear mapping layer, thereby constructing the context contrast loss. Finally, the context contrast loss and the time contrast loss are weightedly summed to obtain the final self-supervised contrast loss. After the gradient descent process, the encoder parameters are updated to obtain the power quality disturbance pre-training model.
[0087] Assume that the sample size of the power quality disturbance signal samples in a training batch is , for the context vector of each view , the context vector of another enhanced view from the same input signal sample is defined as a positive sample, so is considered as a positive sample pair. At the same time, the remaining samples from other input signal samples in the same batch are The context vector is Negative samples are defined as ; Can be formed with its negative sample Therefore, the context contrast loss constructed in this embodiment is used to maximize the similarity between positive sample pairs and minimize the similarity between negative sample pairs, so that the constructed power quality disturbance pre-training model has a strong recognition ability. Expressed as:
[0088] (10)
[0089] in, Indicates calculating the cosine similarity of two elements; Represents an indicator function. When the condition in the square brackets is met, the function value is 1; otherwise, it is 0. Represents the temperature parameter used to scale the similarity scores.
[0090] Step S24: Obtain the overall loss based on the time contrast loss and the context contrast loss, update the model parameters according to the overall loss, repeat the training until the end condition is met, and obtain a pre-trained model that has been trained.
[0091] Specifically, according to the overall loss of the power quality disturbance pre-training model during this training process, the model parameters of the power quality disturbance pre-training model are updated; and the next training is executed, and multiple trainings are performed until the training end conditions are met to obtain a trained power quality disturbance pre-training model.
[0092] Therefore, the overall loss of the power quality disturbance pre-training model constructed in this embodiment is a combination of two time contrast losses and a context contrast loss, as shown below:
[0093] (11)
[0094] in, 、 The weights of temporal contrast loss and contextual contrast loss are determined by the validation set. Based on the above training losses, the parameters are continuously iterated and updated until a complete power quality disturbance pre-training model is obtained.
[0095] Preferably, the training end condition is that the overall loss falls within a preset loss range, or that a preset number of training times is reached.
[0096] Step S3: Extract the encoder and its parameters from the trained power quality disturbance pre-trained model, connect the fully connected layer to the output end of the extracted encoder, and construct a power quality disturbance identification model; use the labeled sample set to perform classification and prediction training on the power quality disturbance identification model.
[0097] It should be noted that after the model training in step S2, the encoder already has a relatively accurate feature extraction capability. Therefore, by performing classification prediction training on the power quality disturbance pre-training model based on a smaller number of labeled sample sets, a high-performance power quality disturbance identification model can be obtained. Preferably, in step S3, each power quality disturbance signal sample in the labeled sample set is used as the input of the power quality disturbance identification model, and the disturbance label of the corresponding power quality disturbance signal sample is used as the prediction output of the power quality disturbance identification model, and the power quality disturbance identification model is subjected to classification prediction training to obtain a trained power quality disturbance identification model.
[0098] The specific real-time process is based on the power quality disturbance pre-training model obtained in step S2, and adds a fully connected layer (such as a linear layer for classification). Then, it is fine-tuned with a small amount of power quality labeled data (the labeled data is used to continue the supervised classification learning and the model parameters are updated during the learning process). A power quality disturbance identification model with strong identification ability can be obtained. During the fine-tuning process, the multi-category cross entropy formula is used as the loss function. Expressed as:
[0099] (12)
[0100] in, is the number of batch samples in the labeled sample set, Indicates the first The disturbance labels of power quality disturbance signal samples, Indicates the Power quality disturbance signal samples for disturbance categories The predicted probability of .
[0101] Step S4: using the power quality disturbance identification model trained by classification prediction to identify the power quality disturbance of the real-time power quality disturbance signal.
[0102] The collected real-time power quality disturbance signal is directly input into the power quality disturbance identification model after classification prediction training, and the power quality disturbance identification model predicts and outputs the disturbance identification result of the real-time power quality disturbance signal.
[0103] In summary, the method provided by this implementation mainly consists of three processes: the construction process of the power quality disturbance pre-training model, the fine-tuning process of the power quality disturbance identification model, and the prediction process based on the power quality disturbance identification model. In the specific implementation process, by introducing a self-supervised comparative learning strategy, a large amount of unlabeled power quality disturbance data is fully utilized to construct a power quality disturbance pre-training model, and the power quality disturbance pre-training model is fine-tuned based on a small number of labeled samples to obtain a power quality disturbance identification model for subsequent prediction. This solution has the following beneficial effects:
[0104] (1) This embodiment introduces a self-supervised contrastive learning method to construct a power quality disturbance pre-training model, which reduces the dependence on a large number of labeled samples and learns a feature representation that is discriminative for the type of power quality disturbance;
[0105] (2) The multi-view input generated by the enhancement strategy in this embodiment enables the model to better adapt to the diverse noise and random disturbances that may appear in actual power quality data. Even when the disturbance type or signal form is unknown, the model still has high accuracy.
[0106] (3) Through the time comparison module, the model in this embodiment can more effectively capture the temporal characteristics of the disturbance signal and further enhance the temporal consistency of the representation through context comparison;
[0107] (4) Based on the fact that the trained encoder has the ability to extract features efficiently, this embodiment fine-tunes the power quality disturbance pre-training model based on a small number of labeled samples, thereby obtaining a power quality disturbance identification model, which effectively improves the model identification accuracy.
[0108] Those skilled in the art will appreciate that all or part of the process steps of the above-described embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, such as a magnetic disk, an optical disk, a read-only memory, or a random access memory.
[0109] The above description is only a preferred specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by any technician familiar with this technical field within the technical scope disclosed by the present invention should be covered by the scope of protection of the present invention.
Claims
1. A method for identifying power quality disturbances based on self-supervised contrastive learning, characterized in that: The method comprises: Each power quality disturbance signal sample in the unlabeled sample set is strongly enhanced and weakly enhanced to obtain the corresponding strongly enhanced view and weakly enhanced view; wherein, the strongly enhanced view is generated by using the time-frequency domain feature retrieval, and the following is performed: the time-frequency domain key feature vector of each power quality disturbance signal sample is calculated respectively , 、 、 Represent root mean square, range, and total harmonic distortion, respectively; calculate the Euclidean distance between the time-frequency domain key feature vectors of each power quality disturbance signal sample in the unlabeled sample set and other power quality disturbance signal samples, select B power quality disturbance signal samples whose Euclidean distance is less than a preset value to form a candidate set, and randomly select one power quality disturbance signal sample from the candidate set as a strongly enhanced view; A power quality disturbance pre-training model based on self-supervised contrastive learning is trained using the strong enhancement view and the weak enhancement view of each power quality disturbance signal sample; the power quality disturbance pre-training model includes an encoder, a time comparison module and a context comparison module in sequence; Extract the encoder and its parameters from the trained power quality disturbance pre-trained model, connect a fully connected layer to the output of the extracted encoder, and build a power quality disturbance identification model; use the labeled sample set to perform classification and prediction training on the power quality disturbance identification model; The power quality disturbance identification model trained by classification prediction is used to identify the power quality disturbance of real-time power quality disturbance signal.
2. The power quality disturbance identification method based on self-supervised contrastive learning according to claim 1, characterized in that: The training is based on a pre-trained model of power quality disturbances using self-supervised contrastive learning. Each training session performs: The encoder extracts features from the strongly enhanced view and the weakly enhanced view of each power quality disturbance signal sample in the same training batch, and obtains corresponding feature vectors; The feature vectors of the strong and weak enhanced views are input into the temporal contrast module, which performs the unsupervised cross-view prediction task, outputs the context vector, and calculates the temporal contrast loss. The context vector is input into the context contrast module to perform self-supervised contrastive learning and calculate the context contrast loss; The overall loss is obtained based on the time contrast loss and the context contrast loss. The model parameters are updated according to the overall loss. The training is repeated until the end condition is met to obtain a pre-trained model that has been trained.
3. The power quality disturbance identification method based on self-supervised contrastive learning according to claim 2, characterized in that: The unsupervised cross-view prediction task includes: In the time comparison module, an autoregressive model is used to summarize the parts of the feature vectors of the strong and weak enhanced views that are no longer than the preset time t into corresponding context vectors. The context vectors of strong and weak augmented views are used to perform unsupervised cross-view prediction tasks.
4. The method for identifying power quality disturbances based on self-supervised contrastive learning according to claim 3, characterized in that: The unsupervised cross-view prediction task refers to: using the context vector of the strongly enhanced view To predict the weakly enhanced view in the future time step potential representation of , using the context vector of the weakly enhanced view To predict the strong enhanced view in the future time step potential representation of .
5. The method for identifying power quality disturbances based on self-supervised contrastive learning according to claim 4, characterized in that: Temporal contrast loss corresponding to strongly enhanced and weakly enhanced views 、 Respectively expressed as: (1) (2) in, represents a nonlinear layer, log represents a logarithmic function, and K represents the total step size for predicting future time steps. represents the set of negative samples in a training batch, Indicates the weight of positive and negative samples to enhance view similarity; is the weakly enhanced view of the current signal sample to be learned in the future time step The potential representation of , used as positive sample; is a strongly enhanced view of the current signal sample to be learned in the future time step The potential representation of , used as positive sample; A latent representation that represents a strongly enhanced view of all other samples in the same batch except the positive samples, used as negative samples; The latent representation that represents the weakly enhanced view of all other samples in the same batch except the positive samples is used as negative samples.
6. The method for identifying power quality disturbances based on self-supervised contrastive learning according to claim 5, characterized in that: Positive and negative samples enhance view similarity weights Expressed as: (3) (4) in, Indicates bandwidth parameter; represents the strongly enhanced view of the current signal sample to be learned, Represents a weakly enhanced view of samples other than the positive samples in the same batch.
7. The method for identifying power quality disturbances based on self-supervised contrastive learning according to claim 6, characterized in that: Contextual Contrastive Loss Expressed as: (5) in, Indicates the sample size of the power quality disturbance signal samples in a training batch; Indicates the The context vector of each view, The context vector of another augmented view from the same input signal sample, are considered as positive sample pairs; the remaining samples from other input signal samples in the same batch The context vector is Negative samples are defined as ; Indicates calculating the cosine similarity of two elements; represents the indicator function; Represents the temperature parameter.
8. The method for identifying power quality disturbances based on self-supervised contrastive learning according to claim 7, characterized in that: The overall loss Expressed as: (6) in, 、 Represent the weights of temporal contrast loss and contextual contrast loss respectively.
9. The method for identifying power quality disturbances based on self-supervised contrastive learning according to any one of claims 1 to 8, characterized in that: Use the labeled sample set to perform classification and prediction training on the power quality disturbance identification model and execute: Each power quality disturbance signal sample in the labeled sample set is used as the input of the power quality disturbance identification model, and the disturbance label of the corresponding power quality disturbance signal sample is used as the prediction output of the power quality disturbance identification model. The power quality disturbance identification model is subjected to classification prediction training to obtain the power quality disturbance identification model after classification prediction training.
10. The method for identifying power quality disturbances based on self-supervised contrastive learning according to claim 9, characterized in that: The power quality disturbance identification model trained by classification prediction is used to identify the power quality disturbance of the real-time power quality disturbance signal and perform: The collected real-time power quality disturbance signal is directly input into the power quality disturbance identification model after classification prediction training, and the power quality disturbance identification model predicts and outputs the disturbance identification result of the real-time power quality disturbance signal.
Citation Information
Patent Citations
Electric power system transient signal identification method
CN117454269A
Small sample spectrum sensing method based on time prediction and context contrast learning
CN120180241A