Small sample distribution network anomaly detection method and device based on graph contrast learning
Through the small sample distribution network anomaly detection method based on graph comparison learning, the distribution network heterogeneous graph and use graph convolution neural network to learn low-dimensional features, the problems of low efficiency and relying on manual analysis in the existing technology are solved, and efficient and robust anomaly detection is achieved.
Patent Information
- Application Number
- CN202411163081.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2044-08-23
AI Technical Summary
The existing distribution network abnormality detection methods are inefficient when dealing with complex abnormal situations and rely on manual analysis, and cannot efficiently model a complete grid topology, and lack the context mining ability of multiple equipment measurement data.
A small sample distribution network anomaly detection method based on graph comparison learning is adopted. By constructing a heterogeneous graph of the distribution network, using graph convolutional neural network to learn graph embedding, node-level and graph-level low-dimensional vector representations are generated, and pre-trained and fine-tuned by contrast learning discriminators to automatically learn low-dimensional features of abnormal topology.
It improves the accuracy and robustness of abnormal detection in the distribution network, and can effectively detect abnormal topology in the absence of abnormal samples, reduces dependence on a large amount of labeled information, and improves detection efficiency.
Smart Images

Figure CN119046840B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of intelligent detection of power grid data, and in particular to a small sample distribution network anomaly detection method and device based on graph comparative learning. Background Art
[0002] With the rapid development of modern power systems, distribution networks, as the terminal link of power transmission, directly connect hundreds of millions of users. Their stable and reliable operation is crucial to the overall performance of the power system. However, the wide geographical distribution of distribution networks, diverse monitoring equipment, and complex and changeable operation modes have brought huge challenges to the detection and location of topological anomalies in distribution networks. According to historical statistics of the power grid, more than 95% of power outages are caused by abnormal distribution network data, which shows that the distribution network is the main cause of power instability.
[0003] In recent years, the vigorous development of big data and Internet of Things technologies has significantly improved the monitoring methods and data acquisition capabilities of distribution networks. At present, researchers at home and abroad have proposed a variety of distribution network topology anomaly detection technologies, which can be roughly divided into two categories: traditional methods and artificial intelligence-based methods. Traditional methods mainly judge and diagnose distribution network anomalies based on expert experience and data mining technology. However, these methods are unable to cope with complex abnormal situations. In addition, traditional methods usually rely on manual analysis and judgment, which are inefficient and easily affected by human factors.
[0004] In contrast, AI-based methods can automatically extract features from large-scale data and output detection results. Common models include neural network models, decision tree models, and support vector machine models. These models have powerful data processing and learning capabilities, and can automatically analyze and judge complex distribution network topology anomalies. However, existing AI-based distribution network anomaly detection methods still face some challenges. First, these methods usually require a large number of training samples and annotation information to achieve ideal performance. Second, these methods are often unable to accurately model the complete power grid topology, and lack the ability to mine the context of measurement data from multiple devices, resulting in low topology analysis performance. Summary of the invention
[0005] In order to efficiently model the distribution network containing feeder graph model data and massive equipment measurement data, and automatically learn the low-dimensional features of abnormal topology in the absence of abnormal samples, so as to improve the accuracy and robustness of anomaly detection, the present invention proposes a small sample distribution network anomaly detection method and device based on graph comparative learning.
[0006] One aspect of the present invention provides a small sample distribution network anomaly detection method based on graph contrast learning, comprising:
[0007] Construct a distribution network heterogeneous graph based on the acquired given feeder graph model data and equipment measurement data;
[0008] Taking each transformer in the distribution network heterogeneous graph as a central node, a subgraph of the distribution network heterogeneous graph corresponding to each transformer is formed respectively, and each subgraph contains the topological structure connected to the transformer and the monitored power grid attribute information; taking any given subgraph as an original sample, performing heterogeneous graph data enhancement on the original sample, and generating a number of positive instance samples; taking the remaining subgraphs outside the any given subgraph as a number of negative instance samples, and combining the positive instance samples, the negative instance samples and the original samples into positive instance pairs and negative instance pairs;
[0009] Using a graph convolutional neural network to which weight matrices of different node relationships are added, respectively learning the graph embeddings in the positive instance samples, negative instance samples, and original samples, and generating node-level low-dimensional vector representations corresponding to the three samples; performing a read operation on the node-level low-dimensional vector representation through the graph convolutional neural network to obtain graph-level low-dimensional vector representations of the positive instance samples, negative instance samples, and original samples;
[0010] According to the graph-level low-dimensional vector representation and the loss function, the final contrast loss of all samples is calculated; according to the final contrast loss, the weight matrix in the graph convolutional neural network is adjusted to obtain a pre-trained graph convolutional neural network;
[0011] Using labeled sample data to fine-tune the weight matrix of the pre-trained graph convolutional neural network to obtain an optimized pre-trained graph convolutional neural network;
[0012] Anomaly detection in distribution networks is performed using an optimized pre-trained graph convolutional neural network.
[0013] Another aspect of the present invention further provides a small sample distribution network anomaly detection device based on graph contrast learning, comprising:
[0014] A graph construction module is configured to construct a distribution network heterogeneous graph based on the acquired given feeder graph model data and device measurement data;
[0015] The sample generation module is configured to take each transformer in the distribution network heterogeneous graph as a central node, and form a subgraph of the distribution network heterogeneous graph corresponding to each transformer, each subgraph containing a topological structure connected to the transformer and monitored grid attribute information; take any given subgraph as an original sample, perform heterogeneous graph data enhancement on the original sample, and generate a number of positive instance samples; take the remaining subgraphs other than any given subgraph as a number of negative instance samples, and combine the positive instance samples, the negative instance samples and the original samples into positive instance pairs and negative instance pairs;
[0016] A graph-level vector generation module is configured to use a graph convolutional neural network to which a weight matrix of different node relationships is added, to learn the graph embeddings in the positive instance samples, the negative instance samples and the original samples respectively, and to generate node-level low-dimensional vector representations corresponding to the three samples; and to read out the node-level low-dimensional vector representations through the graph convolutional neural network to obtain graph-level low-dimensional vector representations of the positive instance samples, the negative instance samples and the original samples;
[0017] The unlabeled pre-training module is configured to calculate the final contrast loss of all samples according to the graph-level low-dimensional vector representation and the loss function; and adjust the weight matrix in the graph convolutional neural network according to the final contrast loss to obtain a pre-trained graph convolutional neural network;
[0018] A labeled fine-tuning module is configured to fine-tune the weight matrix of the pre-trained graph convolutional neural network using labeled sample data to obtain an optimized pre-trained graph convolutional neural network;
[0019] The anomaly detection module is configured to perform anomaly detection on the distribution network using an optimized pre-trained graph convolutional neural network.
[0020] A small sample distribution network anomaly detection method and device based on graph comparative learning provided by the present invention realizes efficient modeling of the distribution network including feeder graph model data and massive equipment measurement data. In the absence of abnormal samples, especially in small sample scenarios, it can automatically learn the low-dimensional features of abnormal topology, improve the accuracy and robustness of anomaly detection, and provide strong support for building a reliable and secure smart grid system. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:
[0022] Figure 1 It is a flowchart of a small sample distribution network anomaly detection method based on graph contrast learning provided by an embodiment of the present application;
[0023] Figure 2 It is a schematic diagram of distribution network feeder diagram data provided by an embodiment of the present application;
[0024] Figure 3 This is a schematic diagram of distribution network measurement data provided by an embodiment of the present application;
[0025] Figure 4 It is a logical framework diagram of a small sample distribution network anomaly detection method based on graph contrast learning provided by an embodiment of the present application;
[0026] Figure 5It is a structural schematic diagram of a small sample distribution network anomaly detection device based on graph comparative learning provided by another embodiment of the present application. DETAILED DESCRIPTION
[0027] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0028] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.
[0029] It should be understood that although the terms first, second, third, etc. may be used to describe the acquisition modules in the embodiments of the present invention, the acquisition modules should not be limited to these terms. These terms are only used to distinguish the acquisition modules from each other.
[0030] The word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.
[0031] It should be noted that the directional words such as "upper", "lower", "left", and "right" described in the embodiments of the present invention are described at the angles shown in the drawings and should not be understood as limiting the embodiments of the present invention. In addition, in the context, it should also be understood that when it is mentioned that an element is formed "on" or "under" another element, it can not only be formed directly "on" or "under" another element, but also be formed "on" or "under" another element indirectly through an intermediate element.
[0032] The present invention provides a small sample distribution network anomaly detection method and device based on graph contrast learning, and its technical concept is:
[0033] Firstly, according to the given feeder diagram data and equipment measurement data, a complete heterogeneous distribution network graph G is constructed, and a subgraph Go is formed with any transformer as the central node. Go contains the topological structure (switches, main lines, etc.) connected to the transformer and the monitored attribute information (power, voltage, etc.).
[0034] Next, we design a variety of data enhancement strategies to perform heterogeneous graph data enhancement on instance Go and randomly enhance m positive instances. Randomly select n negative instances from the large distribution network heterogeneous graph G Use graph convolutional neural networks (equivalent to encoders) GCNo, GCNp and GCNq to learn Go, and Graph embedding.
[0035] Finally, the contrastive learning discriminator is used to evaluate the consistency of each heterogeneous graph instance pair and output whether the type of the target subgraph Go is normal or abnormal. If it is abnormal, it is returned to the business middle station for manual verification.
[0036] See also Figure 1 An embodiment of the present application provides a small sample distribution network anomaly detection method based on graph contrast learning, comprising the following steps:
[0037] Step S101, constructing a distribution network heterogeneous graph according to the acquired given feeder graph model data and equipment measurement data.
[0038] Construct a complete distribution network topology heterogeneous graph, referred to as the distribution network heterogeneous graph. Based on the power grid resource business platform, the distribution network topology data sources include Figure 2 The feeder diagram data and Figure 3 The equipment measurement data shown. With the increase in data sources, multi-source data has various forms of expression, which makes it difficult to directly fuse and correlate analysis. Therefore, it is necessary to preprocess the original data first and form a standardized set of triples, such as [#3 box transformer, commissioning time, 2020-1-1] or [#3 box transformer, output power, 200kW], etc. Based on the processed triple set, the first type of entities are extracted, including substations, transformers, disconnectors, feeders, main lines, circuit breakers, load switches, etc.; the second type of entities include voltage, power, time, users, etc.; and the relationships between entities are extracted. Finally, the feeder graph model data and the measurement data are fused into a complete heterogeneous distribution network graph, such as Figure 4 As shown in area (a) in the figure.
[0039] Step S102, taking each transformer in the distribution network heterogeneous graph as a central node, respectively forming a subgraph of the distribution network heterogeneous graph corresponding to each transformer, each subgraph containing a topological structure connected to the transformer and monitored grid attribute information; taking any given subgraph as an original sample, performing heterogeneous graph data enhancement on the original sample, and generating a number of positive instance samples; taking the remaining subgraphs other than any given subgraph as a number of negative instance samples, and combining the positive instance samples, the negative instance samples and the original samples into positive instance pairs and negative instance pairs.
[0040] Specifically, positive and negative samples of the distribution network are generated based on multi-level data enhancement. Data enhancement aims to expand the training data set, increase the diversity and richness of the data, and thus improve the generalization ability of the model. However, the performance of deep learning models depends largely on the characteristics of sample data, and inappropriate data enhancement will reduce the performance of downstream tasks. Existing graph data enhancement methods mainly generate data enhancement instances of isomorphic graph structures by randomly adding or deleting nodes or edges. Since the nonlinear dependencies of various heterogeneous entities are ignored, they are not suitable for heterogeneous distribution network graphs. At the same time, since such randomly generated samples are not representative, it is difficult for the model to capture and learn the fundamental characteristics of abnormal topology, and the robustness is poor.
[0041] In order to solve the above problems, the present invention proposes an enhancement method based on projected gradient descent and an enhancement method based on interactive diffusion to generate challenging heterogeneous graph instances. The former enhances the distribution network heterogeneous graph instance from the attribute level, and the latter performs adversarial enhancement on the distribution network heterogeneous graph instance from the structure level, thereby capturing more discriminative features of normal topological structures and abnormal topological structures, while enhancing the model's robustness and generalization ability, and improving the diversity and complexity of the data set, providing high-quality comparison samples for subsequent model training.
[0042] Specifically, the enhancement method based on projected gradient descent proposed in the present invention generates real positive sample instances by injecting adversarial perturbations into the node features of heterogeneous graphs. For an input sample, it uses the gradient information generated by the back propagation of the neural network to add a small perturbation along the direction of gradient ascent based on the original sample node features to generate a new sample. The specific process can be calculated by the following formula:
[0043] r 0 =0.
[0044]
[0045] Among them, r 0 is the initial disturbance; r N+1 represents the disturbance generated by the N+1th iteration; r Nis the current perturbation; ∈ represents the spherical limit, where the infinity norm of the added perturbation does not exceed ∈; α is the step size of each iteration, which is used to control the amplitude of the perturbation update; sign() is the sign function used to determine the direction of the perturbation; L() is the loss function, is the gradient of the loss function, which is used to indicate the rate of change of the loss function; G o Represents the original sample.
[0046] Intuitively, given an original instance (original sample) G o =(V o , E o ), where V o represents a node set, E o Represents the edge set. The goal is to find a perturbation δ so that the modified input graph G′=(V, E′) can mislead the classification result of the graph neural network on the subgraph and maximize the classification error.
[0047] Specifically, the interactive diffusion-based enhancement method proposed in the present invention captures and strengthens the complex interactive relationships between nodes by introducing more local context information, thereby improving the model's ability to represent and learn nodes in heterogeneous graphs. This data enhancement method can increase the robustness of the model, enabling it to better cope with novel and unknown heterogeneous graph data.
[0048] The enhanced method of interactive diffusion includes three steps:
[0049] (1) Random walk sampling. Starting from a transformer node P in the graph, a random walk is performed to generate a set of neighbor nodes N of the node. P and the target node set T P ;
[0050] (2) Interaction between diffusion processes. Since the transformer node is the core node in the graph, the interaction between transformers is mainly considered during diffusion enhancement, and the set after diffusion is obtained. and
[0051] (3) Construct new interactive relationships. and Each node in the constructs an interactive relationship, that is, connects the corresponding nodes.
[0052] Through the above three steps, the enhanced positive samples based on interactive diffusion are finally constructed. By utilizing the enhancement of node features and structural features, the present invention mines and generates richer and more complex distribution network topology patterns, providing real and rich positive samples for subsequent comparative learning, which helps to improve the robustness and generalization ability of the model.
[0053] Next, the present invention also samples the remaining subgraph structures from the large distribution network heterogeneous graph G as negative samples. Then, it is further combined with the original sample instance Go into positive instance pairs and negative instance pairs. Among them, the positive instance pair refers to a sample pair with high similarity under a certain metric, usually representing the same category or having similar features; the negative instance pair refers to a sample pair with lower similarity under the same metric, representing a different category or having significantly different features. The constructed positive and negative instance pairs will be used in the subsequent comparative learning process.
[0054] Step S103, using a graph convolutional neural network to which weight matrices of different node relationships are added, respectively learning the graph embeddings in the positive instance samples, negative instance samples, and original samples, and generating node-level low-dimensional vector representations corresponding to the three samples; performing a read operation on the node-level low-dimensional vector representation through the graph convolutional neural network to obtain graph-level low-dimensional vector representations of the positive instance samples, negative instance samples, and original samples.
[0055] Specifically, Figure 4 As shown in the (b) area, the detection method of the present invention then learns and represents the formed positive and negative instance pairs. The traditional graph convolutional neural network does not take into account the influence of different types of nodes and edges on the graph learning process, and cannot process heterogeneous graph data well. When aggregating node information, it is similar to CNN, using the degree matrix and adjacency matrix to weight the attribute features of neighbor nodes to update the features of the target node. The convolution process of the traditional graph convolutional neural network can be expressed as:
[0056]
[0057] Where D is the degree matrix, A is the adjacency matrix, and h (I) represents the node features of layer I, represents the expansion matrix obtained by adding self-loops on the basis of D, Represents the extended adjacency matrix obtained by adding self-loops on the basis of A.
[0058] As can be seen from the above formula, the formula does not take into account the different types of nodes and relationships in the heterogeneous graph, so if the traditional graph convolutional neural network is directly used to process heterogeneous nodes, it will inevitably damage the heterogeneous characteristics of the distribution network graph data. Therefore, the present invention specifically designs a graph convolutional neural network suitable for the distribution network heterogeneous graph to learn and extract graph features.
[0059] Specifically, in order to enable the model to learn different types of nodes and relationships, the present invention sets a different weight matrix for each relationship to capture and utilize the rich heterogeneous information in the distribution network heterogeneous graph. After adding the weight matrices of different relationships, the graph convolution can be expressed as:
[0060] The graph convolutional neural network with the weight matrix of different node relationships added is expressed by the following formula:
[0061]
[0062] Among them, σ() is the activation function, represents the feature vector of node i in layer l, R represents the set of all relationship types, N is the set of neighbor nodes of node i under relationship r, c i,r is the normalization coefficient, is the trainable weight matrix of relation r at layer (I-1), is the feature vector of neighbor node j at the (I-1)th layer.
[0063] Since the above process sets a weight matrix as a trainable parameter for each relationship in the heterogeneous graph, as the number of relationships in the heterogeneous graph increases, the number of weight matrices also increases, which places a heavy burden on model training. In order to alleviate this problem, the present invention uses a matrix decomposition method, and according to the idea of weight sharing, each weight matrix is represented as a linear transformation of the base matrix, that is, the weight matrix of each relationship It can be expressed as a basis matrix Linear transformation of :
[0064]
[0065] in, is the basis matrix, is the linear transformation factor of the relation r, both of which are learnable parameters, and The weight matrices are shared among all relations in the heterogeneous graph and are generated by linear transformation. Therefore, for each relation, only one set of coefficients needs to be learned. To adjust the contribution of the basis matrix to the final weight matrix, the number of model parameters is greatly reduced, reducing the risk of overfitting. In addition, the basis matrix can also be regarded as a feature extraction tool that can capture the common features of different relationship types, enabling the model to learn certain invariant properties of heterogeneous node features, thereby improving the model's predictive ability for unknown samples.
[0066] After obtaining the feature vector of node i in each layer, the present invention connects the feature vectors of all layers (i.e., layers 1 to L, where L is the largest layer of the graph convolutional neural network) of the graph convolutional neural network through the CONCAT function to obtain a complete node-level low-dimensional vector representation:
[0067]
[0068] in, represents the feature vector of node i in layer l, h iRepresents the node-level low-dimensional vector representation of node i.
[0069] For the original sample G to be tested o , after data enhancement, we get m positive instances Get n negative instances by random sampling The present invention defines three identical node-level encoders GCNo, GCNp and GCNq (i.e., three identical graph convolutional neural networks) to process these instances respectively to simultaneously generate their corresponding low-dimensional vector representations.
[0070] After obtaining the representation of each node in the graph instance, use the READOUT operation to obtain the graph-level low-dimensional vector representation READOUT is an important concept in graph neural networks. It aggregates the node features updated by the convolution operation into a single feature vector to capture the global information of the structure and node features of the entire graph, so as to obtain the graph-level representation of the entire graph. The process can be expressed as:
[0071]
[0072] Among them, READOUT() is the readout operation function in the graph convolutional neural network, h i represents the node-level low-dimensional vector representation of node i, Represents the graph-level low-dimensional vector representation of the sample.
[0073] The three graph convolutional neural networks GCNo, GCNp and GCNq all follow the same operation mode as above, generating graph-level encodings for original samples, positive instance samples and negative instance samples respectively. Through the above process, the graph-level low-dimensional vector representation of the heterogeneous graph of the distribution network is finally obtained, which provides a good encoding input for model construction and training.
[0074] Step S104, calculating the final contrast loss of all samples according to the graph-level low-dimensional vector representation and the loss function; adjusting the weight matrix in the graph convolutional neural network according to the final contrast loss to obtain a pre-trained graph convolutional neural network.
[0075] This step performs pre-training of the unlabeled graph convolutional neural network, with the goal of pre-training the weight matrix w of the graph convolutional neural network through the contrastive learning discriminator. The core of the self-supervised contrastive learning method is the contrastive learning discriminator. The present invention constructs a self-supervisory signal based on the similarity comparison between positive and negative instance pairs by designing a loss function that does not require sample label information, and trains the model by improving the similarity of the feature vectors of the positive instance pairs and reducing the similarity of the feature vectors of the negative instance pairs, thereby getting rid of the dependence on labeled data.
[0076] First, design the contrast loss function. When the low-dimensional representation of the positive instance Low-dimensional representation of the original instance Low-dimensional representation of similar or negative examples Low-dimensional representation of the original instance When the similarity is small, the loss function should give a smaller value, indicating that the model is close to the expected effect; when the low-dimensional representation of the positive instance Low-dimensional representation of the original instance Low-dimensional representation of the original instance Low-dimensional representation of instances with small similarity or when they are negative Low-dimensional representation of the original instance When the similarity is high, the loss function should give a larger value, indicating that the model error is large and further training is needed to update the model parameters.
[0077] For the oth distribution network topology instance G to be tested o , the contrast loss between the positive instance pairs is l p (G o ) and the contrast loss l between the negative instance pairs q (G o ) is represented by the following formula:
[0078]
[0079] in, and Respectively represent G o The feature representation of the original image and the feature representation of the enhanced image, h o represents the set of the two. Different subscripts j represent different samples, which are negative instance pairs. sim() represents the feature similarity calculation function between different sample sets, which can be calculated using methods such as cosine similarity. Here we need to pay attention to the optimization direction of the two contrast losses, that is, the positive and negative signs. Since the model training goal is to reduce the value of the loss function, and the contrast similarity between positive instance pairs should increase, so in l p (G o ) uses -log() to correct the optimization direction. The contrast similarity between negative instance pairs should decrease, which just matches the optimization direction of the loss function, so there is no need to change it. By combining the contrast losses between the positive and negative instance pairs of all samples, the final contrast loss L can be obtained, which is expressed as follows:
[0080]
[0081] Among them, λ is a balancing factor, which is used to adjust the relative importance of the contrast loss between positive instance pairs and the contrast loss between negative instance pairs.
[0082] In the above manner, the weight matrices in the three graph convolutional neural networks GCNo, GCNp and GCNq can be updated according to the similarity comparison relationship between the positive and negative instance pairs without label information to obtain a pre-trained graph convolutional neural network.
[0083] Step S105, using labeled sample data to fine-tune the weight matrix of the pre-trained graph convolutional neural network to obtain an optimized pre-trained graph convolutional neural network.
[0084] This step performs labeled downstream anomaly detection tasks. Its goal is to use labeled sample data to fine-tune the weight matrix of the pre-trained graph convolutional neural network to obtain an optimized pre-trained graph convolutional neural network to achieve accurate anomaly detection and classification. The specific process includes:
[0085] First, add a multi-layer perceptron fully connected layer and a Softmax classification layer connected in sequence to the output of the pre-trained graph convolutional neural network;
[0086] Secondly, the graph-level low-dimensional vector representation of each subgraph output by the pre-trained graph convolutional neural network is input into the multi-layer perceptron fully connected layer;
[0087] Finally, the weight matrix of the pre-trained graph convolutional neural network, the parameters of the multi-layer perceptron fully connected layer, and the parameters of the Softmax classification layer are fine-tuned using the labeled sample data and the cross entropy loss function to obtain the optimized pre-trained graph convolutional neural network. Specifically, the prediction value is measured by the following formula and the true label y o The difference between:
[0088]
[0089] Among them, softmax() is the classification function, MLP() is the multi-layer perceptron function, represents the L2 regularization term of the model parameters, ψ is the balancing factor, Represents the predicted value, y o represents the true label;
[0090] According to the predicted value and the true label y o Based on the differences between the two, we fine-tune the weight matrix of the pre-trained graph convolutional neural network, the parameters of the multi-layer perceptron fully connected layer, and the parameters of the Softmax classification layer.
[0091] The pre-trained model can be fine-tuned through multiple rounds of iterations in the above manner. In this stage, only a small amount of labeled data is needed to achieve good results. Therefore, it can be applied to distribution network topology anomaly detection scenarios where labeled data is scarce.
[0092] Step S106, using the optimized pre-trained graph convolutional neural network to perform anomaly detection on the distribution network.
[0093] Specifically, the optimized pre-trained graph convolutional neural network is used to detect anomalies in the distribution network and output whether the type of the target subgraph Go is normal or abnormal. If it is abnormal, it is returned to the business middle station for manual verification.
[0094] The actual effect of the detection method of the present invention is verified below.
[0095] The present invention uses a computer cluster for training, whose operating system type is CentOS Linux release7.6.1810 (Core), the processor is Intel (R) Xeon (R) Silver 4214R, the memory size is 256GB, and the specific hardware configuration is shown in Table 1. The development language is Python, and the deep learning framework is pytorch. For the model parameter setting, the grid search method is used to find the optimal parameter setting. The specific parameter settings of the algorithm of the present invention are shown in Table 2.
[0096] Table 1 Experimental hardware configuration
[0097] name parameter operating system CentOS Linux release 7.6.1810(Core) CPU Intel(R)Xeon(R)Silver 4214R Memory 256G harddisk 3TB
[0098] Table 2 Parameter settings of the present invention
[0099] Parameter name Parameter Value GCN convolutional layers 4 Temperature τ 0.07 Optimizing functions Adam Learning Rate 0.005 attenuation 0.00001 Embedding Dimension 128
[0100] The data set used in the present invention is collected from 100 sample points in the distribution network of a certain city. In order to ensure the representativeness and coverage of the sample points, the present invention comprehensively considers key factors such as the topological structure, voltage level and power of the distribution network. These sample points are evenly distributed in different substations, distribution rooms and lines. During the data collection process, high-precision sensors such as digital voltmeters and power factor meters are also used to record the voltage, power factor and other measurement data of each sample point. The collected data includes normal operation data and abnormal operation data, and the abnormal data includes but is not limited to poor line contact, short circuit and overload. The data collection frequency is once per minute, and the data collection lasts for one week.
[0101] In order to construct the training and test data sets, the present invention adopts the ten-fold cross validation method. Specifically, 20% of the samples of each topological structure are randomly selected as the test set, and the remaining 80% are used as the training set. During the training process, 20% is randomly selected from the training set as the validation set to correct the output deviation in each iteration. This method ensures the comprehensiveness of the model evaluation and the rationality of the data set division. In this way, the model parameters can be adjusted in time during the training process to ensure that the model has good generalization ability and robustness.
[0102] Experiment 1
[0103] In order to verify the effectiveness of the method of the present invention in the distribution network topology anomaly detection task, the present invention selects four existing artificial intelligence-based anomaly detection methods for comparison, including four different deep learning models such as LSTM+K-means, GAN, CNN+RNN and CNN+LSTM+Attention. The effectiveness results of each detection method are shown in Tables 3 and 4.
[0104] Table 3 Experimental results of distribution network topology anomaly detection under sufficient sample scenario
[0105]
[0106] First, it can be seen from the experimental results in Table 3 that the method of the present invention performs well in all evaluation indicators under sufficient sample scenarios, with an accuracy of 96.28%. The advantages of the present invention are attributed to the following aspects. First, compared with traditional deep learning detection methods (i.e., LSTM+K-means, CNN+RNN, CNN+LSTM+Attention), the present invention has achieved at least 3.24% improvement in accuracy, which shows that the present invention not only captures the interaction relationship and contextual semantic structure between various entities in the distribution network topology heterogeneous graph through heterogeneous graphs, but also uses graph convolutional networks to generate fine-grained graph representations, thereby improving the detection performance of the model. Second, although the existing generative detection model GAN can provide a promising self-supervised detection framework, the detection performance of the model is heavily dependent on whether the generated adversarial samples contain sufficient details. On the contrary, the present invention only needs to study the approximate discrimination patterns of comparison examples to achieve the ability to accurately identify the topology of the distribution network. Third, the present invention designs two insightful heterogeneous graph data enhancement methods (an enhancement method based on projected gradient descent and an interactive diffusion enhancement method), which fully simulate the real adversarial environment, provide more challenging training data for the present invention, and further improve the reliability and robustness of the model.
[0107] Table 4 Experimental results of distribution network topology anomaly detection in small sample scenarios
[0108]
[0109]
[0110] Secondly, according to the experimental results in Table 4, the present invention significantly improves the effectiveness of small sample distribution network topology anomaly detection, especially in the 1-shot scenario, the accuracy is 8.75% to 29.48% higher than the existing methods. The reason for this phenomenon is that most of the existing detection methods strongly rely on a large number of labeled sample libraries and train the model in a supervised manner, resulting in poor robustness to new target classes, and therefore cannot effectively identify small sample distribution network topology anomalies. On the contrary, the present invention no longer relies on a large number of labeled sample libraries, but learns more discriminative distribution network topology fingerprints through comparative learning, so that it has better robustness, especially in small sample scenarios.
[0111] In summary, the method of the present invention has good distribution network topology modeling and characterization capabilities, and has significant improvement and good performance in small sample scenarios where sample and label information is lacking. It can effectively deal with multi-source data and complex fault types in distribution network anomaly detection tasks.
[0112] Experiment 2
[0113] The detection time efficiency of the present invention and the comparative method has the following characteristics:
[0114] First, the detection time of the LSTM+K-means model is significantly shorter than that of the present invention, which is attributed to the fact that the LSTM+K-means detection method does not need to consider the complex graph structure involving various business entities and interaction relationships; empirically, the simpler the model structure, the less time is consumed.
[0115] Second, compared with the hybrid model CNN+LSTM+Attention, the detection speed of the present invention is faster. This is because the CNN+LSTM+Attention detection method trains the base models CNN, LSTM and Attention mechanisms respectively to extract multiple features. Multiple base models usually require a long training time to optimize model parameters. In contrast, the method of the present invention directly trains a graph convolutional neural network to simultaneously learn the relationship between nodes and the topological structure of the graph. Compared with the CNN+LSTM+Attention model, its model structure and parameter amount are smaller, and the training process is relatively simple, thereby improving the detection efficiency.
[0116] Third, compared with the existing generative detection model GAN, the detection time of the detection model of the present invention is shorter. This shows that the GAN training process involves adversarial optimization between the generator and the discriminator, and multiple rounds of training iterations are required. In each round of iteration, the generator generates samples, the discriminator evaluates the authenticity of the samples, and updates the parameters according to the feedback of the discriminator. Since the training process of GAN is relatively complicated and involves a large number of parameter updates and network optimizations, it usually takes a long time to run. In contrast, the present invention can use contrastive learning to directly learn distinguishable features or classify contrasting instance pairs. The training process of contrastive learning is relatively simple, and usually only requires calculating the similarity or difference between samples and performing a parameter update. Therefore, the running time of the present invention is relatively short.
[0117] See also Figure 5 Another embodiment of the present invention further provides a small sample distribution network anomaly detection device 200 based on graph contrast learning, including a graph construction module 201, a sample generation module 202, a graph-level vector generation module 203, an unlabeled pre-training module 204, a labeled fine-tuning module 205, and an anomaly detection module 206. The distribution network anomaly detection device 200 can execute the detection method in the method embodiment.
[0118] Specifically, the distribution network anomaly detection device 200 includes:
[0119] A graph construction module 201 is configured to construct a distribution network heterogeneous graph according to the acquired given feeder graph model data and device measurement data;
[0120] The sample generation module 202 is configured to take each transformer in the distribution network heterogeneous graph as a central node, and form a subgraph of the distribution network heterogeneous graph corresponding to each transformer, each subgraph containing a topological structure connected to the transformer and monitored grid attribute information; take any given subgraph as an original sample, perform heterogeneous graph data enhancement on the original sample, and generate a number of positive instance samples; take the remaining subgraphs other than any given subgraph as a number of negative instance samples, and combine the positive instance samples, negative instance samples and original samples into positive instance pairs and negative instance pairs;
[0121] The graph-level vector generation module 203 is configured to use a graph convolutional neural network to which weight matrices of different node relationships are added, respectively learn the graph embeddings in the positive instance samples, negative instance samples and original samples, and generate node-level low-dimensional vector representations corresponding to the three samples; read out the node-level low-dimensional vector representations through the graph convolutional neural network to obtain graph-level low-dimensional vector representations of the positive instance samples, negative instance samples and original samples;
[0122] The unlabeled pre-training module 204 is configured to calculate the final contrast loss of all samples according to the graph-level low-dimensional vector representation and the loss function; adjust the weight matrix in the graph convolutional neural network according to the final contrast loss to obtain a pre-trained graph convolutional neural network;
[0123] A labeled fine-tuning module 205 is configured to use labeled sample data to fine-tune the weight matrix of the pre-trained graph convolutional neural network to obtain an optimized pre-trained graph convolutional neural network;
[0124] The anomaly detection module 206 is configured to perform anomaly detection on the distribution network using the optimized pre-trained graph convolutional neural network.
[0125] It should be noted that the distribution network anomaly detection device 200 provided in this embodiment corresponds to a technical solution that can be used to execute each method embodiment, and its implementation principle and technical effect are similar to the method, which will not be repeated here.
[0126] The above description is only a preferred embodiment of the present invention. Those skilled in the art should understand that the disclosure scope involved in the present invention is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present invention (but not limited to) by each other to form a technical solution.
Claims
1. A small sample distribution network anomaly detection method based on graph contrast learning, characterized in that: include: Construct a distribution network heterogeneous graph based on the acquired given feeder graph model data and equipment measurement data; Taking each transformer in the distribution network heterogeneous graph as a central node, a subgraph of the distribution network heterogeneous graph corresponding to each transformer is formed respectively, and each subgraph contains the topological structure connected to the transformer and the monitored power grid attribute information; taking any given subgraph as an original sample, performing heterogeneous graph data enhancement on the original sample, and generating a number of positive instance samples; taking the remaining subgraphs outside the any given subgraph as a number of negative instance samples, and combining the positive instance samples, the negative instance samples and the original samples into positive instance pairs and negative instance pairs; Using a graph convolutional neural network to which weight matrices of different node relationships are added, respectively learning the graph embeddings in the positive instance samples, negative instance samples, and original samples, and generating node-level low-dimensional vector representations corresponding to the three samples; performing a read operation on the node-level low-dimensional vector representation through the graph convolutional neural network to obtain graph-level low-dimensional vector representations of the positive instance samples, negative instance samples, and original samples; According to the graph-level low-dimensional vector representation and the loss function, the final contrast loss of all samples is calculated; according to the final contrast loss, the weight matrix in the graph convolutional neural network is adjusted to obtain a pre-trained graph convolutional neural network; Using labeled sample data to fine-tune the weight matrix of the pre-trained graph convolutional neural network to obtain an optimized pre-trained graph convolutional neural network; Utilize optimized pre-trained graph convolutional neural networks to detect anomalies in distribution networks; The step of taking any given subgraph as an original sample, performing heterogeneous graph data enhancement on the original sample, and generating a plurality of positive instance samples specifically includes: Using the gradient information generated by the back propagation of the neural network, based on the node features of the original sample, perturbations are added in the direction of gradient ascent to generate enhanced samples, which are used as positive instance samples. The enhanced sample is calculated by the following formula: ; ; in, Indicates The perturbation generated by the iteration; is the current disturbance; represents the spherical limit, where the infinity norm of the added perturbation does not exceed ; is the step size of each iteration, which is used to control the amplitude of the perturbation update; sign() is the sign function used to determine the direction of the perturbation; is the loss function, is the gradient of the loss function, which is used to represent the rate of change of the loss function; represents the original sample; represents the true label.
2. According to the small sample distribution network anomaly detection method based on graph contrast learning according to claim 1, it is characterized in that: The step of using labeled sample data to fine-tune the weight matrix of the pre-trained graph convolutional neural network to obtain an optimized pre-trained graph convolutional neural network specifically includes: Add a multi-layer perceptron fully connected layer and a Softmax classification layer connected in sequence to the output of the pre-trained graph convolutional neural network; Inputting the graph-level low-dimensional vector representation of each subgraph output by the pre-trained graph convolutional neural network into the multi-layer perceptron fully connected layer; The weight matrix of the pre-trained graph convolutional neural network, the parameters of the multi-layer perceptron fully connected layer, and the parameters of the Softmax classification layer are fine-tuned using labeled sample data and the cross entropy loss function to obtain an optimized pre-trained graph convolutional neural network.
3. According to the small sample distribution network anomaly detection method based on graph contrast learning according to claim 1, it is characterized in that: The step of taking any given subgraph as an original sample, performing heterogeneous graph data enhancement on the original sample, and generating a plurality of positive instance samples specifically includes: Starting from a transformer node P in the subgraph corresponding to the original sample, a random walk is performed to generate a set of neighbor nodes of the node P. and the target node set ; Based on the interaction between transformers, the diffused set is obtained. and ; Connection Collection and The corresponding nodes in the set and A new interaction relationship is constructed for each node in , and according to the new interaction relationship of each node, an enhanced positive sample based on interactive diffusion is constructed.
4. According to the small sample distribution network anomaly detection method based on graph contrast learning according to claim 1, it is characterized in that: The graph convolutional neural network with the weight matrix of different node relationships added is expressed by the following formula: ; ; in, Representation Node In the The feature vector of the layer, represents the set of all relationship types, Is a node The set of neighbor nodes under relation r, is the normalization coefficient, is the relationship r in the first ( ) layer’s trainable weight matrix, is the neighbor node j in the ( ) layer’s feature vector, is the basis matrix, It's a relationship The linear transformation factor.
5. According to the method of claim 4, a small sample distribution network anomaly detection method based on graph contrast learning is characterized in that: The step of generating node-level low-dimensional vector representations corresponding to the three samples specifically includes: The CONCAT function is used to connect the feature vectors of all layers in the subgraph to obtain a complete node-level low-dimensional vector representation, which is calculated by the following formula: in, Representation Node In the The feature vector of the layer, Representation Node The node-level low-dimensional vector representation of , L represents the maximum layer of the graph convolutional neural network.
6. The small sample distribution network anomaly detection method based on graph contrast learning according to claim 5 is characterized in that: The step of performing a read operation on the node-level low-dimensional vector representation through the graph convolutional neural network to obtain graph-level low-dimensional vector representations of positive instance samples, negative instance samples, and original samples specifically includes: The graph-level low-dimensional vector representation of each sample is obtained by the following calculation: in, () is the readout operation function in the graph convolutional neural network, Representation Node The node-level low-dimensional vector representation of Represents the graph-level low-dimensional vector representation of the sample, Represents the original sample.
7. The small sample distribution network anomaly detection method based on graph contrast learning according to claim 1 is characterized in that: The step of calculating the final contrast loss of all samples according to the graph-level low-dimensional vector representation and the loss function specifically includes: The final contrast loss of all samples is calculated according to the following formula: ; in, is the contrast loss between positive instance pairs, is the contrast loss between negative instance pairs, and Represent the original samples The feature representation of the original image and the feature representation of the enhanced image, Represents the set of feature representations of the original image and the enhanced image, with different subscripts Represent different samples, which are negative instance pairs for each other. Represents the feature similarity calculation function between different sample sets, is the final contrast loss, is a balancing factor used to adjust the relative importance of the contrast loss between positive instance pairs and the contrast loss between negative instance pairs.
8. The small sample distribution network anomaly detection method based on graph contrast learning according to claim 2 is characterized in that: The step of fine-tuning the weight matrix of the pre-trained graph convolutional neural network, the parameters of the multi-layer perceptron fully connected layer, and the parameters of the Softmax classification layer using the labeled sample data and the cross entropy loss function specifically includes: The predicted value is measured by and the true label The difference between: in, () is the classification function, () is the multi-layer perceptron function, represents the L2 regularization term of the model parameters, is the balancing factor, represents the predicted value, represents the true label; According to the predicted value and the true label Based on the differences between the two, we fine-tune the weight matrix of the pre-trained graph convolutional neural network, the parameters of the multi-layer perceptron fully connected layer, and the parameters of the Softmax classification layer.
9. A small sample distribution network anomaly detection device based on graph contrast learning, characterized in that: include: The graph building module is configured to obtain given feeder graph data and equipment measurement data, Construct a heterogeneous graph of distribution networks; The sample generation module is configured to take each transformer in the distribution network heterogeneous graph as a central node, and form a subgraph of the distribution network heterogeneous graph corresponding to each transformer, each subgraph containing the topological structure connected to the transformer and the monitored power grid attribute information; take any given subgraph as the original sample, perform heterogeneous graph data enhancement on the original sample, and generate a number of positive instance samples, including: using the gradient information generated by the back propagation of the neural network, adding disturbances in the direction of gradient ascent based on the node features of the original sample to generate enhanced samples, and use the enhanced samples as positive instance samples; the enhanced samples are calculated by the following formula: ; ; in, Indicates The perturbation generated by the iteration; is the current disturbance; represents the spherical limit, where the infinity norm of the added perturbation does not exceed ; is the step size of each iteration, which is used to control the amplitude of the perturbation update; sign() is the sign function used to determine the direction of the perturbation; is the loss function, is the gradient of the loss function, which is used to represent the rate of change of the loss function; represents the original sample; Represents the true label; the remaining sub-images outside any given sub-image are taken as several negative instance samples, and the positive instance samples, negative instance samples and original samples are combined into positive instance pairs and negative instance pairs; A graph-level vector generation module is configured to use a graph convolutional neural network to which a weight matrix of different node relationships is added, to learn the graph embeddings in the positive instance samples, the negative instance samples and the original samples respectively, and to generate node-level low-dimensional vector representations corresponding to the three samples; and to read out the node-level low-dimensional vector representations through the graph convolutional neural network to obtain graph-level low-dimensional vector representations of the positive instance samples, the negative instance samples and the original samples; The unlabeled pre-training module is configured to calculate the final contrast loss of all samples according to the graph-level low-dimensional vector representation and the loss function; and adjust the weight matrix in the graph convolutional neural network according to the final contrast loss to obtain a pre-trained graph convolutional neural network; A labeled fine-tuning module is configured to fine-tune the weight matrix of the pre-trained graph convolutional neural network using labeled sample data to obtain an optimized pre-trained graph convolutional neural network; The anomaly detection module is configured to perform anomaly detection on the distribution network using an optimized pre-trained graph convolutional neural network.
Citation Information
Patent Citations
Distribution network state on-line detection method based on graph neural network
CN115114990A