Power system anomaly detection method, system and computer storage medium
Patent Information
- Application Number
- CN202611321585.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-28
- Publication Date
- 2026-10-27
AI Technical Summary
[0003]传统统计阈值类异常检测方法,依赖数据稳态分布假设,难以适配非线性、非平稳的用电时序,易受季节波动干扰,误报率偏高;现有通用稀疏注意力易造成周期特征丢失,异常检测效果不佳
[0022]本发明的有益效果为:本发明通过混合稀疏注意力机制同时提取邻域特征、电力日周周期远距离特征以及序列首尾锚点上下文特征,在控制计算开销的条件下充分挖掘电力负荷时序多尺度关联信息,再融合多项异常指标得到综合异常得分并结合验证子集确定的动态阈值完成异常判别,有效提升了长时序电力场景下异常检测的准确率,降低误告警情况。
Smart Images

Figure CN122986288A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of smart grid safety monitoring and artificial intelligence technology, specifically relating to a method, system, and computer storage medium for detecting power system anomalies. Background Technology
[0002] With the large-scale deployment of smart grids and advanced metering systems (AMIs), the power grid has accumulated massive amounts of fine-grained time-series data on electricity load. Accurately identifying anomalies such as equipment failures, electricity theft, and sudden load changes is crucial for the safe operation and maintenance of the power grid.
[0003] Traditional statistical threshold-based anomaly detection methods rely on the assumption of steady-state data distribution, which makes it difficult to adapt to nonlinear and non-stationary electricity consumption time series, and is easily affected by seasonal fluctuations, resulting in a high false alarm rate. Existing general sparse attention methods are prone to loss of periodic features, resulting in poor anomaly detection performance.
[0004] Therefore, there is an urgent need for a power system anomaly detection scheme that can improve the anomaly detection accuracy over long time periods while controlling computational overhead. Summary of the Invention
[0005] The purpose of this invention is to provide a power system anomaly detection method, system, and computer storage medium that achieves low-overhead, high-precision, and robust power grid timing anomaly detection by designing a hybrid sparse attention mechanism adapted to the characteristics of the power cycle, simultaneously extracting multi-dimensional temporal features and fusing them to obtain high-dimensional spatiotemporal features, and combining self-supervised training optimization and multi-index fusion judgment.
[0006] To achieve the above objectives, this invention proposes a power system anomaly detection method, comprising: preprocessing the original time-series data of power load to output a structured enhanced sample sequence, wherein the structured enhanced sample sequence is divided into a training subset and a validation subset; processing the training subset using hybrid sparse attention to generate neighborhood feature components, periodic interval long-distance feature components, and sequence beginning and end anchor point context feature components; fusing the neighborhood feature components, the periodic interval long-distance feature components, and the sequence beginning and end anchor point context feature components to output high-dimensional spatiotemporal features of the training stage; obtaining a predicted output based on the high-dimensional spatiotemporal features of the training stage, calculating the deviation loss between the predicted output and reference information, updating network parameters according to the deviation loss, and obtaining a trained power anomaly detection model, wherein the power anomaly detection model includes a feature extraction network; inputting the sample to be detected into the power anomaly detection model to output high-dimensional spatiotemporal features of the inference stage, and calculating multiple anomaly indicators based on the high-dimensional spatiotemporal features of the inference stage, fusing the multiple anomaly indicators to obtain a comprehensive anomaly score; determining a dynamic threshold based on the validation subset, and if the comprehensive anomaly score exceeds the dynamic threshold, outputting a power anomaly alarm result.
[0007] In one optional implementation, the preprocessing specifically includes: acquiring raw time-series data of the power load; The original time-series power load data is filled using linear interpolation to obtain missing value recovery data; anomaly suppression processing is performed on the missing value recovery data to obtain anomaly-processed data; the anomaly-processed data is standardized to obtain standardized data; a sliding window strategy is used to perform time-series processing on the standardized data to obtain intermediate time-series samples; the intermediate time-series samples are subjected to periodic time feature encoding processing, and time dimension periodic information is superimposed to obtain the structured enhanced sample sequence.
[0008] In one optional implementation, the hybrid sparse attention independently extracts features from the local short-term dimension, the periodic long-distance dimension, and the sequence global dimension to obtain three complementary spatiotemporal feature components.
[0009] In one optional implementation, the long-distance characteristic component of the periodic interval is set with a step interval according to the inherent periodic characteristics of the power load, so as to match the periodic change pattern of power consumption time sequence.
[0010] In one optional implementation, the feature extraction network embeds temporal location information, so that the output high-dimensional spatiotemporal features carry temporal sequence correlation characteristics. The high-dimensional spatiotemporal features include the high-dimensional spatiotemporal features of the training phase and the high-dimensional spatiotemporal features of the inference phase.
[0011] In one alternative implementation, a multi-task self-supervised constraint method is adopted during the model training phase to utilize unlabeled temporal information to assist in optimizing feature extraction capabilities.
[0012] In one optional implementation, the multi-task self-supervision includes three complementary learning tasks: temporal mask reconstruction, temporal order discrimination, and feature contrast learning.
[0013] In one alternative implementation, a generative adversarial network is incorporated to construct temporal reconstruction constraints, thereby enhancing the model's ability to represent normal electricity consumption patterns.
[0014] In one optional implementation, the plurality of anomaly indicators simultaneously include self-supervised task deviation information and temporal reconstruction difference information.
[0015] In one optional implementation, the multiple abnormal indicators are adaptively weighted and fused, and the weights of each indicator are dynamically matched according to the overall distribution characteristics of the sample.
[0016] In one optional implementation, differentiated fusion weights are configured for the neighborhood feature components, the periodic interval long-distance feature components, and the sequence beginning and end anchor context feature components, and non-equal weighted fusion is performed on the three feature components to obtain the high-dimensional spatiotemporal features of the training stage.
[0017] In one optional implementation, the dynamic threshold is adaptively adjusted based on the comprehensive anomaly score distribution of the verification subset under different load conditions to adapt to the score shift caused by changes in load level.
[0018] In an optional implementation, the power system anomaly detection method further includes: obtaining a comprehensive anomaly score at multiple time points; verifying and correcting the comprehensive anomaly score at the multiple time points based on the temporal continuity of the anomaly, eliminating false anomalies caused by instantaneous random noise, and then performing anomaly alarm judgment.
[0019] In one optional implementation, when outputting the abnormal alarm result, the abnormal score level and the corresponding time sequence location information of the abnormality are output simultaneously.
[0020] This invention also proposes a power system anomaly detection system for implementing the aforementioned power system anomaly detection method. The system includes: a data preprocessing module for preprocessing raw time-series power load data, outputting a structured augmented sample sequence, and dividing the structured augmented sample sequence into a training subset and a validation subset; a feature extraction module, configured with a hybrid sparse attention unit, for processing the training subset, generating neighborhood feature components, periodic interval long-distance feature components, and sequence beginning and end anchor point context feature components, fusing the three feature components to output high-dimensional spatiotemporal features for the training phase; and a model training module for inputting the high-dimensional spatiotemporal features for the training phase into a prediction head network, and outputting... The training phase includes a prediction output corresponding to the mask position. Based on the deviation between the prediction output and the reference information, a deviation loss is calculated. The network parameters are updated according to the deviation loss to obtain a trained power anomaly detection model. The power anomaly detection model includes a feature extraction network; an anomaly inference module, which inputs the sample to be detected into the power anomaly detection model, outputs high-dimensional spatiotemporal features during the inference phase, calculates multiple anomaly indicators based on the high-dimensional spatiotemporal features, and fuses the multiple anomaly indicators to obtain a comprehensive anomaly score; and a threshold determination and alarm module, which determines a dynamic threshold based on the validation subset. When the comprehensive anomaly score exceeds the dynamic threshold, a power anomaly alarm result is output.
[0021] The present invention also proposes a computer storage medium storing a computer program, which, when executed by a processor, implements the power system anomaly detection method.
[0022] The beneficial effects of this invention are as follows: This invention extracts neighborhood features, long-distance features of daily and weekly power cycles, and contextual features of the first and last anchor points of the sequence simultaneously through a hybrid sparse attention mechanism. Under the condition of controlling computational overhead, it fully mines the multi-scale correlation information of power load time series. Then, it integrates multiple anomaly indicators to obtain a comprehensive anomaly score and completes anomaly discrimination by combining the dynamic threshold determined by the validation subset. This effectively improves the accuracy of anomaly detection in long-term power scenarios and reduces false alarms. Attached Figure Description
[0023] Figure 1 A flowchart of a power system anomaly detection method provided in an embodiment of the present invention; Figure 2 Internal flowchart of the hybrid sparse attention method for power system anomaly detection provided in this embodiment of the invention; Figure 3 A flowchart illustrating the preprocessing steps of the power system anomaly detection method provided in this embodiment of the invention; Figure 4 The flowchart below shows the multi-task self-supervised pre-training process of the power system anomaly detection method provided in this embodiment of the invention. Figure 5 A flowchart illustrating the output of anomaly alarm results during the inference phase of the power system anomaly detection method provided in this embodiment of the invention; Figure 6 This is a framework diagram of a power system anomaly detection system provided in an embodiment of the present invention. Detailed Implementation
[0024] Traditional power system anomaly detection typically assumes the system is in a steady state and that data follows a specific probability distribution (such as a Gaussian distribution), identifying observations that deviate from the normal range by setting fixed or dynamic thresholds. While simple to implement and highly interpretable, its ability to model nonlinear, non-stationary, and multimodal modern electricity consumption behavior is extremely limited, making it difficult to capture context-dependent anomalies (e.g., industrial load at night) or collective anomalies (e.g., abnormal patterns lasting for several hours). Furthermore, threshold methods are susceptible to seasonal fluctuations and individual user differences, resulting in a persistently high false alarm rate.
[0025] To improve detection performance, various machine learning methods have been introduced. One type is unsupervised algorithms based on distance or density, such as Local Outlier Factor (LOF) and Isolation Forest, which treat the time window as a high-dimensional vector and identify sparse regions as anomalies in the feature space. Another type is clustering-based methods (such as K-means and DBSCAN), which model "normal" clusters and label outliers. Although these methods do not require labels, they still rely on shallow feature representations and are difficult to characterize the long-term time dependence and complex periodic patterns (such as daily, weekly, and seasonality) inherent in power load. Meanwhile, while linear dimensionality reduction techniques such as Principal Component Analysis (PCA) can be used for residual analysis, their representational ability is clearly insufficient when dealing with highly nonlinear power grid data.
[0026] Recurrent Neural Networks (RNNs) and their variant, Long Short-Term Memory (LSTM), can model sequence dependencies and have achieved some success in power load forecasting and anomaly detection. However, the inherent sequential computation characteristic of RNNs makes their training inefficient, and they are prone to the vanishing gradient problem when dealing with very long sequences, making it difficult to effectively capture long-term dependencies spanning days or even weeks. Convolutional Neural Networks (CNNs) extract local temporal patterns through one-dimensional convolutional kernels and are often combined with LSTMs to form hybrid models that take into account both local and global features. However, their receptive field is limited by the number of convolutional layers and kernel size, limiting their ability to model long-distance event correlations. Autoencoders and their variants (such as Variational Autoencoders, VAEs) identify anomalies through reconstruction errors. Although they perform well in unsupervised scenarios, their reconstruction process is often too smooth, insensitive to subtle anomalies, and lacks explicit modeling of temporal causal structures.
[0027] The Transformer architecture, with its self-attention mechanism and parallel computing advantages, can directly model the dependencies between any two time steps, regardless of distance, and theoretically can perfectly capture the multi-scale periodic and sudden event correlations in power loads. However, the self-attention computational complexity of the standard Transformer is O(n²) (where n is the sequence length). When applied to power load sequences with hundreds or even thousands of time steps, memory consumption and computational overhead increase dramatically, severely limiting its deployment on resource-constrained edge devices or large-scale real-time monitoring platforms.
[0028] More importantly, labeled abnormal samples in real power grid environments are extremely scarce and costly to obtain, making most deep learning models impractical due to their reliance on a large number of labels.
[0029] In summary, there is an urgent need for a novel anomaly detection framework that can overcome the computational bottleneck of the standard Transformer, fully utilize unlabeled data to learn deep normal patterns, and improve detection accuracy and robustness through multi-model collaboration.
[0030] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0031] Combination Figure 1 and Figure 2 As shown, a power system anomaly detection method is proposed. This method aims to address the difficulty of efficiently and accurately identifying anomalies in high-dimensional, non-stationary, and long-term time-series power load data using traditional methods. By introducing a sparse attention mechanism and self-supervised learning, this method can learn robust normal behavior representations from massive amounts of normal electricity consumption data under unlabeled or weakly labeled conditions. Furthermore, through integrated decision-making based on multi-source heterogeneous anomaly signals, it achieves efficient and robust identification of power system anomalies.
[0032] Step S101: Preprocess the original time-series data of power load to output a structured augmented sample sequence, which is divided into a training subset and a validation subset.
[0033] In this step, raw time-series power load data from multiple users, such as smart meters, is first acquired. The raw data typically includes timestamps, user identifiers, and corresponding load values. Due to factors such as communication interruptions and equipment malfunctions during actual data acquisition, the raw data often contains missing values, noise interference, and inconsistencies in units between different users. Therefore, preprocessing is a crucial step in ensuring the quality of subsequent model training. After preprocessing, a structured augmented sample sequence is obtained. This sequence is divided into training and validation subsets for subsequent model training and threshold determination.
[0034] Step S102: The training subset is processed by hybrid sparse attention to generate neighborhood feature components, long-distance feature components with periodic intervals matching the daily or weekly cycle of electricity, and contextual feature components of the first and last anchor points of the sequence.
[0035] This step is the core of feature extraction. The traditional standard Transformer self-attention mechanism has a computational complexity of... When processing long-term power load data, there is a huge computational and memory overhead. To address this, this application employs a hybrid sparse attention mechanism to independently extract features from the local short-term dimension, the periodic long-distance dimension, and the sequence global dimension, resulting in three complementary spatiotemporal feature components.
[0036] Specifically, the hybrid sparse attention mechanism consists of three parts: local attention, stepping attention, and global attention.
[0037] First, the preprocessed data is mapped to a higher-dimensional space, and positional encoding is added so that the model can... It is sufficient to identify the time sequence of the data.
[0038] (1) Local attention: Focuses on short-term dependencies and changes within a short period of time, considering only a few time steps around the current point in time, suitable for capturing short-term fluctuations. Set the local attention range k (e.g., k=12). Only calculate with Attention weights are assigned to locations within the target area. This design can capture local patterns caused by transient changes such as device startup / shutdown and short-term user behavior, as well as sudden increases or decreases in load.
[0039] (2) Step Attention: Modeling Periodic Patterns. Based on the inherent strong diurnal and weekly periodicity of the power load, the step attention step size *s* is set. For example, when the sampling interval is 30 minutes, the step attention step size corresponding to the diurnal period can be set to *s*=48, and the step attention step size corresponding to the weekly period can be set to *s*=336. This ensures that the current time... Worth paying attention to Time steps with the same periodic position are used. This design allows the model to directly correlate the electricity consumption status of "9:00 AM today" with "9:00 AM yesterday" or "9:00 AM last Monday", accurately modeling periodic patterns and generating long-distance feature components with periodic intervals that match the daily or weekly electricity cycle.
[0040] (3) Global attention: Preserve the context information at the beginning and end of the sequence. Force the first and second... indivual( (Window length) Time step can access all This design ensures that key contextual information at the beginning and end of the sequence is not lost during the sparsification process, generating contextual feature components at the beginning and end of the sequence.
[0041] The overall sparsity ratio is controlled below 0.1. Through the above three-way parallel computation, the hybrid sparse attention mechanism preserves key long-range spatiotemporal dependencies while reducing computational complexity from... Down to It can reach near-linear levels, significantly reducing memory usage and computation latency.
[0042] The positional encoding uses a learnable embedding matrix instead of the traditional sine / cosine function, and additionally introduces a temporal feature embedding vector (after MLP mapping) which is added to the input payload value and used together as the Transformer input.
[0043] like Figure 2 As shown, the internal structure and flow of the Sparse Attention Transformer feature extraction module are provided.
[0044] First, the data is embedded. The preprocessed data is mapped to a high-dimensional space, and learnable positional and temporal encodings are added. Feature embedding.
[0045] Local attention computation. Based on local windows. Calculate attention weights to generate neighborhood feature components.
[0046] Step-based attention calculation. Based on step size. Calculate periodic positional attention weights to generate periodically spaced long-distance... Characteristic components.
[0047] Global attention calculation. Global attention weights are calculated based on the positions of the first and last anchor points, and applied to the generated sequence at the first and last anchor points. The following section discusses the characteristic components.
[0048] Feature fusion. The three feature components are fused with non-equal weights to output high-dimensional spatiotemporal features.
[0049] Step S103: After fusing neighborhood feature components, periodic interval long-distance feature components, and sequence beginning and end anchor context feature components, output the high-dimensional spatiotemporal features of the training stage.
[0050] After obtaining the three feature components, they need to be fused to form a complete high-dimensional spatiotemporal feature representation. The fusion method can be weighted summation, concatenation followed by mapping through a fully connected layer, or other nonlinear fusion mechanisms.
[0051] In one implementation, differentiated fusion weights are configured for the neighborhood feature components, the periodic interval long-distance feature components, and the sequence beginning and end anchor context feature components, and non-equal weight fusion is performed on the three feature components. For example, the local feature weights are set to... The periodic feature weights are set to The global feature weights are set to Features after fusion The weighting coefficients can be learned automatically during the training process or preset based on the performance of the validation set.
[0052] Furthermore, temporal positional information is embedded during feature extraction. Positional encoding uses a learnable embedding matrix instead of the traditional sine / cosine function, and additionally introduces a temporal feature embedding vector (after MLP mapping) added to the input payload, which together serve as the Transformer input. This allows the output high-dimensional spatiotemporal features to carry temporal sequence correlation characteristics, reflecting the relative positional relationships between time steps.
[0053] Finally, the high-dimensional spatiotemporal features of the training phase are output, which include the local dynamics, periodic patterns, and global contextual information of the power load data.
[0054] S104: Input the high-dimensional spatiotemporal features from the training phase into the prediction head network, output the prediction output corresponding to the mask position from the training phase, calculate the deviation loss between the prediction output and the reference information, update the network parameters based on the deviation loss, and obtain the trained power anomaly detection model. The power anomaly detection model includes a feature extraction network.
[0055] This step involves the training process of the model. The training objective is to enable the model to learn semantic representations of normal electricity consumption behavior by minimizing the bias loss.
[0056] Combination Figure 4 As shown, during the model training phase, a multi-task self-supervised constraint approach is adopted, utilizing unlabeled temporal information to assist in optimizing feature extraction capabilities. Specifically, this includes the following three types of complementary learning tasks: (1) Temporal masking reconstruction task: A certain proportion (e.g., 15%) of time steps in the input sequence are randomly selected for masking, with some replaced by zero vectors, some replaced by random values, and some remaining unchanged. The training model predicts the true load value of the masked location based on the unmasked context, using mean squared error (MSE) as the loss function. This task forces the model to deeply understand the inherent logic and temporal continuity of normal electricity consumption.
[0057] In this context, the predicted output specifically refers to the estimated power load for the mask time step, output by the prediction head network based on the high-dimensional spatiotemporal features of the training phase during the mask reconstruction task; the reference information is the original real power load data corresponding to the mask time step; and the bias loss is the error loss between the predicted output and the reference information, used to drive iterative updates of the network parameters. It should be noted that the predicted output is only generated during the model training phase.
[0058] (2) Temporal order discrimination task: Two adjacent and non-overlapping sub-windows A and B are extracted from the continuous load sequence of the same user. The original order (A→B) is maintained with a certain probability (e.g., 50%), and the order is shuffled to (B→A) with another probability. The two sub-windows are encoded by a shared encoder and then concatenated. The result is input into a binary classification fully connected network to train it to judge whether the temporal order is correct. Cross-entropy loss is used. This task enhances the model's ability to perceive causal relationships and the direction of temporal evolution.
[0059] (3) Feature contrastive learning task: Apply data augmentation operations (such as adding Gaussian noise, random time axis offset, and random amplitude scaling) to the same original window to generate positive sample pairs; negative sample pairs are sampled from different users or time periods separated by more than a preset number of days (e.g., 7 days). A momentum-updated queue is used to store negative sample features, and the InfoNCE contrastive loss is calculated. : ; in, To query sample features, As a positive sample, For negative samples, For cosine similarity, The temperature coefficient is 0.07 (e.g., 0.07). This task brings semantically similar samples closer together and pushes apart dissimilar samples, forming a clear and compact cluster of normal patterns in the feature space.
[0060] Furthermore, a temporal reconstruction constraint is constructed using a Generative Adversarial Network (GAN) to enhance the model's ability to represent normal electricity consumption patterns. The GAN module comprises a conditional generator and a multi-input discriminator. The conditional generator takes random noise and global features from the feature extraction network as input to reconstruct a synthetic sequence that conforms to a normal electricity consumption distribution. The multi-input discriminator simultaneously receives the original input sequence and high-level feature representations, distinguishing between true and false sequences through a convolutional and attention fusion mechanism. The generator and discriminator are trained using an alternating optimization strategy until Nash equilibrium is reached. The reconstruction error of the GAN... This is one of the losses incurred by the main anomaly detection task.
[0061] The total loss function is: Among them, the weighting coefficient This can be determined through fine-tuning of validation set performance (e.g.) ).
[0062] According to deviation loss The network parameters are updated to obtain the trained power anomaly detection model. This model includes a feature extraction network (Sparse Attention Transformer) and auxiliary networks for anomaly detection (such as a GAN discriminator and a self-supervised prediction head).
[0063] Step S105: Input the sample to be detected into the power anomaly detection model, output the high-dimensional spatiotemporal features of the inference stage, calculate multiple anomaly indicators based on the high-dimensional spatiotemporal features of the inference stage, and fuse the multiple anomaly indicators to obtain a comprehensive anomaly score.
[0064] During the inference phase, new samples to be detected are input into the trained power anomaly detection model. The model outputs high-dimensional spatiotemporal features for the inference phase. Based on these features, multiple anomaly indicators are calculated.
[0065] Multiple anomaly indicators simultaneously contain information on self-supervised task deviations and temporal reconstruction differences. Specifically, these include: (1) GAN reconstruction error : Calculate the original input sequence Synthetic sequences generated by condition generator Differences between them, for example This indicator reflects the anomalies of the sample at the data distribution level.
[0066] (2) The probability of anomalies in the discriminator output Multi-input discriminator The original sequence and high-level features are analyzed to determine the true probability. The probability of an anomaly is defined as follows: This indicator reflects the degree to which the sample deviates from the "normal data manifold".
[0067] (3) Prediction error of self-supervised mask modeling : Calculate the actual load value at the shaded location Compared with model predictions Differences between them, for example This metric reflects the degree to which the sample violates normal temporal logic.
[0068] A comprehensive anomaly score is obtained by integrating multiple anomaly indicators. .
[0069] In one implementation, multiple outlier indicators are adaptively weighted and fused based on the overall sample score. The distribution characteristics are dynamically matched with the weights of each indicator. The fusion formula is: Among them, weight The optimal fusion weights can be determined by maximizing the validation set AUC, or automatically learned through a shallow neural network (such as a single-hidden-layer neural network with 3 input dimensions, 16 hidden units, and 1 output dimension). This network is jointly trained end-to-end with the backbone model. If the value exceeds the dynamic threshold determined based on the Youden exponent of the ROC curve, the window is marked as abnormal and an alarm is triggered.
[0070] In other implementations, a rank fusion strategy can also be adopted, in which the three indicators are sorted separately and the average rank is taken, and those that are lower than the preset percentile are judged as abnormal.
[0071] S106. Determine the dynamic threshold based on the validation subset. If the comprehensive anomaly score exceeds the dynamic threshold, output the power anomaly alarm result.
[0072] Determining the dynamic threshold is crucial for the accuracy of anomaly detection.
[0073] In one implementation, the dynamic threshold is based on the comprehensive anomaly score of the validation subset under different load conditions. The layout is adaptively adjusted to accommodate score shifts caused by changes in load levels.
[0074] Specifically, receiver operating characteristic (ROC) curves are plotted on the validation set, and Youden's value corresponding to each threshold is calculated. index Select to make The highest threshold is used as the final decision threshold. This threshold can balance the false alarm rate and the false negative rate, adapting to the actual needs of power grid operation and maintenance for high accuracy.
[0075] If the overall abnormal score If the dynamic threshold is exceeded, it is determined that there is a power system anomaly in the current time window, and a power anomaly alarm result is output.
[0076] like Figure 3 As shown in the embodiments of this application, a detailed implementation process of the data preprocessing module is also provided.
[0077] Step S1011: Obtain the original time-series data of the power load.
[0078] Step S1012: The original time-series power load data is filled using linear interpolation to obtain the missing values. Complete data. This step fills in missing values using linear interpolation or STL decomposition. For consecutive missing values, linear interpolation of adjacent points is used; for periodic missing values, STL decomposition is used to capture seasonal and trend components before filling.
[0079] Step S1013: Anomaly suppression processing is performed on the missing value recovery data to obtain anomaly-processed data. Using... The IQR method identifies outliers and truncates them using the Winsorization method. Winsorization is then employed to limit the impact of extreme values. Upper and lower thresholds are set; values outside these ranges are replaced with the nearest boundary value.
[0080] Step S1014: Standardize the anomaly handling data to obtain standardized data. Execute user-level Z-... Z-score standardization and time feature min-max scaling. To eliminate differences in electricity consumption patterns among different users, the load data of each user is independently Z-score standardized, so that the mean is 0 and the standard deviation is 1.
[0081] Step S1015: Use a sliding window strategy to perform time series processing on the standardized data to obtain intermediate time series data. Samples. To accommodate the model input requirements, a sliding window technique is used to segment the time series into fixed-length slices. The window size can be dynamically selected to adapt to different scenario requirements.
[0082] Step S1016: Perform periodic time feature encoding on the intermediate time series samples, and superimpose the time dimension periodicity. The information is used to obtain a structured and enhanced sample sequence. Considering the periodicity of power load data, sine / cosine embedding is performed on the timestamps to capture the time characteristics at different scales such as hour, day, and week.
[0083] Specifically, the `data_loader.py::DataProcessor` function is used to effectively preprocess the raw data. This function not only handles missing and outlier values but also performs temporal feature encoding, ensuring the data quality required for model training. The preprocessing process includes missing value imputation, outlier suppression, normalization, sliding window slicing, and periodic temporal feature fusion.
[0084] First, to address the issue of missing values, for gaps with a small number of consecutive missing time steps (e.g., less than or equal to 6 sampling points), linear interpolation is used to fill in the gaps, estimating the missing values using the linear relationship between adjacent known data points. For long gaps with missing values exceeding a preset threshold (e.g., 6 consecutive sampling points), the STL (Seasonal and Trend decomposition using Loess) method is used to decompose the sequence into trend terms, seasonal terms, and residual terms. Each term is then interpolated and recombined to preserve the periodic structure of the data.
[0085] Secondly, to address the outlier problem, the interquartile range (IQR) method is used to identify outliers. The first quartile of the daily load sequence for each household is calculated. With the third quartile Determine the range of outliers Observations outside the specified range are considered outliers and are truncated to the range boundary using the Winsorization method. This approach preserves the overall data distribution while suppressing the interference of extreme values on model training.
[0086] Secondly, regarding data standardization, Z-score standardization was performed independently for each user, ensuring that the processed data had a mean of 0 and a standard deviation of 1, thus eliminating the impact of differences in electricity consumption among different users. Simultaneously, additional time features (such as hours, days of the week, and months) were scaled using Min-Max. Intervals are used to unify the feature scale.
[0087] Subsequently, a sliding window strategy is used to divide the continuous time series into fixed-length subsequences. Window length The optimal value can be selected from the preset set through cross-validation. The step size S is set to 24 time steps to ensure sample overlap, thereby increasing the number of training samples and preserving temporal continuity.
[0088] Finally, periodic time feature encoding is performed. Three types of time features—hours (0-23), days of the week (0-6), and months (1-12)—are added to each time step, and periodic encoding is performed using sine / cosine functions to form an enhanced input vector. This encoding method can explicitly capture the daily and weekly periodic patterns in power load data, providing prior knowledge for subsequent feature extraction.
[0089] After the above preprocessing, a structured augmented sample sequence is obtained. This sequence is divided into a training subset and a validation subset for subsequent model training and threshold determination.
[0090] like Figure 4 As shown in the embodiments of this application, a multi-task pre-training process for a self-supervised learning representation module is also provided. The parallel execution process of three self-supervised tasks is shown in detail: (1) masking modeling task (randomly masking 15% of the time steps and predicting); (2) temporal order prediction task (determining whether the two sub-windows are in the correct order); (3) contrastive learning task (constructing positive and negative sample pairs based on data augmentation and calculating InfoNCE loss). The three tasks jointly drive the encoder to learn robust normal pattern representations. The specific steps are as follows: Step S201: Masking modeling task. Randomize the occlusion time step, predict the occluded value, and calculate the MSE loss.
[0091] Step S202: Temporal order prediction task. Determine the order of sub-windows and calculate the cross-entropy loss.
[0092] Step S203: Contrastive learning task. Construct positive and negative sample pairs and calculate the InfoNCE loss.
[0093] Step S204: Joint optimization. The losses from the three tasks are weighted and summed with the loss from the main task, and the network parameters are updated.
[0094] like Figure 5 As shown in the embodiments of this application, the overall reasoning and decision-making process of the anomaly detection method is also provided.
[0095] First, input the sample to be tested.
[0096] Step S301: Calculate the GAN reconstruction error .
[0097] Step S302: Calculate the discriminator anomaly probability .
[0098] Step S303: Calculate the self-supervised prediction bias .
[0099] Step S304: Integrate the decision-making module and fuse abnormal indicators to obtain a comprehensive score. Compare the overall score with the dynamic If the threshold is exceeded, output the abnormal alarm result, level, and location information.
[0100] Combination Figure 6 As shown in the figure, this application embodiment also provides a power system anomaly detection system for implementing the above. Method. The system includes: a data preprocessing module, a feature extraction module, a model training module, an anomaly inference module, and a threshold determination and alarm module. The model training module includes a self-supervised learning representation function, the anomaly inference module includes an anomaly discrimination function, and the threshold determination and alarm module is used to perform comprehensive anomaly determination and alarm output.
[0101] The data preprocessing module is used to preprocess the raw time-series data of power load, output structured augmented sample sequences, and divide the structured augmented sample sequences into training subsets and validation subsets.
[0102] The feature extraction module is equipped with a hybrid sparse attention unit to process the training subset, generate neighborhood feature components, long-distance feature components with periodic intervals matching the daily or weekly cycle of electricity, and contextual feature components of the first and last anchor points of the sequence, and fuse the three feature components to output high-dimensional spatiotemporal features for the training stage.
[0103] The model training module is used to obtain the prediction output based on the high-dimensional spatiotemporal features during the training phase, calculate the deviation loss based on the deviation between the prediction output and the reference information, update the network parameters according to the deviation loss, and obtain the trained power anomaly detection model. The power anomaly detection model includes a feature extraction network.
[0104] The anomaly inference module is used to input the sample to be detected into the power anomaly detection model, output high-dimensional spatiotemporal features of the inference stage, calculate multiple anomaly indicators based on the high-dimensional spatiotemporal features of the inference stage, and fuse multiple anomaly indicators to obtain a comprehensive anomaly score.
[0105] The threshold determination and alarm module is used to determine the dynamic threshold based on the verification subset. When the comprehensive anomaly score exceeds the dynamic threshold, it outputs a power anomaly alarm result.
[0106] Specifically, the data preprocessing module is used to receive raw multi-user power load time-series data, perform missing value imputation, outlier suppression, normalization, sliding window slicing and periodic time feature fusion, and output a structured training sample sequence. The Sparse Attention Transformer feature extraction module receives structured training sample sequences and uses a hybrid sparse self-attention mechanism to replace standard self-attention computation. It captures short-term dependencies through local attention, models daily / weekly periodic patterns through stepping attention, preserves the contextual information at the beginning and end of the sequence through global attention, and combines learnable positional encoding and temporal embedding vectors to output high-dimensional spatiotemporal feature representations. Under unlabeled data conditions, the self-supervised learning representation module drives the sparse attention Transformer feature extraction module to learn the semantic representation of normal electricity consumption behavior by designing three pre-training tasks: mask modeling, temporal order prediction, and contrastive learning, and outputs an auxiliary loss signal for joint optimization. The anomaly detection module of Generative Adversarial Network (GAN) includes a condition generator and a multi-input discriminator. The condition generator takes random noise and global features output by the sparse attention Transformer feature extraction module as input to reconstruct a synthetic sequence that conforms to the normal power consumption distribution. The multi-input discriminator simultaneously receives the original input sequence and high-level feature representation, distinguishes between true and false through a convolution and attention fusion mechanism, and outputs anomaly confidence scores. The integrated decision module integrates three indicators during the inference phase: GAN reconstruction error, anomaly probability output by GAN discriminator, and prediction bias of self-supervised task. These indicators are dynamically fused using weighted averaging or shallow neural networks. If the comprehensive score exceeds a preset dynamic threshold, it is determined that there is an anomaly in the power system during the current time window.
[0107] Raw time-series power load data from multiple users of smart meters is acquired, with a sampling frequency of once every 30 minutes, to construct a user-time two-dimensional data matrix. The data preprocessing module performs missing value imputation, outlier winsorization, user-level Z-score normalization, sliding window slicing, and temporal feature encoding on the data matrix to generate an input sample set with enhanced features. This input sample set is then fed into a sparse attention Transformer feature extraction module, which uses a hybrid sparse attention mechanism to extract high-dimensional spatiotemporal feature representations. Simultaneously, a self-supervised learning representation module is activated to perform three pre-training tasks, jointly optimizing the encoder parameters. During model training, the global feature vector output by the Transformer, along with random noise, is input into the GAN's conditional generator to generate a synthetic sequence simulating normal power consumption. Simultaneously, a multi-input discriminator receives the real and synthetic sequences and their corresponding high-level features, training the generator and discriminator through an alternating optimization strategy until Nash equilibrium is reached. During inference, three anomaly indicators are calculated for new input windows: ① GAN reconstruction error. ② The probability of anomalies in the discriminator output ③ Self-supervised mask modeling prediction error ; through the integrated decision-making module A weighted fusion is performed to obtain a comprehensive anomaly score. The weight Determined by maximizing the AUC on the validation set; if If the value exceeds the dynamic threshold determined based on the Youden exponent of the ROC curve, the window is marked as abnormal and an alarm is triggered.
[0108] The integrated decision-making module supports multiple fusion strategies, including: (1) Fixed weighted average, with weights allocated according to the proportion of AUC of each indicator on the validation set; (2) Rank fusion: After sorting the three indicators separately, the average rank is taken. Those below the preset percentile are judged as abnormal. (3) Learnable fusion: The optimal fusion weights are automatically learned by a single hidden layer neural network (3 input dimensions, 16 hidden units, 1 output dimension). This network is jointly trained end-to-end with the backbone model.
[0109] Any one or more of the modules, submodules, units, and subunits according to the embodiments of this application, or at least part of the functions of any one or more of them, can be implemented in one module. Any one or more of the modules, submodules, units, and subunits according to the embodiments of this application can be implemented by dividing them into multiple modules. Any one or more of the modules, submodules, units, and subunits according to the embodiments of this application can be at least partially implemented as hardware circuits, such as field-programmable gate arrays (FPGAs), programmable logic arrays (PLAs), systems-on-a-chip, systems-on-a-substrate, systems-on-package, application-specific integrated circuits (ASICs), or implemented by hardware or firmware in any other reasonable manner by integrating or packaging circuits, or implemented in any one of software, hardware, and firmware, or in a suitable combination of any of these. Alternatively, one or more of the modules, submodules, units, and subunits according to the embodiments of this application can be at least partially implemented as computer program modules, which, when run, can perform corresponding functions.
[0110] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0111] In summary, this invention employs a sparse attention Transformer feature extraction module, custom-designed to address the long-sequence, highly periodic characteristics of power load data. By introducing a hybrid sparse attention mechanism, it significantly reduces the computational and memory overhead of the standard Transformer while preserving key long-range spatiotemporal dependencies. The self-supervised learning representation module integrates multiple pre-training tasks, enabling the model to autonomously learn robust and generalized semantic representations of normal behavior from massive amounts of unlabeled normal electricity consumption data in a completely unlabeled environment, effectively addressing the pain point of extremely scarce labeled data in actual power grids. Finally, it utilizes a generative adversarial network (GAN) for anomaly detection. The module constructs a conditional GAN framework, in which the generator uses high-level features extracted by the Transformer to synthesize realistic normal power consumption sequences, while the discriminator performs authenticity discrimination through dual-stream input (original sequence + high-level features), thus providing a powerful anomaly measure based on distribution differences. The integrated decision module is responsible for scientifically and dynamically fusing anomalous signals from different technical paths during the inference stage, including GAN reconstruction errors, anomalous probabilities output by the GAN discriminator, and prediction bias based on self-supervised tasks, and finally outputs a comprehensive and reliable anomaly judgment result, significantly improving the overall robustness and accuracy of the system.
[0112] The present invention achieves the following beneficial technical effects: 1. While the standard Transformer's self-attention mechanism can capture dependencies at arbitrary distances, its O(n²) computational complexity makes it difficult to apply to power load sequences with hundreds or even thousands of time steps. This invention does not simply employ a single sparse pattern, but proposes a hybrid sparse attention strategy integrating "local-step-global." Local attention focuses on several points near each time step (e.g., 12 consecutive 30-minute sampling points), effectively capturing local patterns caused by instantaneous changes such as equipment start-up and shutdown, and short-term user behavior. Step-attention accurately models periodic patterns based on the inherent strong diurnal and weekly periodicity of power load. Global attention ensures that key anchor points such as the start and end of the sequence can access all information, preserving the overall context. This hybrid design not only successfully reduces computational complexity to near-linear levels, but more importantly, it guides attention allocation with prior knowledge highly aligned with the physical characteristics of power data, enabling the model to focus on time step correlations that are truly valuable for anomaly detection at extremely low computational cost. Experimental data shows that, compared with the standard Transformer, the training time of this invention is reduced by 33.7%, the single-sample inference speed is increased by 41.0%, and the GPU memory usage is reduced by 41.7%. This breakthrough enables advanced Transformer models, which were previously unable to be deployed due to resource constraints, to run efficiently on edge computing devices or large-scale real-time monitoring platforms, truly achieving a leap from "laboratory" to "field".
[0113] 2. To address the challenges of high cost and limited quantity of anomaly sample labeling in power grid operation and maintenance, this invention constructs an unsupervised / self-supervised learning paradigm. This framework does not rely on any manual labels but instead learns deep representations "self-driven" from massive amounts of normal data through three pre-training tasks. The Masked Modeling task draws on the successful experience of BERT in natural language processing, randomly masking a portion of the input sequence and training the model to predict the masked true values based on context. This process forces the model to deeply understand the inherent logic and temporal continuity of normal electricity consumption. The Temporal Order Prediction task trains the model to judge whether two adjacent sub-sequences conform to the true time flow by shuffling their order, thereby strengthening the model's ability to perceive causal relationships and the direction of temporal evolution. The Contrastive Learning task constructs positive and negative sample pairs (positive samples are different enhanced views of the same window, negative samples are windows from different users or different time periods), narrowing the feature distance between semantically similar samples and widening the distance between dissimilar samples, thus forming a clear and compact cluster of normal patterns in the feature space. These three tasks complement each other, jointly guiding the model to learn a high-quality representation that can accurately reconstruct, understand temporal logic, and effectively cluster in the feature space, laying a solid foundation for subsequent anomaly detection.
[0114] 3. This invention organically integrates two powerful deep learning paradigms—Transformer and GAN—to construct a complementary collaborative detection mechanism. Traditional anomaly detection based on autoencoders relies solely on input-output reconstruction errors, making it susceptible to noise interference and insensitive to subtle anomalies. The GAN module of this invention provides a higher-dimensional discriminative perspective. Its conditional generator does not start from pure noise but uses the semantically rich global feature vector output by the Transformer encoder as conditional input. This makes the generated synthetic sequence not only numerically approximate real data but also highly consistent with normal power consumption in high-level semantics (such as periodic patterns and load profiles). The design of the multi-input discriminator is crucial; it simultaneously receives the original time series (to capture local details) and high-level features extracted by the Transformer (to grasp the global structure). Through an internal convolution and attention fusion mechanism, it makes a more comprehensive and profound judgment on the authenticity of the input. Therefore, the confidence score output by the discriminator becomes a powerful indicator of whether a sample deviates from the "normal data manifold," greatly enhancing the ability to identify complex and hidden anomalies.
[0115] 4. Single anomaly metrics often have limitations, potentially leading to high false positives or false negatives. The integrated decision module of this invention constructs a more robust final decision by fusing information from three independent but complementary sources. These three signals are: (a) GAN reconstruction error, reflecting the difference between the input time-series data and the normal patterns generated by the generator; (b) the anomaly probability of the GAN discriminator, reflecting the anomaly of the samples at the data distribution level; and (c) the prediction bias of the self-supervised task, reflecting the degree to which the samples violate normal time-series logic. The integrated decision module supports multiple fusion strategies, from simple weighted averaging to complex learnable neural network fusion, and can automatically adjust the weights of each signal based on the validation set performance, dynamically balancing the contributions of different metrics. This "multi-expert voting" mechanism effectively suppresses overfitting or bias in a single model, significantly improving the overall robustness and generalization ability of the system when facing various unknown anomaly types.
[0116] Furthermore, on a publicly available real-world household electricity consumption (LCL) dataset, this invention achieved outstanding performance with Precision=0.9550, Recall=0.8833, F1-Score=0.9177, and AUC=0.9525. Compared to current state-of-the-art baseline models (such as standard Transformer, LSTM, CNN, etc.), the F1-score is improved by more than 3.6%. This significant improvement in accuracy means that in actual power grid operation and maintenance, it can significantly reduce the waste of manpower and resources caused by false alarms, demonstrating extremely high practical value.
[0117] This invention adopts a modular design concept, where each core component (such as sparse attention patterns, self-supervised tasks, GAN structures, and fusion strategies) can be replaced or adjusted according to specific application scenarios. For example, external covariates such as meteorological data and electricity prices can be easily introduced as additional feature inputs, or customized models can be developed for different groups such as industrial users and commercial users. This flexibility ensures that this invention can adapt to the increasingly complex and diverse monitoring needs of future power grids.
[0118] This invention constructs a high-performance, high-efficiency, highly robust and easy-to-deploy power system anomaly detection solution, effectively solving the key bottlenecks of existing technologies.
[0119] This application also provides a computer storage medium storing a computer program, which, when executed by a processor, implements the aforementioned power system anomaly detection method.
[0120] Computer storage media are non-transitory computer-readable storage media, specifically including solid-state drives (SSDs), hard disk drives (HDDs), flash drives (USB Flash Drives), optical discs (CDs / DVDs / Blu-rays), digital versatile optical discs (DVD-ROMs), or read-only memory (ROMs). Internally, the storage media contains a file system and data partitions. Computer programs are stored on the media as executable files, dynamic link libraries, or script files. Program files contain compiled machine code or interpreted code and support operating system environments such as Windows, Linux, and RTOS.
[0121] When the computer program is executed by the processor, it causes the processor to perform the aforementioned power system anomaly detection method, including power load time-series data preprocessing, time-series feature extraction, model training, anomaly index calculation, comprehensive anomaly score determination, and anomaly alarm output. The computer program and model parameters can be stored in the computer storage medium and loaded and executed by the processor.
[0122] The storage medium implementation and the system implementation work together. The storage medium provides the program runtime environment, while the system implementation provides the hardware execution platform. The program can be deployed independently on cloud servers or edge computing nodes, selecting the deployment location based on the application scenario. The program supports version management; during upgrades, files in the storage medium are updated via differential updates or full replacements to ensure system functionality iteration and stability.
[0123] On the other hand, the present invention proposes an electronic device comprising: at least one processor; a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform any of the power system anomaly detection methods.
[0124] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Dual Data SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchlink DRAM (SLDRAM), Rambus Direct RAM (RDRAM), Direct Memory Bus Dynamic RAM (DRDRAM), and Memory Bus Dynamic RAM (RDRAM). The various embodiments described in this specification are presented in a progressive manner, and similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on describing the differences from other embodiments. In particular, for embodiments of apparatus, devices, and non-volatile computer storage media, since they are substantially similar to the method embodiments, the description is relatively simple, and relevant parts can be referred to the description of the method embodiments.
[0125] The above embodiments are merely illustrative examples and are not intended to limit the implementation. Those skilled in the art will recognize that other variations or modifications can be made based on the above description. It is neither necessary nor possible to exhaustively list all possible implementations. However, obvious variations or modifications derived therefrom are still within the scope of protection of this invention.
Claims
1. A method for detecting anomalies in a power system, characterized in that, include: The raw time-series data of power load is preprocessed to output a structured augmented sample sequence, which is divided into a training subset and a validation subset. The training subset is processed by hybrid sparse attention to generate neighborhood feature components, periodic interval long-distance feature components, and sequence start and end anchor point context feature components. After fusing the neighborhood feature components, the periodic interval long-distance feature components, and the sequence beginning and end anchor point context feature components, the high-dimensional spatiotemporal features of the training phase are output. The high-dimensional spatiotemporal features of the training phase are input into the prediction head network, and the prediction output corresponding to the mask position of the training phase is output. The deviation loss between the prediction output and the reference information is calculated, and the network parameters are updated according to the deviation loss to obtain the trained power anomaly detection model. The power anomaly detection model includes a feature extraction network. The sample to be detected is input into the power anomaly detection model, which outputs high-dimensional spatiotemporal features of the inference stage, and calculates multiple anomaly indicators based on the high-dimensional spatiotemporal features of the inference stage. The multiple anomaly indicators are then fused to obtain a comprehensive anomaly score. A dynamic threshold is determined based on the validation subset. If the overall anomaly score exceeds the dynamic threshold, then... Output power abnormality alarm results.
2. The power system anomaly detection method according to claim 1, characterized in that, The preprocessing specifically includes: Acquire raw time-series data of power load; The original time-series power load data was filled using linear interpolation to obtain data for restoring missing values. Anomaly suppression processing is performed on the missing value recovery data to obtain anomaly-processed data. The anomaly handling data is standardized to obtain standardized data; The standardized data is processed using a sliding window strategy to obtain intermediate time series samples. The intermediate time series samples are subjected to periodic time feature encoding processing, and the time dimension periodic information is superimposed to obtain the structured enhanced sample sequence.
3. The power system anomaly detection method according to claim 1, characterized in that, The hybrid sparse attention extracts features independently from the local short-term dimension, the periodic long-distance dimension, and the sequence global dimension, resulting in three complementary spatiotemporal feature components.
4. The power system anomaly detection method according to claim 3, characterized in that, The long-distance characteristic component of the periodic interval is set according to the inherent periodic characteristics of the power load to match the periodic change pattern of power consumption time sequence.
5. The power system anomaly detection method according to claim 1, characterized in that, The feature extraction network embeds temporal location information, enabling the output high-dimensional spatiotemporal features to carry temporal sequence correlation characteristics. The high-dimensional spatiotemporal features include the high-dimensional spatiotemporal features of the training phase and the high-dimensional spatiotemporal features of the inference phase.
6. The power system anomaly detection method according to any one of claims 1 to 5, characterized in that, During the model training phase, a multi-task self-supervised constraint approach is adopted, utilizing unlabeled temporal information to assist in optimizing feature extraction capabilities.
7. The power system anomaly detection method according to claim 6, characterized in that, The multi-task self-supervised learning includes three complementary learning tasks: temporal mask reconstruction, temporal order discrimination, and feature comparison learning.
8. The power system anomaly detection method according to claim 6, characterized in that, By combining generative adversarial networks to construct temporal reconstruction constraints, the model's ability to represent normal power consumption patterns can be enhanced.
9. The power system anomaly detection method according to claim 8, characterized in that, The multiple abnormal indicators simultaneously include self-supervised task deviation information and temporal reconstruction difference information.
10. The power system anomaly detection method according to any one of claims 1 to 5, characterized in that, The multiple abnormal indicators are adaptively weighted and fused, and the weights of each indicator are dynamically matched according to the overall distribution characteristics of the sample.
11. The power system anomaly detection method according to any one of claims 1 to 5, characterized in that, Differential fusion weights are configured for the neighborhood feature components, the periodic interval long-distance feature components, and the sequence beginning and end anchor point context feature components. Non-equal weight fusion is performed on the three feature components to obtain the high-dimensional spatiotemporal features of the training stage.
12. The power system anomaly detection method according to any one of claims 1 to 5, characterized in that, The dynamic threshold is adaptively adjusted based on the comprehensive anomaly score distribution of the verification subset under different load conditions to adapt to the score offset caused by changes in load level.
13. The power system anomaly detection method according to any one of claims 1 to 5, characterized in that, Also includes: Obtain the comprehensive anomaly score at multiple time points; Based on the abnormal temporal continuity, the comprehensive abnormal score of the multiple time points is verified and corrected to eliminate false abnormalities caused by instantaneous random noise, and then an abnormal alarm judgment is performed.
14. The power system anomaly detection method according to any one of claims 1 to 5, characterized in that, When outputting the abnormal alarm result, the abnormal score level and the corresponding time position information of the abnormality are output simultaneously.
15. A power system anomaly detection system, characterized in that, For implementing the power system anomaly detection method as described in any one of claims 1 to 8, the system comprises: The data preprocessing module is used to preprocess the raw time-series data of power load, output a structured augmented sample sequence, and divide the structured augmented sample sequence into a training subset and a validation subset; The feature extraction module is equipped with a hybrid sparse attention unit to process the training subset, generate neighborhood feature components, periodic interval long-distance feature components, and sequence beginning and end anchor context feature components, and fuse the three feature components to output high-dimensional spatiotemporal features during the training phase. The model training module is used to input the high-dimensional spatiotemporal features of the training phase into the prediction head network, output the prediction output corresponding to the mask position of the training phase, calculate the deviation loss based on the deviation between the prediction output and the reference information, update the network parameters according to the deviation loss, and obtain the trained power anomaly detection model. The power anomaly detection model includes a feature extraction network. An anomaly reasoning module is used to input the sample to be detected into the power anomaly detection model, output high-dimensional spatiotemporal features of the reasoning stage, calculate multiple anomaly indicators based on the high-dimensional spatiotemporal features of the reasoning stage, and fuse the multiple anomaly indicators to obtain a comprehensive anomaly score. The threshold determination and alarm module is used to determine a dynamic threshold based on the verification subset, and output a power anomaly alarm result when the comprehensive anomaly score exceeds the dynamic threshold.
16. A computer storage medium, characterized in that, The device contains a computer program that, when executed by a processor, implements the power system anomaly detection method as described in any one of claims 1 to 14.