Power distribution system anomaly detection method and device, storage medium and computer device

By using a hierarchical attention network model, combined with daily and weekly attention networks, the nonlinear time-dependent modeling problem of anomaly detection in medium and low voltage power distribution systems was solved, achieving high-accuracy anomaly identification and early warning.

CN116561558BActive Publication Date: 2026-05-12STATE GRID BEIJING ELECTRIC POWER CO +3
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
STATE GRID BEIJING ELECTRIC POWER CO
Filing Date
2023-05-05
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

In existing technologies, anomaly detection schemes for medium and low voltage power distribution systems cannot effectively model complex nonlinear time dependencies, leading to frequent anomaly identification errors.

Method used

A hierarchical attention network model is adopted, combining daily and weekly attention networks to capture short-term and long-term time dependencies. Daily features are learned through the daily attention network, and periodicity is modeled using the weekly attention network. Finally, a multilayer perceptron network is used to predict anomaly probabilities.

Benefits of technology

It improves the accuracy of anomaly detection in medium and low voltage power distribution systems, enabling timely detection of anomalies and early warning, thus solving the problem of inaccurate anomaly perception.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116561558B_ABST
    Figure CN116561558B_ABST
Patent Text Reader

Abstract

The application discloses a power distribution system anomaly detection method and device, a storage medium and computer equipment. The method comprises the following steps: determining an input vector according to time series data of a power distribution system in a time window, wherein the length of the time window is seven days, and each input vector corresponds to one day in the seven days; inputting the input vector into a corresponding daily attention network to obtain a daily time feature vector, wherein each daily attention network corresponds to one day in the seven days; inputting part of the daily time feature vector into a weekly attention network to obtain a weekly time feature vector, wherein the part of the daily time feature vector is output by different networks in the daily attention network; and predicting an anomaly probability of the power distribution system at a target time according to the daily time feature vector and the weekly time feature vector, wherein the time window comprises the target time. The application solves the technical problem of inaccurate anomaly perception in a medium and low voltage power distribution system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of power distribution detection, and more specifically, to a method, apparatus, storage medium, and computer equipment for detecting anomalies in power distribution systems. Background Technology

[0002] To support the perception and defense of operational risks in medium- and low-voltage power distribution systems, data mining can be performed on the time-series data generated by these systems to conduct real-time anomaly detection, enabling timely discovery and early warning of abnormal situations. A key challenge in univariate time-series anomaly detection is modeling complex nonlinear time dependencies. However, existing modeling schemes often fail to accurately predict anomalies in medium- and low-voltage power distribution systems, frequently resulting in anomaly identification errors.

[0003] There is currently no effective solution to the above problems. Summary of the Invention

[0004] This invention provides a method, apparatus, storage medium, and computer equipment for detecting anomalies in power distribution systems, in order to at least solve the technical problem of inaccurate perception of anomalies in medium and low voltage power distribution systems.

[0005] According to one aspect of the present invention, a method for detecting anomalies in a power distribution system is provided, comprising: determining an input vector based on time-series data of the power distribution system within a time window, wherein the length of the time window is seven days, and each input vector corresponds to one day within the seven days; inputting the input vector into a corresponding daily-level attention network to obtain a daily-level time feature vector, wherein each daily-level attention network corresponds to one day within the seven days; inputting a portion of the daily-level time feature vector into a weekly-level attention network to obtain a weekly-level time feature vector, wherein the portion of the vector is output by different networks in the daily-level attention network; and predicting the probability of anomalies in the power distribution system at a target time based on the daily-level time feature vector and the weekly-level time feature vector, wherein the time window includes the target time.

[0006] Optionally, inputting the input vector into the corresponding daily attention network to obtain the daily time feature vector includes: dividing the input vector into seven groups of vectors according to the corresponding date, wherein each of the seven groups of vectors corresponds to a network in the daily attention network, and the daily attention network is a multi-head self-attention network; inputting the seven groups of vectors into the corresponding daily attention network respectively, and having the daily attention network output seven groups of daily vectors that correspond one-to-one with the seven groups of vectors, wherein the daily time feature vector includes the seven groups of daily vectors.

[0007] Optionally, inputting a portion of the daily time feature vectors into a weekly attention network to obtain a weekly time feature vector includes: selecting one daily time feature vector from each of the seven groups of daily vectors to obtain the portion vectors, wherein the portion vectors include a target daily time feature vector corresponding to the target time; constructing a weekly network input matrix for the weekly attention network based on the portion vectors, wherein the weekly attention network is the multi-head self-attention network; and inputting the weekly network input matrix into the weekly attention network to obtain the weekly time feature vectors, wherein the weekly time feature vectors include a target weekly time feature vector corresponding to the target daily time feature vector.

[0008] Optionally, inputting the weekly network input matrix into the weekly attention network to obtain the weekly time feature vector includes: projecting the weekly network input matrix onto query Q', key K', and value V'; and executing an attention function and applying a scaled dot product method based on the query Q', the key K', and the value V' to obtain the multi-head outputs of each of the weekly attention networks. h '; Based on the multi-head outputs of each of the weekly attention networks h ', determine the weekly time feature vector.

[0009] Optionally, based on the daily time feature vector and the weekly time feature vector, the probability of anomaly of the power distribution system at the target time is predicted, wherein the time window includes the target time, and includes: constructing a joint feature vector corresponding to the target time based on the target daily time feature vector and the target weekly time feature vector; and predicting the probability of anomaly of the power distribution system at the target time based on the joint feature vector.

[0010] Optionally, predicting the anomaly probability of the power distribution system at the target time based on the joint feature vector includes: inputting the joint feature vector into a pre-trained multilayer perceptron network to obtain the anomaly probability, wherein the multilayer perceptron network includes a sigmoid activation function.

[0011] Optionally, determining the input vector based on the time-series data of the power distribution system within the time window includes: acquiring the time-series data and the data order information corresponding to the time-series data; determining the input embedding vector based on the time-series data; determining the location encoding vector based on the data order information, wherein the location encoding vector has the same dimension as the input embedding vector; and determining the input vector based on the input embedding vector and the location encoding vector.

[0012] According to another aspect of the present invention, a power distribution system anomaly detection device is also provided, comprising: an input module, configured to determine an input vector based on time series data of the power distribution system within a time window, wherein the length of the time window is seven days, and each input vector corresponds to one day within the seven days; a first feature extraction module, configured to input the input vectors into a corresponding daily-level attention network to obtain a daily-level time feature vector, wherein each daily-level attention network corresponds to one day within the seven days; a second feature extraction module, configured to input a portion of the daily-level time feature vectors into a weekly-level attention network to obtain a weekly-level time feature vector, wherein the portion of the vectors are output by different networks in the daily-level attention network; and a prediction module, configured to predict the anomaly probability of the power distribution system at a target time based on the daily-level time feature vectors and the weekly-level time feature vectors, wherein the time window includes the target time.

[0013] According to another aspect of the present invention, a non-volatile storage medium is also provided, the non-volatile storage medium including a stored program, wherein, when the program is executed, the device where the non-volatile storage medium is located is controlled to execute any of the above-described power distribution system anomaly detection methods.

[0014] According to another aspect of the present invention, a computer device is also provided, the computer device including a memory and a processor, the memory being used to store a program, and the processor being used to run the program stored in the memory, wherein the program, when running, executes any one of the above-described power distribution system anomaly detection methods.

[0015] In this embodiment of the invention, input vectors for each of the seven days are determined based on the time series data of the power distribution system within a seven-day time window. These input vectors are then input into the corresponding daily attention networks to obtain daily time feature vectors, where each daily attention network corresponds to one day within the seven days. A portion of the daily time feature vectors is input into a weekly attention network to obtain weekly time feature vectors, where the portion of the vectors is output by different networks within the daily attention network. Based on the daily and weekly time feature vectors, the probability of anomalies in the power distribution system at a target time is predicted, where the time window includes the target time. This achieves the goal of risk perception of anomalies in the power distribution system while considering the long-term time dependence of periodicity, thereby improving the accuracy of identifying abnormal conditions in the power distribution system and solving the technical problem of inaccurate anomaly perception in medium- and low-voltage power distribution systems. Attached Figure Description

[0016] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:

[0017] Figure 1 A hardware structure block diagram of a computer terminal for implementing a power distribution system anomaly detection method is shown.

[0018] Figure 2 This is a schematic diagram of anomalous data determined based on the periodic time dependence in the power distribution system dataset;

[0019] Figure 3 This is a flowchart illustrating the power distribution system anomaly detection method provided according to an embodiment of the present invention;

[0020] Figure 4 This is a schematic diagram of the structure of a hierarchical attention network model according to an optional embodiment of the present invention;

[0021] Figure 5 This is a flowchart illustrating a power distribution system anomaly detection method according to an optional embodiment of the present invention;

[0022] Figure 6 This is a structural block diagram of a power distribution system anomaly detection device provided according to an embodiment of the present invention. Detailed Implementation

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

[0024] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0025] According to an embodiment of the present invention, a method for determining anomalies in a power distribution system is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.

[0026] The method embodiment provided in Embodiment 1 of this application can be executed on a mobile terminal, computer terminal, or similar computing device. Figure 1 A hardware block diagram of a computer terminal for implementing a power distribution system anomaly detection method is shown. Figure 1 As shown, the computer terminal 10 may include one or more processors (shown as processors 102a, 102b, ..., 102n in the figure) (the processor may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of a BUS bus), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 10 may also include... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.

[0027] It should be noted that the aforementioned one or more processors and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be implemented wholly or partially as software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be wholly or partially integrated into any other element in the computer terminal 10. As involved in the embodiments of this application, the data processing circuits serve as processor control (e.g., selection of a variable resistor termination path connected to an interface).

[0028] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the power distribution system anomaly detection method in this embodiment of the invention. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby realizing the power distribution system anomaly detection method of the aforementioned application. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor, and these remote memories can be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0029] The display may be, for example, a touchscreen liquid crystal display (LCD) that allows the user to interact with the user interface of the computer terminal 10.

[0030] The method provided by this invention can be used for real-time anomaly detection of time series data in medium and low voltage power distribution systems, enabling timely detection of anomalies and early warning. A key challenge in univariate time series anomaly detection is modeling complex nonlinear time correlations. Related technologies only model short-term time dependencies, neglecting periodic long-term time dependencies.

[0031] Figure 2 This is a schematic diagram of outlier data determined based on the periodic time dependence in the power distribution system dataset, such as... Figure 2 As shown, univariate time series data can represent the medium and low voltage power distribution volume of a power distribution system. Figure 2 The distribution volume of medium and low voltage in the system shows a clear periodicity over a week, but the distribution volume of medium and low voltage on December 28th significantly broke this periodicity. Therefore, it can be confirmed that an anomaly occurred in the power distribution system on that day.

[0032] To address this issue, this paper proposes a novel hierarchical attention network (HAN) model. This model introduces a daily attention network to capture fine-grained short-term dependencies and a weekly attention network to model periodic long-term dependencies. Daily features learned by the daily attention network and weekly features acquired by the weekly attention network are combined to obtain high-level temporal features, which are then used to calculate anomaly probabilities and further detect anomalies.

[0033] Existing solutions in related technologies only model short-term time dependencies, neglecting periodic long-term time dependencies. To address this issue, this invention proposes a novel hierarchical attention network (HAN). Optionally, it incorporates seven daily attention networks to capture fine-grained short-term time dependencies and uses a weekly attention network to model periodic long-term time dependencies. The daily time features learned by the daily attention networks and the weekly time features learned by the weekly attention networks are then combined to obtain high-level time features, from which anomaly probabilities are calculated for anomaly detection. Extensive experiments on publicly available anomaly detection datasets and deployment in real-world low-voltage power distribution systems demonstrate that the proposed framework outperforms state-of-the-art frameworks.

[0034] Figure 3 This is a flowchart illustrating the power distribution system anomaly detection method provided according to an embodiment of the present invention, as shown below. Figure 3 As shown, the method includes the following steps:

[0035] Step S302: Based on the time series data of the power distribution system within the time window, determine the input vectors. The time window is seven days long, and each input vector corresponds to one day within those seven days. The power distribution system can be a medium- or low-voltage power distribution system, and the time series data can be univariate data, meaning the time series data has only one independent variable: time. Optionally, corresponding to the seven days in the time window, the input vectors can be divided into seven groups, and each of the seven groups of input vectors is input into its corresponding daily attention network.

[0036] As an optional embodiment, the input vector can be determined as follows: obtain time series data and the corresponding data order information; determine the input embedding vector based on the time series data; determine the position encoding vector based on the data order information, wherein the position encoding vector has the same dimension as the input embedding vector; and determine the input vector based on the input embedding vector and the position encoding vector.

[0037] Based on the above optional embodiments, an embedding module can be used to embed the time series data x corresponding to each input timestamp t (i.e., any moment within a time window). tThe input embeddings are transformed into d-dimensional vectors. Furthermore, positional encodings can be generated based on the order information of the time series data, resulting in positional encoding vectors. These vectors are then combined to obtain the input vector. Optionally, sine and cosine functions of different frequencies can be used as positional encodings for the time series data to encode the relative positional information of the data. The positional encoding can be a vector with the same dimension as the input embeddings. Adding the input embeddings and positional encodings yields the input vector g of the d-dimensional self-attention network. t :

[0038] g t =emb(x t )+pos_enc(x t )

[0039] Where g t ∈R d emb represents linear mapping, and pos_enc is the positional encoding process, as detailed below:

[0040] PE (pos,2i) =sin(pos / 10000) 2i / d )

[0041] PE (pos,2i+1) =cos(pos / 10000) 2i / d )

[0042] Where pos is the position and i is the dimension. The dimension encoded by each position corresponds to a sine curve, and the wavelength forms a geometric series from 2π to 10000.2π.

[0043] Through the embedding layer above, the time series data x for day n within the time window can be... t-nw+1 ,···,x t-(n-1)w Transform into input vector g t-nw+1 ,…,g t-(n-1)w , represented as g n ∈R w×d , where n represents the nth day within a seven-day time window.

[0044] Step S304: Input the input vector into the corresponding daily attention network to obtain the daily time feature vector, where each daily attention network corresponds to one day within seven days.

[0045] Optionally, the daily attention network can be seven pre-defined, independent networks. Each daily attention network processes the input vector corresponding to a specific day within a time window and extracts the corresponding daily time feature vector. Multiple daily attention networks can be multi-head self-attention networks with identical structures.

[0046] As an optional embodiment, the input vector is input into the corresponding daily attention network to obtain the daily time feature vector, including: dividing the input vector into seven groups of vectors according to the corresponding date, wherein each of the seven groups of vectors corresponds to a network in the daily attention network, and the daily attention network is a multi-head self-attention network; inputting the seven groups of vectors into the corresponding daily attention network respectively, and the daily attention network outputting seven groups of daily vectors that correspond one-to-one with the seven groups of vectors, wherein the daily time feature vector includes seven groups of daily vectors.

[0047] Optionally, the following example uses any one of the seven day-level attention networks to illustrate how to extract day-level vectors when the day-level attention network is a multi-head self-attention network.

[0048] After obtaining the input vectors g corresponding to each of the seven days. n ∈R w×d Next, the input vector is projected onto the query Q, key K, and value V of the hierarchical attention network:

[0049] Q = g n W i Q K = g n W i K V=g n W i V

[0050] Where Q∈R w×d , K∈R w×d , V∈R w×d W i Q ∈R d×d W i K ∈R d×d W i V ∈R d×d Let be the linear mapping matrix. For the nth multi-head self-attention network with H heads, Q, K, and V can be linearly mapped to d using H different sets of learnable parameter matrices. k d k d v The attention function is then executed in parallel, and a scaled dot product is applied to obtain the output for each head, denoted as head.h :

[0051]

[0052]

[0053] in, It is a linear mapping matrix, and d k =d v =d / H.

[0054] Finally, the outputs of all heads can be concatenated and projected again to obtain the final output of the day-level multi-head self-attention network:

[0055] MultiHead(Q,K,V)=Concat(head1,…,head H W O

[0056] Where H is the number of heads in the multi-head self-attention network. It is a linear mapping matrix. The output of the nth daily-level multi-head self-attention network is denoted as the daily-level vector y corresponding to that network. t-nw+1 ,···,y t-(n-1)w abbreviated as y n :

[0057] y n =MultiHead(Q,K,V)

[0058] The seven sets of daily-level vectors output by the seven daily-level multi-head self-attention networks are the daily-level time feature vectors.

[0059] Step S306: Input a portion of the daily time feature vector into the weekly attention network to obtain the weekly time feature vector, wherein the portion of the vector is output by different networks in the daily attention network.

[0060] Optionally, the last daily time feature vector y output from each daily attention network can be used. t-6w ,y t-5w ,···,y t Construct a matrix y∈R 7×d The matrix y is a partial vector that serves as the input to the weekly attention network.

[0061] As an optional embodiment, a portion of the daily time feature vectors is input into a weekly attention network to obtain a weekly time feature vector. This includes: selecting one daily time feature vector from each of the seven groups of daily vectors to obtain a portion vector, wherein the portion vector includes the target daily time feature vector corresponding to the target time; constructing a weekly network input matrix for the weekly attention network based on the portion vectors, wherein the weekly attention network is a multi-head self-attention network; and inputting the weekly network input matrix into the weekly attention network to obtain a weekly time feature vector, wherein the weekly time feature vector includes the target weekly time feature vector corresponding to the target daily time feature vector.

[0062] As an optional embodiment, inputting the weekly network input matrix into a weekly attention network to obtain a weekly time feature vector may include the following steps: projecting the weekly network input matrix onto query Q', key K', and value V'; and executing an attention function and applying a scaled dot product method based on query Q', key K', and value V' to obtain the multi-head outputs of each weekly attention network. h '; Based on the multi-head output of each of the weekly attention networks h ', determine the weekly time feature vector.

[0063] The input to a weekly attention network is a daily feature vector matrix y∈R. 7×d The input matrix y is first mapped to a query Q′, a key K′, and a value V′:

[0064]

[0065] Where the query, key, and value are Q′∈R 7×d ,K′∈R 7×d ,V′∈R 7×d . Let Q′, K′, V′ be a linear mapping matrix. Then, different linear mapping matrices can be used to map Q′, K′, V′ to H different subspaces. For the h-th head, the output head′ can be obtained by applying a scaled dot product. h :

[0066]

[0067]

[0068] in, Let be a linear mapping matrix, and d k =d v = d / H. Connecting the outputs of H heads yields the final output of the weekly multi-head self-attention network:

[0069] MultiHead(Q′,K′,V′)=Concat(head1′,…,head H ′)Θ O

[0070] Where H is the number of heads in the weekly multi-head self-attention network. It is a linear mapping matrix. The output of the weekly multi-head self-attention network is denoted as the weekly time feature vector y′. t-6w ,…,y′ t Abbreviated as y′:

[0071] y′=MultiHead(Q′,K′,V′)

[0072] Step S308: Based on the daily time feature vector and the weekly time feature vector, predict the probability of anomalies in the power distribution system at the target time, wherein the time window includes the target time.

[0073] As an optional embodiment, the probability of anomalies in the power distribution system at a target time is predicted based on daily and weekly time feature vectors. The time window includes the target time, and the process includes: constructing a joint feature vector corresponding to the target time based on the target daily and weekly time feature vectors; and predicting the probability of anomalies in the power distribution system at the target time based on the joint feature vector. It should be noted that both the target daily and target weekly time feature vectors used to construct the joint feature vector are vectors corresponding to the target time.

[0074] As an optional embodiment, predicting the probability of anomalies in the power distribution system at a target time based on the joint feature vector includes: inputting the joint feature vector into a pre-trained multilayer perceptron network to obtain the anomaly probability, wherein the multilayer perceptron network includes a sigmoid activation function.

[0075] Optionally, the daily and weekly time feature vectors learned through the daily and weekly attention networks, respectively, can be concatenated to obtain a joint feature vector. This joint feature vector is then fed into a multilayer perceptron (MLP) network with a sigmoid activation function to obtain the anomaly probability O at the target time t. t :

[0076] O t =MLP([y t ,y′ t ])

[0077] When training the hierarchical attention network proposed in the embodiments or any optional embodiments of the present invention, the binary cross-entropy loss function can be used as the objective function to minimize the anomaly probability O. t and real label Gt Differences between them:

[0078] L BCE =-G t log(O t )-(1-G t log(1-O) t )

[0079] The anomaly probability O in the output of the multilayer perceptron network t If the value is greater than or equal to 0.5, the predicted anomaly label can be set to 1, indicating that an anomaly occurred at the target time t. Otherwise, the anomaly label can be set to 0, indicating that the power distribution system is normal at the target time t. Specifically,

[0080]

[0081] In the above steps, input vectors for each of the seven days are determined based on the time series data of the power distribution system within a seven-day time window. These input vectors are then fed into the corresponding daily attention networks to obtain daily time feature vectors, where each daily attention network corresponds to one day within the seven days. A portion of the daily time feature vectors is fed into a weekly attention network to obtain weekly time feature vectors, where a portion of the vectors is output by different networks within the daily attention network. Based on the daily and weekly time feature vectors, the probability of anomalies in the power distribution system at a target time is predicted. This process, where the time window includes the target time, achieves the goal of risk perception of anomalies in the power distribution system while considering the long-term time dependence of periodicity. This improves the accuracy of identifying abnormal conditions in the power distribution system and solves the technical problem of inaccurate anomaly perception in medium- and low-voltage power distribution systems.

[0082] Figure 4 This is a schematic diagram of the structure of a hierarchical attention network model according to an optional embodiment of the present invention, such as... Figure 4 As shown, the hierarchical attention network model can include a daily attention network, a weekly attention network, and a multilayer perceptron network as a classifier. An embedding layer is set before each of the seven daily attention networks to extract the input embedding vector and the position encoding vector from the time series data, and the two are added together to obtain the input vector of each daily self-attention network. Figure 4 The hierarchical attention network model is used to identify the anomaly probability at target time t, and time series data from the seven days prior to target time t are used as the basis for prediction. The seventh-day self-attention network outputs the target day-level time feature vector y. t Furthermore, the weekly self-attention network outputs the target weekly time feature vector y′. tFurthermore, both the target daily time feature vector and the target weekly time feature vector correspond to the target time t. Therefore, the target daily time feature vector y can be... t and the target weekly time feature vector y′ t Input a multilayer perceptron network and predict the probability of anomalies in the power distribution system at the target time t.

[0083] Figure 5 This is a flowchart illustrating a power distribution system anomaly detection method according to an optional embodiment of the present invention, such as... Figure 5 As shown, to simultaneously model fine-grained short-term time dependencies and periodic long-term time dependencies, we solve for anomaly probabilities using a hierarchical attention network comprising seven daily self-attention networks and one weekly self-attention network. Specifically, the daily self-attention networks use seven multi-head self-attention networks to model the time series data for the seven days preceding the target time t. Specifically, the data from the last day can be used as the input to the last multi-head self-attention network to obtain the target daily time feature vector y corresponding to the target time t. t The system uses data from the previous six days as input to six other multi-head attention networks to obtain daily time feature vectors for each day. Finally, these seven daily time feature vectors are used as input to a weekly multi-head self-attention network to further extract the target weekly feature vector y′ corresponding to the target time t. t In the output layer, which serves as the classifier, the target daily time feature vector y is... t and the target weekly time feature vector y′ t The network is connected and an MLP (Multi-Level Processing) network is used to obtain the anomaly probability at the target time t. During the training phase, we use the binary cross-entropy loss function to measure the difference between the anomaly probability and the anomaly label, and use gradient backpropagation to enable the model to learn the features of the anomaly data. When detecting anomalies, if the anomaly probability at the target time t is greater than or equal to 0.5, an anomaly is considered to have occurred at that moment.

[0084] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the present invention is not limited to the described order of actions, because according to the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to the present invention.

[0085] Through the above description of the embodiments, those skilled in the art can clearly understand that the power distribution system anomaly detection method according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platform. Of course, it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods of the various embodiments of the present invention.

[0086] According to embodiments of the present invention, a power distribution system anomaly detection device for implementing the above-described power distribution system anomaly detection method is also provided. Figure 6 This is a structural block diagram of a power distribution system anomaly detection device provided according to an embodiment of the present invention, such as... Figure 6 As shown, the power distribution system anomaly detection device includes: an input module 62, a first feature extraction module 64, a second feature extraction module 66, and a prediction module 68. The power distribution system anomaly detection device will be described below.

[0087] Input module 62 is used to determine input vectors based on the time series data of the power distribution system within a time window, wherein the length of the time window is seven days, and each input vector corresponds to one day within the seven days;

[0088] The first feature extraction module 64 is connected to the above-mentioned input module 62 and is used to input the input vector into the corresponding daily attention network to obtain the daily time feature vector, wherein each of the daily attention networks corresponds to one day within seven days;

[0089] The second feature extraction module 66 is connected to the first feature extraction module 64 and is used to input a portion of the daily time feature vector into the weekly attention network to obtain the weekly time feature vector, wherein the portion of the vector is output by different networks in the daily attention network.

[0090] The prediction module 68, connected to the second feature extraction module 66, is used to predict the probability of anomalies in the power distribution system at a target time based on the daily time feature vector and the weekly time feature vector, wherein the time window includes the target time.

[0091] It should be noted that the input module 62, the first feature extraction module 64, the second feature extraction module 66, and the prediction module 68 mentioned above correspond to steps S302 to S308 in the embodiments. Multiple modules and their corresponding steps implement the same instances and application scenarios, but are not limited to the content disclosed in the above embodiments. It should also be noted that the above modules, as part of the device, can run on the computer terminal 10 provided in the embodiments.

[0092] Embodiments of the present invention may provide a computer device. Optionally, in this embodiment, the computer device may be located in at least one of a plurality of network devices in a computer network. The computer device includes a memory and a processor.

[0093] The memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the power distribution system anomaly detection method and device in this embodiment of the invention. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, thereby realizing the aforementioned power distribution system anomaly detection method. The memory may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include memory remotely located relative to the processor, and these remote memories can be connected to a computer terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0094] The processor can invoke information and application programs stored in memory via a transmission device to perform the following steps: Based on the time-series data of the power distribution system within a time window, determine an input vector, where the time window is seven days long and each input vector corresponds to one day within those seven days; input the input vectors into the corresponding daily-level attention network to obtain daily-level time feature vectors, where each daily-level attention network corresponds to one day within those seven days; input a portion of the daily-level time feature vectors into a weekly-level attention network to obtain weekly-level time feature vectors, where a portion of the vectors is output by different networks within the daily-level attention network; based on the daily-level and weekly-level time feature vectors, predict the probability of anomalies in the power distribution system at a target time, where the time window includes the target time.

[0095] Optionally, the processor may also execute program code with the following steps: inputting the input vector into the corresponding daily attention network to obtain the daily time feature vector, including: dividing the input vector into seven groups of vectors according to the corresponding date, wherein each of the seven groups of vectors corresponds to a network in the daily attention network, and the daily attention network is a multi-head self-attention network; inputting the seven groups of vectors into the corresponding daily attention network respectively, and having the daily attention network output seven groups of daily vectors that correspond one-to-one with the seven groups of vectors, wherein the daily time feature vector includes seven groups of daily vectors.

[0096] Optionally, the processor may also execute program code with the following steps: inputting a portion of the daily time feature vectors into a weekly attention network to obtain a weekly time feature vector, including: selecting one daily time feature vector from each of the seven groups of daily vectors to obtain a portion vector, wherein the portion vector includes the target daily time feature vector corresponding to the target time; constructing a weekly network input matrix for the weekly attention network based on the portion vector, wherein the weekly attention network is a multi-head self-attention network; inputting the weekly network input matrix into the weekly attention network to obtain a weekly time feature vector, wherein the weekly time feature vector includes the target weekly time feature vector corresponding to the target daily time feature vector.

[0097] Optionally, the processor may also execute program code that performs the following steps: inputting the weekly network input matrix into the weekly attention network to obtain the weekly time feature vector, including: projecting the weekly network input matrix onto query Q', key K', and value V'; and, based on query Q', key K', and value V', executing the attention function and applying the scaling dot product method to obtain the multi-head outputs of each weekly attention network. h '; Based on the multi-head output of each of the weekly attention networks h ', determine the weekly time feature vector.

[0098] Optionally, the processor may also execute program code that performs the following steps: predicting the probability of anomalies in the power distribution system at a target time based on the daily time feature vector and the weekly time feature vector, wherein the time window includes the target time, including: constructing a joint feature vector corresponding to the target time based on the target daily time feature vector and the target weekly time feature vector; and predicting the probability of anomalies in the power distribution system at the target time based on the joint feature vector.

[0099] Optionally, the processor may also execute program code that performs the following steps: predicting the probability of anomalies in the power distribution system at a target time based on the joint feature vector, including: inputting the joint feature vector into a pre-trained multilayer perceptron network to obtain the anomaly probability, wherein the multilayer perceptron network includes a sigmoid activation function.

[0100] Optionally, the processor may also execute program code for the following steps: determining an input vector based on time-series data of the power distribution system within a time window, including: acquiring time-series data and corresponding data order information; determining an input embedding vector based on the time-series data; determining a location encoding vector based on the data order information, wherein the location encoding vector has the same dimension as the input embedding vector; and determining the input vector based on the input embedding vector and the location encoding vector.

[0101] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a non-volatile storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk, etc.

[0102] Embodiments of the present invention also provide a non-volatile storage medium. Optionally, in this embodiment, the aforementioned non-volatile storage medium can be used to store the program code executed by the power distribution system anomaly detection method provided in the above embodiments.

[0103] Optionally, in this embodiment, the non-volatile storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any mobile terminal in a group of mobile terminals.

[0104] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for performing the following steps: determining input vectors based on the time series data of the power distribution system within a time window, wherein the length of the time window is seven days, and each input vector corresponds to one day within the seven days; inputting the input vectors into the corresponding daily-level attention network to obtain daily-level time feature vectors, wherein each daily-level attention network corresponds to one day within the seven days; inputting a portion of the daily-level time feature vectors into a weekly-level attention network to obtain weekly-level time feature vectors, wherein the portion of the vectors is output by different networks in the daily-level attention network; predicting the probability of anomalies in the power distribution system at a target time based on the daily-level time feature vectors and the weekly-level time feature vectors, wherein the time window includes the target time.

[0105] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for performing the following steps: inputting the input vector into the corresponding daily attention network to obtain the daily time feature vector, including: dividing the input vector into seven groups of vectors according to the corresponding date, wherein each of the seven groups of vectors corresponds to a network in the daily attention network, and the daily attention network is a multi-head self-attention network; inputting the seven groups of vectors into the corresponding daily attention network respectively, and having the daily attention network output seven groups of daily vectors that correspond one-to-one with the seven groups of vectors, wherein the daily time feature vector includes seven groups of daily vectors.

[0106] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for performing the following steps: inputting a portion of the daily time feature vector into a weekly attention network to obtain a weekly time feature vector, including: selecting one daily time feature vector from each of the seven groups of daily vectors to obtain a portion vector, wherein the portion vector includes a target daily time feature vector corresponding to the target time; constructing a weekly network input matrix for the weekly attention network based on the portion vector, wherein the weekly attention network is a multi-head self-attention network; inputting the weekly network input matrix into the weekly attention network to obtain a weekly time feature vector, wherein the weekly time feature vector includes a target weekly time feature vector corresponding to the target daily time feature vector.

[0107] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for performing the following steps: inputting the weekly network input matrix into the weekly attention network to obtain the weekly temporal feature vector, including: projecting the weekly network input matrix onto query Q', key K', and value V'; and executing the attention function and applying the scaling dot product method according to query Q', key K', and value V' to obtain the multi-head output of each weekly attention network. h '; Based on the multi-head output of each of the weekly attention networks h ', determine the weekly time feature vector.

[0108] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for performing the following steps: predicting the probability of anomalies in the power distribution system at a target time based on the daily time feature vector and the weekly time feature vector, wherein the time window includes the target time, including: constructing a joint feature vector corresponding to the target time based on the target daily time feature vector and the target weekly time feature vector; and predicting the probability of anomalies in the power distribution system at the target time based on the joint feature vector.

[0109] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for performing the following steps: predicting the probability of anomalies in the power distribution system at a target time based on the joint feature vector, including: inputting the joint feature vector into a pre-trained multilayer perceptron network to obtain the anomaly probability, wherein the multilayer perceptron network includes a sigmoid activation function.

[0110] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for performing the following steps: determining an input vector based on time-series data of the power distribution system within a time window, including: acquiring time-series data and corresponding data order information; determining an input embedding vector based on the time-series data; determining a location encoding vector based on the data order information, wherein the location encoding vector has the same dimension as the input embedding vector; and determining the input vector based on the input embedding vector and the location encoding vector.

[0111] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0112] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

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

[0114] 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 units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0115] Furthermore, the functional units in the various embodiments of the present invention 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.

[0116] 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 non-volatile storage medium. Based on this understanding, the technical solution of the present invention, 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 to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.

[0117] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A method for detecting anomalies in a power distribution system, characterized in that, include: Based on the time series data of the power distribution system within a time window, an input vector is determined, wherein the length of the time window is seven days, and each input vector corresponds to one day within the seven days; The input vector is input into the corresponding daily attention network to obtain the daily time feature vector, wherein each of the daily attention networks corresponds to one day within the seven days; A portion of the daily time feature vector is input into a weekly attention network to obtain a weekly time feature vector, wherein the portion of the vector is output by different networks in the daily attention network. Based on the daily time feature vector and the weekly time feature vector, the probability of anomaly in the power distribution system at a target time is predicted, wherein the time window includes the target time; The step of inputting the input vector into the corresponding daily attention network to obtain the daily time feature vector includes: dividing the input vector into seven groups of vectors according to the corresponding date, wherein each of the seven groups of vectors corresponds to one of the networks in the daily attention network, and the daily attention network is a multi-head self-attention network; inputting the seven groups of vectors into the corresponding daily attention network respectively, and having the daily attention network output seven groups of daily vectors that correspond one-to-one with the seven groups of vectors, wherein the daily time feature vector includes the seven groups of daily vectors.

2. The method according to claim 1, characterized in that, A portion of the daily time feature vector is input into the weekly attention network to obtain the weekly time feature vector, including: One daily time feature vector is selected from each of the seven groups of daily vectors to obtain the partial vector, wherein the partial vector includes the target daily time feature vector corresponding to the target time. Based on the partial vectors, construct the weekly network input matrix of the weekly attention network, wherein the weekly attention network is the multi-head self-attention network; The weekly network input matrix is ​​input into the weekly attention network to obtain the weekly time feature vector, wherein the weekly time feature vector includes the target weekly time feature vector corresponding to the target daily time feature vector.

3. The method according to claim 2, characterized in that, The weekly network input matrix is ​​input into the weekly attention network to obtain the weekly time feature vector, including: Project the weekly network input matrix onto the query, key, and value; Based on the query, the key, and the value, an attention function is executed and a scaled dot product method is applied to obtain the multi-head outputs of each of the weekly attention networks; The weekly time feature vector is determined based on the multi-head outputs of each of the weekly attention networks.

4. The method according to claim 2, characterized in that, Based on the daily time feature vector and the weekly time feature vector, the probability of anomaly in the power distribution system at the target time is predicted, wherein the time window includes the target time, including: Based on the target daily time feature vector and the target weekly time feature vector, construct a joint feature vector corresponding to the target time. Based on the joint feature vector, the probability of anomaly in the power distribution system at the target time is predicted.

5. The method according to claim 4, characterized in that, Based on the joint feature vector, predicting the probability of anomalies in the power distribution system at the target time includes: The joint feature vector is input into a pre-trained multilayer perceptron network to obtain the anomaly probability, wherein the multilayer perceptron network includes a sigmoid activation function.

6. The method according to any one of claims 1 to 5, characterized in that, The step of determining the input vector based on the time series data of the power distribution system within the time window includes: Obtain the time series data and the data order information corresponding to the time series data; Based on the time series data, determine the input embedding vector; Based on the data order information, a position encoding vector is determined, wherein the position encoding vector has the same dimension as the input embedding vector; The input vector is determined based on the input embedding vector and the position encoding vector.

7. A power distribution system anomaly detection device, characterized in that, include: The input module is used to determine input vectors based on the time series data of the power distribution system within a time window, wherein the length of the time window is seven days, and each input vector corresponds to one day within the seven days; The first feature extraction module is used to input the input vector into the corresponding daily attention network to obtain a daily time feature vector, wherein each of the daily attention networks corresponds to one day within the seven days; The second feature extraction module is used to input a portion of the daily time feature vector into the weekly attention network to obtain the weekly time feature vector, wherein the portion vectors are output by different networks in the daily attention network. The prediction module is used to predict the probability of anomalies in the power distribution system at a target time based on the daily time feature vector and the weekly time feature vector, wherein the time window includes the target time. The first feature extraction module is further configured to divide the input vector into seven groups of vectors according to the corresponding date, wherein each of the seven groups of vectors corresponds to one of the networks in the daily attention network, and the daily attention network is a multi-head self-attention network; the seven groups of vectors are respectively input into the corresponding daily attention network, and the daily attention network respectively outputs seven groups of daily vectors that correspond one-to-one with the seven groups of vectors, wherein the daily time feature vector includes the seven groups of daily vectors.

8. A non-volatile storage medium, characterized in that, The non-volatile storage medium includes a stored program, wherein, when the program is executed, it controls the device containing the non-volatile storage medium to perform the power distribution system anomaly detection method according to any one of claims 1 to 6.

9. A computer device, characterized in that, The computer device includes a memory and a processor. The memory is used to store a program, and the processor is used to run the program stored in the memory. When the program runs, it executes the power distribution system anomaly detection method according to any one of claims 1 to 6.