Power consumption data anomaly detection method and device based on reconstruction-discrimination dual-path collaborative optimization
By employing a dual-path collaborative optimization method of reconstruction and discrimination, the robustness and cross-domain generalization issues of anomaly detection in the electricity consumption information acquisition system are resolved, enabling efficient and accurate anomaly identification of electricity consumption data.
Patent Information
- Application Number
- CN202511322145.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-16
- Publication Date
- 2025-12-26
AI Technical Summary
Existing technologies lack robust and highly sensitive intelligent identification tools in electricity information collection systems, making it difficult to effectively identify anomalies in massive amounts of electricity user data. Furthermore, existing zero-sample time-series anomaly detection methods have limitations in cross-domain generalization ability and sensitivity.
An anomaly detection method for electricity consumption data based on reconstruction-discrimination dual-path collaborative optimization is adopted. By dividing multivariate long-term series data into time windows, the reconstruction path is used to capture global temporal dependency features and the discrimination path is used to capture local discriminative features. Combined with an alternating training strategy and a discriminative weighting module, the sensitivity and discrimination ability of anomaly patterns are improved.
It significantly improves the generalization ability and robustness of electricity data anomaly detection, can flexibly aggregate temporal and spatial information, realize fine-grained anomaly discrimination, and improve the accuracy and efficiency of anomaly detection.
Smart Images

Figure CN121213293A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of electricity metering technology, and more specifically, to a method and apparatus for detecting abnormal electricity consumption data based on reconstruction-discrimination dual-path collaborative optimization. Background Technology
[0002] Currently, the electricity consumption information collection system connects to smart meters of all electricity users within the company's operating area, realizing the collection of electricity consumption and power data at different time dimensions such as daily and hourly. As the sole source of electricity consumption data for the company's users, it has accumulated massive electricity user data resources, laying a solid foundation for professional applications such as user energy demand analysis and power grid operation status monitoring, as well as national power data analysis. However, due to objective constraints such as data volume and collection conditions, the identification of anomalies in massive data mostly relies on expert experience threshold judgment rules, lacking robust and highly sensitive intelligent identification tools. Therefore, it is urgent to design and develop a robust and highly accurate source-end data anomaly identification model to effectively identify anomalies in data items such as electricity consumption readings, power, voltage, and current, ensuring that electricity consumption data can be used efficiently and conveniently for analysis, decision-making, and business applications, better serving government economic operation regulation, the construction of new power systems, and the company's professional business operations.
[0003] Research on multidimensional time series anomaly detection in electricity consumption scenarios aims to accurately model the complex patterns of multidimensional time series data to identify anomalous behaviors that significantly deviate from normal patterns. Therefore, it is highly dependent on equipment operating characteristics and data distribution features. Current mainstream methods generally employ unsupervised learning frameworks, calculating anomaly scores at each time point and then comparing these scores to a certain threshold. Due to the complexity of time series data patterns, deep learning-based methods have achieved state-of-the-art results in authoritative and publicly available multidimensional time series dataset benchmarks. However, mainstream multidimensional time series anomaly detection methods often require a large amount of historical data on the target to fully mine its sequence patterns, which may be difficult to meet in many practical scenarios. For massive amounts of electricity user data requiring anomaly identification, these methods need to train a model from scratch for each user class, which not only places high demands on the quantity and quality of historical data for each user but is also unacceptable in terms of resource and time consumption.
[0004] With the continuous development of electricity consumption data acquisition systems, the multi-dimensional time-series data they monitor often contains complex and diverse distribution patterns. To achieve anomaly identification in electricity consumption data, existing anomaly detection methods often require a large amount of historical data of the detection targets for training, and a model must be trained from scratch for each type of user. Existing zero-shot time-series anomaly detection methods can generalize across different user data, but existing zero-shot methods are all based on a reconstruction paradigm, which often can only capture shallow shared time-series structures and is difficult to transfer deep semantic information, thus limiting generalization ability; when the information bottleneck is relaxed to improve generalization, it is easy to weaken the sensitivity to difficult-to-distinguish anomalies. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention provides a method and apparatus for detecting abnormal electricity consumption data based on reconstruction-discrimination dual-path collaborative optimization.
[0006] According to one aspect of the present invention, a method for detecting anomalies in electricity consumption data based on reconstruction-discrimination dual-path collaborative optimization is provided, comprising:
[0007] Acquire multivariate long-term series data of historical measurements of the energy meter under test;
[0008] Divide multivariate long-term series data into multiple time windows of a preset window length;
[0009] Multiple time window data and their adjacent time window data are input into a pre-trained anomaly detection model, and the anomaly score corresponding to each time window data is output. The anomaly detection model is generated based on reconstruction-discrimination dual-path collaborative optimization.
[0010] Based on the anomaly scores corresponding to the data in each time window, the degree of anomaly at each time point of the energy meter under test is determined.
[0011] According to another aspect of the present invention, an anomaly detection device for electricity consumption data based on reconstruction-discrimination dual-path collaborative optimization is provided, comprising:
[0012] The acquisition module is used to acquire multivariate long-term series data of historical tests of the energy meter under test;
[0013] The partitioning module is used to divide multivariate long-term series data into multiple time windows of a preset window length;
[0014] The prediction module is used to input multiple time window data and their adjacent time window data into a pre-trained anomaly detection model and output the anomaly score corresponding to each time window data. The anomaly detection model is generated based on reconstruction-discrimination dual-path collaborative optimization.
[0015] The determination module is used to determine the degree of abnormality of the energy meter under test at each time point based on the abnormality score corresponding to the data in each time window.
[0016] According to another aspect of the present invention, a computer-readable storage medium is provided, the storage medium storing a computer program for performing the methods described in any of the above aspects of the present invention.
[0017] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising: a processor; a memory for storing executable instructions of the processor; the processor being configured to read the executable instructions from the memory and execute the instructions to implement the method described in any of the preceding aspects of the present invention.
[0018] Therefore, this invention proposes a method for detecting anomalies in electricity consumption data based on the collaborative optimization of reconstruction and discriminative dual paths. First, this invention proposes a zero-sample temporal anomaly detection modeling framework that integrates reconstruction and discriminative paradigms. The reconstruction path focuses on capturing global temporal dependency features, effectively modeling common evolutionary patterns across multiple domains, while the discriminative path focuses on capturing local discriminative features, thereby improving the model's sensitivity and discriminative ability to anomaly patterns. Second, a three-stage strategy of "reconstruction-hard-example screening-discrimination-driven" is adopted during training to achieve alternating training of the two paths. This achieves the complementarity and deep integration of the temporal dependency modeling advantage of reconstruction and the cross-domain generalization advantage of discriminative methods, significantly improving the generalization ability and robustness of detection performance. Finally, the designed discriminative weighted module, through point-level attention layers and graph attention networks, can achieve flexible temporal and spatial information aggregation, enabling fine-grained anomaly discrimination for any focal point. Attached Figure Description
[0019] Exemplary embodiments of the present invention can be more fully understood by referring to the following figures:
[0020] Figure 1 This is a flowchart illustrating an exemplary embodiment of the present invention for a method of detecting abnormal electricity consumption data based on reconstruction-discrimination dual-path collaborative optimization;
[0021] Figure 2 This is a schematic diagram of an anomaly detection method framework based on reconstruction-discrimination dual-path collaborative optimization provided by an exemplary embodiment of the present invention;
[0022] Figure 3 This is a schematic diagram of an anti-reconstruction module provided in an exemplary embodiment of the present invention;
[0023] Figure 4 This is a schematic diagram of a focus point selection mechanism provided in an exemplary embodiment of the present invention;
[0024] Figure 5 This is a schematic diagram of a discriminative weighting module provided in an exemplary embodiment of the present invention;
[0025] Figure 6 This is a schematic diagram of the structure of an anomaly detection device for electricity consumption data based on reconstruction-discrimination dual-path collaborative optimization provided in an exemplary embodiment of the present invention;
[0026] Figure 7 This is the structure of an electronic device provided in an exemplary embodiment of the present invention. Detailed Implementation
[0027] Hereinafter, exemplary embodiments according to the present invention will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of the present invention, and not all embodiments of the present invention. It should be understood that the present invention is not limited to the exemplary embodiments described herein.
[0028] It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values of the components and steps described in these embodiments do not limit the scope of the invention.
[0029] Those skilled in the art will understand that the terms "first," "second," etc., in the embodiments of the present invention are only used to distinguish different steps, devices, or modules, and do not represent any specific technical meaning, nor do they indicate a necessary logical order between them.
[0030] It should also be understood that in the embodiments of the present invention, "multiple" can refer to two or more, and "at least one" can refer to one, two or more.
[0031] It should also be understood that any component, data or structure mentioned in the embodiments of the present invention can generally be understood as one or more unless explicitly defined or given contrary instructions in the context.
[0032] Furthermore, the term "and / or" in this invention is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this invention generally indicates that the preceding and following related objects have an "or" relationship.
[0033] It should also be understood that the description of the various embodiments in this invention emphasizes the differences between the various embodiments, and the similarities or similarities can be referred to each other. For the sake of brevity, they will not be described in detail.
[0034] At the same time, it should be understood that, for ease of description, the dimensions of the various parts shown in the accompanying drawings are not drawn according to actual scale.
[0035] The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit the invention or its application or use.
[0036] Techniques, methods, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, they should be considered part of the specification.
[0037] It should be noted that similar labels and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be discussed further in subsequent figures.
[0038] The embodiments of this invention can be applied to electronic devices such as terminal devices, computer systems, and servers, and can operate together with a wide range of other general-purpose or special-purpose computing system environments or configurations. Well-known examples of terminal devices, computing systems, environments, and / or configurations suitable for use with electronic devices such as terminal devices, computer systems, and servers include, but are not limited to: personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputer systems, mainframe computer systems, and distributed cloud computing environments including any of the above systems, etc.
[0039] Electronic devices such as terminal devices, computer systems, and servers can be described in the general context of computer system executable instructions (such as program modules) executed by a computer system. Typically, program modules can include routines, programs, object programs, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. Computer systems / servers can be implemented in distributed cloud computing environments, where tasks are executed by remote processing devices linked through communication networks. In distributed cloud computing environments, program modules can reside on local or remote computing system storage media, including storage devices.
[0040] Exemplary methods
[0041] Figure 1 This is a flowchart illustrating an exemplary embodiment of the present invention regarding a method for detecting anomalies in electricity consumption data based on a reconstruction-discrimination dual-path collaborative optimization. This embodiment can be applied to electronic devices, such as… Figure 1 As shown, the electricity consumption data anomaly detection method 100 based on reconstruction-discrimination dual-path collaborative optimization includes the following steps:
[0042] Step 101: Obtain multivariate long-term series data of historical tests of the electricity meter under test;
[0043] Step 102: Divide the multivariate long-term series data into multiple time windows of a preset window length;
[0044] Step 103: Input multiple time window data and their adjacent time window data into the pre-trained anomaly detection model, and output the anomaly score corresponding to each time window data. The anomaly detection model is generated based on reconstruction-discrimination dual-path collaborative optimization.
[0045] Step 104: Determine the degree of abnormality of the energy meter under test at each time point based on the abnormality score corresponding to the data of each time window.
[0046] Specifically, this invention proposes a method for detecting anomalies in electricity consumption data based on a dual-path collaborative optimization of reconstruction and discrimination. It employs a dual-path design to collaboratively model common temporal features across multiple domains, thereby effectively modeling common evolutionary patterns across multiple domains while enhancing the model's sensitivity and discriminative ability to anomaly patterns. Furthermore, this invention proposes a training mechanism based on alternating optimization and dual-task multi-module collaborative optimization, which complements the temporal dependency modeling advantages of reconstruction with the cross-domain generalization advantages of discrimination. The designed discriminative weighted module can aggregate point-level discriminative information from both temporal and spatial dimensions, capturing inter-dimensional correlations and achieving good cross-domain generalization.
[0047] Because the massive amounts of electricity consumption data collected by electricity consumption acquisition systems exhibit complex and diverse distribution patterns, mainstream multidimensional time-series anomaly detection methods struggle to adapt to different users. Existing reconstruction-based zero-shot multidimensional time-series anomaly detection methods still have significant limitations in adapting to different data distributions. To address these issues, this invention proposes a electricity consumption data anomaly detection method, DPF-Net, based on reconstruction-discrimination dual-path collaborative optimization. The following sections first define the multidimensional time-series anomaly detection problem under zero-shot conditions, then demonstrate the overall framework and training process of the proposed method, and finally present the detailed design of each module.
[0048] 1. Problem Description
[0049] Multidimensional time series, as an ordered record of a set of measurements over time, can characterize the changes in the operating state of a system over time. Formally, the domain D... T ={X T ,P T (X)} can describe the distribution of the operating states of the system, where P represents the feature space of multidimensional time-series data in the domain. T (X) represents the marginal distribution of time series data within this domain. Then the domain... A sample in X can be represented as X = {x1, x2, ... x} i ,...,x L}∈XT This is a multidimensional time series with a total observation time length of L and the number of observed variables of C, where Let be the observation vector at time i. When X, sampled in the middle, is used as the detection object, it can be called... The target domain is defined as the zero-sample multidimensional temporal anomaly detection task addressed in this invention. Under the premise of judging from The observation vector x at each time point in the input time series data X obtained by mid-sampling t The degree of abnormality is determined and an abnormality score is given.
[0050] To achieve this task, this paper assumes a certain distributional similarity between the domains describing different systems, and expects the proposed model to be similar from the source domain set. After training on the sampled data, it can be directly applied to anomaly detection in the target domain data without further fine-tuning. The source domain can be described as D. s ={X s ,Y s ,P s (X,y)}, where This represents the data feature space of the s-th source domain; P represents the label space corresponding to the s-th source domain, where 0 represents normal and 1 represents abnormal; s (X,y) represents the joint distribution of time series data and anomaly labels in the s-th source domain.
[0051] 2. Framework Overview
[0052] like Figure 2 As shown, this invention proposes a power consumption data anomaly detection method, DPF-Net, based on reconstruction-discrimination dual-path collaborative optimization. It consists of an adversarial reconstruction module, a discriminative weighting module, and a focus point selection mechanism. Addressing the shortcomings of existing methods where a single reconstruction model lacks cross-domain adaptability and a single discriminative model struggles to adequately model temporal dependencies, DPF-Net employs a dual-path design to collaboratively model common temporal features across multiple domains. The reconstruction path focuses on capturing global temporal dependency features, while the discriminative path focuses on capturing local discriminative features.
[0053] To achieve deep integration of reconstruction and discrimination tasks, DPF-Net employs a three-stage strategy of "reconstruction-driven, hard example selection, and discrimination-driven" in each iteration of the training process. This allows for alternating training using two pathways, complementing the temporal dependency modeling advantage of reconstruction with the cross-domain generalization advantage of discrimination. Specifically, before training the discriminative weighted module, the model's test results are used to select the focus point. This not only alleviates the imbalance problem of positive anomalous samples but also allows the discriminative weighted module to focus on learning key segments of anomalous samples that the model struggles to recall, thus compensating for the shortcomings of the reconstruction task in identifying difficult-to-distinguish anomalies. When training the adversarial reconstruction module, the anomalous confidence score output by the discriminative weighted module is introduced as guiding weights to optimize the adversarial reconstruction module, achieving synergistic complementarity between the two functions.
[0054] 3. Training mechanism based on alternating optimization of dual tasks and multi-module collaborative optimization
[0055] To ensure that each module in the model functions effectively, the model employs three phases in each training iteration. Within each phase, the behavior of each module and its interactions with other modules differ, allowing for full interaction and integration. Figure 2 As shown. Specifically:
[0056] Initialization: Before training begins, the anomaly confidence output of the discriminative weighted module is initialized to 0.5 for all samples. This ensures that there is no additional bias during the initial training of the reconstructed module.
[0057] Reconstruction-driven phase: The adversarial reconstruction module is set to training mode, and the discriminative weighting module is set to testing mode. For the input source domain multidimensional time series window samples, they are input to the adversarial reconstruction module in a channel-independent manner to capture temporal dependencies in a single dimension. The anomaly confidence provided by the discriminative weighting module weights the reconstruction error at specific time points, guiding the reconstruction module to focus on certain segments.
[0058] Difficult Example Selection Phase: Both the adversarial reconstruction module and the discriminative weighted module are set to test mode. The source domain data time series windows are re-input into the adversarial reconstruction module and the discriminative weighted module in parallel. The resulting anomaly confidence and reconstruction error are multiplied by a dot product, resulting in a weighted reconstruction error, which is used as the anomaly score. The desired test result is that the model gives a smaller anomaly score to the normal parts of the samples and a larger anomaly score to the abnormal parts. However, in general, some difficult-to-identify anomalies have relatively small anomaly scores, which are confused with the normal patterns. To enable the model to focus on identifying difficult-to-identify anomalies, a focal point selection mechanism is used to select segments with smaller anomaly scores, ensuring that the number of selected normal segments and abnormal segments is equal. The selection result is reflected in the labeling of each source domain. Mark the corresponding position of the focal point as 1, where s is the index of the source domain, L s The length of the source domain time series data is given. The labels and the source domain dataset are repackaged into a labeled dataset, markedT, which is then used for training the discriminative weighted module.
[0059] Discriminator-driven phase: The discriminative weighted module is set to training mode and trained using a labeled dataset. The discriminative weighted module is essentially a cross-domain classification model designed to extract features in the temporal and spatial dimensions near a labeled point and predict the positive / abnormal label for that point (normal is denoted as 0, and anomalous as 1).
[0060] The next reconstruction-driven phase involves setting the adversarial reconstruction module to training mode and the discriminative weighted module to testing mode. While training the reconstruction module, the discriminative weighted module outputs the anomaly confidence at each time point, guiding further adjustments to the reconstruction module. The desired result is that the weighted module assigns higher weights to anomalies, resulting in higher anomaly scores. This is particularly effective in distinguishing difficult-to-identify anomalies from normal ones. However, the weights assigned by the weighted module are not always accurate or appropriate; it may incorrectly assign higher weights to some normal patterns. Therefore, during further training, the weights guide the reconstruction module to focus more on feature fitting of normal data with higher weights (which the discriminative weighted module mistakenly identifies as anomalies), thus complementing the output of the discriminative weighted module.
[0061] Testing Phase: Both the adversarial reconstruction module and the discriminative weighted module are set to test mode. Similar to the testing and selection phases, the target domain test data window X is input into the model, and the weighted reconstruction error output is used as the outlier score. To achieve anomaly detection.
[0062] In the first iteration of training, to ensure training stability, the reconstruction module and the discriminator module should be fully trained during the reconstruction-driven phase and the discriminator-driven phase. In subsequent iterations, each iteration can train for only one epoch, allowing the reconstruction module and the weighted module to interact fully and converge.
[0063] The training process of DPF-Net can be summarized as shown in the pseudocode in Algorithm 1.
[0064]
[0065]
[0066] 4. Design of the anti-refactoring module
[0067] The adversarial reconstruction module aims to find common features of temporal dependency patterns in multi-source domain data to achieve cross-domain generalization capability for anomaly detection. The architecture of the adversarial reconstruction module designed in this invention adopts a full-channel independence strategy, that is, decomposing the input data dimensionally into X = {x...} (1) ,x (2) ,...,x (c) ,...,x (C) And process the data for each dimension separately, such as Figure 3 As shown.
[0068] For the encoding part, since the input is single-dimensional time-series data, a linear projection layer is needed to map the input x to a higher dimension before using the Transformer encoder:
[0069]
[0070] Where H input Here, `proj()` represents the mapped latent vector, `w` is the input window length, and `d` is the number of dimensions after projection. Then, a Transformer encoder with added positional encoding is used for encoding.
[0071]
[0072] Where TransformerEncoder is the Transformer encoder, and Z is the encoded representation.
[0073] For the decoding part, the entire sequence is generated at once using a Transformer decoder, employing a learnable, fixed query instead of data. The decoding process can then be represented as:
[0074]
[0075] Q = PE(Q0), (4)
[0076]
[0077] Where Q0 is a set of queries learned by the model during training, PE() is the positional encoding, TransformerDecoder is the Transformer decoder, and MLP() is a multi-layer feedforward network using ReLU activation. For the reconstruction result, Z is the previously obtained feature encoding, w is the input window length, and d is the embedding dimension.
[0078] Although reconstruction models are commonly used in unsupervised tasks, using anomaly labels to guide the reconstruction model and mitigate its overfitting to anomaly patterns is an important path to achieve cross-domain generalization in anomaly detection tasks. Therefore, an adversarial mechanism is introduced through a dual-decoder structure to enable anomaly labels to guide the reconstruction model. The idea is to set up two decoding paths that do not share parameters:
[0079]
[0080] Where Z is the feature code, and D normal and D anomaly These represent two different decoding paths, which can be called the normal decoder and the abnormal decoder, respectively. GRL() is a gradient inversion layer, which inverts the gradient by multiplying it by -λ during backpropagation, where λ is a hyperparameter. The loss L of the adversarial reconstruction module... AReM It can be represented as:
[0081]
[0082] in, R represents the weights given by the discriminative weighting module. train (X,y) represents the reconstruction error obtained by the adversarial reconstruction module in training mode. and These are the reconstructed data of the c-th dimension of the multidimensional time-series window, obtained and concatenated from the normal decoder and the abnormal decoder, respectively. X c Let x be the c-th dimension of the input data, and y be the input window and the corresponding positive anomaly label, respectively. ⊙ represents the dot product operation. DR For difference regularization loss, This represents the reconstructed data at the t-th time point of a multi-dimensional temporal window obtained and concatenated by a normal decoder, where w represents the length of the temporal window, C is the total number of dimensions of the input data, and λ is the time window length. normal , λ anomaly , λ dr These are the normal reconstruction loss coefficient, the abnormal reconstruction loss coefficient, and the difference regularization term coefficient, respectively.
[0083] Because a gradient inversion layer is applied before the anomalous decoder, the loss provided by the anomalous samples contributes inversely to both the anomalous decoder and the encoder. In other words, the actual optimization objectives of the encoder and the normal decoder are:
[0084]
[0085] The actual optimization objective of the anomaly decoder is:
[0086]
[0087] Where θ E , These are the learnable parameters for the encoder, normal decoder, and abnormal decoder, respectively. and These refer to the reconstruction errors of normal samples and abnormal samples obtained by the adversarial reconstruction module in training mode, respectively.
[0088] 5. Focus point selection mechanism design
[0089] To construct a dataset suitable for discrimination tasks for hard-to-distinguish anomalies with low recall (low anomaly scores), the proposed method incorporates a focus selection mechanism, such as... Figure 4 As shown.
[0090] First, regarding the source domain set Time series data of each source domain within Where X (s) y (s) dm (s) Domain D s Using time-series data, positive anomaly labels, and domain-specific one-hot encoded labels, the corresponding anomaly score prediction values are obtained through testing. For each time point t in the time series data, the average of the anomaly scores within a span / 2 range before and after that point is calculated as the local anomaly level of that point in the context:
[0091]
[0092] Where mean() is the average operation, s is the field index, and L is the mean value. s For sampling from domain D s The sequence length. Then, each time point of the time series data collectively forms a focal point sample library.
[0093] The goal of the selection module is to identify noteworthy outliers with low outlier scores in the data from each source domain, while simultaneously selecting an equal number of normal points with low outlier scores as controls during training, thus forming a dataset suitable for the discrimination task. In the proposed method, this goal is achieved through sorting and the selection of Top K samples. In each source domain dataset, the K samples with the lowest outlier scores from both the normal and outlier sample sets are selected and marked with a Mark.
[0094]
[0095] Where nMark (s) and aMark (s) These are the labels for normal and outlier points in the data within the source domain s, respectively. ∨ is a bitwise logical OR operator, used to combine the labels for normal and outlier points into a single overall label, Mark, for the data in the source domain. (s)argtopK is the set obtained after selecting the K smallest sample points.
[0096] 6. Design of Discriminative Weighted Module
[0097] The discriminative weighting module aims to extract discriminative features from a single point, which requires extracting information from adjacent time and space as contributions. The architecture of this discriminative weighting module is designed as follows: Figure 5 As shown.
[0098] Z1, obtained after Transformer encoding, is a timing window. The overall characteristics. To flexibly realize the correlation between window-level features and marker point positions, this invention uses a point-level attention layer, which only calculates the query at a specified time point and performs multi-head attention calculation with the entire sequence to obtain the feature representation at the specified time point. Let m∈{0,1} w The point-level attention mechanism designed for this window can be represented as:
[0099] Q = m T Z1·W Q (18)
[0100] K = Z1·W K (19)
[0101] V = Z1·W V (20)
[0102]
[0103] Among them W Q W K W V These are the query weight matrix, key weight matrix, and value weight matrix, respectively. k Z1 represents the attention dimension, and Z1 is the previously obtained temporal window feature. Following the general design of a Transformer encoder, the multi-head attention outputs are concatenated, residual connections are added, and layer normalization is performed to obtain the output of the point-level attention layer. Where N is the number of marked focal points within the input window, z n This is the encoding result for the positive anomaly label prediction task targeting the nth focal point.
[0104] In the latter half of the discriminative weighting module, the channel-independent strategy is no longer adopted; instead, the correlation between channels is captured. To effectively extract the discriminative information for each focal point, a separate positive anomaly label prediction task should be established for each focal point. To achieve the mining of inter-dimensional correlations and the aggregation of inter-dimensional information when the number of dimensions is uncertain, this invention uses a graph attention layer to realize inter-dimensional information interaction. Let x be the c-th dimension of the input data for the positive anomaly label prediction task of a certain focal point. (c) The encoding is z (c) Then a fully connected graph is established:
[0105] V = {v1, v2, ..., v} c ,...,v C}, (twenty two)
[0106] E = {(v i ,v j )|v i ,v j ∈V, i≠j}, (23)
[0107] G = {V, E}, (24)
[0108] Where V and E are the set of nodes and the set of edges of the graph structure, respectively. c Let represent the c-th node, corresponding to the dimension of the c-th input data, where C is the total number of dimensions of the input data. Then, the initial features of each node... The graph is input into the GAT network to capture the relationships between nodes. To compress the output features of the GAT network and construct a global representation, a fusion module is set up according to general practice to aggregate the features of all nodes into a graph representation:
[0109]
[0110] Where z f To represent the obtained graph, For node v c The output, W f and b f Let be the learnable parameter matrix and bias vector, respectively; σ() be the sigmoid function; C be the total number of dimensions of the input samples; and d be the feature embedding dimension.
[0111] Finally, a DANN-like architecture is used to generalize the prediction results of positive anomaly labels to multi-domain data. Specifically, for a sample (X,y,m,dm), where X, y, m, and dm are the time-series data, positive anomaly label, focal point marker, and domain one-hot encoded label, respectively, the feature extraction representation obtained from the positive anomaly label prediction task of the nth focal point is used. As input:
[0112]
[0113] in and These are the anomaly confidence score and domain label prediction, respectively; anocls() and domcls() are the weight generator and domain classifier, respectively (see...). Figure 5 The outputs of these modules are constrained to the range of 0 to 1 by the sigmoid function. Furthermore, similar to the adversarial mechanism in Section 3.3.3, a gradient reversal layer GRL() is used to form an adversarial relationship. The loss of the discriminative weighted module is...
[0114]
[0115] in, and y n These refer to the anomaly confidence level and positive anomaly label corresponding to the nth focal point, respectively. and dm n These refer to the predicted and true domain labels corresponding to the nth focal point, respectively; N is the total number of focal points within the current window; CE() is the cross-entropy loss; and λ class With λ domain These are the positive anomaly cross-entropy loss coefficient and the domain label cross-entropy loss coefficient, respectively. Due to the existence of the gradient reversal layer GRL(), the actual optimization objective is:
[0116]
[0117]
[0118] Where θ extract θ anocls θ domcls These represent the learnable parameters of the first half of the discriminative weighted module, the weight generator, and the domain classifier, respectively. By introducing adversarial training for the discriminator, the discriminative weighted module can learn deep shared features related to positive anomaly judgment across different domains, thereby improving anomaly detection performance in the target domain without touching the target domain.
[0119] 7. Reasoning Pattern
[0120] Since both the adversarial reconstruction module and the discriminative weighting module in the proposed method have a dual-branch structure, their outputs differ during training and testing.
[0121] When the discriminative weighted module is in test mode, the point-level attention layer is reverted to a Transformer encoder layer, and the degree of anomalousness is given for each time step of the input sample X:
[0122]
[0123] in Z refers to the feature representation obtained when the nth time point is taken as the focal point. f This represents the characteristics of the entire window, where w is the window length. The anomaly confidence is set for all time steps. If the training of the adversarial reconstruction module is guided by a discriminative weighted module, the weights used for guidance at each time step are set to...
[0124]
[0125] Where the gate function
[0126]
[0127] The aim is to shield outliers exceeding a threshold θ in the reconstruction error provided by the adversarial reconstruction module. t Let w be the t-th value of the input vector, and w be the window length; Let X and y represent the reconstruction error of outlier samples output by the adversarial reconstruction module during training mode, respectively. ⊙ represents the inner product operation. These outliers are considered to significantly interfere with model training if included in the training process.
[0128] When both the adversarial reconstruction module and the discriminative weighting module are in test mode, the adversarial reconstruction module directly uses the normal decoder without using filters. The discriminative weighting module, on the other hand, directly uses... The reconstruction error of the adversarial reconstruction module is weighted, i.e., the anomaly score obtained from the test is...
[0129]
[0130] in
[0131]
[0132] To combat the refactoring errors that occur when the refactoring module is in test mode, and X c These refer to the reconstructed data obtained by the adversarial reconstruction module through the normal decoder and the c-th dimension of the input data, respectively, where C is the total number of dimensions of the input data and ⊙ represents the inner product operation.
[0133] Therefore, in the technical solution implemented by this invention, addressing the problems that existing mainstream time-series anomaly detection methods are difficult to adapt to the data distribution of different users and that zero-shot methods still have generalization limitations, a power consumption data anomaly detection method based on reconstruction-discrimination dual-path collaborative optimization is proposed. First, this invention proposes a zero-shot time-series anomaly detection modeling framework that integrates reconstruction and discrimination paradigms. The reconstruction path focuses on capturing global time-series dependency features, effectively modeling common evolutionary patterns across multiple domains, while the discrimination path focuses on capturing local discriminative features, thereby improving the model's sensitivity and discrimination ability to anomaly patterns. Second, a three-stage strategy of "reconstruction-driven, difficult-example screening, and discrimination-driven" is adopted during training to achieve alternating training of the two paths. This achieves the complementarity and deep integration of the time-series dependency modeling advantage of reconstruction and the cross-domain generalization advantage of discrimination, significantly improving the generalization ability and robustness of detection performance. Finally, the designed discriminative weighting module, through point-level attention layers and graph attention networks, can achieve flexible temporal and spatial information aggregation, enabling fine-grained anomaly discrimination for any focal point.
[0134] In one embodiment of the present invention, DPF-Net was compared with 17 more advanced models on a real-world electricity consumption dataset, which confirmed the effectiveness and advancement of the DPF-Net algorithm.
[0135] 1. Evaluation Indicators
[0136] This invention selects AUC, Fc1, and F1PA%K as evaluation metrics to verify the performance of the proposed method and the baseline model.
[0137] AUC (Area Under Curve) is one of the most commonly used methods for evaluating unsupervised anomaly detection tasks. The AUC evaluation metric primarily calculates the area under the ROC (Receiver Operating Characteristic) curve, ranging from 0 to 1. A perfect dataset will result in an AUC of 1, while random data will produce an AUC value close to 0.5. Compared to traditional evaluation metrics, the advantage of AUC is that it is not affected by threshold settings. However, AUC only reflects the number of time points where the method correctly detects anomalies; a high AUC does not necessarily mean that the method accurately detects all anomaly segments.
[0138] Fc1 (Composite F-score) is a recently proposed metric for time series anomaly detection. Unlike AUC, Fc1's advantage lies in its ability to comprehensively reflect all correctly detected anomaly segments in a multi-dimensional time series, focusing on the algorithm's ability to detect anomalous events. Fc1 calculates both recall within the anomalous time segment and precision at specific time points, thus avoiding the overestimation of algorithm performance by point adjustment strategies. Models with higher recall within anomaly segments and lower false positive rates across time steps receive higher Fc1 scores.
[0139] F1PA%K (Point Adjustment%K). Similarly, F1PA%K, proposed in recent literature, addresses the overestimation of model performance due to point adjustment. It calculates the point-level F1 score, but adjusts the results when the proportion of outliers detected by the model in consecutive outlier segments exceeds K%. To reduce dependence on the parameter K, F1PA%K can adaptively calculate the area under the F1PA%K curve by adjusting the value of K.
[0140] 2. Comparison Methods
[0141] The baseline comparison methods used in this experiment are currently influential mainstream methods, as shown in Table 1. These methods belong to different categories, including some classic methods: LOF, OCSVM, and iForest. Channel-independent algorithms: DCdetector. Reconstruction-based algorithms: InterFusion. Generative adversarial models: BeatGAN, USAD. Models focusing on dimensionality or temporal analysis: GDN, GTA, and MSCRED. The former two use graph structures to learn the relationships and couplings between different sensors, thus achieving robust dimensional correlation analysis of multivariate time series data. MSCRED utilizes long short-term memory networks and attention mechanisms to analyze the data. The latest temporal anomaly detection algorithms: TranAD and AT. The former builds a Transformer-based anomaly detection model based on an adaptive and adversarial training process. AT designs a method based on prior and sequence correlation based on attention mechanisms, and performs anomaly detection according to different correlation differences in positive anomalous states. Multidimensional temporal anomaly detection reconstruction methods: CAE-AD, RAE, TSMAE, MOUT. CAE-AD is a contrastive learning-based method used for implicit analysis of noise or anomalies, while the following three methods explicitly design modules for noise analysis. The mask reconstruction algorithm, ImDiffusion, implements unconditional generation time interpolation based on a diffusion model, and uses the mask reconstruction interpolation error for anomaly detection.
[0142] Table 1 Baseline Methods
[0143]
[0144]
[0145] 3. Implementation details
[0146] The hyperparameter settings for achieving the final experimental results of DPF-Net are as follows: the sliding window length for input is 128, the sliding step size during reconstruction module training is 64, the threshold of the anomaly gating function in the weighted strategy of the discriminative reinforcement module against the adversarial reconstruction module is set to 5, the number of sample points selected from the positive anomaly sample points in each source domain dataset is set to 200, and the context range for considering the overall anomaly degree when selecting labeled sample points is set to 16. In the reconstruction module, the inversion strength, normal reconstruction loss coefficient, anomaly reconstruction loss coefficient, and difference regularization term coefficient of the GRL layer are set to 0.15, 1, 1, and 0.1, respectively; in the discriminative module, the inversion strength, positive anomaly cross-entropy loss coefficient, and domain label cross-entropy loss coefficient of the GRL layer are set to 10, 1, and 0.1, respectively.
[0147] DPF-Net is optimized using the Adam optimizer, with a learning rate of 1e-5 used when training the reconstruction module and 1e-4 used when training the discriminant module, and a batch size of 128. DPF-Net is implemented using Python 3.8.16 and PyTorch 1.13.0, and the training environment is a workstation equipped with an Intel(R) Core(TM) I9-10900x 10-core 3.70GHz CPU and an NVIDIA GeForce RTX3090 GPU.
[0148] 4. Introduction to Actual Electricity Consumption Dataset
[0149] The specific characteristics of the electricity consumption dataset (ELE) collected by smart meters are shown in Table 2. This dataset is collected from nine three-phase meters in multiple distribution areas. Each device includes 22 sensor values: current (phase A, phase B, phase C), voltage (phase A, phase B, phase C), energy reading (positive active), energy reading (reverse active), energy reading (positive reactive), energy reading (reverse reactive), active power (phase A, phase B, phase C, total), reactive power (phase A, phase B, phase C, total), and power factor (phase A, phase B, phase C, total).
[0150] Table 2 Characteristics of Actual Electricity Consumption Data Set
[0151]
[0152] These smart meters exhibited various anomalies during their respective data recording periods, including reverse power flow, current loss, meter running backwards, meter flying away, uneven meter readings, meter terminal block issues, and power differential anomalies. The dataset contains data collected daily at 96 sampling points from each physical meter device over 9-16 consecutive months. The actual electricity consumption dataset includes data from 9 complete physical devices, exhibiting variations in data size, uneven anomaly rates, and significant differences in distribution patterns across different devices.
[0153] In the experiments, for mainstream baseline methods for temporal anomaly detection, training was performed on the training set of each dataset, followed by testing on the test set. For zero-shot methods like DPF-Net, the labeled test sets of the remaining eight datasets (excluding the target dataset) were used as the training set for training, and then tested on the target dataset to simulate the effect of training on a subset of user data and then testing on any user under zero-shot conditions. The final evaluation results represent the mean performance of the methods across all datasets.
[0154] 5. Evaluation of results from actual datasets
[0155] To verify the universality of the proposed model, the performance of the proposed model was evaluated and analyzed on a real-world electricity consumption dataset. The comparative experimental results are shown in Table 3. The table presents the AUC and F of the proposed DPF-Net and the baseline method. c1 F1 PA%K Three performance metrics are presented. All results shown in the table are averages obtained from five individual runs, allowing the study to assess the robustness of each baseline method. Furthermore, the best-performing method is highlighted in bold, while the second-best-performing method is indicated by underline.
[0156] As can be seen, DPF-Net performs exceptionally well on the ELE dataset, achieving high scores in AUC and F. c1 F1 PA%K It achieved first place in performance across all metrics. Specifically, DPF-Net's AUC was 8.13% higher than the second-place finisher, indicating that DPF-Net has high accuracy in detecting outliers and is less affected by data uncertainty. DPF-Net's F... c1 This represents a 43.54% improvement over the second-place finisher, demonstrating DPF-Net's high recall and high accuracy for detecting anomalous time periods. And in F1... PA%KIn terms of score, DPF-Net improved by 42.35%, thus demonstrating its high accuracy in detecting anomalous time periods. This not only proves the feasibility and practical value of zero-shot temporal anomaly detection trained on labeled data, but also highlights the superior performance of DPF-Net in anomaly detection.
[0157] Table 3 shows the comparative experimental results on the actual electricity consumption dataset.
[0158]
[0159]
[0160] The key point of this application is:
[0161] 1. A modeling framework for zero-shot temporal anomaly detection that integrates reconstruction and discriminative paradigms.
[0162] Given the significant differences in electricity consumption patterns among different users, and addressing the insufficient cross-domain adaptability of existing methods with single reconstruction models, the proposed framework employs a dual-path design to collaboratively model common temporal features across multiple domains. The reconstruction path focuses on capturing global temporal dependency features, effectively modeling common evolutionary patterns across multiple domains; the discriminative path focuses on capturing local discriminative features, thereby enhancing the model's sensitivity and discriminative ability to abnormal patterns.
[0163] 2. Training mechanism based on alternating optimization of dual tasks and multi-module collaborative optimization
[0164] To achieve deep integration of reconstruction and discriminative tasks in zero-shot temporal anomaly detection, a three-stage strategy of "reconstruction-hard example selection-discrimination-driven" is adopted in each iteration of the training process. This allows for alternating training using two paths, complementing the temporal dependency modeling advantage of reconstruction with the cross-domain generalization advantage of discriminative methods. Specifically, before training the discriminative weighted module, the model's test results are used to select the focus point. This not only alleviates the imbalance problem of positive anomaly samples but also allows the discriminative weighted module to focus on learning key segments of anomalies that the model struggles to recall, thus compensating for the shortcomings of the reconstruction task in identifying difficult-to-distinguish anomalies. When training the adversarial reconstruction module, the anomaly confidence score output by the discriminative weighted module is introduced as a guiding weight to optimize the adversarial reconstruction module, achieving synergistic complementarity between the two functions.
[0165] 3. Discriminative weighted module for effectively extracting multi-domain time-series point-level spatiotemporal discriminative features
[0166] To achieve fine-grained anomaly detection at any focal point, a point-level attention layer is used to flexibly and efficiently aggregate window-level temporal dependency features into point-level features. To avoid the problem of dimensional mismatch between multi-domain temporal data and the model, a graph attention network is used to capture and generalize the dependencies between dimensions and to achieve information aggregation between dimensions, which effectively improves the discrimination capability.
[0167] Exemplary device
[0168] Figure 6 This is a schematic diagram of the structure of an anomaly detection device for electricity consumption data based on reconstruction-discrimination dual-path collaborative optimization, provided in an exemplary embodiment of the present invention. Figure 6 As shown, the device 600 includes:
[0169] The acquisition module 610 is used to acquire multivariate long-term series data of historical detection of the energy meter under test;
[0170] The partitioning module 620 is used to partition multivariate long-term series data into multiple time windows of a preset window length;
[0171] The prediction module 630 is used to input multiple time window data and their adjacent time window data into a pre-trained anomaly detection model and output the anomaly score corresponding to each time window data. The anomaly detection model is generated based on reconstruction-discrimination dual-path collaborative optimization.
[0172] The determination module 640 is used to determine the degree of abnormality of the energy meter under test at each time point based on the abnormality score corresponding to the data of each time window.
[0173] Exemplary electronic devices
[0174] Figure 7 This is the structure of an electronic device provided in an exemplary embodiment of the present invention. For example... Figure 7 As shown, the electronic device 70 includes one or more processors 71 and a memory 72.
[0175] The processor 71 may be a central processing unit (CPU) or other form of processing unit with data processing and / or instruction execution capabilities, and may control other components in the electronic device to perform desired functions.
[0176] The memory 72 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 71 may execute the program instructions to implement the methods of the software programs of the various embodiments of the present invention described above, and / or other desired functions. In one example, the electronic device may also include an input device 73 and an output device 74, these components being interconnected via a bus system and / or other forms of connection mechanisms (not shown).
[0177] In addition, the input device 73 may also include, for example, a keyboard, a mouse, etc.
[0178] The output device 74 can output various information to the outside. The output device 74 may include, for example, a display, a speaker, a printer, and a communication network and its connected remote output devices, etc.
[0179] Of course, for the sake of simplicity, Figure 7 Only some of the components of this electronic device relevant to the present invention are shown, omitting components such as buses, input / output interfaces, etc. In addition, the electronic device may include any other suitable components depending on the specific application.
[0180] Exemplary computer program products and computer-readable storage media
[0181] In addition to the methods and apparatus described above, embodiments of the present invention may also be computer program products, which include computer program instructions that, when executed by a processor, cause the processor to perform the steps in the methods according to various embodiments of the present invention described in the "Exemplary Methods" section above.
[0182] The computer program product can be written in any combination of one or more programming languages to perform the operations of the embodiments of the present invention. The programming languages include object-oriented programming languages such as Java and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0183] Furthermore, embodiments of the present invention may also be computer-readable storage media storing computer program instructions thereon, which, when executed by a processor, cause the processor to perform the steps of the methods according to various embodiments of the present invention described in the "Exemplary Methods" section above.
[0184] The computer-readable storage medium may be any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof.
[0185] The basic principles of the present invention have been described above with reference to specific embodiments. However, it should be noted that the advantages, benefits, and effects mentioned in the present invention are merely examples and not limitations, and should not be considered as essential features of each embodiment of the present invention. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the present invention to the necessity of employing the aforementioned specific details.
[0186] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For system embodiments, since they largely correspond to method embodiments, the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0187] The block diagrams of devices, systems, devices, and systems involved in this invention are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, systems, devices, and systems can be connected, arranged, and configured in any manner. Words such as “comprising,” “including,” “having,” etc., are open-ended terms meaning “including but not limited to,” and are used interchangeably with them. The terms “or” and “and” as used herein refer to the terms “and / or,” and are used interchangeably with them unless the context clearly indicates otherwise. The term “such as” as used herein refers to the phrase “such as but not limited to,” and is used interchangeably with it.
[0188] The methods and systems of the present invention may be implemented in many ways. For example, they may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above-described order of steps for the methods is for illustrative purposes only, and the steps of the methods of the present invention are not limited to the order specifically described above unless otherwise specifically stated. Furthermore, in some embodiments, the present invention may also be implemented as a program recorded on a recording medium, the program comprising machine-readable instructions for implementing the methods according to the present invention. Thus, the present invention also covers recording media storing programs for performing the methods according to the present invention.
[0189] It should also be noted that in the systems, apparatus, and methods of the present invention, the components or steps can be disassembled and / or recombined. These disassemblies and / or recombinations should be considered equivalents of the present invention. The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the invention. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein can be applied to other aspects without departing from the scope of the invention. Therefore, the invention is not intended to be limited to the aspects shown herein, but rather to be carried out within the widest scope consistent with the principles and novel features disclosed herein.
[0190] The above description has been given for purposes of illustration and description. Furthermore, this description is not intended to limit the embodiments of the invention to the forms disclosed herein. Although numerous exemplary aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations thereof.
Claims
1. A method for detecting anomalies in electricity consumption data based on reconstruction-discrimination dual-path collaborative optimization, characterized in that, include: Acquire multivariate long-term series data of historical measurements of the energy meter under test; The multivariate long-term series data is divided into multiple time windows of a preset window length; Multiple time window data and their adjacent time window data are input into a pre-trained anomaly detection model, and anomaly scores corresponding to each time window data are output. The anomaly detection model is generated based on reconstruction-discrimination dual-path collaborative optimization. The degree of abnormality of the energy meter under test at each time point is determined based on the abnormality score corresponding to the data of each time window.
2. The method according to claim 1, characterized in that, The training process of the anomaly detection model includes a reconstruction-driven phase, a hard sample selection phase, and a discrimination-driven module, specifically implemented as follows: Construct a pattern-weighted discrimination module and an adversarial reconstruction module; The anomaly confidence output of the discriminative weighted module is initialized to 0.5 for all samples; In the reconstruction-driven phase, the adversarial reconstruction module is set to training mode, the discriminative weighted module is set to testing mode, the parameters are iteratively optimized based on the input source domain multidimensional time series window samples, and the optimized adversarial reconstruction module is output. In the difficult sample selection stage, both the parameter-optimized adversarial reconstruction module and the discriminative weighting module are set to test mode to construct difficult samples, and the difficult sample labeled dataset is output based on the input source domain multidimensional time series window samples. In the discriminative driving module, the discriminative weighted module is set to training mode, and parameter iterative optimization training is performed based on the hard sample labeled data to obtain the parameter-optimized discriminative weighted module; The reconstruction-driven stage, the hard sample selection stage, and the discrimination-driven module are iterated multiple times until convergence is achieved, generating the anomaly detection model, which includes a discrimination mode weighting module and an adversarial reconstruction module for the test mode.
3. The method according to claim 2, characterized in that, In the reconstruction-driven phase, the adversarial reconstruction module is set to training mode, and the discriminative weighted module is set to testing mode. Parameters are iteratively optimized based on the input source domain multidimensional time series window samples, and the optimized adversarial reconstruction module is output, including: Step 1: Input the source domain multidimensional time series window samples into the discriminative weighting module of the test mode and output the anomaly confidence level; Step 2: Input the source domain multidimensional time series window samples into the adversarial reconstruction module during the training phase, and output the reconstruction error of normal samples and the reconstruction error of abnormal samples; Step 3: Input the abnormal confidence, the normal sample reconstruction error, and the abnormal sample reconstruction error into the pre-constructed reconstruction driving loss function to obtain the reconstruction driving loss; Step 4: Return to Step 1 for iterative calculation until the reconstruction-driven loss converges, and obtain the parameter-optimized adversarial reconstruction module.
4. The method according to claim 2, characterized in that, In the hard sample selection stage, both the parameter-optimized adversarial reconstruction module and the discriminative weighting module are set to test mode for hard sample construction. Based on the input source domain multidimensional time series window samples, a hard sample labeled dataset is output, including: The source domain multidimensional time series window samples are input into the discriminative weighting module of the test mode, and the anomaly confidence level is output. The source domain multidimensional time series window sample is input into the adversarial reconstruction module of the test mode, and the reconstruction error is output. The anomaly score is obtained by performing a dot product operation on the anomaly confidence and the reconstruction error. A focal point selection mechanism is used to select and mark segments based on anomaly scores, resulting in marked segments. The hard sample labeled dataset is generated based on the labeled fragments and the source domain multidimensional time series window samples.
5. The method according to claim 4, characterized in that, A focal point selection mechanism is used to select and label segments based on anomaly scores, resulting in labeled segments, including: The mean of the abnormal scores within a preset range before and after each time point is calculated as the degree of local abnormality. Based on the degree of local anomalies, sample points to be labeled are selected by sorting and using TopK samples; The selected sample points to be labeled are labeled to obtain the labeled fragment.
6. The method according to claim 2, characterized in that, In the discriminative driving module, the discriminative weighting module is set to training mode, and parameter iterative optimization training is performed based on the hard sample labeled data to obtain the parameter-optimized discriminative weighting module, including: Step 1: Input the hard sample labeled dataset into the discriminative weighted module of the training mode and output the anomaly confidence score; Step 2: Input the positive anomaly labels of the source domain multidimensional time series window samples and the anomaly confidence into the pre-constructed discriminative cross-entropy loss function to calculate the discriminative cross-entropy loss; Step 3: Return to Step 1 for iterative calculation until the discriminant cross-entropy loss converges, and obtain the parameter-optimized discriminant weighted module.
7. The method according to claim 2, characterized in that, The adversarial reconstruction module adopts a single-channel independent strategy throughout the entire process, and its data processing flow is as follows: A linear projection layer is used to map the input data to a higher dimension, resulting in the mapped latent vector; The latent vector is encoded using a position-coded Transformer encoder to obtain the encoded vector Z; The encoded vector is decoded using a non-parameter-sharing Transformer decoder to obtain reconstructed data of abnormal samples and reconstructed data of normal samples.
8. The method according to claim 7, characterized in that, The abnormal sample reconstruction data and normal sample reconstruction data The decoding path is: In the formula, Z is the feature code, and D is the feature encoding. normal and D anomaly These represent the normal decoder and the abnormal decoder, respectively; GRL() is the gradient inversion layer; The loss L of the anti-reconstruction module of the anti-reconstruction module AReM for: in, In the formula, R represents the weights given by the discriminative weighting module. train (X,y) represents the reconstruction error obtained by the adversarial reconstruction module in training mode. and These are the reconstructed data of the c-th dimension of the multidimensional time-series window, obtained and concatenated from the normal decoder and the abnormal decoder, respectively. X c Let be the c-th dimension of the input data, X and y be the input window and the corresponding positive anomaly label, respectively, and ⊙ be the dot product operation; For difference regularization loss, This represents the reconstructed data at the t-th time point of a multi-dimensional temporal window obtained and concatenated by a normal decoder, where w represents the length of the temporal window, C is the total number of dimensions of the input data, and λ is the time window length. normal , λ anomaly , λ dr These are the normal reconstruction loss coefficient, the abnormal reconstruction loss coefficient, and the difference regularization term coefficient, respectively. The actual optimization objective for the encoder and normal decoder is: The optimization objective of the anomaly decoder is: In the formula, θ E , These are the learnable parameters for the encoder, normal decoder, and abnormal decoder, respectively. and These refer to the normal sample reconstruction error and the abnormal sample reconstruction error obtained by the adversarial reconstruction module in the training mode, respectively.
9. The method according to claim 2, characterized in that, The data processing flow of the discriminative weighting module is as follows: The input data is encoded using a projection layer and a Transformer encoder to obtain the encoded vector Z1; A point attention layer is used to calculate the multi-head attention of the encoded vector at a specified time point to obtain the feature vector at the specified time point; A graph attention layer is used to perform inter-dimensional information interaction on the feature vectors at a specified time point to obtain graph feature vectors. The graph feature vectors are generalized to multi-domain data to obtain anomaly confidence and domain label prediction values. The discriminant weighting loss L of the discriminant weighting module DWM for: In the formula, and y n These refer to the anomaly confidence level and positive anomaly label corresponding to the nth focal point, respectively. and dm n These refer to the predicted and true domain labels corresponding to the nth focal point, respectively; N is the total number of focal points within the current window; CE() is the cross-entropy loss; and λ class With λ domain These are the positive anomaly cross-entropy loss coefficient and the domain label cross-entropy loss coefficient, respectively. The actual optimization objective of the discriminative weighting module is: Where θ extract θ anocls θ domcls These are the learnable parameters for the first half of the discriminative weighted module, the weight generator, and the domain classifier, respectively.
10. A power consumption data anomaly detection device based on reconstruction-discrimination dual-path collaborative optimization, characterized in that, include: The acquisition module is used to acquire multivariate long-term series data of historical tests of the energy meter under test; The partitioning module is used to divide the multivariate long-term series data into multiple time windows of a preset window length; The prediction module is used to input multiple time window data and their adjacent time window data into a pre-trained anomaly detection model and output the anomaly score corresponding to each time window data, wherein the anomaly detection model is generated based on reconstruction-discrimination dual-path collaborative optimization; The determination module is used to determine the degree of abnormality of the energy meter under test at each time point based on the abnormality score corresponding to the data of each time window.
Citation Information
Cited By
Power transmission line anomaly detection method and system
CN121502238A