A smart grid electricity stealing detection method, device, equipment and medium

CN122594958APending Publication Date: 2026-08-18STATE GRID BEIJING ELECTRIC POWER CO
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202610665167.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-14
Publication Date
2026-08-18

AI Technical Summary

Technical Problem

[0007]本发明的目的在于提供一种智能电网窃电检测方法、装置、设备及介质,解决背景技术中智能电网窃电检测不准确的问题

Benefits of technology

通过设置全局特征提取模型和局部特征提取模型,分别从用户日用电量序列中提取全局特征向量和局部特征向量,并将二者融合后输出窃电概率,能够同时兼顾用户长期用电规律和短期局部异常用电模式;全局特征提取模型用于提取用户完整用电序列中的整体变化趋势和全局统计特征,局部特征提取模型用于将日用电量序列转换为二维周矩阵,并依次进行局部异常信号增强、卷积特征转换、残差特征提取、通道注意力重标定以及池化输出处理,从而提取周级别细粒度局部异常特征,能够缓解单一特征提取方式难以同时兼顾全局长期特征和局部短期异常特征的问题,提高窃电检测结果的准确性和稳定性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122594958A_ABST
    Figure CN122594958A_ABST
Patent Text Reader

Abstract

The present application belongs to the technical field of smart grid electricity stealing detection, and particularly relates to a smart grid electricity stealing detection method, device, equipment and medium. The method comprises: acquiring a daily electricity consumption sequence of a user; inputting the daily electricity consumption sequence into a preset global feature extraction model to acquire a global feature vector; inputting the daily electricity consumption sequence into a preset local feature extraction model to acquire a local feature vector; the local feature extraction model converts the daily electricity consumption sequence into a two-dimensional week matrix, sequentially performs local abnormal signal enhancement, convolution feature conversion, residual feature extraction, channel attention re-labeling and pooling output processing, and extracts the local feature vector; fuses the global feature vector and the local feature vector to acquire a fusion feature, inputs the fusion feature into a classifier, and the classifier outputs an electricity stealing probability; and determines an electricity stealing detection result according to the electricity stealing probability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of smart grid electricity theft detection technology, specifically relating to a smart grid electricity theft detection method, device, equipment, and medium. Background Technology

[0002] With the widespread application of smart meters and advanced metering systems in power distribution networks, daily electricity consumption data of power users can be continuously collected and stored, providing a data foundation for electricity consumption behavior analysis and electricity theft detection. Electricity theft is typically committed through methods such as tampering with meters, illegal bypass wiring, or manipulating meter readings, resulting in electricity revenue losses for power companies and affecting the accuracy of distribution network line loss statistics and operation management. Therefore, intelligent detection of electricity theft based on users' historical electricity consumption data has become an important technological direction in the field of smart grid electricity management.

[0003] Traditional methods of detecting electricity theft mainly rely on manual inspections, on-site verification, and rule-based anomaly comparisons. These methods typically identify suspicious users by checking the installation status of electricity meters, comparing historical changes in user electricity consumption, or investigating abnormal wiring. However, in distribution network scenarios with a large number of users and significant differences in electricity consumption behavior, these methods suffer from high labor costs, low detection efficiency, and difficulty in timely detecting concealed electricity theft.

[0004] With the development of machine learning methods, supervised algorithms such as support vector machines, random forests, and gradient boosting models have been used for electricity theft detection. These methods can extract statistical features based on historical meter data and use classification models to determine whether users have abnormal electricity consumption behavior, thus improving detection efficiency to some extent. However, these methods usually rely on manual feature engineering and have limited ability to represent complex nonlinear electricity consumption patterns, periodic changes, and short-term abnormal fluctuations, making it difficult to fully adapt to the diverse electricity theft behaviors in real power distribution networks.

[0005] In recent years, deep learning methods have been increasingly applied to the field of electricity theft detection. Existing methods include processing user electricity consumption data as a one-dimensional time series to learn long-term electricity consumption trends; converting electricity consumption data into two-dimensional data according to weekly, monthly, or other periodic structures, and using convolutional neural networks to extract local periodic features; and employing a network structure combining wide and deep models to extract features from both the one-dimensional electricity consumption sequence and the two-dimensional electricity consumption matrix, then outputting the electricity theft detection results through a classifier. Compared to traditional machine learning methods, these methods can automatically learn some electricity consumption features, resulting in a certain improvement in the accuracy of electricity theft detection. However, in actual smart grid electricity theft detection scenarios, the abnormal electricity consumption features corresponding to electricity theft behavior often do not always manifest as long-term, continuous, and significant changes in electricity consumption, but may only manifest as localized sudden drops, continuous low values, short-term abnormal fluctuations, or disruptions to periodic electricity consumption patterns at the weekly or daily level. These localized abnormal features typically have characteristics such as short duration, unstable amplitude changes, and sparse distribution, making them easily confused with the random electricity fluctuations of normal users. If only ordinary convolutional networks are used to extract features from two-dimensional electricity consumption data, the model may have difficulty highlighting local abnormal signals at the input stage, resulting in insufficient distinguishability of fine-grained electricity theft features.

[0006] Chinese invention patent CN114841253A discloses a method for detecting electricity theft, comprising: acquiring user electricity consumption data, wherein the electricity consumption data includes time series data of electricity consumption parameters; inputting the electricity consumption data into a trained feature representation model to obtain a time feature vector, wherein the feature representation model is trained using a self-supervised learning method; and using a trained anomaly detection model to perform anomaly detection on the time feature vector to obtain the user's electricity theft category. The above scheme gradually extracts high-level semantic features through multiple convolution, pooling, or downsampling operations. However, features such as local mutations and short-term abnormal low values ​​in electricity theft behavior are themselves relatively sparse and short-lived. They may be gradually smoothed or diluted during deep convolution and downsampling, making it difficult for the model to retain local anomaly information that is of great significance for electricity theft identification, thereby reducing the ability to identify subtle or low-intensity electricity theft behavior. Moreover, different channel features have different effects on the electricity theft detection results. Some channels may correspond to local mutations, periodic disruptions, or abnormal low value features related to electricity theft behavior, while some channels may mainly reflect normal electricity fluctuations or irrelevant noise. Existing methods, which simply perform conventional stacking or pooling on convolutional features, cannot adaptively distinguish the importance of different channel features according to the electricity theft detection task. This can easily lead to insufficient expression of key abnormal channels and significant noise interference in irrelevant channels. Summary of the Invention

[0007] The purpose of this invention is to provide a method, device, equipment and medium for detecting electricity theft in smart grids, thereby solving the problem of inaccurate electricity theft detection in smart grids in the prior art.

[0008] To achieve the above objectives, the present invention adopts the following technical solution: In a first aspect, the present invention provides a method for detecting electricity theft in a smart grid, comprising: Obtain the user's daily electricity consumption sequence; The daily electricity consumption sequence is input into a preset global feature extraction model to obtain a global feature vector; The daily electricity consumption sequence is input into a preset local feature extraction model to obtain local feature vectors; the local feature extraction model converts the daily electricity consumption sequence into a two-dimensional weekly matrix, and sequentially performs local abnormal signal enhancement, convolutional feature transformation, residual feature extraction, channel attention recalibration, and pooling output processing to extract local feature vectors; The global feature vector and the local feature vector are fused to obtain the fused feature. The fused feature is then input into a classifier, which outputs the probability of electricity theft. The electricity theft detection result is determined based on the stated probability of electricity theft.

[0009] Preferably, the step of performing global statistical pattern modeling on the daily electricity consumption sequence to obtain a global feature vector specifically includes: The daily electricity consumption sequence is input into the global feature extraction model as a complete electricity consumption sequence. The complete electricity consumption sequence is feature-mapped by the first fully connected layer to obtain the first global mapping feature; the first global mapping feature is then subjected to batch normalization and ReLU activation processing to obtain the first global intermediate feature. The first global intermediate feature is randomly deactivated by the Dropout layer connected to the first fully connected layer to obtain the second global intermediate feature; The second global intermediate feature is dimensionality-reduced and mapped by a second fully connected layer connected to the Dropout layer, and then the global feature vector is output after ReLU activation.

[0010] Preferably, the step of extracting local spatiotemporal features from the daily electricity consumption sequence to obtain local feature vectors specifically includes: The daily electricity consumption sequence is reshaped into a two-dimensional weekly matrix according to the weekly cycle; The two-dimensional periodic matrix is ​​subjected to local anomaly signal enhancement to obtain a local feature map after differential enhancement; The local feature map after differential enhancement is converted into a convolutional feature map with a resolution corresponding to the two-dimensional periodic matrix; Residual features are extracted from the convolutional feature map to obtain local residual features; The residual local features are recalibrated by the SE channel attention module to obtain the recalibrated residual local features. Local feature vectors are obtained based on the residual local features after channel recalibration.

[0011] Preferably, the step of fusing the global feature vector and the local feature vector to obtain fused features specifically includes: The global feature vector and the local feature vector are concatenated along the feature dimension to obtain a joint feature vector; The joint feature vector is input into the fusion module, and the joint feature vector is mapped through the first fusion fully connected layer to obtain the first fusion mapped feature. The first fused mapping feature is sequentially subjected to batch normalization, nonlinear activation, and random deactivation to obtain the first fused intermediate feature. The first fused intermediate features are dimensionality-reduced and mapped using a second fused fully connected layer, and then nonlinear activation is performed to obtain the fused features.

[0012] Preferably, the step of inputting the fused features into a classifier, and the classifier outputting the probability of electricity theft, specifically includes: The fused features are input into the output layer of the classifier, and the fused features are linearly mapped through the output layer to obtain the classification mapping value; Based on the classification mapping value, the probability of electricity theft for each user is obtained by performing probability transformation through the Sigmoid activation function.

[0013] Preferably, the step of determining the electricity theft detection result based on the electricity theft probability specifically includes: The probability of electricity theft is compared with a preset probability threshold: When the probability of electricity theft is greater than or equal to the preset probability threshold, the user's electricity theft detection result is determined to indicate a risk of electricity theft. When the probability of electricity theft is less than the preset probability threshold, the user's electricity theft detection result is determined to be that there is no risk of electricity theft.

[0014] Preferably, before inputting the user's daily electricity consumption sequence, the system also trains a global feature extraction model and a local feature extraction model. During training, Focal Loss is used as the loss function to address the class imbalance problem in the dataset caused by the low proportion of electricity theft users. ; in, This represents the predicted probability corresponding to the true category. Represents the category balance factor. γ This indicates the focus parameter.

[0015] In a second aspect, the present invention provides a smart grid electricity theft detection device, comprising: The acquisition module is used to acquire the user's daily electricity consumption sequence; A global feature extraction module is used to input the daily electricity consumption sequence into a preset global feature extraction model to obtain a global feature vector; The local feature extraction module is used to input the daily electricity consumption sequence into a preset local feature extraction model to obtain local feature vectors. The local feature extraction model converts the daily electricity consumption sequence into a two-dimensional weekly matrix and sequentially performs local abnormal signal enhancement, convolutional feature transformation, residual feature extraction, channel attention recalibration, and pooling output processing to extract local feature vectors. The fusion and classification module is used to fuse the global feature vector and the local feature vector to obtain fused features, input the fused features into a classifier, and output the probability of electricity theft from the classifier. The detection module is used to determine the electricity theft detection result based on the electricity theft probability.

[0016] In a third aspect, the present invention provides an electronic device including a processor and a memory, the processor being configured to execute a computer program stored in the memory to implement the aforementioned smart grid electricity theft detection method.

[0017] In a fourth aspect, the present invention provides a computer-readable storage medium storing at least one instruction that, when executed by a processor, implements the smart grid electricity theft detection method.

[0018] Compared with the prior art, the beneficial effects of the present invention are as follows: By setting up a global feature extraction model and a local feature extraction model, global and local feature vectors are extracted from the user's daily electricity consumption sequence, respectively. The two are then fused to output the probability of electricity theft, which can simultaneously take into account the user's long-term electricity consumption patterns and short-term local abnormal electricity consumption patterns. The global feature extraction model is used to extract the overall trend and global statistical features in the user's complete electricity consumption sequence, while the local feature extraction model is used to convert the daily electricity consumption sequence into a two-dimensional weekly matrix and sequentially perform local abnormal signal enhancement, convolutional feature transformation, residual feature extraction, channel attention recalibration, and pooling output processing to extract fine-grained local abnormal features at the weekly level. This can alleviate the problem that a single feature extraction method cannot simultaneously take into account both global long-term features and local short-term abnormal features, and improve the accuracy and stability of electricity theft detection results.

[0019] By performing feature mapping on the complete electricity consumption sequence through the first fully connected layer, and combining batch normalization and ReLU activation, the nonlinear modeling capability of global feature representation can be enhanced. Random deactivation through the Dropout layer can reduce the risk of model overfitting. Dimensionality reduction mapping through the second fully connected layer can form a compact global feature vector, which can more accurately represent the user's electricity consumption level, changing trend and overall fluctuation pattern over time, providing global feature basis for subsequent fusion and discrimination.

[0020] By performing periodic reshaping and local spatiotemporal feature extraction on the electricity consumption sequence through a local feature extraction process, the ability to identify short-term, sparse, and low-intensity electricity theft features can be enhanced. The electricity consumption sequence is reshaped into a two-dimensional periodic matrix according to the periodicity, which can utilize the periodic structure of the electricity consumption data. Local anomalous signal enhancement is performed on the two-dimensional periodic matrix to improve the distinguishability of fine-grained features such as local abrupt changes, continuous low values, and abnormal fluctuations. Convolutional feature transformation converts the local feature map after differential enhancement into a convolutional feature map suitable for deep network processing. Residual feature extraction can preserve local anomalous information and alleviate feature degradation in the deep feature extraction process. Channel recalibration is performed through the SE channel attention module to adaptively emphasize key channels related to electricity theft and suppress noise in irrelevant channels. Finally, local feature vectors are obtained based on the residual local features after channel recalibration, thereby improving the model's sensitivity to subtle abnormal electricity consumption behavior.

[0021] By concatenating global and local feature vectors along the feature dimension and performing feature mapping, normalization, nonlinear activation, random deactivation, and dimensionality reduction through a fusion module, the nonlinear interaction between the two feature paths can be fully modeled. Compared to using only single-path features or simple classification output, this approach can jointly express global long-term electricity consumption patterns and local short-term anomaly patterns, enabling the fused features to simultaneously contain long-term trend information and local anomaly information, thereby improving the classifier's ability to detect complex electricity theft behaviors.

[0022] By linearly mapping the fused features through the classifier output layer and performing probability transformation through the Sigmoid activation function, the fused features can be converted into an intuitive probability of electricity theft, representing the likelihood of a user engaging in electricity theft. This facilitates power companies in prioritizing risks, conducting key inspections, and arranging on-site audits based on the probability magnitude.

[0023] By comparing the probability of electricity theft with a preset probability threshold to determine the detection result, clear and executable judgment rules can be formed. When the probability of electricity theft is greater than or equal to the preset probability threshold, it is determined that the user has a risk of electricity theft; when the probability of electricity theft is less than the preset probability threshold, it is determined that the user does not have a risk of electricity theft. The threshold can be flexibly adjusted according to different regions, different business scenarios or different inspection strategies, thereby improving the adaptability and practicality of the electricity theft detection method.

[0024] Using Focal Loss as the loss function can alleviate the class imbalance problem in the dataset caused by the low proportion of electricity theft users. Focal Loss adjusts the contribution of different samples to the loss function through class balance factors and focusing parameters, which can reduce the loss weight of easily classified majority class samples and make the model training pay more attention to the difficult-to-identify minority class electricity theft samples, reduce the problem of model bias towards normal user samples, and improve the detection ability of rare electricity theft behavior and low-intensity abnormal electricity consumption behavior. Attached Figure Description

[0025] The accompanying drawings, which form part of this application, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an undue limitation of the invention. In the drawings: Figure 1 This is a schematic diagram comparing the global electricity consumption curves of normal users and electricity thieves in Embodiment 1 of the present invention. The curve of normal users is continuous and stable, while the curve of electricity thieves shows repeated sharp drops and continuous abnormally low values. Figure 2 This is a schematic diagram comparing the local weekly electricity consumption patterns of normal users and electricity thieves in Embodiment 1 of the present invention. The weekly curves of normal users are relatively consistent, while electricity thieves exhibit abnormally low values ​​throughout the week and sudden and severe fluctuations. Figure 3 This is a flowchart of a smart grid electricity theft detection method according to Embodiment 1 of the present invention; Figure 4 This is a flowchart of the global feature extraction process for a smart grid electricity theft detection method according to Embodiment 1 of the present invention; Figure 5 This is a flowchart of a local feature extraction method for a smart grid electricity theft detection method according to Embodiment 1 of the present invention; Figure 6 This is a flowchart illustrating the full fusion and classification process of a smart grid electricity theft detection method according to Embodiment 1 of the present invention. Figure 7 This is a structural block diagram of the smart grid electricity theft detection device according to an embodiment of the present invention; Figure 8 This is a structural block diagram of an electronic device according to an embodiment of the present invention. Detailed Implementation

[0026] The present invention will now be described in detail with reference to the accompanying drawings and embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other.

[0027] The following detailed description is exemplary and intended to provide further detailed explanation of the invention. Unless otherwise specified, all technical terms used in this invention have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. The terminology used in this invention is for the purpose of describing particular embodiments only and is not intended to limit the scope of exemplary embodiments according to the invention.

[0028] Example 1 like Figure 3 As shown, a smart grid electricity theft detection method includes: S1. Obtain the user's daily electricity consumption sequence; Specifically, obtain the daily electricity consumption data for each user over 1036 days: The daily electricity consumption data is sorted according to the collection date to form a daily electricity consumption sequence; ; in, Indicates user number t Daily electricity consumption.

[0029] The daily electricity consumption sequence is normalized to eliminate differences in the dimensions and numerical ranges of electricity consumption among different users, resulting in a normalized electricity consumption sequence: ; in,

[0030] In one implementation, a max-min normalization process is used: ; in, This represents the minimum value in the daily electricity consumption sequence. This represents the maximum value in the daily electricity consumption sequence. To prevent constants with a denominator of zero.

[0031] Preferably, at least one of missing values, outliers, and non-numerical data in the daily electricity consumption sequence is corrected to obtain a corrected daily electricity consumption sequence; Based on the statistics of the corrected daily electricity consumption sequence, the corrected daily electricity consumption sequence is normalized to obtain a normalized electricity consumption sequence.

[0032] S2. Input the daily electricity consumption sequence into a preset global feature extraction model to obtain a global feature vector.

[0033] like Figure 4 As shown, specifically: The normalized electricity consumption sequence The complete electricity consumption sequence is input into the global feature extraction model; The global feature extraction model uses a fully connected network to model the global statistical pattern of the complete 1036-day electricity consumption sequence.

[0034] The global feature extraction model includes: The first fully connected layer is used to project the 1036-dimensional input to 256 dimensions, followed by batch normalization (BN) and ReLU activation to obtain the first global intermediate features. Specifically, the 1036-dimensional input is projected to 256 dimensions through the first fully connected layer to obtain the first global mapping feature. : ; in, This represents the weight parameters of the first fully connected layer. This represents the bias parameters of the first fully connected layer.

[0035] The first global mapping feature is subjected to batch normalization and ReLU activation sequentially to obtain the activated first global intermediate feature. : ; in, This indicates batch normalization processing. This represents the ReLU activation function.

[0036] The Dropout layer is connected to the first fully connected layer to prevent overfitting.

[0037] Specifically, for the first global intermediate feature Random inactivation is performed to reduce the risk of overfitting: ; In this embodiment, the random deactivation probability of the Dropout layer is: p =0.15.

[0038] The second fully connected layer, connected to the Dropout layer, is used to compress the 256-dimensional vector to 128-dimensional vectors, followed by ReLU activation, and outputs a 128-dimensional global feature vector. : ; in, , representing the global feature vector. This represents the weight parameters of the second fully connected layer. This represents the bias parameters of the second fully connected layer.

[0039] Through the above two-stage fully connected transformation, the global feature extraction model can capture the nonlinear long-range time-series features and global statistical regularities spanning a complete 1036-day electricity consumption sequence.

[0040] S3. Input the daily electricity consumption sequence into a preset local feature extraction model to obtain local feature vectors.

[0041] like Figure 5 As shown, for the local feature extraction model, the normalized electricity consumption sequence is reshaped into a two-dimensional periodic matrix according to the periodic period. : ; in, Indicates the week number. This indicates the weekday position, where 148 represents the week number and 7 represents the number of days in a week. Indicates the first Zhou Di The daily electricity consumption value corresponding to the week number is used to provide input for subsequent local spatiotemporal feature extraction by utilizing the weekly periodic structure of user electricity consumption data.

[0042] Preferably, for each matrix element in the two-dimensional periodic matrix Select data from the previous few weeks that have the same weekday position as the current element to form a historical sample set with the same weekday position: ; in, Indicates the current element The corresponding historical sample set of the same week, Preset historical week number.

[0043] Based on the historical sample set of the same week Determine the weekday reference value corresponding to the current matrix element. and fluctuation tolerance In one specific implementation, the weekday reference value is the median of the historical sample set for the same weekday, and the fluctuation tolerance is the absolute median difference of the historical sample set for the same weekday, i.e.: ; ; in, To prevent extremely small positive numbers with a denominator of zero, a baseline value and fluctuation tolerance are determined according to the same week period. This allows the current daily electricity consumption to be compared with historical electricity consumption data with the same week period attributes, thereby reducing the impact of differences in electricity consumption patterns across different week periods on anomaly detection.

[0044] After determining the weekday reference value and fluctuation tolerance, calculate the standardized deviation of the current matrix element relative to its weekday reference value: ; Simultaneously determine the deviation direction of the current matrix element: ; in, Used to indicate the degree to which the current daily electricity consumption deviates from the normal electricity consumption level for the same week. This indicates whether the current daily electricity consumption deviates from the weekday reference value by an increase or a decrease.

[0045] Furthermore, to avoid misjudging random fluctuations on a single day as abnormal, this embodiment introduces the concept of consecutive deviations between adjacent dates. Specifically, the two-dimensional weekly matrix is ​​expanded chronologically, and a preset number of dates before and after the date corresponding to the current matrix element are determined as the set of adjacent dates. For each adjacent date in the set of adjacent dates, its standardized deviation degree and deviation direction are calculated. When the standardized deviation degree of an adjacent date is greater than a first preset deviation threshold, and its deviation direction is consistent with the deviation direction of the current matrix element, it is determined that the adjacent date and the current matrix element constitute a continuous deviation in the same direction. Based on the number and intensity of consecutive deviations in the same direction, the continuous deviation degree of adjacent dates is calculated. : ; in, The first preset deviation threshold, This is an indicator function. When multiple adjacent dates contain data that deviate from the current matrix element in the same direction and exceed a threshold, the degree of continuous deviation between the adjacent dates increases, indicating that the anomaly is more likely to originate from continuous abnormal electricity consumption behavior.

[0046] Furthermore, this embodiment also introduces the deviation degree of the same week position period. Specifically, data with the same week position as the current matrix element within a preset number of weeks prior to the current matrix element are selected. It is determined whether these historical data with the same week position have a deviation in the same direction as the current matrix element that exceeds a second preset deviation threshold, and the deviation degree of the same week position period is calculated. : ; in, The historical week number used for determining cycle deviation. This is the second preset deviation threshold. When the current matrix element and the same week position of the previous several weeks all deviate in the same direction, the degree of deviation of the same week position increases, which is used to characterize the correlation between the anomaly and the user's weekly electricity consumption pattern.

[0047] After obtaining the standardized deviation of the current matrix elements Degree of consecutive deviation between adjacent dates and the degree of deviation of the same week period Then, a local anomaly enhancement coefficient is generated based on the combined results of the three factors. In one specific embodiment, the local anomaly enhancement coefficient is calculated according to the following formula: ; in, The maximum enhancement amplitude coefficient, For the Sigmoid function, , , These are the weighting coefficients for the degree of standardized deviation, the degree of consecutive deviation between adjacent dates, and the degree of deviation within the same week period, respectively. To enhance the trigger threshold.

[0048] Therefore, the local anomaly enhancement coefficient is determined not only by the degree of deviation of the current matrix element from the reference value of the same week, but also by the degree of continuous deviation of adjacent dates and the degree of deviation of the same week period. When the current matrix element has only isolated slight deviation, the local anomaly enhancement coefficient is close to 1; when the current matrix element has significant deviation, and this deviation is consistent with the continuous anomalies of adjacent dates or the anomalies of the same week period, the local anomaly enhancement coefficient increases.

[0049] Finally, the corresponding matrix elements in the two-dimensional Zhou matrix are reweighted using the local anomaly enhancement coefficients to obtain the local anomaly enhancement matrix: ; ; in, Represents the local anomaly enhancement matrix. This represents the reweighted matrix elements. The local anomaly enhancement matrix maintains the week number dimension and week position dimension of the original two-dimensional week matrix unchanged, and enables electricity consumption data with continuous or periodic anomaly features to obtain a higher response in the subsequent convolutional feature transformation process, thereby improving the local feature extraction branch's ability to identify short-term abnormal electricity consumption, intermittent abnormal electricity consumption, and periodic abnormal electricity consumption behavior.

[0050] The two-dimensional weekly matrix is ​​input into a local feature extraction model. The local feature extraction model includes, in sequence, a differential kernel preprocessing module, an initial convolution module, a residual block, an SE channel attention module, a global average pooling module, and a fully connected output module, including: The differential kernel preprocessing module is used to enhance the local anomaly matrix. Perform a 3x nearest neighbor space copy to generate an intermediate tensor. , Among them, 444 is 3 times 148, and 21 is 3 times 7.

[0051] Specifically: For local anomaly enhancement matrix The Middle Zhou Di Weekly Enhancement Elements Copy it to the enhanced copy tensor The corresponding non-overlapping 3×3 local block Within, the local block is represented as: ; The local block With Enhancement Elements One-to-one correspondence, used to carry the local differential response after subsequent differential transformation.

[0052] Within each 3×3 local block formed by spatial replication, for three adjacent observations , , Apply the difference transform: ; ; ; The result of the differential transformation is written into the corresponding 3×3 local block to obtain the local feature map after differential enhancement. : ; in, This indicates the differential kernel preprocessing operation.

[0053] The enhanced local feature map is input into the initial convolutional module. In this embodiment, 32 3×3 convolutional kernels are used with a stride of 3 to compress the spatially expanded input back to a resolution of 148×7. The output shape is as follows: ; The initial convolution process is represented as: ; in, This indicates a convolution operation with a kernel size of 3×3 and a stride of 3.

[0054] In this embodiment, each convolution is followed by BN and ReLU, and the convolution weights of the initial convolution module are initialized using KaimingNormal.

[0055] The convolutional feature map is input into the residual block for residual feature extraction. The residual block consists of two consecutive 3×3 convolutional layers, each followed by batch normalization, and the input of the residual block is added element-wise to the convolutional output through an identity shortcut connection.

[0056] When the number of input features and the number of channels in the convolution output features are the same, the residual block output is: ; in, The input features representing the residual block, This represents the output of the convolutional layer in the residual block after performing a nonlinear transformation on the input features. This represents the local characteristics of the residual.

[0057] When the number of channels in the input features and the convolutional output features are inconsistent, dimensionality matching of the shortcut path is performed through 1×1 convolution and batch normalization. The residual block output is: ; in, This represents a 1×1 convolution transformation used for dimension matching.

[0058] Introduce the first residual block to extend the channel depth from 32 to 64.

[0059] The first residual block is followed by the first SE channel attention module, which performs channel recalibration on the local features of the residual. The first SE channel attention module includes compression operation, excitation operation and channel recalibration operation.

[0060] Specifically: Perform global average pooling on the feature map of each channel to obtain the channel descriptor: ; in, Indicates the first c Each channel is located in eigenvalues ​​at that location H and W These represent the height and width of the feature map, respectively. Indicates the first c Channel descriptors for each channel.

[0061] Channel attention weights are generated using two fully connected layers: ; in, z This represents a vector composed of channel descriptors. Represents the ReLU activation function. This represents the Sigmoid activation function. and These represent the weight parameters of the two fully connected layers, respectively.

[0062] In this embodiment, the bottleneck compression ratio of the SE channel attention module is: ; And there are: , ; in, C Indicates the number of channels.

[0063] The residual local features are weighted channel-by-channel based on the channel attention weights: ; in, Indicates the first c Attention weights for each channel, Indicates the first c Local features of residuals after channel recalibration.

[0064] The first SE channel attention module enables the model to adaptively emphasize key channels relevant to electricity theft and suppress noise in irrelevant channels.

[0065] Then, downsampling is performed using a 2×2 max pooling layer with a pooling step size of 2, reducing the spatial resolution to 64×74×3.

[0066] The expanded features are then fed into a second residual block, which further expands the channel depth from 64 to 128. A second SE channel attention module is then connected after the residual block, and the configuration of the second SE channel attention module is the same as that of the first SE channel attention module.

[0067] Through progressive channel expansion, the local feature extraction model can gradually learn high-level periodic anomaly patterns from the low-level electricity consumption mutation features.

[0068] Global average pooling is applied to the 128-channel feature map to obtain the pooled local features: ; in, and These represent the height and width of the feature map, respectively.

[0069] A 128-dimensional local feature vector is output through a fully connected layer and the ReLU activation function: ; in, , representing a local eigenvector. This represents the weight parameters of the fully connected layer. This represents the bias parameters of the fully connected layer.

[0070] In this embodiment, a Dropout layer is set after the fully connected layer, and the random deactivation probability is: ; The weights of the fully connected layer are initialized using Xavier Uniform.

[0071] S4. The global feature vector and the local feature vector are fused to obtain the fused feature. The fused feature is then input into a classifier, and the classifier outputs the probability of electricity theft. Specifically: like Figure 6 As shown, the global feature vector and the local feature vector By concatenating the features along their respective dimensions, we obtain a 256-dimensional joint feature vector: ; in, This indicates a feature splicing operation.

[0072] The joint feature vector is input into the fusion module, and the joint feature vector is mapped through the first fusion fully connected layer to map the 256-dimensional joint representation to 128 dimensions, thus obtaining the first fusion mapping feature.

[0073] The first fused mapping feature is sequentially subjected to batch normalization, nonlinear activation, and random deactivation to obtain the first fused intermediate feature. ; in, This represents the weight parameters of the first fused fully connected layer. This represents the bias parameters of the first fused fully connected layer.

[0074] In this embodiment, the random deactivation probability of the Dropout layer is: .

[0075] The first fused intermediate features are dimensionality-reduced by a second fully connected fusion layer, mapping the 128-dimensional features to 64 dimensions, and then subjected to nonlinear activation to obtain the fused features. : ; in, , indicating fusion characteristics; This represents the weight parameters of the second fused fully connected layer. This represents the bias parameters of the second fused fully connected layer.

[0076] The fused features are input into the output layer of the classifier, and the output layer performs a linear mapping on the fused features to obtain the classification mapping value. : ; in, Represents the classification mapping value. Indicates the output layer weight parameters. This represents the output layer bias parameters.

[0077] Based on the classification mapping value, a probability transformation is performed using the Sigmoid activation function to obtain the probability of electricity theft for each user. : ; in, This indicates the probability that a user is stealing electricity.

[0078] S5. Determine the electricity theft detection result based on the stated electricity theft probability.

[0079] Specifically: Compare the probability of electricity theft with a preset probability threshold. Comparison: ; When the probability of electricity theft is greater than or equal to the preset probability threshold, the user's electricity theft detection result is determined to indicate a risk of electricity theft. When the probability of electricity theft is less than the preset probability threshold, the user's electricity theft detection result is determined to be that there is no risk of electricity theft.

[0080] Preferably, before inputting the user's daily electricity consumption sequence, the system also trains a global feature extraction model and a local feature extraction model. During training, Focal Loss is used as the loss function to address the class imbalance problem in the dataset caused by the low proportion of electricity theft users. ; in, This represents the predicted probability corresponding to the true category. Represents the category balance factor. γ This indicates the focus parameter.

[0081] In this embodiment, the category balance factor and the focusing parameter are set as follows: =0.75, γ=2.0; Focal Loss effectively mitigates the bias effect of class imbalance on the model by reducing the loss weight of easily separable samples and focusing on difficult-to-separate minority class samples.

[0082] The model optimizer uses AdamW, trained with a cosine annealing learning rate scheduling strategy. Model evaluation employs five-fold hierarchical cross-validation to ensure that the proportion of electricity theft users in each fold remains consistent with the proportion of electricity theft users in the original dataset.

[0083] In one implementation, this method is based on a PyTorch 1.13.1, Python 3.9, and CUDA 11.6 environment and runs on an NVIDIA RTX 3060 GPU.

[0084] Example 2 like Figure 7 As shown, based on the same inventive concept as the above embodiments, the present invention also provides a smart grid electricity theft detection device, comprising: The acquisition module is used to acquire the user's daily electricity consumption sequence; A global feature extraction module is used to input the daily electricity consumption sequence into a preset global feature extraction model to obtain a global feature vector; The local feature extraction module is used to input the daily electricity consumption sequence into a preset local feature extraction model to obtain local feature vectors. The local feature extraction model converts the daily electricity consumption sequence into a two-dimensional weekly matrix and sequentially performs local abnormal signal enhancement, convolutional feature transformation, residual feature extraction, channel attention recalibration, and pooling output processing to extract local feature vectors. The fusion and classification module is used to fuse the global feature vector and the local feature vector to obtain fused features, input the fused features into a classifier, and output the probability of electricity theft from the classifier. The detection module is used to determine the electricity theft detection result based on the electricity theft probability.

[0085] Example 3 like Figure 8 As shown, the present invention also provides an electronic device 100 for implementing a smart grid electricity theft detection method; The electronic device 100 includes a memory 101, at least one processor 102, a computer program 103 stored in the memory 101 and executable on at least one processor 102, and at least one communication bus 104.

[0086] The memory 101 can be used to store computer program 103. The processor 102 implements the steps of the smart grid electricity theft detection method of Embodiment 1 by running or executing the computer program stored in the memory 101 and calling the data stored in the memory 101.

[0087] The memory 101 may primarily include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created based on the use of the electronic device 100 (such as audio data), etc. In addition, the memory 101 may include non-volatile memory, such as hard disk, RAM, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other non-volatile solid-state storage device.

[0088] At least one processor 102 may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Processor 102 may be a microprocessor or any conventional processor. Processor 102 is the control center of electronic device 100, connecting various parts of electronic device 100 via various interfaces and lines.

[0089] The memory 101 in the electronic device 100 stores multiple instructions to implement a smart grid electricity theft detection method, and the processor 102 can execute multiple instructions to achieve the following: Obtain the user's daily electricity consumption sequence; The daily electricity consumption sequence is input into a preset global feature extraction model to obtain a global feature vector; The daily electricity consumption sequence is input into a preset local feature extraction model to obtain local feature vectors; the local feature extraction model converts the daily electricity consumption sequence into a two-dimensional weekly matrix, and sequentially performs local abnormal signal enhancement, convolutional feature transformation, residual feature extraction, channel attention recalibration, and pooling output processing to extract local feature vectors; The global feature vector and the local feature vector are fused to obtain the fused feature. The fused feature is then input into a classifier, which outputs the probability of electricity theft. The electricity theft detection result is determined based on the stated probability of electricity theft.

[0090] Example 4 If the modules / units integrated in the electronic device 100 are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, and read-only memory (ROM).

[0091] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0092] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0093] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0094] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0095] In the description of this specification, references to terms such as "an embodiment," "example," "specific example," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0096] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the specific implementation of the present invention. Any modifications or equivalent substitutions that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.

Claims

1. A method for detecting electricity theft in a smart grid, characterized in that, include: Obtain the user's daily electricity consumption sequence; The daily electricity consumption sequence is input into a preset global feature extraction model to obtain a global feature vector; The daily electricity consumption sequence is input into a preset local feature extraction model to obtain local feature vectors. The local feature extraction model converts the daily electricity consumption sequence into a two-dimensional weekly matrix and performs local abnormal signal enhancement, convolutional feature transformation, residual feature extraction, channel attention recalibration, and pooling output processing in sequence to extract local feature vectors. The global feature vector and the local feature vector are fused to obtain the fused feature. The fused feature is then input into a classifier, which outputs the probability of electricity theft. The electricity theft detection result is determined based on the stated probability of electricity theft.

2. The smart grid electricity theft detection method as described in claim 1, characterized in that, The step of inputting the daily electricity consumption sequence into a preset global feature extraction model to obtain a global feature vector specifically includes: The daily electricity consumption sequence is input into the global feature extraction model as a complete electricity consumption sequence. The complete electricity consumption sequence is feature-mapped by the first fully connected layer to obtain the first global mapping feature; the first global mapping feature is then subjected to batch normalization and ReLU activation processing to obtain the first global intermediate feature. The first global intermediate feature is randomly deactivated by the Dropout layer connected to the first fully connected layer to obtain the second global intermediate feature; The second global intermediate feature is dimensionality-reduced and mapped by a second fully connected layer connected to the Dropout layer, and then the global feature vector is output after ReLU activation.

3. The smart grid electricity theft detection method as described in claim 1, characterized in that, The step of inputting the daily electricity consumption sequence into a preset local feature extraction model to obtain local feature vectors specifically includes: The daily electricity consumption sequence is reshaped into a two-dimensional weekly matrix according to the weekly cycle; The two-dimensional periodic matrix is ​​subjected to local anomaly signal enhancement to obtain a local feature map after differential enhancement; The local feature map after differential enhancement is converted into a convolutional feature map with a resolution corresponding to the two-dimensional periodic matrix; Residual features are extracted from the convolutional feature map to obtain local residual features; The residual local features are recalibrated by the SE channel attention module to obtain the recalibrated residual local features. Local feature vectors are obtained based on the residual local features after channel recalibration.

4. The smart grid electricity theft detection method as described in claim 3, characterized in that, The steps of performing local anomalous signal enhancement on the two-dimensional periodic matrix to obtain the differentially enhanced local feature map specifically include: The elements in the two-dimensional periodic matrix are spatially copied along two dimensions to generate an intermediate tensor; Within the local block formed by spatial replication, differential transformation is performed on adjacent observations to obtain a differentially enhanced local feature map; The local block is a 3×3 local block, and the adjacent observations include , ,and The difference transform includes: ; ; 。 5. The smart grid electricity theft detection method as described in claim 1, characterized in that, The step of fusing the global feature vector and the local feature vector to obtain the fused feature vector specifically includes: The global feature vector and the local feature vector are concatenated along the feature dimension to obtain a joint feature vector; The joint feature vector is input into the fusion module, and the joint feature vector is mapped through the first fusion fully connected layer to obtain the first fusion mapped feature. The first fused mapping feature is sequentially subjected to batch normalization, nonlinear activation, and random deactivation to obtain the first fused intermediate feature. The first fused intermediate features are dimensionality-reduced and mapped using a second fused fully connected layer, and then nonlinear activation is performed to obtain the fused features.

6. The smart grid electricity theft detection method as described in claim 1, characterized in that, The step of inputting the fused features into a classifier, and the classifier outputting the probability of electricity theft, specifically includes: The fused features are input into the output layer of the classifier, and the fused features are linearly mapped through the output layer to obtain the classification mapping value; Based on the classification mapping value, the probability of electricity theft for each user is obtained by performing probability transformation through the Sigmoid activation function.

7. The smart grid electricity theft detection method as described in claim 6, characterized in that, The steps for determining the electricity theft detection result based on the aforementioned electricity theft probability specifically include: The probability of electricity theft is compared with a preset probability threshold: When the probability of electricity theft is greater than or equal to the preset probability threshold, the user's electricity theft detection result is determined to indicate a risk of electricity theft. When the probability of electricity theft is less than the preset probability threshold, the user's electricity theft detection result is determined to be that there is no risk of electricity theft.

8. A smart grid electricity theft detection device, characterized in that, include: The acquisition module is used to acquire the user's daily electricity consumption sequence; A global feature extraction module is used to input the daily electricity consumption sequence into a preset global feature extraction model to obtain a global feature vector; The local feature extraction module is used to input the daily electricity consumption sequence into a preset local feature extraction model to obtain local feature vectors. The local feature extraction model converts the daily electricity consumption sequence into a two-dimensional weekly matrix and sequentially performs local abnormal signal enhancement, convolutional feature transformation, residual feature extraction, channel attention recalibration, and pooling output processing to extract local feature vectors. The fusion and classification module is used to fuse the global feature vector and the local feature vector to obtain fused features, input the fused features into a classifier, and output the probability of electricity theft from the classifier. The detection module is used to determine the electricity theft detection result based on the electricity theft probability.

9. An electronic device, characterized in that, It includes a processor and a memory, the processor being used to execute a computer program stored in the memory to implement the smart grid electricity theft detection method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one instruction, which, when executed by a processor, implements the smart grid electricity theft detection method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Electricity stealing detection method and device, storage medium and electronic equipment

    CN114841253A