Power grid-oriented deep learning model backdoor anomaly detection method, device and equipment

CN123013090APending Publication Date: 2026-10-30ELECTRIC POWER RES INST CHINA SOUTHERN POWER GRID CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611360295.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-03
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0005]本申请提供了面向电网的深度学习模型后门异常检测方法、装置及设备,用于解决现有技术检测灵敏度不足且容易误判、模型训练开销大且对网络结构依赖性强,检测结果缺乏可解释性,导致实际检测的精度和效率均较差的技术问题

Benefits of technology

[0052]本申请中,提供了面向电网的深度学习模型后门异常检测方法,包括:对采集的电网系统数据进行图结构分析,并执行标准化特征提取操作,得到电网物理特征向量,电网系统数据包括测量数据、用电行为数据和物理拓扑关系;在初始Transformer架构中引入动态特征增强机制与注意力稳定约束,生成目标预测模型;将电网物理特征向量输入目标预测模型进行预测训练,记录不同时刻的预测输出量和各注意力层的注意力矩阵;根据电网物理特征向量计算物理加权得分,同时依据注意力矩阵计算注意力变化参数,注意力变化参数包括注意力变化强度和响应一致性指标;结合预测输出量、物理加权得分和注意力变化参数计算后门风险的综合评分,并根据综合评分确定后门异常等级。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123013090A_ABST
    Figure CN123013090A_ABST
Patent Text Reader

Abstract

The application discloses a power grid-oriented deep learning model backdoor anomaly detection method, device and equipment, which comprises the following steps: standardizing feature extraction of power grid system data to obtain a power grid physical feature vector; introducing a dynamic feature enhancement mechanism and attention stability constraint in an initial Transformer architecture to generate a target prediction model; inputting the power grid physical feature vector into the target prediction model for prediction training, recording prediction output and attention matrix of each attention layer at different time points; calculating a physical weighting score according to the power grid physical feature vector, and calculating an attention change parameter according to the attention matrix; combining the prediction output, the physical weighting score and the attention change parameter to calculate a comprehensive score of the backdoor risk, and determining a backdoor anomaly level according to the comprehensive score. Therefore, the application can solve the technical problems of insufficient detection sensitivity, easy misjudgment, large model overhead, strong dependence on structure and lack of explanation of the detection result in the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of power system technology, and in particular to a method, apparatus and equipment for detecting backdoor anomalies in deep learning models for power grids. Background Technology

[0002] With the widespread deployment of smart grids, power systems are generating massive amounts of time-series operational data. The Transformer model, with its powerful self-attention mechanism, is widely used in smart grid analysis scenarios such as load forecasting and fault diagnosis. However, the security issues of deep learning models are becoming increasingly prominent. If backdoor triggers are maliciously implanted into the training data, the model will produce erroneous outputs under specific triggering conditions, posing a serious security threat to the power grid, a critical infrastructure. A backdoor attack refers to a security threat in which attackers illegally implant backdoor programs into software, hardware, or systems to gain unauthorized access to or control of the target system.

[0003] Monitoring techniques for backdoor attacks mainly include data analysis, model output analysis, training process monitoring, retraining and auditing, and adversarial training. Data analysis methods use anomaly detection algorithms such as Isolation Forest and Support Vector Machines to identify samples deviating from the normal distribution. Model output analysis techniques generate adversarial examples to verify the consistency of model output. Training process monitoring involves analyzing the model's attention map and intermediate layer features, observing their distribution and changes; abnormal attention distributions or features may indicate the presence of backdoors. Retraining and auditing methods involve retraining on clean datasets to remove potential backdoors; simultaneously, interpretive models are used for auditing, analyzing feature importance, which helps in discovering backdoors. Adversarial training methods introduce potential backdoor samples during training to enhance model robustness and reduce the risk of attack.

[0004] However, current backdoor attack detection technologies still have shortcomings. For example, data analysis methods rely on the statistical differences of abnormal samples, making it difficult to identify hidden backdoor samples that are highly similar to normal data distributions, resulting in insufficient detection sensitivity. Moreover, monitoring the training process requires in-depth analysis of the model's internal mechanisms, incurring high computational costs and strong dependence on the model structure. In addition, model output analysis methods are greatly affected by the model's own stability, making it difficult to distinguish between normal fluctuations and backdoor anomalies, easily leading to misjudgments. Furthermore, existing methods generally lack interpretability support for detection results, making it difficult to pinpoint the specific mechanism of backdoor attacks. Therefore, the actual backdoor attack detection accuracy, computational efficiency, and interpretability are all poor, making it difficult to ensure the secure operation of deep learning models for smart grids. Summary of the Invention

[0005] This application provides a method, apparatus, and equipment for detecting backdoor anomalies in deep learning models for power grids. It addresses the technical problems of existing technologies, such as insufficient detection sensitivity leading to easy misjudgment, high model training overhead and strong dependence on network structure, and lack of interpretability of detection results, resulting in poor accuracy and efficiency in actual detection.

[0006] In view of this, the first aspect of this application provides a method for backdoor anomaly detection in deep learning models for power grids, including:

[0007] Graph structure analysis is performed on the collected power grid system data, and standardized feature extraction is carried out to obtain the power grid physical feature vector. The power grid system data includes measurement data, electricity consumption behavior data, and physical topology relationships.

[0008] A dynamic feature enhancement mechanism and attention stabilization constraint are introduced into the initial Transformer architecture to generate a target prediction model;

[0009] The power grid physical feature vector is input into the target prediction model for prediction training, and the prediction output and attention matrix of each attention layer are recorded at different times.

[0010] A physical weighted score is calculated based on the physical feature vector of the power grid, and attention change parameters are calculated based on the attention matrix. The attention change parameters include the intensity of attention change and the response consistency index.

[0011] A comprehensive score for backdoor risk is calculated by combining the predicted output, the physical weighted score, and the attention change parameter, and the backdoor anomaly level is determined based on the comprehensive score.

[0012] Preferably, the step of performing graph structure analysis on the collected power grid system data and executing standardized feature extraction operations to obtain the power grid physical feature vector includes:

[0013] The PMU collects high-frequency synchronous voltage and current of the power grid system, and the AMI obtains load power and user electricity consumption data to determine the physical topology relationship between distribution network nodes and generate power grid system data.

[0014] Dynamic time alignment based on a sliding time window is performed on the power grid system data to obtain power grid time series data;

[0015] A power grid structure diagram is constructed based on the power grid time series data, and a power grid node state matrix and a high-dimensional spatiotemporal feature tensor are generated.

[0016] The high-dimensional spatiotemporal feature tensor is subjected to adaptive standardization and features are extracted to obtain the power grid physical feature vector. The adaptive standardization process includes normalization, encoding and statistical elimination.

[0017] Preferably, the step of calculating the physical weighted score based on the power grid physical feature vector and simultaneously calculating the attention change parameter based on the attention matrix includes:

[0018] The contribution of each type of physical feature is calculated based on the power grid physical feature vector, and a physical weighted score is calculated based on the contribution.

[0019] The magnitude of attention change in adjacent time intervals is calculated based on the attention matrix to obtain the intensity of attention change;

[0020] The local response of each attention head is analyzed using the attention matrix, and a consistency index is calculated to obtain the response consistency index.

[0021] Preferably, the step of calculating a comprehensive score for backdoor risk by combining the predicted output, the physical weighted score, and the attention change parameter, and determining the backdoor anomaly level based on the comprehensive score, includes:

[0022] Analyze the magnitude of change in the predicted output at adjacent time points and define the magnitude of change in the model output;

[0023] A joint risk index is obtained by combining the physical weighted score and the attention change parameter;

[0024] The comprehensive score of backdoor risk is obtained by weighting the changes in the model output, the joint risk index, and the intensity of the attention change.

[0025] Based on the comprehensive score, the power grid system data is divided into multiple different anomaly levels to determine the backdoor anomaly level.

[0026] Preferably, the step of calculating a comprehensive score for backdoor risk by combining the predicted output, the physical weighted score, and the attention change parameter, and determining the backdoor anomaly level based on the comprehensive score, further includes:

[0027] If the backdoor anomaly level is low risk, then the power grid system data will be verified a second time.

[0028] If the backdoor anomaly level is medium risk, then extract the location of the abnormal power grid node and reduce the model weight corresponding to the current abnormal node data.

[0029] If the backdoor anomaly level is high risk, an isolation mechanism will be triggered to remove the abnormal data samples.

[0030] Preferably, the step of calculating a comprehensive score for backdoor risk by combining the predicted output, the physical weighted score, and the attention change parameter, and determining the backdoor anomaly level based on the comprehensive score, further includes:

[0031] Based on the attention matrix, calculate multiple attention change statistics to determine the attention change trend;

[0032] Record the time information of the model training process, the location of the power grid node, the predicted output, the comprehensive score, the intensity of the attention change and the trend of the attention change, and construct a backdoor attack risk feature library.

[0033] The second aspect of this application provides a backdoor anomaly detection device for deep learning models in power grids, comprising:

[0034] The feature construction unit is used to perform graph structure analysis on the collected power grid system data and perform standardized feature extraction operations to obtain the power grid physical feature vector. The power grid system data includes measurement data, electricity consumption behavior data and physical topology relationships.

[0035] The model generation unit is used to introduce dynamic feature enhancement mechanisms and attention stabilization constraints into the initial Transformer architecture to generate a target prediction model.

[0036] The training and monitoring unit is used to input the power grid physical feature vector into the target prediction model for prediction training, and record the prediction output and attention matrix of each attention layer at different times.

[0037] The change calculation unit is used to calculate the physical weighted score based on the power grid physical feature vector, and at the same time calculate the attention change parameters based on the attention matrix. The attention change parameters include the attention change intensity and the response consistency index.

[0038] An anomaly detection unit is used to calculate a comprehensive score of backdoor risk by combining the predicted output, the physical weighted score, and the attention change parameter, and to determine the backdoor anomaly level based on the comprehensive score.

[0039] Preferably, the feature construction unit is specifically used for:

[0040] The PMU collects high-frequency synchronous voltage and current of the power grid system, and the AMI obtains load power and user electricity consumption data to determine the physical topology relationship between distribution network nodes and generate power grid system data.

[0041] Dynamic time alignment based on a sliding time window is performed on the power grid system data to obtain power grid time series data;

[0042] A power grid structure diagram is constructed based on the power grid time series data, and a power grid node state matrix and a high-dimensional spatiotemporal feature tensor are generated.

[0043] The high-dimensional spatiotemporal feature tensor is subjected to adaptive standardization and features are extracted to obtain the power grid physical feature vector. The adaptive standardization process includes normalization, encoding and statistical elimination.

[0044] Preferably, the change calculation unit is specifically used for:

[0045] The contribution of each type of physical feature is calculated based on the power grid physical feature vector, and a physical weighted score is calculated based on the contribution.

[0046] The magnitude of attention change in adjacent time intervals is calculated based on the attention matrix to obtain the intensity of attention change;

[0047] The local response of each attention head is analyzed using the attention matrix, and a consistency index is calculated to obtain the response consistency index.

[0048] The third aspect of this application provides a backdoor anomaly detection device for deep learning models in power grids, the device including a processor and a memory;

[0049] The memory is used to store program code and transmit the program code to the processor;

[0050] The processor is used to execute the method for detecting backdoor anomalies in a deep learning model for power grids as described in the first aspect, according to the instructions in the program code.

[0051] As can be seen from the above technical solutions, the embodiments of this application have the following advantages:

[0052] This application provides a method for backdoor anomaly detection using a deep learning model for power grids, comprising: performing graph structure analysis on collected power grid system data and performing standardized feature extraction operations to obtain power grid physical feature vectors, wherein the power grid system data includes measurement data, electricity consumption behavior data, and physical topology relationships; introducing a dynamic feature enhancement mechanism and attention stability constraints into the initial Transformer architecture to generate a target prediction model; inputting the power grid physical feature vectors into the target prediction model for prediction training, recording the prediction output and attention matrices of each attention layer at different times; calculating a physical weighted score based on the power grid physical feature vectors, and simultaneously calculating attention change parameters based on the attention matrices, wherein the attention change parameters include attention change intensity and response consistency index; combining the prediction output, physical weighted score, and attention change parameters to calculate a comprehensive score for backdoor risk, and determining the backdoor anomaly level based on the comprehensive score.

[0053] This application provides a backdoor anomaly detection method for deep learning models targeting power grids. It comprehensively analyzes both the physical characteristics of the power grid and the attention behavior of the model from two dimensions. This allows for both capturing abnormal disturbances at the physical level of the power grid to achieve prediction goals and analyzing and monitoring local anomalies in the model through attention change analysis. These two approaches enable complementary backdoor detection, improving detection sensitivity. Furthermore, this process does not require complete analysis of the model's internal mechanisms or full training; it only requires synchronously recording the attention matrix of the attention layer during training. Subsequent parameter calculations and comprehensive scoring based on this matrix can achieve backdoor detection, significantly reducing computational resource consumption. In addition, the introduction of attention stability constraints in the model limits the magnitude of abrupt changes in attention distribution, compressing the space of normal fluctuations. The introduction of a response consistency index during calculation measures the temporal coherence of attention behavior, distinguishing normal model fluctuations from abnormal offsets triggered by backdoors, reducing false positives. Moreover, the entire process uses multi-dimensional parameter calculations, including physical weighted scores, attention change intensity, and response consistency indices, combined with the predicted output to calculate a comprehensive score. This provides multi-source, multi-dimensional parameters for risk assessment, with each dimension of information independently traceable, interpretable, and accountable for the source of the detection results. Therefore, this application can solve the technical problems of insufficient detection sensitivity and easy misjudgment in existing technologies, large model training overhead and strong dependence on network structure, lack of interpretability of detection results, resulting in poor accuracy and efficiency in actual detection. Attached Figure Description

[0054] Figure 1 A flowchart illustrating the backdoor anomaly detection method for a deep learning model for power grids provided in this application embodiment;

[0055] Figure 2 A schematic diagram of the backdoor anomaly detection device for a deep learning model for power grids provided in this application embodiment;

[0056] Figure 3 This is an example diagram illustrating the overall process of backdoor anomaly detection using a deep learning model for power grids, as provided in an embodiment of this application. Detailed Implementation

[0057] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.

[0058] For easier understanding, please refer to Figure 1The embodiments of the backdoor anomaly detection method for deep learning models for power grids provided in this application include:

[0059] Step 101: Perform graph structure analysis on the collected power grid system data and perform standardized feature extraction to obtain the power grid physical feature vector. The power grid system data includes measurement data, electricity consumption behavior data, and physical topology relationships.

[0060] It should be noted that the power grid system data in this embodiment includes power grid information of different dimensions from various heterogeneous systems, belonging to the multi-source heterogeneous operation data of the smart grid system; specifically, it can be obtained in different ways, such as PMU or AMI. The power grid system data includes various information such as operating parameter information, electricity consumption behavior information, and physical topology, and can be added to the design according to the actual detection task, without specific limitations here.

[0061] Based on power grid system data, a topology graph structure can be constructed. The node set and edge set can accurately describe the relationships between nodes. Moreover, the node set can provide sample data for precise location of subsequent backdoor anomaly detection, quickly finding the target abnormal node data. The standardized feature extraction process includes standardization processing and feature extraction processing. Standardization processing is mainly to unify the dimensions of power grid system data to facilitate subsequent analysis. Feature extraction integrates the power grid system data into a vector format that meets the model input requirements, i.e., the power grid physical feature vector.

[0062] Further, step 101 includes:

[0063] The PMU collects high-frequency synchronous voltage and current of the power grid system, and the AMI obtains load power and user electricity consumption data to determine the physical topology relationship between distribution network nodes and generate power grid system data.

[0064] Dynamic time alignment based on a sliding time window is performed on the power grid system data to obtain power grid time series data;

[0065] A power grid structure diagram is constructed based on power grid time series data, and a power grid node state matrix and a high-dimensional spatiotemporal feature tensor are generated.

[0066] Adaptive standardization is performed on the high-dimensional spatiotemporal feature tensor, and features are extracted to obtain the power grid physical feature vector. The adaptive standardization process includes normalization, encoding, and statistical elimination.

[0067] It should be noted that this embodiment mainly acquires multi-source heterogeneous operation data in real time from the smart grid system. Specifically, it collects high-frequency synchronous voltage and current phasor data through the synchronous phasor measurement unit (PMU); acquires load power and user electricity consumption behavior data sequences through the advanced metering architecture (AMI); and acquires the physical topology relationships between distribution network nodes. This information is used as the power grid system data.

[0068] Since there are significant differences in the data sampling frequency of different devices, this embodiment also designs a dynamic time alignment mechanism. Specifically, it uses a sliding time window to uniformly map power grid system data at different time scales, thereby ensuring the consistency of heterogeneous data on the same time axis.

[0069] The power grid time series data obtained after time alignment can be used to construct a power grid diagram structure, i.e., a power grid structure diagram, which can be expressed as follows: ,in, For a set of nodes, Let be the set of connections between nodes, i.e., the set of edges. For each time t, a power grid node state matrix can be constructed. The power grid node state matrices at all times can then form a unified high-dimensional spatiotemporal feature tensor, which can be specifically expressed as: Where N represents the number of nodes, T represents the time step, and F represents the dimension of the power grid physical features; this high-dimensional spatiotemporal feature tensor not only preserves the dynamic operation law of the power grid system, but also implicitly encodes the spatial coupling relationship between nodes, which can provide unified and complete data support for subsequent backdoor anomaly attack detection.

[0070] Since the power grid system data in this embodiment is multi-source heterogeneous data, the standardization process is not a simple normalization process, but includes different preprocessing operations such as normalization and encoding. It should be noted that during the standardization process, the high-dimensional spatiotemporal feature tensor... The node dimension N and time dimension T remain unchanged, and only the feature dimension F is standardized to ensure that the model can accurately capture both spatial topological information and temporal dynamic information at the same time.

[0071] For continuous numerical data in high-dimensional spatiotemporal feature tensors, such as node voltage magnitude, load power, and current phasor offset, Min-Max normalization can be used to eliminate the influence of dimensions.

[0072]

[0073] in, , These represent the running data after normalization and before normalization, respectively. , These represent the minimum and maximum values ​​of the data being run for the current data type, respectively.

[0074] For discrete state information, such as circuit breaker open / close status, equipment start / stop flags, and operating mode codes, discrete labels can be used for encoding, such as One-Hot encoding; alternatively, it can be input into the model as an independent feature type along with other standardized data. Care should be taken not to disrupt the inherent semantic boundaries of the information during standardization. For absolute time features, such as timestamps, they can be directly converted into relative time offsets or periodic time codes, such as the nth sampling point of the day.

[0075] Standardized data sequences can be identified using the interquartile range (IQR) statistical method, and these extreme outliers can be removed to prevent extreme values ​​caused by instantaneous power grid disturbances (such as lightning strikes or short circuits) from stretching the normalization interval, thereby effectively reducing noise interference in subsequent model training.

[0076] Standardized data obtained after standardization processing Feature extraction can be performed to obtain the physical feature vector of the power grid. This embodiment uses a feature extraction function. Feature extraction is performed to obtain the set of physical features of the power grid, namely the physical feature vector of the power grid.

[0077] Step 102: Introduce a dynamic feature enhancement mechanism and attention stabilization constraints into the initial Transformer architecture to generate a target prediction model.

[0078] The basic framework of the deep learning model used in this embodiment is Transformer. The core aspects of backdoor anomaly detection in the target prediction model mainly include mechanism introduction, attention analysis, and feature processing. Furthermore, the target prediction model has two main output tasks: one is the normal power grid task prediction output structure, such as load forecasting or state estimation; the other is the real-time capture of attention-related parameters during training to analyze attention evolution characteristics. Combining these two output tasks for subsequent computation and analysis enables accurate backdoor anomaly detection.

[0079] To enhance the model's ability to detect local anomalies in the power grid, this embodiment introduces a dynamic feature enhancement mechanism during the model input phase. Specifically, after extracting features from the initial power grid data, it also calculates the feature changes between adjacent time windows, such as load change rate, voltage fluctuation rate, and node power offset. If a certain feature vector of a node at time t is... ,in, , , These represent the characteristics of voltage, power, and current, respectively; based on this, the rate of change characteristics can be constructed:

[0080]

[0081] Then, the original feature vector is fused with the constructed rate of change feature:

[0082]

[0083] Generated fusion features These are the enhanced features, and this mechanism can enhance the model's ability to perceive sudden abnormal behaviors and hidden disturbances.

[0084] To address the issue that traditional attention mechanisms tend to overemphasize local strong features, leading to the hiding of backdoor triggers, this embodiment introduces temporal stability constraints, or attention stability constraints, on top of the standard Transformer attention mechanism. These constraints limit attention variations across different time windows. Specifically, the attention calculation formula can be expressed as:

[0085]

[0086] Where Q, K, and V represent the query matrix, key matrix, and value matrix, respectively. The attention stability constraint introduced to prevent abrupt shifts in the attention distribution due to outliers can be expressed as:

[0087]

[0088] in, This represents the attention matrix at time t, i.e., the multi-head attention weight matrix, with dimension 1. N represents the length of the input sequence; Each element in This represents the influence weight of the j-th input position on the i-th input position. Normal samples typically exhibit a relatively stable attention distribution, while backdoor anomaly samples, due to trigger effects, can lead to abnormally concentrated local attention. Therefore, this constraint can effectively enhance the model's ability to identify anomalous behavior.

[0089] Because this embodiment introduces an attention stabilization constraint, the model's loss function is a joint loss function, specifically expressed as follows:

[0090]

[0091] in, This represents either classification loss or regression loss, which is determined based on the model's task objective. This represents a regularization term used to prevent the model from overfitting. This indicates a constraint on attentional stability. , All of these are weight coefficients. By optimizing this joint loss function, the model can maintain the temporal stability of the attention distribution while completing the learning of the main task, thereby suppressing abnormal attention mutations caused by backdoor triggers.

[0092] Step 103: Input the power grid physical feature vector into the target prediction model for prediction training, and record the prediction output and attention matrix of each attention layer at different times.

[0093] By inputting the physical feature vectors of the power grid into the target prediction model for prediction training, relevant parameters for model training at each time window can be obtained, such as the predicted output at different times and the attention matrices of each attention layer. The predicted output between multiple adjacent time points can be used to calculate the magnitude of change and analyze the fluctuation of the prediction results; while the attention matrix can participate in the subsequent analysis of attention change characteristics, thereby achieving accurate backdoor anomaly detection.

[0094] Step 104: Calculate the physical weighted score based on the power grid physical feature vector, and at the same time calculate the attention change parameters based on the attention matrix. The attention change parameters include the intensity of attention change and the response consistency index.

[0095] It should be noted that the physical weighted score is essentially the result of a comprehensive summation of scores for different power grid physical characteristics. It is used to describe the contribution of power grid physical characteristics to the prediction results. The contribution of each physical characteristic can be calculated separately, and then the comprehensive score can be calculated by combining the preset contribution weights to obtain the physical weighted score.

[0096] The attention change parameters calculated in this embodiment include, but are not limited to, the intensity of attention change and the response consistency index. Other change parameter information, such as the attention mean and attention fluctuation value, can also be calculated. Any parameter that can reflect the change or evolution characteristics of attention can be calculated to evaluate the change characteristics of attention and thus control the backdoor mutation situation.

[0097] Further, step 104 includes:

[0098] The contribution of each type of physical feature is calculated based on the power grid physical feature vector, and a physical weighted score is calculated based on the contribution.

[0099] The magnitude of attention change between adjacent time periods is calculated based on the attention matrix to obtain the intensity of attention change;

[0100] The local response of each attention head is analyzed by attention matrix, and the consistency index is calculated to obtain the response consistency index.

[0101] It should be noted that the contribution of each type of power grid physical feature vector to the prediction task can be calculated, which can also be regarded as an assessment of the importance of physical features. Therefore, the calculation process of the contribution is as follows:

[0102]

[0103] in, This represents the mean of the physical eigenvectors. This represents the corresponding standard deviation and contribution score. A higher value indicates a more significant deviation of the object's characteristics from the normal range during abnormal periods, and a greater impact on prediction. Therefore, further analysis of the comprehensive deviation of physical characteristics can be conducted based on this. Also known as the physics weighted score, its calculation process is as follows:

[0104]

[0105] in, Let M be the deviation weighting coefficient corresponding to the i-th physical feature, and M be the total number of physical features. The deviation weighting coefficient can be set according to the sensitivity of the feature type to grid stability; for example, the weight of voltage features can be higher than that of power features, and the sum of all deviation weighting coefficients must be 1. Furthermore, the physical weighted score... The larger the value, the more significant the deviation of the current sample in multiple physical dimensions, and the higher the risk of it being a potential backdoor sample.

[0106] It should be noted that in normal samples, the attention distribution typically exhibits continuity and stability during model inference, meaning that attention changes smoothly across different time windows. However, in backdoor samples, under the influence of triggers, the model may exhibit abnormal attention to local input regions, causing abrupt changes in the attention distribution within a short period. Therefore, this embodiment focuses on analyzing the trend of attention changes over time, rather than relying solely on statistical values ​​at a single moment for backdoor detection.

[0107] Specifically, the intensity of attention change can be obtained by calculating the magnitude of attention changes between adjacent time periods based on the attention matrix:

[0108]

[0109] Wherein, the attention matrix at time t medium elements This represents the influence weight of the j-th input position on the i-th input position; This refers to the intensity of attentional changes, which is a scalar value, typical of normal samples. Typically, the intensity is relatively small, but backdoor samples, during the triggering phase, cause a rapid concentration of local attention, resulting in a sudden change in the overall matrix structure and thus a significantly increased intensity of attention changes. Understandably, since the attention matrix cannot be directly calculated using scalar differences across time periods, this embodiment uses the Frobenius norm to measure the temporal variation of attention distribution and obtain the intensity of attention change.

[0110] To avoid low detection accuracy due to a single detection criterion, this embodiment introduces a local response consistency analysis mechanism. If the local response value of each attention head is analyzed using the attention matrix... Then, we can calculate the consistency index to obtain the response consistency index:

[0111]

[0112] in, Let be the average response value of all attention heads, and N be the number of attention heads. In normal samples, the attention heads usually have good dispersion, while in backdoor samples, there is a tendency for local responses to be abnormally consistent.

[0113] Step 105: Calculate the comprehensive score of backdoor risk by combining the predicted output, physical weighted score and attention change parameters, and determine the backdoor anomaly level based on the comprehensive score.

[0114] The process of calculating the comprehensive score of backdoor risk by combining the predicted output, physical weighted score and attention change parameters takes into account the backdoor detection impact of multiple different dimensions of parameters. Moreover, these parameters can be independently traced, ensuring that both the calculation process and the detection results are interpretable, thus guaranteeing the reliability of the detection results.

[0115] Based on the comprehensive score, backdoor anomalies can be classified into multiple anomaly levels. The specific criteria for level classification can be designed according to the actual situation, such as scoring thresholds, which compare the comprehensive score with different scoring thresholds to determine different backdoor anomaly levels. The number of backdoor anomaly levels can be designed as needed, such as two, three, or more levels; only the level classification needs to be implemented, so there is no limitation here.

[0116] Further, step 105 includes:

[0117] Analyze the magnitude of change in the predicted output at adjacent time points and define the magnitude of change in the model output;

[0118] By combining the physics-weighted score and the attention change parameter, a joint risk index is obtained.

[0119] The comprehensive score of backdoor risk is obtained by weighting the changes in model output, joint risk indicators, and the intensity of attention changes.

[0120] Based on the comprehensive score, the power grid system data is divided into multiple different anomaly levels to determine the backdoor anomaly level.

[0121] Specifically, by calculating the difference between the predicted outputs of two adjacent time points, the magnitude of change in the current time period can be obtained; alternatively, the Euclidean distance or KL divergence can be calculated based on the predicted outputs of two adjacent time points, and used as the model output change O. Either one can be used for calculation, and there is no limitation here; the model output change is used to describe the magnitude of change in the prediction results for the same input sample within adjacent time windows.

[0122] Combined with physics weighted score Intensity of attention changes and response consistency metrics We can perform a weighted calculation to obtain the joint risk index value S:

[0123]

[0124] in, , , These are the weight coefficients corresponding to each parameter. This weighted fusion of physical and attention features avoids data leakage and model performance degradation caused by differences in feature dimensions and temporal asynchrony. If the joint risk index value S exceeds the preset risk threshold, it can be directly determined that the current sample data has a backdoor risk; however, to achieve more accurate anomaly level classification and detection, this embodiment requires further calculation and analysis.

[0125] Next, based on the model output change O, the joint risk index S, and the intensity of attention change... By performing a weighted calculation, a comprehensive score for the backdoor risk can be obtained:

[0126]

[0127] in, , , This is the risk weighting coefficient; used to adjust the contribution of different risk factors to the overall score. Based on the overall score and a preset risk threshold range, the backdoor anomaly level can be classified. In this embodiment, samples are divided into three levels: low risk, medium risk, and high risk. For the overall detection process, please refer to [link to relevant documentation]. Figure 3 .

[0128] Furthermore, step 105, followed by:

[0129] If the backdoor anomaly level is low risk, then the power grid system data will be verified a second time.

[0130] If the backdoor anomaly level is medium risk, then extract the location of the abnormal power grid node and reduce the model weight corresponding to the current abnormal node data.

[0131] If the backdoor anomaly level is high risk, the isolation mechanism will be triggered to remove the abnormal data samples.

[0132] This embodiment does not use the conventional alarm mode after classifying the risk levels. Instead, it designs corresponding adjustment strategies for different risk levels. For low risk, the power grid system data samples are re-verified and then re-input into the model for prediction training, while monitoring changes in the model's attention. For medium risk, the model weights of samples classified as medium-risk abnormalities are reduced to decrease the impact of abnormal data on the model results. For high risk, the isolation mechanism is triggered directly to isolate abnormal samples, remove the corresponding abnormal data from the dataset, and then the model is locally corrected again.

[0133] Furthermore, step 105, followed by:

[0134] Calculate multiple statistics on attention changes based on the attention matrix to determine the trend of attention changes;

[0135] Record the time information, grid node location, predicted output, comprehensive score, intensity of attention change and attention change trend during the model training process, and construct a backdoor attack risk feature library.

[0136] To enhance the model's defense capabilities, this embodiment can also design an abnormal feature update mechanism to record the changes in attention parameters, predicted output, and related node information corresponding to backdoor samples. Furthermore, it can calculate various other attention change statistics based on the attention matrix and construct a backdoor attack risk feature database by combining multiple attention change parameters, output change parameters, and various information from the model training process. ,in, This represents the characteristics of the i-th type of abnormal behavior. With this database, similar behaviors in the risk feature database can be analyzed in a limited way in subsequent detection tasks, thereby improving detection efficiency. The specific process will not be elaborated here.

[0137] It is understood that the information recorded during the model training process in this embodiment includes, but is not limited to, time information, grid node location, predicted output, comprehensive score, intensity of attention change and attention change trend. Other directly acquired information or indirect parameters calculated based on the acquired information to reflect the change characteristics of adjacent time periods or long time periods can also be recorded as needed. No specific limitations are imposed.

[0138] For example, attention change statistics calculated based on the attention matrix can include the attention mean, attention fluctuation value, and local peaks. The attention mean reflects the model's overall attention baseline to the global input at the current moment; the attention fluctuation value reflects the drastic change in attention weights between adjacent time steps; and the local peaks reflect whether the model shows abnormally concentrated attention to a specific input position. These statistics are all characteristic parameters that reflect the trend of attention changes and can be comprehensively analyzed by combining the above detection results. They will not be elaborated further here but can be added as needed. For example, the attention fluctuation value... The calculation process is as follows:

[0139]

[0140] in, Let represent the response value of the i-th attention head at time t. Let be the average response value of all attention heads at time t.

[0141] The backdoor anomaly detection method for deep learning models targeting power grids provided in this application provides a comprehensive analysis of both the physical characteristics of the power grid and the attention behavior of the model. This allows for both capturing abnormal disturbances at the physical level of the power grid to achieve prediction goals and analyzing and monitoring local anomalies in the model through attention change analysis. These two approaches enable complementary backdoor detection, improving detection sensitivity. Furthermore, this process does not require complete analysis of the model's internal mechanisms or full training; it only requires synchronously recording the attention matrix of the attention layer during training. Subsequent parameter calculations and comprehensive scoring based on this matrix can achieve backdoor detection, significantly reducing computational resource consumption. Additionally, the introduction of attention stability constraints in the model limits the magnitude of abrupt changes in attention distribution, compressing the space for normal fluctuations. The introduction of a response consistency index during calculation measures the temporal coherence of attention behavior, distinguishing normal model fluctuations from abnormal offsets triggered by backdoors, reducing false positives. Moreover, the entire process uses multi-dimensional parameter calculations, including physical weighted scores, attention change intensity, and response consistency indices, combined with the predicted output to calculate a comprehensive score. This provides multi-source, multi-dimensional parameters for risk assessment, with each dimension of information independently traceable, interpretable, and accountable for the source of the detection results. Therefore, the embodiments of this application can solve the technical problems of insufficient detection sensitivity and easy misjudgment in the prior art, large model training overhead and strong dependence on network structure, lack of interpretability of detection results, resulting in poor accuracy and efficiency of actual detection.

[0142] For easier understanding, please refer to Figure 2 This application provides an embodiment of a backdoor anomaly detection device for deep learning models for power grids, including:

[0143] The feature construction unit 201 is used to perform graph structure analysis on the collected power grid system data and perform standardized feature extraction operations to obtain the power grid physical feature vector. The power grid system data includes measurement data, electricity consumption behavior data and physical topology relationships.

[0144] Model generation unit 202 is used to introduce dynamic feature enhancement mechanism and attention stabilization constraint into the initial Transformer architecture to generate target prediction model;

[0145] The training and monitoring unit 203 is used to input the power grid physical feature vector into the target prediction model for prediction training, and record the prediction output and attention matrix of each attention layer at different times.

[0146] The change calculation unit 204 is used to calculate the physical weighted score based on the power grid physical feature vector, and at the same time calculate the attention change parameters based on the attention matrix. The attention change parameters include the attention change intensity and the response consistency index.

[0147] Anomaly detection unit 205 is used to calculate a comprehensive score of backdoor risk by combining the predicted output, physical weighted score and attention change parameters, and to determine the backdoor anomaly level based on the comprehensive score.

[0148] Furthermore, the feature construction unit 201 is specifically used for:

[0149] The PMU collects high-frequency synchronous voltage and current of the power grid system, and the AMI obtains load power and user electricity consumption data to determine the physical topology relationship between distribution network nodes and generate power grid system data.

[0150] Dynamic time alignment based on a sliding time window is performed on the power grid system data to obtain power grid time series data;

[0151] A power grid structure diagram is constructed based on power grid time series data, and a power grid node state matrix and a high-dimensional spatiotemporal feature tensor are generated.

[0152] Adaptive standardization is performed on the high-dimensional spatiotemporal feature tensor, and features are extracted to obtain the power grid physical feature vector. The adaptive standardization process includes normalization, encoding, and statistical elimination.

[0153] Furthermore, the change calculation unit 204 is specifically used for:

[0154] The contribution of each type of physical feature is calculated based on the power grid physical feature vector, and a physical weighted score is calculated based on the contribution.

[0155] The magnitude of attention change between adjacent time periods is calculated based on the attention matrix to obtain the intensity of attention change;

[0156] The local response of each attention head is analyzed by attention matrix, and the consistency index is calculated to obtain the response consistency index.

[0157] This application also provides a backdoor anomaly detection device for deep learning models for power grids, the device including a processor and a memory;

[0158] The memory is used to store program code and transfer the program code to the processor;

[0159] The processor is used to execute the backdoor anomaly detection device method for a deep learning model oriented towards the power grid in the above method embodiment according to the instructions in the program code.

[0160] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0161] The units described as separate components may or may not be physically separate. 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 units can be selected to achieve the purpose of this embodiment according to actual needs.

[0162] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0163] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for executing all or part of the steps of the methods described in the various embodiments of this application through a computer device (which may be a personal computer, server, or network device, etc.). The aforementioned storage medium includes: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, optical disks, and other media capable of storing program code.

[0164] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.

Claims

1. A backdoor anomaly detection method for deep learning models in power grids, characterized in that, include: Graph structure analysis is performed on the collected power grid system data, and standardized feature extraction is carried out to obtain the power grid physical feature vector. The power grid system data includes measurement data, electricity consumption behavior data, and physical topology relationships. A dynamic feature enhancement mechanism and attention stabilization constraint are introduced into the initial Transformer architecture to generate a target prediction model; The power grid physical feature vector is input into the target prediction model for prediction training, and the prediction output and attention matrix of each attention layer are recorded at different times. A physical weighted score is calculated based on the physical feature vector of the power grid, and attention change parameters are calculated based on the attention matrix. The attention change parameters include the intensity of attention change and the response consistency index. A comprehensive score for backdoor risk is calculated by combining the predicted output, the physical weighted score, and the attention change parameter, and the backdoor anomaly level is determined based on the comprehensive score.

2. The backdoor anomaly detection method for deep learning models for power grids according to claim 1, characterized in that, The process involves performing graph structure analysis on the collected power grid system data and executing standardized feature extraction operations to obtain the power grid physical feature vector, including: The PMU collects high-frequency synchronous voltage and current of the power grid system, and the AMI obtains load power and user electricity consumption data to determine the physical topology relationship between distribution network nodes and generate power grid system data. Dynamic time alignment based on a sliding time window is performed on the power grid system data to obtain power grid time series data; A power grid structure diagram is constructed based on the power grid time series data, and a power grid node state matrix and a high-dimensional spatiotemporal feature tensor are generated. The high-dimensional spatiotemporal feature tensor is subjected to adaptive standardization and features are extracted to obtain the power grid physical feature vector. The adaptive standardization process includes normalization, encoding and statistical elimination.

3. The backdoor anomaly detection method for deep learning models for power grids according to claim 1, characterized in that, The step of calculating the physical weighted score based on the power grid physical feature vector and simultaneously calculating the attention change parameters based on the attention matrix includes: The contribution of each type of physical feature is calculated based on the power grid physical feature vector, and a physical weighted score is calculated based on the contribution. The magnitude of attention change in adjacent time intervals is calculated based on the attention matrix to obtain the intensity of attention change; The local response of each attention head is analyzed using the attention matrix, and a consistency index is calculated to obtain the response consistency index.

4. The backdoor anomaly detection method for deep learning models for power grids according to claim 1, characterized in that, The process of calculating a comprehensive score for backdoor risk by combining the predicted output, the physical weighted score, and the attention change parameter, and determining the backdoor anomaly level based on the comprehensive score, includes: Analyze the magnitude of change in the predicted output at adjacent time points and define the magnitude of change in the model output; A joint risk index is obtained by combining the physical weighted score and the attention change parameter; The comprehensive score of backdoor risk is obtained by weighting the changes in the model output, the joint risk index, and the intensity of the attention change. Based on the comprehensive score, the power grid system data is divided into multiple different anomaly levels to determine the backdoor anomaly level.

5. The backdoor anomaly detection method for deep learning models for power grids according to claim 1, characterized in that, The process involves calculating a comprehensive score for backdoor risk by combining the predicted output, the physical weighted score, and the attention change parameter, and determining the backdoor anomaly level based on the comprehensive score. This process further includes: If the backdoor anomaly level is low risk, then the power grid system data will be verified a second time. If the backdoor anomaly level is medium risk, then extract the location of the abnormal power grid node and reduce the model weight corresponding to the current abnormal node data. If the backdoor anomaly level is high risk, an isolation mechanism will be triggered to remove the abnormal data samples.

6. The backdoor anomaly detection method for deep learning models for power grids according to claim 1, characterized in that, The process involves calculating a comprehensive score for backdoor risk by combining the predicted output, the physical weighted score, and the attention change parameter, and determining the backdoor anomaly level based on the comprehensive score. This process further includes: Based on the attention matrix, calculate multiple attention change statistics to determine the attention change trend; Record the time information of the model training process, the location of the power grid node, the predicted output, the comprehensive score, the intensity of the attention change and the trend of the attention change, and construct a backdoor attack risk feature library.

7. A backdoor anomaly detection device for deep learning models in power grids, characterized in that, include: The feature construction unit is used to perform graph structure analysis on the collected power grid system data and perform standardized feature extraction operations to obtain the power grid physical feature vector. The power grid system data includes measurement data, electricity consumption behavior data and physical topology relationships. The model generation unit is used to introduce dynamic feature enhancement mechanisms and attention stabilization constraints into the initial Transformer architecture to generate a target prediction model. The training and monitoring unit is used to input the power grid physical feature vector into the target prediction model for prediction training, and record the prediction output and attention matrix of each attention layer at different times. The change calculation unit is used to calculate the physical weighted score based on the power grid physical feature vector, and at the same time calculate the attention change parameters based on the attention matrix. The attention change parameters include the attention change intensity and the response consistency index. An anomaly detection unit is used to calculate a comprehensive score of backdoor risk by combining the predicted output, the physical weighted score, and the attention change parameter, and to determine the backdoor anomaly level based on the comprehensive score.

8. The backdoor anomaly detection device for deep learning models for power grids according to claim 7, characterized in that, The feature construction unit is specifically used for: The PMU collects high-frequency synchronous voltage and current of the power grid system, and the AMI obtains load power and user electricity consumption data to determine the physical topology relationship between distribution network nodes and generate power grid system data. Dynamic time alignment based on a sliding time window is performed on the power grid system data to obtain power grid time series data; A power grid structure diagram is constructed based on the power grid time series data, and a power grid node state matrix and a high-dimensional spatiotemporal feature tensor are generated. The high-dimensional spatiotemporal feature tensor is subjected to adaptive standardization and features are extracted to obtain the power grid physical feature vector. The adaptive standardization process includes normalization, encoding and statistical elimination.

9. The backdoor anomaly detection device for deep learning models in power grids according to claim 7, characterized in that, The change calculation unit is specifically used for: The contribution of each type of physical feature is calculated based on the power grid physical feature vector, and a physical weighted score is calculated based on the contribution. The magnitude of attention change in adjacent time intervals is calculated based on the attention matrix to obtain the intensity of attention change; The local response of each attention head is analyzed using the attention matrix, and a consistency index is calculated to obtain the response consistency index.

10. A backdoor anomaly detection device for deep learning models in power grids, characterized in that, The device includes a processor and a memory; The memory is used to store program code and transmit the program code to the processor; The processor is configured to execute the method of the backdoor anomaly detection device for deep learning models oriented towards power grids according to any one of the instructions in the program code.