Power grid anomaly detection method, storage medium and electronic device
By using the dual-channel self-attention model to process the voltage and current data of multiple points on the grid line, the limitations of single-point detection and insufficient edge computing capabilities in the existing technology are solved, and a more accurate and comprehensive grid abnormality detection effect is achieved.
Patent Information
- Application Number
- CN202410771207.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-14
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2044-06-14
AI Technical Summary
The existing power grid abnormality detection technology can only determine a single detection point, and cannot perceive the correlation relationship between different points, and the edge computing power is limited, resulting in poor detection effect and low detection rate.
Using the dual-channel self-attention model, by obtaining the phase voltage data and phase current data of multiple points on the power grid line, synchronous and position embedding encoding, a voltage continuous representation sequence and a current continuous representation sequence are obtained, and the point status representation sequence is obtained, thereby achieving the state information of each point on the power grid line.
It improves the effectiveness of grid abnormal detection, can perceive the correlation between different points, improves the accuracy and detection rate, and has good portability and scalability.
Smart Images

Figure CN118861905B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of power grid detection, and in particular, to a method for detecting power grid anomalies, a storage medium, and an electronic device. Background Art
[0002] Regarding the detection of power grid anomalies, in the related art, after collecting phase voltage signals and current signals, indicators such as the effective value of phase voltage, the fundamental effective value of phase voltage, the harmonic effective value of phase voltage, the effective value of phase current, the fundamental effective value of phase current, and the harmonic effective value of phase current are calculated. Then, it is determined whether each indicator exceeds the corresponding alarm threshold, and when it exceeds, the corresponding alarm information is generated. However, this technology usually analyzes based on single-point detection values, which can only be limited to the points where detection devices are deployed, and the range of anomalies that can be detected is limited, and the recall rate is relatively low.
[0003] The related art also proposes a railway power grid inspection robot equipped with a detection device. During the process of traveling on the track, the detection device is used to detect potential safety hazards of the power grid, and the detection results are processed manually. However, this technology requires manual and accurate processing one by one after the detection, which requires labor costs and depends on the knowledge range of manual processing experts. Moreover, the line is not considered globally, and the single-point information is still analyzed during the manual processing process. Summary of the Invention
[0004] The present invention aims to at least solve one of the technical problems in the related art to some extent. For this purpose, the object of the present invention is to propose a method for detecting power grid anomalies, a storage medium, and an electronic device to solve the problems in the related art that only a single detection point can be determined, the correlation relationship between different points cannot be perceived, and the edge computing ability is limited, thereby improving the effect of power grid anomaly detection, and having good portability and scalability.
[0005] To achieve the above object, a first aspect embodiment of the present invention proposes a method for detecting power grid anomalies, including: obtaining phase voltage data and phase current data at multiple points on a power grid line to obtain a voltage sequence and a current sequence; using the first self-attention model in a pre-trained dual-channel self-attention model to obtain a voltage continuous representation sequence according to the voltage sequence and a current continuous representation sequence according to the current sequence, where the voltage continuous representation sequence includes attention information between point voltages, and the current continuous representation sequence includes attention information between point currents; using the second self-attention model in the dual-channel self-attention model to obtain a point state representation sequence according to the voltage continuous representation sequence and the current continuous representation sequence; and obtaining state information of each point on the power grid line according to the point state representation sequence.
[0006] In addition, the method for detecting power grid anomalies according to the embodiment of the present invention may also have the following additional technical features:
[0007] According to an embodiment of the present invention, before obtaining the voltage continuous representation sequence based on the voltage sequence and the current continuous representation sequence based on the current sequence by using the first path self-attention model, the method further includes: synchronizing the voltage sequence and the current sequence, and respectively performing positional embedding encoding on the voltage sequence and the current sequence to obtain a voltage feature sequence and a current feature sequence.
[0008] According to an embodiment of the present invention, the first path self-attention model includes N first blocks connected in sequence, the first block includes a first multi-head self-attention unit, a voltage feed-forward network, and a current feed-forward network, the first multi-head self-attention unit includes h self-attention sub-units, and N and h are integers greater than 0; wherein, using the first path self-attention model in the pre-trained dual-path self-attention model to obtain the voltage continuous representation sequence based on the voltage sequence and the current continuous representation sequence based on the current sequence, includes:
[0009] Dividing the voltage feature sequence into h parts by the first multi-head self-attention unit in the first first block, and inputting the h parts into the h self-attention sub-units for calculation one by one, splicing the obtained h calculation results, and performing a linear transformation of the voltage feature on the splicing result through the voltage feed-forward network in the first first block, and inputting the result of the linear transformation of the voltage feature into the next first block for processing until the voltage continuous representation sequence is output through the last first block;
[0010] Dividing the current feature sequence into h parts by the first multi-head self-attention unit in the first first block, and inputting the h parts into the h self-attention sub-units for calculation one by one, splicing the obtained h calculation results, and performing a linear transformation of the current feature on the splicing result through the current feed-forward network in the first first block, and inputting the result of the linear transformation of the current feature into the next first block for processing until the current continuous representation sequence is output through the last first block.
[0011] According to an embodiment of the present invention, the calculation formula of the self-attention sub-unit is as follows:
[0012]
[0013] Among them, Attention i represents the output of the i-th self-attention sub-unit, N a represents the total number of the points, Q i1 represents the query vector of the first feature X i1 input into the i-th self-attention sub-unit, Kij The key vector, V, representing feature X ij ij The value vector, d, representing feature X ij k = d / h, where d represents the dimension of Q and K, and K ij T represents K ij The transpose of, softmax() represents the activation function, and when i≠j, represents the attention information between points;
[0014] The calculation formula of the splicing result is as follows:
[0015] MAttention = Concat[Attention 1 ,…,Attention h
[0016] where MAttention represents the splicing result, and Concat represents the splicing function.
[0017] According to an embodiment of the present invention, the second self-attention model includes M second blocks connected in sequence, and the second block includes a second multi-head self-attention unit and a voltage-current collaborative feed-forward network, where M is an integer greater than 0; among them, using the second self-attention model in the dual self-attention model to obtain the point state representation sequence according to the voltage continuous representation sequence and the current continuous representation sequence includes:
[0018] Performing two attention operations on the voltage continuous representation sequence and the current continuous representation sequence through the second multi-head self-attention unit in the first second block to obtain the voltage feature with current information perception and the current feature with voltage information perception, and respectively performing voltage-current collaborative feature linear transformation on the voltage feature with current information perception and the current feature with voltage information perception through the voltage-current collaborative feed-forward network in the first second block, and inputting the voltage-current collaborative feature linear transformation result to the next second block for processing until the point state representation sequence is output through the last second block.
[0019] According to an embodiment of the present invention, in one of the two attention operations, the current continuous representation sequence is used as the query vector, the voltage continuous representation sequence is used as the key vector and the value vector to obtain the voltage feature with current information perception; in the other of the two attention operations, the voltage continuous representation sequence is used as the query vector, the current continuous representation sequence is used as the key vector and the value vector to obtain the current feature with voltage information perception.
[0020] According to an embodiment of the present invention, obtaining the status information of each point on the power grid line according to the point status representation sequence includes: using the sigmoid activation layer in the dual-path self-attention model to obtain the status information of each point on the power grid line according to the point status representation sequence.
[0021] According to an embodiment of the present invention, when training the dual-path self-attention model, the following loss function is used:
[0022]
[0023] where N a represents the total number of the points, represents the predicted value of the status of the i-th point, and y i represents the true value of the status of the i-th point.
[0024] To achieve the above object, an embodiment of the second aspect of the present invention proposes a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the power grid anomaly detection method described in the above embodiment of the first aspect is implemented.
[0025] To achieve the above object, an embodiment of the third aspect of the present invention proposes an electronic device, including a memory, a processor, and a computer program stored on the memory. When the computer program is executed by the processor, the power grid anomaly detection method described in the above embodiment of the first aspect is implemented.
[0026] In the power grid anomaly detection method, storage medium, and electronic device according to the embodiments of the present invention, first, the phase voltage data and phase current data of multiple points on the power grid line are obtained to obtain a voltage sequence and a current sequence; then, the first-path self-attention model in the pre-trained dual-path self-attention model is used to obtain a voltage continuous representation sequence according to the voltage sequence and a current continuous representation sequence according to the current sequence, and the second-path self-attention model in the dual-path self-attention model is used to obtain a point status representation sequence according to the voltage continuous representation sequence and the current continuous representation sequence; then, the status information of each point on the power grid line is obtained according to the point status representation sequence. Thus, the problems in the related art that only a single detection point can be determined, the correlation between different points cannot be perceived, and the edge computing ability is limited can be solved, so that the effect of power grid anomaly detection can be improved, and the portability and scalability are good.
[0027] The additional aspects and advantages of the present invention will be partially given in the following description, partially become obvious from the following description, or be understood through the practice of the present invention. Description of the Drawings
[0028] Figure 1It is a flowchart of the power grid anomaly detection method according to an embodiment of the present invention;
[0029] Figure 2 It is a schematic structural diagram of the dual-channel self-attention model according to an embodiment of the present invention;
[0030] Figure 3 It is a schematic structural diagram for implementing the power grid anomaly detection method according to an embodiment of the present invention;
[0031] Figure 4 It is a structural block diagram of an electronic device according to an embodiment of the present invention. Detailed implementation manners
[0032] The embodiments of the present invention will be described in detail below. The examples of the embodiments are shown in the accompanying drawings, where the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below by referring to the accompanying drawings are exemplary and are intended to explain the present invention, and should not be construed as a limitation to the present invention.
[0033] The power grid anomaly detection method, storage medium, and electronic device according to the embodiments of the present invention will be described below with reference to the accompanying drawings.
[0034] Figure 1 It is a flowchart of the power grid anomaly detection method according to an embodiment of the present invention.
[0035] As Figure 1 shown, the power grid anomaly detection method includes:
[0036] S101, acquiring phase voltage data and phase current data at multiple points on the power grid line to obtain a voltage sequence and a current sequence.
[0037] Among them, the power grid can be a subway power grid, an industrial power grid, or a civilian power grid. The power grid line can be the same power grid line or different power grid lines. The multiple points are the positions of multiple sampling points for collecting the phase voltage and phase current of the power grid.
[0038] Specifically, the phase voltage data at multiple points on the power grid line can be collected through a voltage signal acquisition module to obtain a voltage sequence The phase current data at multiple points on the power grid line is collected through a current signal acquisition module to obtain a current sequence Among them, N a is the number of data acquisition points on the power grid line, that is, the total number of points.
[0039] S102. Use the first self-attention model in the pre-trained dual-path self-attention model to obtain a voltage continuous representation sequence based on the voltage sequence and a current continuous representation sequence based on the current sequence, where the voltage continuous representation sequence includes the attention information between point voltages, and the current continuous representation sequence includes the attention information between point currents.
[0040] In some embodiments of the present invention, the first self-attention model includes N sequentially connected first blocks. The first block includes a first multi-head self-attention unit, a voltage feed-forward network, and a current feed-forward network. The first multi-head self-attention unit includes h self-attention sub-units, where N and h are integers greater than 0. Among them, using the first self-attention model in the pre-trained dual-path self-attention model to obtain a voltage continuous representation sequence based on the voltage sequence and a current continuous representation sequence based on the current sequence includes: dividing the voltage feature sequence into h parts through the first multi-head self-attention unit in the first block, and inputting the h parts into h self-attention sub-units for calculation one by one, splicing the obtained h calculation results, and performing a linear transformation of voltage features on the spliced result through the voltage feed-forward network in the first block, and inputting the voltage feature linear transformation result into the next first block for processing until the voltage continuous representation sequence is output through the last first block; dividing the current feature sequence into h parts through the first multi-head self-attention unit in the first block, and inputting the h parts into h self-attention sub-units for calculation one by one, splicing the obtained h calculation results, and performing a linear transformation of current features on the spliced result through the current feed-forward network in the first block, and inputting the current feature linear transformation result into the next first block for processing until the current continuous representation sequence is output through the last first block.
[0041] Among them, the calculation formula of the self-attention sub-unit is as follows:
[0042]
[0043] Among them, Attention i represents the output of the i-th self-attention sub-unit, N a represents the total number of points, Q i1 represents the query vector of the first feature X i1 input into the i-th self-attention sub-unit, K ij represents the key vector of the feature X ij , V ij represents the value vector of the feature X ij , d k =d / h, d represents the dimension of Q and K, K ij T represents K ijThe transpose of, softmax() represents the activation function, and when i≠j, represents the attention information between points.
[0044] The calculation formula of the splicing result is as follows:
[0045] MAttention = Concat[Attention 1 ,…,Attention h (2)
[0046] Among them, MAttention represents the splicing result, and Concat represents the splicing function.
[0047] In some embodiments of the present invention, before using the first self-attention model to obtain the voltage continuous representation sequence according to the voltage sequence and the current continuous representation sequence according to the current sequence, the method further includes: synchronizing the voltage sequence and the current sequence, and respectively performing positional embedding encoding on the voltage sequence and the current sequence to obtain a voltage feature sequence and a current feature sequence.
[0048] Specifically, if the voltage sequence and the current sequence are not synchronized, it is necessary to synchronize the voltage sequence and the current sequence to ensure the reliability of subsequent processing. The structure of the dual-channel self-attention model is as Figure 2 shown. See Figure 2 , the dual-channel self-attention model has two inputs, one is the voltage sequence, and the other is the current sequence. Positional embedding encoding processing is respectively performed, that is, the position information of each element is explicitly embedded for the voltage sequence and the current sequence respectively. For the voltage After encoding processing, the voltage feature For the current After encoding processing, the current feature Among them, d represents the dimension of the feature after positional embedding encoding, which is the same as the dimension of the above Q and K.
[0049] Then, the voltage feature sequence and the current feature sequence are input into N first blocks connected in sequence and having the same structure (N is an experimental variable, and the specific value can be obtained through experiments) for feature extraction. Each first block contains a first multi-head attention unit (Multi-Head Attention) and two feed-forward networks (Feed Forward) (that is, a voltage feed-forward network and a current feed-forward network). Among them, the multi-head attention can focus on different positions in the input sequence, enhancing the expression ability of self-attention to the data of each point between the voltage or current sequences; the feed-forward network can introduce non-linear transformation through the activation function, further strengthening the expression ability of the model to the voltage and current, and enhancing the fitting effect.
[0050] The first multi-head attention unit divides the input feature sequence into h parts (which can be evenly divided, and each part contains N a / h data points), and then inputs each part into a self-attention sub-unit corresponding to that part for calculation, and splices the calculated results together. The return value Attention i of each self-attention sub-unit is calculated as shown in the above formula (1). Splicing the return values Attention i of each self-attention sub-unit together can form the return value of the first multi-head attention unit, as shown in the above formula (2).
[0051] Specifically, first, the result of the voltage or current position embedding encoding of X in the first first block is input. X is multiplied by the weight matrices W Q 、W K and W V (which can be obtained by pre-training) to obtain the query vector Q, the key vector K, and the value vector V. Secondly, calculate the self-attention score value, that is, the attention information, which represents the degree of attention of a certain point to other points when encoding a certain point. Taking voltage as an example, and are the voltage features at two of the points. For the voltage feature , calculate the attention value of this point to other points. For the voltage feature , the attention value to itself is and the attention value to the voltage feature of other points is Q i ·K j T . Thirdly, divide the attention value by and then perform a softmax calculation to obtain the magnitude of the correlation between the current point and itself and other points. The value of d k is d / h. Fourthly, multiply the value obtained after the softmax calculation by the value vector corresponding to the key vector in the softmax calculation, and then sum all the products to obtain the value of the self-attention at the current point, that is, the self-attention result at the current point. Similarly, obtain the self-attention results of each point for the part it belongs to. Fifthly, splice the return values of the h self-attention sub-units to obtain the return value of the first multi-head self-attention unit, connect this return value to the voltage feed-forward network, perform a linear transformation of the voltage feature, and use the transformed value as the input of the next first block.
[0052] The above process is repeated N times, and the voltage feature sequence can be mapped to a continuous representation sequence, that is, the voltage continuous representation sequence Similarly, the same processing is performed on the current feature sequence, and the current feature sequence is mapped to a continuous representation sequence, that is, the current continuous representation sequence
[0053] S103, using the second self-attention model in the dual-channel self-attention model, obtain the point state representation sequence according to the voltage continuous representation sequence and the current continuous representation sequence.
[0054] In some embodiments of the present invention, the second self-attention model includes M second blocks connected in sequence, and the second block includes a second multi-head self-attention unit and a voltage-current collaborative feed-forward network, where M is an integer greater than 0; among them, using the second self-attention model in the dual-channel self-attention model to obtain the point state representation sequence according to the voltage continuous representation sequence and the current continuous representation sequence includes: performing two attention operations on the voltage continuous representation sequence and the current continuous representation sequence through the second multi-head self-attention unit in the first second block to obtain the voltage feature with current information perception and the current feature with voltage information perception, and respectively performing voltage-current collaborative feature linear transformation on the voltage feature with current information perception and the current feature with voltage information perception through the voltage-current collaborative feed-forward network in the first second block, and inputting the voltage-current collaborative feature linear transformation result into the next second block for processing until the point state representation sequence is output through the last second block.
[0055] Among them, in one of the two attention operations, the current continuous representation sequence is used as the query vector, the voltage continuous representation sequence is used as the key vector and the value vector, and the voltage feature with current information perception is obtained; in the other of the two attention operations, the voltage continuous representation sequence is used as the query vector, the current continuous representation sequence is used as the key vector and the value vector, and the current feature with voltage information perception is obtained.
[0056] Specifically, the voltage continuous representation sequence and the current continuous representation sequence are input into the second multi-head attention unit in the first second block. In this second multi-head attention unit, two attention operations need to be performed: one attention operation is to use the current continuous representation sequence as the query vector Q, the voltage continuous representation sequence as the key vector K and the value vector V, and output the voltage feature with current information perception The other attention operation is to use the voltage continuous representation sequence as the query vector Q, the current continuous representation sequence as the key vector K and the value vector V, and output the current feature with voltage information perception In this way, the relationship between different points of voltage and current is obtained. After splicing the voltage characteristics perceived by the current information and the current characteristics perceived by the voltage information, the input voltage-current collaborative feedforward network is used to perform a feature linear transformation, and the transformed values are split and input into the next second block.
[0057] The above process is repeated M times (M is an experimental variable, and the specific value can be obtained through experiments), and a point state representation sequence can be obtained
[0058] S104. Obtain the state information of each point on the power grid line according to the point state representation sequence.
[0059] Specifically, the activation layer in the dual-channel self-attention model (such as the activation layer using the sigmoid function) can be used to obtain the state information of each point on the power grid line according to the point state representation sequence, and the state information can be expressed as y i ∈{0,1}, i∈[1,N a , y i =1 indicates that the point i is abnormal, otherwise the point is normal. The activation layer is provided with a function that runs on the neurons of the artificial neural network, and this function is responsible for mapping the input of the neuron to the output end to provide the non-linear modeling ability of the network. Taking the sigmoid function as an example, each point state representation in the point state representation sequence can be used as x and substituted into to obtain the corresponding y (i.e., the state information), and the value of y is 0 or 1.
[0060] Among them, the abnormal points can be sorted according to the preset layout order to better determine the abnormal points, and the preset layout can be set in advance according to the power grid line.
[0061] In some embodiments of the present invention, when training the dual-channel self-attention model, the following loss function is used:
[0062]
[0063] where N a represents the total number of points, represents the state prediction value of the i-th point, and y i represents the state true value of the i-th point.
[0064] Specifically, the power grid historical voltage data and historical current data can be used in advance to Figure 2 train the model shown in formula (3), and use formula (3) as the loss function to train the optimal parameters of the dual-channel self-attention model, that is, obtain the trained dual-channel self-attention model.
[0065] In some embodiments of the present invention, the power grid anomaly detection method can be implemented through the Figure 3 structure shown. After the structure runs, first, initialization processing is performed through an initialization module, including initialization of related parameters and the like. Then, voltage data at multiple points on the power grid line is collected through a voltage signal acquisition module to obtain a voltage sequence; current data at multiple points on the power grid line is collected through a current signal acquisition module to obtain a current sequence. Subsequently, the voltage sequence and the current sequence are synchronized through a synchronization module, and the synchronized voltage sequence is input into a voltage embedding encoding module for position embedding encoding to obtain a voltage feature sequence; the synchronized current sequence is input into a current embedding encoding module for position embedding encoding to obtain a current feature sequence. Then, the voltage feature sequence and the current feature sequence are input into a dual-channel self-attention module for processing, and the processing result is output as a point status sequence through a point status sequence output module. Finally, using a sigmoid activation layer, the status information of each point on the power grid line can be obtained according to the point status representation sequence. Thus, it is possible to determine whether each point is abnormal based on the status information, and an alarm can be issued for the abnormal points for timely targeted maintenance.
[0066] The power grid anomaly detection method according to the embodiments of the present invention is based on a dual-channel self-attention model to output the positions of abnormal points according to the phase voltage and current data collected at different points. That is to say, the input of the dual-channel self-attention model corresponding to algorithm G is a voltage sequence and a phase current sequence, and the output is a sequence indicating whether the points are abnormal. Through the dual-channel self-attention model, the relationship between different points can be modeled from two aspects. On the one hand, the relationship between the voltage characteristics of a certain point in the voltage sequence and the voltage characteristics of other points, and the relationship between the current characteristics of a certain point in the current sequence and the current characteristics of other points are modeled; on the other hand, the relationship between the voltage characteristics of a certain point and the current characteristics of all points on the line, and the relationship between the current characteristics of a certain point and the voltage characteristics of all points on the line are modeled, so as to output the abnormal conditions of each point on the power grid line according to the multiple relationships. Thus, the problem that the related technology can only determine a single detection point, cannot perceive the correlation between different points on different lines, and has limited edge computing ability can be solved, thereby improving the effect of power grid anomaly detection, and the method has good portability and scalability.
[0067] In addition, other detection methods can also be used, such as using a temporal convolutional neural network method to replace the method based on the self-attention model prediction to implement anomaly detection. However, compared with the method based on the self-attention model prediction, the temporal convolutional neural network method has the following deficiencies:
[0068] First, the temporal convolutional neural network works within a local receptive field, mainly focusing on capturing changes between adjacent points and lacking the ability to model long-distance point dependencies. Second, due to the complex changes in point data in the real world, it is difficult to mine the dependencies between discrete points solely through temporal convolution, resulting in poor generalization performance. If the network is deepened to mine dependencies, a large amount of original data is required. Without sufficient data, the model is prone to overfitting to a local optimal solution rather than the global optimal solution. Third, deep networks are prone to feature smoothing, reducing the discriminability of the obtained feature representations and being unable to focus on internal patterns within the sequence, such as trends. Fourth, there is a pooling layer in the convolutional neural network, which will lose feature details for the application of voltage or current sequences and is difficult to be used for refined regression.
[0069] Based on the power grid anomaly detection method of the above embodiments, the present invention proposes a computer-readable storage medium.
[0070] In this embodiment, a computer program is stored on the computer-readable storage medium. When the computer program is executed by a processor, the power grid anomaly detection method of the above embodiments is implemented.
[0071] Based on the power grid anomaly detection method of the above embodiments, the present invention proposes an electronic device Figure 4 It is a structural block diagram of the controller according to the embodiment of the present invention.
[0072] As Figure 4 shown, the controller 400 includes: a processor 401 and a memory 403. Among them, the processor 401 and the memory 403 are connected, such as connected through a bus 402. Optionally, the controller 400 may further include a transceiver 404. It should be noted that in practical applications, the transceiver 404 is not limited to one, and the structure of the controller 400 does not constitute a limitation to the embodiments of the present invention.
[0073] The processor 401 may be a CPU (Central Processing Unit, central processor), a general-purpose processor, a DSP (Digital Signal Processor, digital signal processor), an ASIC (Application Specific Integrated Circuit, application-specific integrated circuit), an FPGA (Field Programmable Gate Array, field programmable gate array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It can implement or execute various exemplary logic blocks, modules and circuits described in combination with the disclosure of the present invention. The processor 401 may also be a combination that implements a computing function, such as a combination including one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0074] The bus 402 may include a path for transmitting information among the above components. The bus 402 may be a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. The bus 402 may be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, Figure 4 it is represented by only one thick line in the figure, but this does not mean that there is only one bus or one type of bus.
[0075] The memory 403 is used to store a computer program corresponding to the power grid anomaly detection method in the foregoing embodiments of the present invention, and the computer program is controlled and executed by the processor 401. The processor 401 is used to execute the computer program stored in the memory 403 to implement the content shown in the foregoing method embodiments.
[0076] Among them, the controller 400 includes but is not limited to: mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Tablet Computers), PMPs (Portable Multimedia Players), etc., and fixed terminals such as digital TVs, desktop computers, and the like. Figure 4 The controller 400 shown is only an example and should not impose any limitations on the functions and usage scope of the embodiments of the present invention.
[0077] Note that the logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a definite sequence list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other systems that can fetch and execute instructions from the instruction execution system, apparatus, or device), or used in combination with these instruction execution systems, apparatus, or devices. For the purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. More specific examples (non-exhaustive list) of computer-readable media include the following: an electrical connection portion having one or more wirings (electronic device), a portable computer diskette (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpretation, or otherwise processing as appropriate, and then stored in a computer memory.
[0078] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware, or a combination thereof. In the above-described embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, any one or a combination of the following techniques well known in the art can be used: discrete logic circuits having logic gate circuits for implementing logical functions on data signals, application specific integrated circuits having appropriate combinational logic gate circuits, programmable gate arrays (PGAs), field programmable gate arrays (FPGAs), etc.
[0079] In the description of this specification, the description with reference to terms such as "one embodiment", "some embodiments", "example", "specific example", or "some examples", etc. means that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0080] In the description of the present invention, it should be understood that the orientation or positional relationship indicated by the terms "center", "longitudinal", "transverse", "length", "width", "thickness", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", "clockwise", "counterclockwise", "axial", "radial", "circumferential", etc. is based on the orientation or positional relationship shown in the drawings, and is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be construed as a limitation on the present invention.
[0081] In addition, the terms "first" and "second" are only used for descriptive purposes and should not be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include at least one of such features. In the description of the present invention, "a plurality of" means at least two, such as two, three, etc., unless otherwise specifically defined.
[0082] In the present invention, unless otherwise clearly defined and limited, the terms "mounted", "connected", "coupled", "fixed", etc. shall be construed in a broad sense. For example, it may be a fixed connection, a detachable connection, or integrated; it may be a mechanical connection or an electrical connection; it may be directly connected or indirectly connected through an intermediate medium, and it may be the internal communication of two elements or the interaction relationship between two elements, unless otherwise clearly limited. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0083] In the present invention, unless otherwise clearly defined and limited, the first feature being "on" or "under" the second feature may be that the first and second features are in direct contact, or the first and second features are indirectly in contact through an intermediate medium. Moreover, the first feature being "above", "over" and "on top of" the second feature may be that the first feature is directly above or obliquely above the second feature, or merely indicates that the first feature has a higher horizontal height than the second feature. The first feature being "under", "beneath" and "underneath" the second feature may be that the first feature is directly below or obliquely below the second feature, or merely indicates that the first feature has a lower horizontal height than the second feature.
[0084] Although the embodiments of the present invention have been shown and described above, it can be understood that the above embodiments are exemplary and should not be construed as a limitation on the present invention. Those of ordinary skill in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. A method for detecting anomalies in a power grid, characterized in that: include: Obtain phase voltage data and phase current data of multiple points on the power grid line to obtain voltage sequence and current sequence; Using a first self-attention model in a pre-trained dual-path self-attention model, a voltage continuous representation sequence is obtained according to the voltage sequence and a current continuous representation sequence is obtained according to the current sequence, wherein the voltage continuous representation sequence includes attention information between point voltages and the current continuous representation sequence includes attention information between point currents; Using the second self-attention model in the dual-path self-attention model, a point state representation sequence is obtained according to the voltage continuous representation sequence and the current continuous representation sequence; Obtaining status information of each point on the power grid line according to the point status representation sequence; The second self-attention model includes M second blocks connected in sequence, the second block includes a second multi-head self-attention unit and a voltage-current collaborative feedforward network, and M is an integer greater than 0; wherein, the second self-attention model in the dual-path self-attention model is used to obtain a point state representation sequence according to the voltage continuous representation sequence and the current continuous representation sequence, including: The second multi-head self-attention unit in the first second block performs two attention operations on the voltage continuous representation sequence and the current continuous representation sequence to obtain the voltage characteristics of current information perception and the current characteristics of voltage information perception, and the voltage-current collaborative feature linear transformation is performed on the voltage characteristics of current information perception and the current characteristics of voltage information perception respectively through the voltage-current collaborative feedforward network in the first second block, and the voltage-current collaborative feature linear transformation result is input into the next second block for processing until the point state representation sequence is output through the last second block.
2. The power grid anomaly detection method according to claim 1, characterized in that: Before obtaining a voltage continuous representation sequence according to the voltage sequence and obtaining a current continuous representation sequence according to the current sequence by using the first self-attention model, the method further includes: The voltage sequence and the current sequence are synchronized, and position embedding coding is performed on the voltage sequence and the current sequence respectively to obtain a voltage characteristic sequence and a current characteristic sequence.
3. The power grid anomaly detection method according to claim 2, characterized in that: The first self-attention model includes N first blocks connected in sequence, the first block includes a first multi-head self-attention unit, a voltage feedforward network and a current feedforward network, the first multi-head self-attention unit includes h self-attention sub-units, N and h are integers greater than 0; wherein, using the first self-attention model in the pre-trained dual-path self-attention model to obtain a voltage continuous representation sequence according to the voltage sequence and a current continuous representation sequence according to the current sequence includes: The voltage feature sequence is divided into h parts by the first multi-head self-attention unit in the first first block, and the h parts are input into the h self-attention sub-units for calculation one by one, the h calculation results are spliced together, and the voltage feature linear transformation is performed on the spliced result by the voltage feedforward network in the first first block, and the voltage feature linear transformation result is input into the next first block for processing, until the voltage continuous representation sequence is output through the last first block; The current feature sequence is divided into h parts by the first multi-head self-attention unit in the first first block, and the h parts are input one by one to h self-attention sub-units for calculation, the h calculation results are spliced together, and the current feature linear transformation is performed on the splicing result through the current feedforward network in the first first block, and the current feature linear transformation result is input to the next first block for processing until the current continuous representation sequence is output through the last first block.
4. The power grid anomaly detection method according to claim 3, characterized in that: The calculation formula of the self-attention subunit is as follows: Among them, Attention i represents the output of the i-th self-attention subunit, N a Indicates the total number of points, Q i1 Represents the first feature X of the input i-th self-attention subunit i1 The query vector K ij Represents feature X ij The key vector, V ij Represents feature X ij The value vector of d k =d / h, d represents the dimension of Q, K, K ij T K ij The transpose of , softmax() represents the activation function, and when i≠j, Represents the attention information between points; The calculation formula of the splicing result is as follows: MAttention=Concat[Attention1,…,Attention h ] Among them, MAttention represents the concatenation result, and Concat represents the concatenation function.
5. The power grid anomaly detection method according to claim 1, characterized in that: One of the two attention operations uses the current continuous representation sequence as a query vector and the voltage continuous representation sequence as a key vector and a value vector to obtain the voltage characteristics perceived by the current information; the other of the two attention operations uses the voltage continuous representation sequence as a query vector and the current continuous representation sequence as a key vector and a value vector to obtain the current characteristics perceived by the voltage information.
6. The power grid anomaly detection method according to claim 1, characterized in that: The step of obtaining the status information of each point on the power grid line according to the point status representation sequence includes: The activation layer in the dual-path self-attention model is used to obtain the state information of each point on the power grid line according to the point state representation sequence.
7. The power grid anomaly detection method according to claim 1, characterized in that: When training the two-way self-attention model, the following loss function is used: Among them, N a Indicates the total number of points. represents the state prediction value of the i-th point, y i Represents the true value of the state of the i-th point.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the power grid anomaly detection method according to any one of claims 1 to 7 is implemented.
9. An electronic device comprising a memory, a processor and a computer program stored in the memory, characterized in that: When the computer program is executed by the processor, the power grid anomaly detection method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Distributed photovoltaic grid-connected power generation and energy storage equipment control method based on big data
CN115600146A
Lithium ion battery SOH estimation method based on adaptive joint model
CN117494558A
Abnormality diagnosis method and device, equipment, storage medium and product
CN118034988A