Generative adversarial network and multi-task optimization-based electric energy measurement data anomaly detection method
By generating adversarial networks and multi-task optimization methods, the problems of insufficient data and unbalanced distribution in anomaly detection of electricity metering data are solved, the coordinated optimization of anomaly detection and load forecasting is achieved, the quality monitoring accuracy of electricity metering data and the load forecasting accuracy are improved, and the efficient operation of smart grids is supported.
Patent Information
- Application Number
- CN202510740938.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-05
- Publication Date
- 2025-09-12
AI Technical Summary
Existing methods for detecting anomalies in electricity metering data face bottlenecks in areas such as insufficient and unbalanced data distribution, insufficient feature expression, and weak task collaborative optimization. These bottlenecks result in low detection accuracy and insufficient load forecasting precision, making it difficult to cope with highly dynamic and complex electricity usage scenarios, thus affecting the operational efficiency and economic benefits of smart grids.
A method based on generative adversarial networks and multi-task optimization is adopted to improve data robustness and feature expression through data preprocessing, dynamic resampling, generative adversarial network training and multi-task joint optimization, achieve collaborative optimization of anomaly detection and load forecasting, and improve model performance using shared feature extraction modules and joint loss functions.
It improves the quality monitoring accuracy of electricity metering data, provides reliable load forecasting, realizes efficient repair of energy consumption collection data, provides technical support for the efficient operation of smart grids, and improves operational efficiency and economic benefits.
Smart Images

Figure CN120633409A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of power systems, and in particular to a method for detecting anomalies in electric energy metering data based on a generative adversarial network and multi-task optimization. Background Art
[0002] Electricity metering is a core component of electricity trade settlement and the assessment of technical and economic indicators for electricity production. It is crucial for the stable operation and economic benefits of the power system. User-side electricity metering data refers to various data related to electricity consumption collected from electricity users' electricity metering devices (such as smart meters). This data reflects the user's electricity usage behavior and consumption characteristics and can be widely used in scenarios such as electricity billing and electricity monitoring. With the rapid growth of electricity market demand and the dramatic fluctuations in user electricity consumption, errors may occur during the collection of electricity metering data, resulting in abnormal metering data. If these abnormal data are not detected and addressed in a timely manner, they will not only affect the efficiency of power grid operations but may also lead to billing errors or waste of electricity resources.
[0003] The related technologies for detecting anomalies in electric energy metering data mainly include the following categories: Rule-based methods detect abnormal data by presetting upper and lower limits, change rate thresholds and other rules. This type of method relies on manual experience, has poor flexibility, and is difficult to adapt to complex and changing electricity metering scenarios.
[0004] Statistical models and machine learning methods use models such as ARIMA, support vector machines, and random forests for anomaly detection or load forecasting. However, these models have limited processing capabilities for nonlinear and complex time series data and are unable to handle multiple tasks simultaneously.
[0005] Deep learning methods use long short-term memory networks or convolutional neural networks to achieve load forecasting. Such methods lack the coordinated optimization of anomaly detection and load forecasting tasks and have insufficient model generalization capabilities.
[0006] In summary, existing methods for detecting anomalies in electricity metering data have technical bottlenecks in the following aspects: Due to insufficient data and unbalanced distribution, abnormal samples in electricity metering data are usually scarce, which easily leads to the performance degradation of the anomaly detection model.
[0007] Insufficient feature expression: Time series data often contain complex multi-scale features (such as trends, periodicity, and random fluctuations), making it difficult to fully capture this information.
[0008] Task independence problem: Electricity metering data anomaly detection and load forecasting are usually handled separately, failing to fully utilize the potential correlation between the two, resulting in affected modeling accuracy and efficiency.
[0009] The above problems lead to low accuracy in detecting anomalies in electricity metering and insufficient load forecasting precision, making it difficult to cope with highly dynamic and complex electricity usage scenarios. As a result, anomalies in electricity metering cannot be discovered in a timely manner, thus affecting the operating efficiency and economic benefits of the smart grid. Summary of the Invention
[0010] The purpose of the present invention is to solve the problems of insufficient and unbalanced data distribution, insufficient feature expression, weak task collaborative optimization, etc. in the existing electric energy metering data anomaly detection algorithm. A method for detecting anomaly of electric energy metering data based on generative adversarial networks and multi-task optimization is proposed, which can improve the accuracy of quality monitoring of electric energy metering data on the user side, and at the same time provide reliable load forecasting for abnormal electric energy metering data, realize efficient repair of energy consumption collection data, and provide technical service support for the efficient operation of smart grids.
[0011] To achieve the above object, the technical solution of the present invention is: A method for detecting anomalies in electric energy metering data based on a generative adversarial network and multi-task optimization includes the following steps: S1. Data preprocessing: processing the original electricity metering data to improve data robustness and the model's generalization ability for abnormal data; S2, dynamic resampling, uses a dynamic resampling strategy on the preprocessed data to solve the problem of data imbalance in electricity metering data. The dynamic resampling strategy combines time distribution, category distribution and sample characteristics, flexibly adjusts the sampling strategy, and finally merges the sampled data to generate a balanced training set; S3. Generative Adversarial Network Training. GAN training is used to expand the dataset and improve the robustness of anomaly detection. The generator uses random noise and energy metering features as input to generate pseudo-energy metering data. The discriminator receives real data and generated data and judges the authenticity of the input data based on adversarial training. Physical consistency constraints are introduced to optimize the GAN training process. S4, multi-task joint optimization, extracts common feature representations for anomaly detection and load forecasting tasks through a shared feature extraction module, integrates the physical consistency feature representation of electricity metering data, performs task-specific optimization at the head of each task, and comprehensively considers the objective functions of both tasks by designing a joint loss function, thereby achieving collaborative optimization between tasks and improving overall performance; S5, anomaly detection and load forecasting, inputs the electric energy metering time series data within a certain time window, extracts the common feature representation through the shared feature extraction module, and then inputs it into the anomaly detection layer and load forecasting layer respectively, and outputs its anomaly detection results and load forecast values.
[0012] Furthermore, in step S1, the original electricity metering data is preprocessed by using time window decomposition and time fuzzy enhancement. Time window decomposition is to divide the long-time series of electricity metering data into short-time series data of fixed length, which enables the model to focus on analyzing local features within the fixed window. Time fuzzy enhancement is to smooth the electricity metering data by weighted sliding average, thereby reducing the noise in the data and enhancing the trend pattern of the time series data.
[0013] Furthermore, the algorithm execution process in step S2 is as follows: S201, statistical data distribution, calculating the weight of the electric energy metering sample category; S202: Divide the data by time period, calculate the time weight, and perform weighted sampling on the entire sample; S203, oversampling abnormal measurement samples using SMOTE and noise perturbation, and undersampling normal measurement samples by random sampling; S204: Merge the sampled data to generate a balanced training set.
[0014] Furthermore, the generator model in step S3 is mainly used to generate pseudo data that conforms to the distribution of electric energy metering data. Its input is random noise, electric energy metering features and time series historical data, and its output is pseudo sample data, where the random noise is standard Gaussian distribution noise, and the electric energy metering features include current, voltage, phase angle, and power electric energy metering prior features; The generator model adopts a time series generation model and combines LSTM and Transformer models to capture the timing information and global correlation of electricity metering data. Its model architecture includes input layer, LSTM time modeling layer, Transformer self-attention layer, physical constraint mapping layer, and output layer. The input layer mainly maps the input features through a fully connected layer and normalization. The LSTM time modeling layer uses multi-layer LSTM to extract the time dependency of electricity data. The Transformer self-attention layer uses a self-attention mechanism to enhance the global dependency across time steps. The physical constraint mapping layer ensures that the generated data conforms to the physical characteristics of electricity through differentiable constraints. The output layer converts the generated data into the electricity metering data format through a fully connected layer.
[0015] Furthermore, the discriminator model in step S3 is mainly used to determine whether the input data comes from the real energy metering data distribution, while ensuring that the data meets the physical laws of energy metering. Its input is real data or pseudo sample data and energy metering features, and the output is the judgment of the input data; The network architecture of the discriminator model includes a spatial feature extraction layer, an LSTM temporal feature extraction layer, a physical constraint layer, and a classification output layer. The spatial feature extraction layer uses one-dimensional convolution to extract local features of electric energy data. The LSTM temporal feature extraction layer uses an LSTM model to learn the temporal dependencies of metering data. The physical constraint layer and generator type add physical constraints for electric energy metering. The classification output layer outputs a true or false judgment of the input data through a fully connected layer.
[0016] Furthermore, the shared feature extraction module in step S4 is based on the Transformer structure and aims to extract the global features of the energy metering time series data and the dependencies between time steps, providing feature representation for anomaly detection and load forecasting tasks; The shared feature extraction module first converts the time series data into a high-dimensional representation, and then adopts a multi-head self-attention mechanism to calculate and capture different aspects of the feature sequence through different attention heads, thereby enhancing the feature expression. Then, through a feedforward neural network, a nonlinear transformation is performed on the representation of each time step. Finally, a normalization operation is performed to output the shared feature representation to achieve universal feature extraction.
[0017] Furthermore, in the anomaly detection task in step S4, based on the shared feature extraction module, convolutional neural networks and attention mechanisms are used for further feature representation to better capture local abnormal features and global dependencies in time series data. The anomaly detection task first uses a convolutional layer to extract local features, then uses an attention mechanism to capture global feature representation and physical consistency feature representation, fuses them through a gating mechanism, and finally uses a fully connected layer to output the anomaly probability of the measurement data at each time step.
[0018] Furthermore, in the load forecasting task in step S4, based on the shared feature extraction module, multi-scale convolutional layers and long short-term memory networks are introduced to enhance the model's ability to capture trend and periodic changes in time series data. The load forecasting task first uses a multi-scale convolutional layer and convolution kernels with different receptive fields to extract short-term and long-term features, which are then input into a long short-term memory network to capture the long-term dependency features of time series data. The attention mechanism is then used to weight the features according to the importance of the time step and map the energy metering features of the input data into a physically consistent feature representation. This is then fused through a gating mechanism and finally outputs the load forecast value for each time step through a fully connected layer.
[0019] Furthermore, the joint loss function in step S4 is as follows: in and Represents the weight of each loss, which is used to balance the anomaly detection and load forecasting tasks, ensuring that the two tasks are coordinated and optimized within a framework.
[0020] Furthermore, multi-task joint optimization is performed to construct a joint loss function to balance the anomaly detection and load forecasting tasks, thereby achieving the purpose of collaborative optimization.
[0021] Compared with the prior art, the present invention has the following beneficial effects: The present invention can effectively detect anomalies in user-side electricity consumption data through a series of steps including data preprocessing, dynamic resampling, generative adversarial network training, multi-task joint optimization, and anomaly detection and load forecasting. At the same time, it provides an effective load forecasting method, achieves efficient repair of energy collection data, and provides technical service support for the efficient operation of smart grids, thereby ensuring the operating efficiency of smart grids and improving the economic benefits of smart grids. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 This is the architecture diagram of the power metering data anomaly detection model based on generative adversarial networks and multi-task optimization; Figure 2 It is a schematic diagram of the dynamic resampling strategy; Figure 3 This is the network architecture diagram for the anomaly detection task; Figure 4 This is the network architecture diagram for the load forecasting task. DETAILED DESCRIPTION
[0023] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of devices consistent with certain aspects of the present application, as detailed in the appended claims.
[0024] The terminology used in this application is for the purpose of describing specific embodiments only and is not intended to limit this application. Unless otherwise defined, technical or scientific terms used in this application should have the same ordinary meaning as understood by persons of ordinary skill in the art to which this invention belongs. The use of "a," "an," and similar terms in this specification and claims does not indicate a limitation of quantity, but rather indicates the presence of at least one. "A plurality" includes two and is equivalent to at least two. "Includes" or "comprising" and similar terms mean that the elements or items preceding "includes" or "comprising" include the elements or items listed after "includes" or "comprising," and their equivalents, and do not exclude other elements or items. "Connected" or "connected" and similar terms are not limited to physical or mechanical connections and may include electrical connections, whether direct or indirect. As used in this specification and the appended claims, the singular forms "a," "the," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
[0025] Electricity metering is an important method for electricity trade settlement and assessment of technical and economic indicators of electricity production. The present invention provides an effective method for detecting anomalies in electricity metering data, which can improve the accuracy of quality monitoring of electricity metering data on the user side, and at the same time provide load forecasts for abnormal metering data, realize efficient repair of energy consumption collection data, and provide technical support for the efficient operation of smart grids.
[0026] Please refer to Figure 1 , a method for detecting anomaly in electric energy metering data based on generative adversarial networks and multi-task optimization, comprising the following steps: S1. Data preprocessing: processing the original electricity metering data to improve data robustness and the model's generalization ability for abnormal data; S2, dynamic resampling, uses a dynamic resampling strategy on the preprocessed data to solve the problem of data imbalance in electricity metering data. The dynamic resampling strategy combines time distribution, category distribution and sample characteristics, flexibly adjusts the sampling strategy, and finally merges the sampled data to generate a balanced training set; S3. Generative Adversarial Network Training. GAN training is used to expand the dataset and improve the robustness of anomaly detection. The generator uses random noise and energy metering features as input to generate pseudo-energy metering data. The discriminator receives real data and generated data and judges the authenticity of the input data based on adversarial training. Physical consistency constraints are introduced to optimize the GAN training process. S4, multi-task joint optimization, extracts common feature representations for anomaly detection and load forecasting tasks through a shared feature extraction module, integrates the physical consistency feature representation of electricity metering data, performs task-specific optimization at the head of each task, and comprehensively considers the objective functions of both tasks by designing a joint loss function, thereby achieving collaborative optimization between tasks and improving overall performance; S5, anomaly detection and load forecasting, inputs the electric energy metering time series data within a certain time window, extracts the common feature representation through the shared feature extraction module, and then inputs it into the anomaly detection layer and load forecasting layer respectively, and outputs its anomaly detection results and load forecast values.
[0027] Please refer to Figure 1 ,The specific steps of data preprocessing are as follows: In this embodiment, time window decomposition and time fuzzy enhancement are mainly used to preprocess the original electric energy metering data.
[0028] Time window decomposition is an operation that divides long-term series of energy metering data into short series of data or windows of fixed length. This allows the model to focus on analyzing local features within the fixed window rather than dealing with the global complexity of the entire sequence. The energy metering data is divided into fixed time windows (such as hourly or daily), and the window size is set to T. The original energy metering time series data is divided into N windows: Where X represents the full amount of data, Represents the electric energy metering data of the i-th time window.
[0029] Time fuzzy enhancement is mainly used to reduce noise in the data and enhance the trend pattern of time series data. In this embodiment, weighted moving average is used to smooth the energy metering data: in represents the smoothed data points, is the data point in the original time series, Represents the weighting coefficient, which must meet the normalization conditions: Please refer to Figure 2 , the specific execution steps of the dynamic resampling step are as follows: Considering the data imbalance problem in electricity metering data, normal samples account for the majority and abnormal samples are scarce, which causes the anomaly detection model to easily ignore abnormal samples and reduce the anomaly detection rate. Therefore, a dynamic resampling strategy is adopted to obtain a balanced training set.
[0030] First, we need to define the data distribution and imbalance level. Assume that the data set includes normal samples. and abnormal samples , then the class imbalance rate is: Secondly, dynamic sampling weights are determined. Dynamic weights are defined based on sample categories and time period distribution. In terms of sample category weights, the weight of normal measurement samples is , the weight of abnormal measurement samples is ,Such a weight ratio can ensure that abnormal samples are selected first.
[0031] On this basis, the samples are divided into time period weights and time period weights are set. For example, the weights are set as : in and In order to dynamically adjust the coefficient, the full sample is weighted sampled based on dynamic weights, which are divided into category weights and time period weights.
[0032] In order to make up for the lack of abnormal samples, a dynamic oversampling strategy is used to generate new samples. This embodiment adopts two methods: one is time series oversampling based on SMOTE, and the other is to generate new samples based on noise disturbance. Among them, the time series oversampling method based on SMOTE requires selecting an abnormal sample. and its nearest neighbor Synthesize new samples : in Is a uniformly distributed random number used to control the position of the new sample so that it generates samples Located in abnormal samples and the nearest neighbor samples The noise perturbation method adds a small amount of Gaussian noise to the abnormal power samples. : Noise amplitude Dynamic adjustments are made based on the distribution of electricity metering data to avoid generating unreasonable samples.
[0033] In view of the fact that the proportion of normal measurement samples is too large, an undersampling method is adopted in this embodiment to reduce redundancy. This embodiment randomly samples normal samples to ensure that key features are not lost during the random sampling process.
[0034] Based on the above sampling strategies, the selection and generation of samples are dynamically adjusted. The execution process of the dynamic resampling algorithm is as follows: 1) Statistical data distribution and calculation of energy metering sample category weights; 2) Divide the data by time period, calculate the time weight, and perform weighted sampling on the entire sample; 3) Oversampling abnormal energy metering samples using SMOTE and noise perturbation, and undersampling normal energy metering samples through random sampling; 4) Merge the sampled data to generate a balanced training set.
[0035] Please refer to Figure 1 , the specific execution steps of generative adversarial network training are as follows: After obtaining balanced training data using the aforementioned steps, a generative adversarial network model is trained to effectively model complex data distributions, thereby improving the robustness of anomaly detection. The generator uses random noise and energy metering features as input to generate pseudo-energy metering data. The discriminator receives both real and generated data and uses adversarial training to determine the authenticity of the input data. Physical consistency constraints are introduced to optimize the generative adversarial network training process.
[0036] The input of the generator model is a random noise vector , Electricity metering characteristics and time series historical data . Where the random noise vector , can be obtained from the standard normal distribution Or sampling in uniform distribution, energy metering characteristics Including electric energy measurement prior features such as current, voltage, phase angle, power, and time series historical data , represents the electricity metering data over a period of time in the past, helping the model to generate samples with temporal dependencies.
[0037] First, the low-dimensional noise vector, energy metering features, and time series historical data are input into the input layer, and projected into the high-dimensional feature space through the fully connected layer and normalization to generate the initial feature representation. .
[0038] Then it is input into the LSTM time modeling layer, and a multi-layer LSTM is used to extract the time dependency of the energy metering data: in represents the hidden layer state at the current moment, Represents historical electric energy time series data, represents the initial feature representation, Represents the hidden layer state at the previous moment.
[0039] Then the feature is represented Enter the Transformer self-attention layer, which enhances the global dependencies across time steps through the self-attention mechanism: Among them, Q, K, and V are output features of LSTM The Transformer self-attention layer can assign different weights to different time steps through attention weight distribution, enhance the attention to key time information, and obtain time-dependent representation. .
[0040] Then the time dependency is expressed as and energy metering characteristics Input physical constraint mapping layer to obtain intermediate feature representation that combines time-dependent features and electrical energy physics information : in and represents the trainable parameters in the model, used to map physical features to latent feature space, It is the key physical feature in electric energy metering data. V represents voltage, I represents current, P represents active power, and Q represents reactive power.
[0041] In order to ensure that the generated data conforms to the laws of electrical physics, the physical constraint mapping layer represents the intermediate features. Applying power balance constraints, the power balance equation is as follows: in and represents the estimated values of active and reactive power used to generate the data, is the generated voltage data, is the generated current data, is the phase angle difference between voltage and current.
[0042] To ensure that the generated data meets the physical constraints of the electric energy metering data, this embodiment defines a physical consistency loss function: in and Indicates the real active power and reactive power (from actual energy metering data), represents the mean square error.
[0043] In order to optimize the generated data and make it conform to the physical laws of electric energy metering, this embodiment uses the Lagrange multiplier method for constraint optimization: in is the final corrected feature representation, used to generate the final data, It is an intermediate feature representation that combines time-dependent features and electrical energy physics information. is the physical constraint weight hyperparameter, which is used to control the strength of the physical consistency adjustment. It is the gradient of the loss function with respect to the generated data, which is used to adjust the data to satisfy the physical consistency constraint.
[0044] After optimizing the physical constraints, the final energy data is mapped back to the original data space by multiple fully connected layers: Where X is the final generated electric energy data, represents the Sigmoid activation function, and Represents a trainable parameter in the model.
[0045] The input of the discriminator model is real data or pseudo sample data and electricity metering features, and the output is a true or false judgment of the input data.
[0046] First, one-dimensional convolution is used to extract the local features of the power data: The convolution kernel is used to learn the local patterns of power data at different time steps. ReLU is used as the activation function to improve the nonlinear representation ability of the model. Based on the spatial features extracted by CNN, the LSTM model is used to learn the temporal dependencies of the data: in is the feature representation extracted by the LSTM model.
[0047] To ensure that the discriminator can utilize the physical laws of energy metering data to enhance its discrimination capability, this example designs a physical constraint mapping layer, which is defined as follows: in represents the intermediate feature representation of the discriminator model, The physical characteristics of the energy measurement input data, and is a trainable parameter in the model, used to map physical features to a high-dimensional discriminant space.
[0048] Similar to the generator model, the discriminator model also applies the power balance constraint and defines the physical consistency loss as follows: in and is the real active power and reactive power in the input data, and The power value calculated from the input voltage and current data is constrained and optimized using the Lagrange multiplier method to obtain the feature representation after physical constraint enhancement. , and finally input the output layer to output the true or false judgment of the input data: in and are the final fully connected layer parameters of the discriminator model, Represents the Sigmoid activation function, which maps the judgment output to [0, 1] and is used to determine whether the input data is real data (1) or forged data (0).
[0049] In order to make the generator model and the discriminator model reach the optimal confrontation state, an alternating optimization strategy is adopted for training.
[0050] First, optimize the parameters of the discriminator model. The training goal of the discriminator model is to maximize the probability output of real samples and minimize the probability output of forged samples. The corresponding loss function is as follows: in represents the real sample data, is the predicted probability of the discriminator model that the real sample belongs to the real category, Represents pseudo sample data generated by the generator model, is the predicted probability of the discriminator model whether the generated sample is a real sample.
[0051] At the same time, the above-mentioned physical consistency loss is integrated to obtain the total loss function of the discriminator model as follows: The weight used to control the physical constraint loss is used to optimize the parameters of the discriminator model using the gradient descent method.
[0052] Then optimize the parameters of the generator model. The training goal of the generator model is to maximize the probability that the discriminator misjudges the generated data: in Represents pseudo sample data generated by the generator model, represents the probability that the discriminator model predicts that the generated data is real data. Similarly, the physical consistency loss is applied to it, and the total loss function of the generator model is obtained as follows: The generator model parameters are optimized by gradient descent so that the data it generates is closer to the real data distribution. The training process is repeated, alternating between generator model training and discriminator model training until the model converges.
[0053] Please refer to Figure 1 ,The specific execution steps of multi-task joint optimization are as follows: Multi-task joint optimization aims to achieve collaborative optimization by constructing a joint loss function to balance the anomaly detection and load forecasting tasks. Specifically, multi-task joint optimization aims to extract common feature representations for anomaly detection and load forecasting tasks through a shared feature extraction module. This integrates the physically consistent feature representation of electricity metering data and performs task-specific optimization at the head of each task. By constructing a joint loss function, collaborative optimization of anomaly detection and load forecasting tasks is achieved, thereby improving model performance.
[0054] First, the energy metering data is fed into the shared feature extraction module. This shared feature extraction module is based on the Transformer structure and is used to extract the global features of the energy metering data and the dependencies between time steps. It provides a common feature representation for anomaly detection and load forecasting tasks. First, the time series data X is converted into a high-dimensional representation: in , T represents the time step, d represents the feature dimension of each time step, Represents the embedding matrix, which is responsible for mapping the features of time series data to high-dimensional representation , Represents position encoding, which is used to identify the position of the time step in the time series data. Represents the embedded input features.
[0055] Then, a multi-head self-attention mechanism is used to calculate and capture different aspects of the feature sequence through different attention heads, thereby enhancing feature expression: in represents the output of the multi-head self-attention mechanism, represents the output of each attention head, It means that the outputs of all attention heads are spliced together. The output projection matrix is responsible for mapping the feature representation back to the input embedding dimension.
[0056] Then, through the feedforward neural network, the representation of each time step is nonlinearly transformed to enhance the feature expression ability: in Represents the hidden layer dimension, which is used to enhance feature representation. represents the weight of the feedforward layer, and Represents the bias vector.
[0057] Finally, the shared feature representation is output through the normalization operation: Represents a normalization operation to prevent the gradient from disappearing or exploding.
[0058] Please see the details Figure 3 ,The anomaly detection task uses convolutional neural networks and attention mechanisms for further ,feature representation based on the shared feature extraction module to better ,capture local abnormal features and global dependencies in time series data.
[0059] First, the convolutional layer is used to extract local features: in Represents a one-dimensional convolution operation, which is used to capture local features of time series data.
[0060] Then the attention mechanism is used to capture the global feature representation And mapping the energy metering features of the input data into physical consistency feature representation : Fusion of global feature representations via gating mechanism and physical consistency feature representation , combined with physical constraints to perform feature correction: Finally, the fully connected layer outputs the abnormal probability of the measurement data at each time step: in and represents the weights and bias terms of the classification output layer, Represents the Sigmoid activation function, which is responsible for limiting the output to [0, 1] as the abnormal probability output.
[0061] Please refer to Figure 4,Based on the shared feature extraction module, the load forecasting task introduces ,multi-scale convolutional layers and long short-term memory networks to enhance ,the model’s ability to capture trend and periodic changes in time series ,data.
[0062] First, a multi-scale convolutional layer is used to extract short-term and long-term features using convolution kernels with different receptive fields: in represents multi-scale feature representation, is the convolution output dimension, , Indicates that the convolution kernel sizes are 3 and 5 respectively, which are used to extract features at different time scales.
[0063] It is then fed into the long short-term memory network to capture the long-term dependency features of time series data: in and Represents the state of the long short-term memory network at the previous moment and the current moment.
[0064] The feature representation is then weighted through the attention mechanism and the energy metering features of the input data are mapped to physical consistency feature representations. : Then, feature fusion is performed through a gating mechanism, and the feature representation is modified in combination with physical feature constraints: Finally, the load forecast value for each time step is output through the fully connected layer: in and Represents the weights and bias terms of the regression output layer.
[0065] The joint loss function is obtained by weight coefficient and To balance the anomaly detection and load forecasting tasks, thereby achieving the purpose of collaborative optimization.
[0066] The anomaly detection task uses the cross entropy loss function: in Indicates the true label, 1 indicates abnormality, and 0 indicates normality; Represents the anomaly probability predicted by the model.
[0067] The load forecasting task uses the mean square error loss function: in Indicates the true load value, Represents the load value predicted by the model.
[0068] This embodiment constructs the following joint loss function: in and Represents the weight of each loss, which is used to balance the anomaly detection and load forecasting tasks, ensuring that the two tasks are coordinated and optimized within a framework.
[0069] In summary, the steps for anomaly detection and load forecasting are: The electric energy metering time series data within a certain time window is input, and the common feature representation is extracted through the shared feature extraction module. Then, the data is input into the anomaly detection layer and the load forecasting layer respectively, and the anomaly detection results and load forecast values are output.
[0070] The basic principles, main features, and advantages of the present invention are shown and described above. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The above embodiments and descriptions are merely illustrative of the principles of the present invention. Various changes and modifications may be made to the present invention without departing from the spirit and scope of the present invention. Such changes and modifications are intended to fall within the scope of the present invention. The scope of protection claimed in the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for detecting anomalies in electric energy metering data based on generative adversarial networks and multi-task optimization, characterized in that: The following steps are involved: S1. Data preprocessing: processing the original electric energy metering data to improve data robustness and the model's generalization ability for abnormal data; S2, dynamic resampling, uses a dynamic resampling strategy on the preprocessed data to solve the problem of data imbalance in electricity metering data. The dynamic resampling strategy combines time distribution, category distribution and sample characteristics, flexibly adjusts the sampling strategy, and finally merges the sampled data to generate a balanced training set; S3. Generative Adversarial Network Training. GAN training is used to expand the dataset and improve the robustness of anomaly detection. The generator uses random noise and energy metering features as input to generate pseudo-energy metering data. The discriminator receives real data and generated data and judges the authenticity of the input data based on adversarial training. Physical consistency constraints are introduced to optimize the GAN training process. S4, multi-task joint optimization, extracts common feature representations for anomaly detection and load forecasting tasks through a shared feature extraction module, integrates the physical consistency feature representation of electricity metering data, performs task-specific optimization at the head of each task, and comprehensively considers the objective functions of both tasks by designing a joint loss function, thereby achieving collaborative optimization between tasks and improving overall performance; S5, anomaly detection and load forecasting, inputs the electric energy metering time series data within a certain time window, extracts the common feature representation through the shared feature extraction module, and then inputs it into the anomaly detection layer and load forecasting layer respectively, and outputs its anomaly detection results and load forecast values.
2. The method for detecting anomalies in electric energy metering data based on generative adversarial networks and multi-task optimization according to claim 1, characterized in that: In step S1, the original electric energy metering data is preprocessed using two methods: time window decomposition and time fuzzy enhancement. Time window decomposition is to divide the long series of electric energy metering data into short series of fixed length, which allows the model to focus on analyzing local features within the fixed window. Time fuzzy enhancement is to smooth the electric energy metering data by weighted sliding average, thereby reducing the noise in the data and enhancing the trend pattern of time series data.
3. The method for detecting anomalies in electric energy metering data based on generative adversarial networks and multi-task optimization according to claim 1, characterized in that: The algorithm execution process in step S2 is as follows: S201, statistical data distribution, calculating the weight of the electric energy metering sample category; S202: Divide the data by time period, calculate the time weight, and perform weighted sampling on the entire sample; S203, oversampling abnormal measurement samples using SMOTE and noise perturbation, and undersampling normal measurement samples by random sampling; S204: Merge the sampled data to generate a balanced training set.
4. The method for detecting anomalies in electric energy metering data based on generative adversarial networks and multi-task optimization according to claim 1, characterized in that: The generator model in step S3 is mainly used to generate pseudo data that conforms to the distribution of electric energy metering data. Its input is random noise, electric energy metering features and time series historical data, and its output is pseudo sample data, where the random noise is standard Gaussian distribution noise, and the electric energy metering features include current, voltage, phase angle, and power electric energy metering prior features. The generator model adopts a time series generation model and combines LSTM and Transformer models to capture the timing information and global correlation of electricity metering data. Its model architecture includes input layer, LSTM time modeling layer, Transformer self-attention layer, physical constraint mapping layer, and output layer. The input layer mainly maps the input features through a fully connected layer and normalization. The LSTM time modeling layer uses multi-layer LSTM to extract the time dependency of electricity data. The Transformer self-attention layer uses a self-attention mechanism to enhance the global dependency across time steps. The physical constraint mapping layer ensures that the generated data conforms to the physical characteristics of electricity through differentiable constraints. The output layer converts the generated data into the electricity metering data format through a fully connected layer.
5. The method for detecting anomaly in electric energy metering data based on generative adversarial networks and multi-task optimization according to claim 1, characterized in that: The discriminator model in step S3 is mainly used to determine whether the input data comes from the real energy metering data distribution, while ensuring that the data meets the physical laws of energy metering. Its input is real data or pseudo sample data and energy metering features, and the output is the judgment of the input data; The network architecture of the discriminator model includes a spatial feature extraction layer, an LSTM temporal feature extraction layer, a physical constraint layer, and a classification output layer. The spatial feature extraction layer uses one-dimensional convolution to extract local features of electric energy data. The LSTM temporal feature extraction layer uses an LSTM model to learn the temporal dependencies of metering data. The physical constraint layer and generator type add physical constraints for electric energy metering. The classification output layer outputs a true or false judgment of the input data through a fully connected layer.
6. The method for detecting anomalies in electric energy metering data based on generative adversarial networks and multi-task optimization according to claim 1, characterized in that: The shared feature extraction module in step S4 is based on the Transformer structure and is designed to extract the global features of the energy metering time series data and the dependencies between time steps, providing feature representation for anomaly detection and load forecasting tasks. The shared feature extraction module first converts the time series data into a high-dimensional representation, and then adopts a multi-head self-attention mechanism to calculate and capture different aspects of the feature sequence through different attention heads, thereby enhancing the feature expression. Then, through a feedforward neural network, a nonlinear transformation is performed on the representation of each time step. Finally, a normalization operation is performed to output the shared feature representation to achieve universal feature extraction.
7. The method for detecting anomalies in electric energy metering data based on generative adversarial networks and multi-task optimization according to claim 1, characterized in that: In the anomaly detection task in step S4, based on the shared feature extraction module, convolutional neural networks and attention mechanisms are used for further feature representation to better capture local abnormal features and global dependencies in time series data. The anomaly detection task first uses a convolutional layer to extract local features, then uses an attention mechanism to capture global feature representation and physical consistency feature representation, fuses them through a gating mechanism, and finally uses a fully connected layer to output the anomaly probability of the measurement data at each time step.
8. According to the method for detecting anomalies in electric energy metering data based on generative adversarial networks and multi-task optimization in claim 1, in the load forecasting task in step S4, based on the shared feature extraction module, a multi-scale convolutional layer and a long short-term memory network are introduced to enhance the model's ability to capture trend and periodic changes in time series data; The load forecasting task first uses a multi-scale convolutional layer and convolution kernels with different receptive fields to extract short-term and long-term features, which are then input into a long short-term memory network to capture the long-term dependency features of time series data. The attention mechanism is then used to weight the features according to the importance of the time step and map the energy metering features of the input data into a physically consistent feature representation. This is then fused through a gating mechanism and finally outputs the load forecast value for each time step through a fully connected layer.
9. The method for detecting anomalies in electric energy metering data based on generative adversarial networks and multi-task optimization according to claim 1, characterized in that: The joint loss function in step S4 is as follows: in and Represents the weight of each loss, which is used to balance the anomaly detection and load forecasting tasks, ensuring that the two tasks are coordinated and optimized within a framework.
10. The method for detecting anomalies in electric energy metering data based on generative adversarial networks and multi-task optimization according to claim 9, characterized in that: Multi-task joint optimization is to construct a joint loss function to balance the anomaly detection and load forecasting tasks, thereby achieving the purpose of collaborative optimization.
Citation Information
Cited By
Neural network enabled machine room abnormal flow real-time monitoring method and system
CN121000519A
Virtual electric energy meter-based electricity utilization information acquisition abnormal working condition simulation method, system and equipment and medium
CN121480037A
Method and system for repairing abnormal measurement data of main and distribution networks based on multiple modes and Transformer
CN121579866A
Augmentation system and method for field groundwater magnetic resonance detection small sample data
CN122045787A