Multi-task processing method and device for power system, terminal equipment and storage medium
By generating a multi-modal input feature matrix in the power system and using deep learning models for multi-task analysis, the problem of low efficiency of multi-task scenario analysis in the prior art is solved, and efficient multi-task synchronization processing is achieved.
Patent Information
- Application Number
- CN202510595892.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-09
- Publication Date
- 2025-08-15
AI Technical Summary
The prior art has low efficiency in multi-task scenario analysis in power systems and is difficult to meet the needs of real-time response. It requires retraining the model or redesigning the network structure.
By obtaining the task characteristics and equipment operation data of each task of the power system, a multi-modal input feature matrix is generated, tensor data is expanded and spliced, and a deep learning model with attention score matrix is used for analysis to realize the synchronous processing of multi-tasks.
The analysis efficiency of multi-power scenario tasks is improved, and the simultaneous analysis of multi-tasks is realized, which reduces the time for model training and structural adjustment, and meets the needs of real-time response.
Smart Images

Figure CN120493166A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of power systems, and in particular to a multi-tasking processing method, apparatus, terminal equipment and storage medium for power systems. Background Art
[0002] In modern power systems, power scenarios typically involve equipment fault detection, load forecasting, energy consumption analysis, and equipment status monitoring. These tasks involve the fusion of multimodal data, including text records (such as maintenance logs), image monitoring (such as photos of equipment status), and time series data (such as sensor readings).
[0003] Existing technologies usually rely on static network structures and train a model separately for each task. In the face of dynamically added task requirements, existing technologies need to retrain the model or redesign the network structure, which is time-consuming and inefficient, and it is difficult to meet the needs of real-time response in power scenarios. Therefore, when processing multiple power scenario tasks, there is a problem of low efficiency in multi-task scenario analysis. Summary of the Invention
[0004] The present invention provides a multi-task processing method, apparatus, terminal equipment and storage medium for a power system, which can solve the problem of low efficiency of multi-task scenario analysis existing in the prior art operations.
[0005] The present invention provides a multi-task processing method for a power system, comprising:
[0006] Obtain task characteristics and equipment operation data corresponding to each task of the power system;
[0007] Based on the task characteristics and equipment operation data corresponding to each task, determine the tensor data corresponding to each task; fuse the equipment operation data corresponding to all tasks to generate a multimodal input feature matrix;
[0008] Expand each tensor data, and when the batch data of the current tensor data is the same as the batch data of the multimodal input feature matrix, obtain the expanded tensor of each tensor data, and splice all the expanded tensors with the multimodal input feature matrix based on the sequence data to obtain the spliced feature matrix;
[0009] The concatenated feature matrix is input into a deep learning model with an attention score matrix. The deep learning model generates an output feature matrix. According to the position of the sequence data corresponding to each extended tensor in the sequence data corresponding to the concatenated feature matrix, it is indexed in the output feature matrix to obtain the output result corresponding to each task. Each output result is used as the device feature of each task, so that users can analyze the power system based on the device features of each task.
[0010] Furthermore, the task features include: batch data, sequence data, and feature dimensions; and determining the tensor data corresponding to each task based on the task features and device operation data corresponding to each task includes:
[0011] In each task, the equipment operation data is extracted based on batch data, sequence data and feature dimensions to obtain the initial feature matrix;
[0012] Calculate the position encoding of each element in the initial feature matrix to obtain the encoding matrix;
[0013] Add the initial feature matrix and the encoding matrix to obtain the feature tensor;
[0014] The feature tensor is projected through a linear transformation operation to obtain the tensor data of the current task.
[0015] Furthermore, the calculation of position encoding for each element in the initial feature matrix to obtain the encoding matrix includes:
[0016] According to the position index, feature dimension index and feature dimension of each element in the initial feature matrix, the position encoding calculation formula is substituted into the feature matrix to obtain the encoding matrix. The position encoding calculation formula satisfies the following conditions:
[0017]
[0018] Where pos represents the position index of an element in the initial feature matrix, q is the feature dimension index, and d is the feature dimension of the current task.
[0019] Furthermore, before inputting the concatenated feature matrix into the deep learning model with the attention weight matrix, the method further includes:
[0020] Determine a mask matrix based on the sequence data of the spliced feature matrix; wherein the sequence data of the spliced feature matrix is obtained by superimposing the sequence data [0, N] of the multimodal input feature matrix with the sequence data [0, L] of n tensor data to obtain the sequence data [0, N + nL] of the spliced feature matrix;
[0021] It consists of the sequence data of each tensor data and the sequence data of the multimodal input feature matrix;
[0022] Determine the attention score matrix of the deep learning model based on the mask matrix and the attention calculation matrix of the deep learning model.
[0023] Furthermore, the determining of the mask matrix based on the sequence data of the splicing feature matrix includes:
[0024] The initial matrix is established with the number of sequence data of the spliced feature matrix as the number of rows and the number of sequence data of the spliced feature matrix as the number of columns;
[0025] Judge each element in the initial matrix;
[0026] If the row position of the current element is at any position in the sequence data of the spliced feature matrix, and the column position of the current element is at the position where the sequence data of the multimodal input feature matrix is located in the sequence data of the spliced feature matrix, then the current element is 0;
[0027] If the row position of the current element is at the position where the sequence data of the tensor data is located in the sequence data of the spliced feature matrix, and the column position of the current element is at the position where the sequence data of the tensor data is located in the sequence data of the spliced feature matrix, then the current element is 0;
[0028] If the row position of the current element is at the position where the sequence data of the multimodal input feature matrix is located in the sequence data of the spliced feature matrix, and the column position of the current element is at the position where the sequence data of the tensor data is located in the sequence data of the spliced feature matrix, then the current element is 1;
[0029] After determining the value of each element in the initial matrix, a mask matrix is generated.
[0030] Furthermore, the attention score matrix satisfies the following conditions:
[0031]
[0032] Where, Calculate the matrix for attention, Q, K are query and key matrices respectively, d k is the dimension of the key, Mask OnlyLook is the mask matrix.
[0033] Furthermore, determining the attention score matrix of the deep learning model based on the mask matrix and the attention calculation matrix of the deep learning model includes:
[0034] The mask matrix is added to the attention calculation matrix of the deep learning model, and the attention calculation matrix with the added mask matrix is normalized to obtain the attention score matrix of the deep learning model.
[0035] Another embodiment of the present invention further provides a multi-task processing device for a power system, comprising: a data acquisition module, a data processing module, a data splicing module, and a result generation module;
[0036] The data acquisition module is used to obtain task characteristics and equipment operation data corresponding to each task of the power system;
[0037] The data processing module is used to determine the tensor data corresponding to each task based on the task characteristics and equipment operation data corresponding to each task; fuse the equipment operation data corresponding to all tasks to generate a multimodal input feature matrix;
[0038] The data splicing module is used to expand each tensor data, obtain the expanded tensor of each tensor data when the batch data of the current tensor data is the same as the batch data of the multimodal input feature matrix, and splice all the expanded tensors with the multimodal input feature matrix based on the sequence data to obtain a spliced feature matrix;
[0039] The result generation module is used to input the spliced feature matrix into a deep learning model with an attention score matrix, generate an output feature matrix by the deep learning model, and index the output feature matrix according to the position of the sequence data corresponding to each extended tensor in the sequence data corresponding to the spliced feature matrix to obtain the output result corresponding to each task, and use each output result as the equipment feature of each task, so that the user can analyze the power system based on the equipment feature of each task.
[0040] Another embodiment of the present invention further provides a terminal device, comprising: a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, the steps of the multi-tasking processing method for the power system of the present invention are implemented.
[0041] Another embodiment of the present invention further provides a computer-readable storage medium item, comprising: a stored computer program, which controls the device where the computer-readable storage medium is located to execute the steps of the multi-tasking processing method for power systems of the present invention when the computer program is running.
[0042] The following beneficial effects are achieved by implementing the present invention:
[0043] The present invention analyzes the task characteristics and equipment operation data of each task in the power system to determine the tensor data of each task, and fuses the equipment operation data of each task to obtain a multimodal input feature matrix. By expanding each tensor data, each expanded tensor obtained after expansion maintains the same batch data as the multimodal input feature matrix. Then, based on the sequence data, all expanded tensors of the same batch data are spliced with the multimodal input feature matrix to obtain a spliced feature matrix, thereby concatenating multiple task features with the multimodal input feature matrix. The spliced feature matrix is input into a deep learning model with an attention score matrix to generate an output feature matrix. The output result of each task is indexed by the position of the sequence data of the expanded tensor in the corresponding sequence data of the spliced feature matrix to obtain the device characteristics of each task, allowing users to analyze the power system based on the device characteristics. Therefore, the present invention realizes the simultaneous analysis of multiple tasks by the deep learning model. Compared with the existing technology that uses a single model to analyze a single task, the present invention realizes the simultaneous analysis of multiple tasks, greatly improving the analysis efficiency of multiple power scenario tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solution of the present application, the following is a brief introduction to the drawings required for use in the implementation. Obviously, the drawings described below are only some implementation methods of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0045] Figure 1 is a flow chart of a multi-task processing method for a power system provided by one embodiment of the present invention;
[0046] Figure 2 1 is a schematic structural diagram of a multi-task processing device for a power system provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0047] To make the objectives, technical solutions, and advantages of this application more clear, the technical solutions in this application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making any creative efforts are within the scope of protection of this application.
[0048] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned figure descriptions are intended to cover non-exclusive inclusions.
[0049] In the description of the embodiments of this application, the technical terms "first" and "second" are used only to distinguish different objects and should not be understood to indicate or imply relative importance or implicitly specify the quantity, specific order, or primary and secondary relationship of the indicated technical features. In the description of the embodiments of this application, the meaning of "plurality" is more than two, unless otherwise clearly and specifically defined.
[0050] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0051] In the description of the embodiments of this application, the term "and / or" is simply a description of the association relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can represent the following three situations: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in this document generally indicates that the associated objects are in an "or" relationship.
[0052] In the description of the embodiments of the present application, the term "multiple" refers to more than two (including two). Similarly, "multiple groups" refers to more than two groups (including two groups), and "multiple pieces" refers to more than two pieces (including two pieces).
[0053] In the description of the embodiments of the present application, unless otherwise expressly specified or limited, technical terms such as "installed," "connected," "connected," and "fixed" should be understood in a broad sense. For example, they can refer to fixed connections, detachable connections, or integration; mechanical connections or electrical connections; direct connections or indirect connections through an intermediate medium; internal connections between two components or interactions between two components. Those skilled in the art can understand the specific meanings of the above terms in the embodiments of the present application based on specific circumstances.
[0054] See also Figure 1To solve the problem of low efficiency in multi-task scenario analysis in the prior art, an embodiment of the present invention provides a multi-task processing method for a power system, comprising:
[0055] 101. Obtain the task characteristics and equipment operation data corresponding to each task of the power system.
[0056] 102. Based on the task characteristics and equipment operation data corresponding to each task, determine the tensor data corresponding to each task; fuse the equipment operation data corresponding to all tasks to generate a multimodal input feature matrix.
[0057] Furthermore, the task features include: batch data, sequence data, and feature dimensions; and determining the tensor data corresponding to each task based on the task features and device operation data corresponding to each task includes:
[0058] In each task, the equipment operation data is extracted based on batch data, sequence data and feature dimensions to obtain the initial feature matrix;
[0059] Calculate the position encoding of each element in the initial feature matrix to obtain the encoding matrix;
[0060] Add the initial feature matrix and the encoding matrix to obtain the feature tensor;
[0061] The feature tensor is projected through a linear transformation operation to obtain the tensor data of the current task.
[0062] In a specific embodiment, the device operation data is extracted according to a readout tensor with a shape of (batch data, sequence data, feature dimension) to obtain an initial feature matrix.
[0063] Furthermore, the calculation of position encoding for each element in the initial feature matrix to obtain the encoding matrix includes:
[0064] According to the position index, feature dimension index and feature dimension of each element in the initial feature matrix, the position encoding calculation formula is substituted into the feature matrix to obtain the encoding matrix. The position encoding calculation formula satisfies the following conditions:
[0065]
[0066] Where pos represents the position index of an element in the initial feature matrix, q is the feature dimension index, and d is the feature dimension of the current task.
[0067] In a specific embodiment, the function of the readout module is to define a set of independent tensor data for each task, which is used for the output processing of a specific task. iis the readout tensor of the i-th task, whose shape is (1,L i ,D), 1 is batch data, L i is the length of the task (or sequence data), and D is the feature dimension.
[0068] In a specific embodiment, the encoding matrix PE includes: PE (pos,2i) and PE (pos,2i+1) .
[0069] In the position encoding process PE, the present invention uses fixed sine and cosine functions to generate position encodings. Position encoding is a technique widely used in sequence modeling that can assign a unique spatial representation to each position in the sequence. The mathematical expression of position encoding is as follows:
[0070]
[0071] Here, pos represents the position index of an element in the task sequence, q is the index of the feature dimension, and d is the total feature dimension. The sine and cosine functions generate different encoding values for even and odd dimensions, respectively, ensuring that each position is unique and distinct.
[0072] By adding the generated encoding matrix to the initial features of the task element by element, a feature tensor containing position information can be obtained. For example, based on batch data, sequence data and feature dimensions, the equipment operation data is extracted to obtain the initial feature matrix. Assume that the initial feature matrix of a task is R ′ ∈R L×D , where L is the sequence length and D is the feature dimension, then the feature tensor R after adding the position encoding pos for:
[0073] R pos =R ′ +PE
[0074] After adding position encoding, the feature tensor corresponding to each task feature not only retains the numerical information of the task but also embeds the global perception of the position sequence. This approach provides sequential information in the temporal or spatial dimensions for the task features, enabling the model to better understand the temporal relationship between tasks.
[0075] To further ensure that the feature tensor can be operated in the same feature space as the multimodal input features, the present invention projects the position-encoded feature tensor to the target feature dimension through a linear transformation operation Linear(·) to obtain tensor data. The linear transformation expression is as follows:
[0076] y=W·x+b
[0077] Where x∈R Dis the feature tensor after position encoding, W∈R D×D is the weight matrix of linear transformation, b∈R D is the bias term, y∈R D Is the tensor data after linear transformation. For the entire task feature matrix, the result tensor data R linear It can be expressed as:
[0078] R linear =Linear(R pos )
[0079] The goal of the linear transformation is to ensure that the features of the task readout tensor are consistent with the feature space of the multimodal input, thus laying the foundation for subsequent splicing operations. In actual implementation, the weight matrix W is initialized using the Xavier normal distribution to ensure numerical stability of the model in the initial stage and reduce the risk of gradient vanishing or exploding.
[0080] Specifically, the initialization formula of Xavier normal distribution is:
[0081]
[0082] Among them, W represents the weight matrix, N(0,σ 2 ) means taking 0 as the mean, σ 2 is the normal distribution with variance, n in Indicates the number of input neurons, n out Represents the number of output neurons.
[0083] Through this formula, Xavier initialization ensures that the input and output signals of each neuron maintain roughly the same scale throughout the network, which is particularly important for deep networks. In practical applications, this initialization method can accelerate model convergence, reduce the workload of parameter tuning, and improve the final performance of the model.
[0084] In this invention, Xavier normal distribution is used to initialize the weight matrix W of the readout module to ensure that the initial value of the weight matrix does not lead to information amplification or attenuation when the task feature vector undergoes linear transformation. For example, when the dimension of the task feature is D=128, the size of the weight matrix W is 128×128. According to Xavier initialization, each element in the matrix will start from a mean of 0 and a variance of Sampling from a normal distribution.
[0085] This initialization method ensures the numerical stability of the task readout tensor in the initial stage and provides a good starting point for further network optimization. Combined with the characteristics of positional encoding and task independence, the application of Xavier normal distribution further enhances the robustness and scalability of the task module.
[0086] The input dimensions of the task readout module are determined by the length L of the task information and the target feature dimension D, while the output dimensions are tensors of shape (1, L, D), where 1 represents the batch size. For example, if the task length L = 64 and the feature dimension D = 128, the generated task readout tensor shape is (1, 64, 128).
[0087] By embedding positional encodings and aligning linearly transformed features, this paper achieves serialization and spatial consistency of task features, making them both independent and universal. This design provides highly flexible scalability for dynamic task splicing and multimodal collaborative processing, making it suitable for multi-task modeling in complex scenarios.
[0088] 103. Expand each tensor data. When the batch data of the current tensor data is the same as the batch data of the multimodal input feature matrix, obtain the expanded tensor of each tensor data, and splice all the expanded tensors with the multimodal input feature matrix based on the sequence data to obtain the spliced feature matrix.
[0089] In one specific embodiment, the core concept of multi-task concatenation is to construct a dynamic input structure that can adapt to any task by concatenating the task readout tensor with the multimodal input feature matrix along specific dimensions. The concatenated result incorporates multimodal information while preserving the independence of the tasks, providing flexibility and efficiency for subsequent neural network processing.
[0090] First, assume that the multimodal input feature matrix is M∈R B×N×D , where B represents the batch size, N represents the sequence length of the multimodal input feature matrix, and D represents the feature dimension.
[0091] The task readout tensor is R∈R 1×L×D , where: 1 represents the batch size (initialized to 1), L represents the length of the task readout (task sequence data), and D represents the feature dimension consistent with the multimodal input.
[0092] In order to adapt to the current batch size B, the task readout tensor needs to be expanded. The expansion operation is completed through torch.expand, and its expression is:
[0093] R expanded=expand(R,B,L,D)
[0094] Where: R expanded ∈R B×L×D is the expanded task readout tensor (i.e., the expanded tensor described in the present invention), and expand(·) repeats the tensor B times in a specific dimension.
[0095] Next, the multimodal input feature matrix M is combined with the expanded tensor R expanded Splicing is performed on the dimension of sequence data. The splicing operation is completed by torch.cat, and its expression is:
[0096] M combined =cat(M,R expanded , dim=1)
[0097] in:
[0098] M combined ∈R B×(N+L)×D represents the concatenated feature matrix, and cat(·) represents tensor concatenation in the specified dimension (here is the sequence length dimension).
[0099] To further illustrate, let's take a specific example:
[0100] Assume that the shape of the multimodal input feature matrix M is (B=2, N=128, D=64), and the shape of the task readout tensor R is (1, L=32, D=64). expanded The shape is: R expanded ∈R B =2×L=32×D=64 , after splicing, the splicing feature matrix M combined The shape is: M combined ∈R B=2×(N+L)=160×D=64 .
[0101] 104. The concatenated feature matrix is input into a deep learning model with an attention score matrix, and the deep learning model generates an output feature matrix. According to the position of the sequence data corresponding to each extended tensor in the sequence data corresponding to the concatenated feature matrix, the output result corresponding to each task is indexed in the output feature matrix, and each output result is used as the device feature of each task, so that the user can analyze the power system based on the device feature of each task.
[0102] Furthermore, before inputting the concatenated feature matrix into the deep learning model with the attention weight matrix, the method further includes:
[0103] Determine a mask matrix based on the sequence data of the spliced feature matrix; wherein the sequence data of the spliced feature matrix is obtained by superimposing the sequence data [0, N] of the multimodal input feature matrix with the sequence data [0, L] of n tensor data to obtain the sequence data [0, N + nL] of the spliced feature matrix;
[0104] It consists of the sequence data of each tensor data and the sequence data of the multimodal input feature matrix;
[0105] Determine the attention score matrix of the deep learning model based on the mask matrix and the attention calculation matrix of the deep learning model.
[0106] Furthermore, the determining of the mask matrix based on the sequence data of the splicing feature matrix includes:
[0107] The initial matrix is established with the number of sequence data of the spliced feature matrix as the number of rows and the number of sequence data of the spliced feature matrix as the number of columns;
[0108] Judge each element in the initial matrix;
[0109] If the row position of the current element is at any position in the sequence data of the spliced feature matrix, and the column position of the current element is at the position where the sequence data of the multimodal input feature matrix is located in the sequence data of the spliced feature matrix, then the current element is 0;
[0110] If the row position of the current element is at the position where the sequence data of the tensor data is located in the sequence data of the spliced feature matrix, and the column position of the current element is at the position where the sequence data of the tensor data is located in the sequence data of the spliced feature matrix, then the current element is 0;
[0111] If the row position of the current element is at the position where the sequence data of the multimodal input feature matrix is located in the sequence data of the spliced feature matrix, and the column position of the current element is at the position where the sequence data of the tensor data is located in the sequence data of the spliced feature matrix, then the current element is 1;
[0112] After determining the value of each element in the initial matrix, a mask matrix is generated.
[0113] In a specific embodiment, in a multi-task neural network, to ensure the independence of each task, especially when multiple task readout modules are spliced together, a mechanism is needed to control the flow of information and prevent interference between tasks. This paper proposes a custom OnlyLookMask masking mechanism that, by precisely controlling the attention matrix, ensures that each task focuses only on a specific portion of the input without affecting the processing of other tasks or input data.
[0114] In deep learning models based on attention mechanisms (such as Transformer), the calculation of the attention matrix is crucial for the model to capture global information. However, in multi-task scenarios, without control, tasks may share unnecessary information, leading to a decline in model performance. The OnlyLookMask masking mechanism restricts the information transfer direction by setting specific positions in the attention matrix to be invisible (i.e., masked).
[0115] Suppose the concatenated feature matrix M combined has the following shape:
[0116] M combined ∈R B×(N+L)×D
[0117] where B represents the batch size, N represents the sequence data of multi-modal input, L represents the length of the task readout (sequence data of the task), and D represents the feature dimension.
[0118] In the feature matrix, the multi-modal input features occupy the position indices [0, N), and the task readout module occupies the position indices [N, N + L).
[0119] The OnlyLookMask mask matrix Mask OnlyLook is defined as follows:
[0120]
[0121] where i and j are the row and column indices of the mask matrix, with the value range 0 ≤ i, j < N + L. The element value of 1 in the mask matrix indicates that the attention at the corresponding position is masked (i.e., invisible), and the value of 0 indicates that the attention at the corresponding position can be calculated.
[0122] Through the above definition, OnlyLookMask achieves the following information flow control:
[0123] 1. Attention calculation between multi-modal input features:
[0124] When i, j ∈ [0, N), it represents the attention calculation between multi-modal input features. At this time, Mask OnlyLook [i, j] = 0, allowing free information interaction.
[0125] 2. Attention calculation between the task readout module and multi-modal input features:
[0126] The task readout focuses on multi-modal input features: when i ∈ [N, N + L), [0, N), j ∈ [0, N), Mask OnlyLook[i,j]=0, allowing the task readout module to obtain information from multimodal input.
[0127] Multimodal input feature attention task readout module: When i∈[0,N),j∈[N,N+L), Mask OnlyLook [i,j]=1, shielding this information flow and preventing multimodal input from being affected by the task readout module.
[0128] 3. Attention calculation within the task readout module:
[0129] When i,j∈[N,N+L), Mask OnlyLook [i,j]=0, allowing information interaction within the task readout module.
[0130] For better explanation, in the specific implementation process, the implementation steps of the mask matrix are as follows:
[0131] 1. Initialize the mask matrix:
[0132] Create an all-zero matrix of size (N+L)×(N+L):
[0133] Mask OnlyLook =0 (N+L)×(N+L)
[0134] 2. Set the mask position:
[0135] According to the mask formula mentioned above, the elements that meet the conditions are set to 1:
[0136]
[0137] 3. Application to attention calculation:
[0138] In the Transformer’s attention calculation, a mask matrix is added to the attention score matrix A to mask the attention weights at specific positions:
[0139]
[0140] in:
[0141] Q, K are query and key matrices respectively, d k is the dimension of the key.
[0142] 4.Softmax Normalization:
[0143] Perform Softmax operation on the adjusted attention score matrix A to obtain the attention weight matrix α:
[0144]
[0145] The masked positions have their exponential values approaching zero due to the addition of a large negative number (usually -∞ or a sufficiently large negative number), so that their weights are zero after normalization.
[0146] Example description:
[0147] Assumptions:
[0148] The length of the multimodal input feature sequence is N=4.
[0149] The task readout task length L=2.
[0150] The length of the concatenated feature matrix is N+L=6, and the index range is [0,5].
[0151] Mask matrix Mask OnlyLook for:
[0152]
[0153] The row index i corresponds to the query position. The column index j corresponds to the key position. The position with a value of 1 indicates that it is masked.
[0154] The information flow between different tasks is independent of each other, and the processing of multimodal input features is completely unaffected by the task readout module. This independence enables the model to maintain stability and efficiency when handling multi-task scenarios.
[0155] This mechanism also precisely controls the flow of information. Specifically, the task readout module can freely obtain the required information from the multimodal input features, while the multimodal input features are not interfered with by the operations of the task module. This one-way information flow design ensures efficient and logically clear feature interaction, fundamentally avoiding mutual interference between tasks.
[0156] Furthermore, the mask matrix offers strong dynamic scalability. As the number of tasks increases or decreases, the mask matrix can be dynamically generated based on actual needs without modifying or retraining the existing model structure. This flexibility allows the model to quickly adapt to new task scenarios and meet the real-time scalability requirements of complex applications.
[0157] Overall, the customized OnlyLookMask mechanism achieves decoupling between tasks and precise allocation of information flow through precise control of the attention matrix. This not only ensures task independence and controllable information flow, but also provides strong support for dynamic task splicing and expansion. This mechanism lays the technical foundation for the application of multi-task neural networks in complex scenarios, enabling the model to flexibly and efficiently adapt to the needs of different tasks, and has broad application prospects.
[0158] Furthermore, the attention score matrix satisfies the following conditions:
[0159]
[0160] Where, Calculate the matrix for attention, Q, K are query and key matrices respectively, d k is the dimension of the key, Mask OnlyLook is the mask matrix.
[0161] Furthermore, determining the attention score matrix of the deep learning model based on the mask matrix and the attention calculation matrix of the deep learning model includes:
[0162] The mask matrix is added to the attention calculation matrix of the deep learning model, and the attention calculation matrix with the added mask matrix is normalized to obtain the attention score matrix of the deep learning model.
[0163] As can be seen, the introduction of task-independent readout modules and the OnlyLookMask masking mechanism enables dynamic concatenation of multimodal tasks and isolated processing of output features. Each task's readout module can be independently added to the multimodal input features as needed, and the Transformer model is used to complete dynamic task joint processing. Ultimately, the task output is directly extracted from the designated readout component, ensuring task independence and real-time scalability.
[0164] In a specific embodiment, in the present invention, multimodal input features and task readout modules are concatenated and then fed into a Transformer model for feature processing. Through the Transformer's multi-layer encoding mechanism, the model can effectively extract the associated features between multimodal input and tasks and conduct in-depth analysis of task requirements. After completing feature processing at all layers, the final feature matrix output only needs to extract the readout portion of the corresponding task as the output result of that task. This process is quickly achieved through indexing operations.
[0165] The output feature matrix of Transformer can be expressed as Z∈R (N+L)×D , where N is the multimodal input sequence data, L is the task readout module sequence data, and D is the feature dimension. The first N rows of the matrix represent the processing results of the multimodal input features, and the last L rows represent the processing results of the task readout module.
[0166] Assuming that the index range of the matrix corresponding to the readout part of a task is [N, N+L), the final output features of the task can be extracted by the following formula:
[0167] O=Z[N:N+L]
[0168] Among them, O∈R L×D Represents the final output features of the task. Through this indexing operation, the model can accurately obtain the output results of the task without additional post-processing of the entire feature matrix.
[0169] Because the readout for each task is independently generated and dynamically appended to the multimodal input features, the model's operations during the task output phase are completely decoupled from those during the input phase. This decoupling ensures dynamic scalability. For example, when adding a new task, simply add the corresponding task readout module to the input phase and extract the output features of the newly added task during the output phase, without retraining or modifying the Transformer's internal structure.
[0170] Features and advantages of task output:
[0171] 1. Accurate positioning of task results: Directly extract readout processing results through indexing operations without complex filtering or calculations, ensuring efficient and stable output.
[0172] 2. Support multi-task parallel output: For multiple tasks existing at the same time, the model can extract the corresponding output features according to the index range of each task, realizing parallel processing of multiple tasks.
[0173] 3. Ease of task expansion: When the number or type of tasks changes, only the concatenation and indexing logic of the input and output stages needs to be adjusted, without retraining or adjusting Transformer internal parameters. This flexibility provides technical support for the dynamic expansion of complex task scenarios.
[0174] Output example
[0175] Assume that the multimodal input sequence data is N = 512, the feature dimension is D = 128, and the readout sequence data of the current task is L = 64. After the Transformer is processed, the shape of the output matrix Z is (512 + 64) × 128 = 576 × 128. The model extracts the task output through indexing operations:
[0176] O=Z[512:576]
[0177] Extracted result O∈R 64×128 That is, the output feature of the current task, which can be directly used for downstream task processing.
[0178] This readout-based task output mechanism complements the splicing operation, providing an efficient and flexible solution for multi-task learning and real-time task expansion in complex scenarios.
[0179] In a specific embodiment, the masking mechanism can be expanded to other forms of attention mechanisms, or more layers of rules can be added to accommodate more complex tasks. Furthermore, more dimensions can be added to the readout to support higher-dimensional or feature-rich task outputs. Furthermore, this patchwork design is applicable not only to the Transformer architecture but also to other neural network structures, such as RNNs or GNNs, achieving broader adaptability.
[0180] like Figure 2 As shown, based on the above method embodiment, a corresponding device embodiment is provided;
[0181] An embodiment of the present invention provides a multi-task processing device for a power system, comprising: a data acquisition module 201, a data processing module 202, a data splicing module 203, and a result generation module 204;
[0182] The data acquisition module is used to obtain task characteristics and equipment operation data corresponding to each task of the power system;
[0183] The data processing module is used to determine the tensor data corresponding to each task based on the task characteristics and equipment operation data corresponding to each task; fuse the equipment operation data corresponding to all tasks to generate a multimodal input feature matrix;
[0184] The data splicing module is used to expand each tensor data, obtain the expanded tensor of each tensor data when the batch data of the current tensor data is the same as the batch data of the multimodal input feature matrix, and splice all the expanded tensors with the multimodal input feature matrix based on the sequence data to obtain a spliced feature matrix;
[0185] The result generation module is used to input the spliced feature matrix into a deep learning model with an attention score matrix, generate an output feature matrix by the deep learning model, and index the output feature matrix according to the position of the sequence data corresponding to each extended tensor in the sequence data corresponding to the spliced feature matrix to obtain the output result corresponding to each task, and use each output result as the equipment feature of each task, so that the user can analyze the power system based on the equipment feature of each task.
[0186] It can be understood that the above-mentioned device embodiment corresponds to the method embodiment of the present invention, which can implement any one of the above-mentioned method embodiments of the present invention to provide a multi-tasking processing method for a power system.
[0187] It should be noted that the device embodiments described above are merely illustrative, and some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. Furthermore, in the drawings of the device embodiments provided by the present invention, the connection relationship between modules indicates that they have a communication connection, which may be implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement the present invention without inventive effort.
[0188] Based on the above-mentioned embodiment of the multi-tasking processing method for the power system, another embodiment of the present invention provides a terminal device, which includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements the multi-tasking processing method for the power system of any embodiment of the present invention.
[0189] For example, in this embodiment, the computer program may be divided into one or more modules, which are stored in the memory and executed by the processor to implement the present invention. The one or more module elements may be a series of computer program instruction segments capable of performing specific functions, and the instruction segments are used to describe the execution process of the computer program in the terminal device.
[0190] The terminal device may be a computing device such as a desktop computer, a notebook computer, a PDA, a cloud server, etc. The terminal device may include, but is not limited to, a processor and a memory.
[0191] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the terminal device, connecting various parts of the entire terminal device using various interfaces and lines.
[0192] Based on the above-mentioned method embodiments, another embodiment of the present invention provides a computer-readable storage medium, including a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the multi-tasking processing method for the power system described in any one of the above-mentioned method embodiments of the present invention.
[0193] Wherein, the module / unit integrated in the device / terminal equipment, if implemented in the form of a software functional unit and sold or used as an independent product, can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the process in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by the processor, it can implement the steps of the above-mentioned various method embodiments. Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device that can carry the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc.
[0194] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A multi-tasking method for a power system, characterized in that: include: Obtain task characteristics and equipment operation data corresponding to each task of the power system; Based on the task characteristics and equipment operation data corresponding to each task, determine the tensor data corresponding to each task; fuse the equipment operation data corresponding to all tasks to generate a multimodal input feature matrix; Expand each tensor data, and when the batch data of the current tensor data is the same as the batch data of the multimodal input feature matrix, obtain the expanded tensor of each tensor data, and splice all the expanded tensors with the multimodal input feature matrix based on the sequence data to obtain the spliced feature matrix; The concatenated feature matrix is input into a deep learning model with an attention score matrix. The deep learning model generates an output feature matrix. According to the position of the sequence data corresponding to each extended tensor in the sequence data corresponding to the concatenated feature matrix, it is indexed in the output feature matrix to obtain the output result corresponding to each task. Each output result is used as the device feature of each task, so that users can analyze the power system based on the device features of each task.
2. The multi-tasking processing method for a power system according to claim 1, wherein: The task features include: batch data, sequence data, and feature dimensions; the tensor data corresponding to each task is determined based on the task features and device operation data corresponding to each task, including: In each task, the equipment operation data is extracted based on batch data, sequence data and feature dimensions to obtain the initial feature matrix; Calculate the position encoding of each element in the initial feature matrix to obtain the encoding matrix; Add the initial feature matrix and the encoding matrix to obtain the feature tensor; The feature tensor is projected through a linear transformation operation to obtain the tensor data of the current task.
3. The multi-tasking processing method for a power system according to claim 2, wherein: The calculation of position encoding for each element in the initial feature matrix to obtain the encoding matrix includes: According to the position index, feature dimension index and feature dimension of each element in the initial feature matrix, the position encoding calculation formula is substituted into the feature matrix to obtain the encoding matrix. The position encoding calculation formula satisfies the following conditions: Where pos represents the position index of an element in the initial feature matrix, q is the feature dimension index, and d is the feature dimension of the current task.
4. The multi-tasking processing method for a power system according to claim 3, wherein: Before inputting the concatenated feature matrix into the deep learning model with the attention weight matrix, the method further includes: Determine a mask matrix based on the sequence data of the spliced feature matrix; wherein the sequence data of the spliced feature matrix is obtained by superimposing the sequence data [0, N] of the multimodal input feature matrix with the sequence data [0, L] of n tensor data to obtain the sequence data [0, N + nL] of the spliced feature matrix; It consists of the sequence data of each tensor data and the sequence data of the multimodal input feature matrix; Determine the attention score matrix of the deep learning model based on the mask matrix and the attention calculation matrix of the deep learning model.
5. The multi-tasking method for a power system according to claim 4, wherein: The determining of the mask matrix based on the sequence data of the splicing feature matrix includes: The initial matrix is established with the number of sequence data of the spliced feature matrix as the number of rows and the number of sequence data of the spliced feature matrix as the number of columns; Judge each element in the initial matrix; If the row position of the current element is at any position in the sequence data of the spliced feature matrix, and the column position of the current element is at the position where the sequence data of the multimodal input feature matrix is located in the sequence data of the spliced feature matrix, then the current element is 0; If the row position of the current element is at the position where the sequence data of the tensor data is located in the sequence data of the spliced feature matrix, and the column position of the current element is at the position where the sequence data of the tensor data is located in the sequence data of the spliced feature matrix, then the current element is 0; If the row position of the current element is at the position where the sequence data of the multimodal input feature matrix is located in the sequence data of the spliced feature matrix, and the column position of the current element is at the position where the sequence data of the tensor data is located in the sequence data of the spliced feature matrix, then the current element is 1; After determining the value of each element in the initial matrix, a mask matrix is generated.
6. The multi-tasking method for a power system according to claim 5, wherein: The attention score matrix satisfies the following conditions: Where, Calculate the matrix for attention, Q, K are query and key matrices respectively, d k is the dimension of the key, Mask OnlyLook is the mask matrix.
7. The multi-tasking method for a power system according to claim 6, wherein: Determining the attention score matrix of the deep learning model based on the mask matrix and the attention calculation matrix of the deep learning model includes: The mask matrix is added to the attention calculation matrix of the deep learning model, and the attention calculation matrix with the added mask matrix is normalized to obtain the attention score matrix of the deep learning model.
8. A multi-tasking processing device for a power system, characterized in that: include: Data acquisition module, data processing module, data splicing module and result generation module; The data acquisition module is used to obtain task characteristics and equipment operation data corresponding to each task of the power system; The data processing module is used to determine the tensor data corresponding to each task based on the task characteristics and equipment operation data corresponding to each task; fuse the equipment operation data corresponding to all tasks to generate a multimodal input feature matrix; The data splicing module is used to expand each tensor data, obtain the expanded tensor of each tensor data when the batch data of the current tensor data is the same as the batch data of the multimodal input feature matrix, and splice all the expanded tensors with the multimodal input feature matrix based on the sequence data to obtain a spliced feature matrix; The result generation module is used to input the spliced feature matrix into a deep learning model with an attention score matrix, generate an output feature matrix by the deep learning model, and index the output feature matrix according to the position of the sequence data corresponding to each extended tensor in the sequence data corresponding to the spliced feature matrix to obtain the output result corresponding to each task, and use each output result as the equipment feature of each task, so that the user can analyze the power system based on the equipment feature of each task.
9. A terminal device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein when the processor executes the computer program, the multi-tasking processing method for a power system according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that include: A stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the multi-tasking processing method for a power system according to any one of claims 1 to 7.