Methods to improve the accuracy of smart meter data completion
By combining low-rank tensor decomposition and the Transformer model, the accuracy problem of smart meter data completion in complex and large-scale scenarios is solved, achieving high-precision data recovery and improving the stability and reliability of the power system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUNAN UNIV
- Filing Date
- 2025-07-16
- Publication Date
- 2026-06-30
AI Technical Summary
Existing methods for completing smart meter data have limited effectiveness in handling complex and large-scale scenarios, making it difficult to achieve high-precision data recovery.
By combining low-rank tensor decomposition technology with the Transformer model, feature-enhanced meter data sequences are generated through multi-path delay embedding transformation, time block partitioning, tensor decomposition, and position encoding. Finally, data completion is performed through inverse tensor decomposition.
This improves the accuracy of smart meter data completion, enabling more accurate capture of the temporal and spatial dependencies of meter data, thereby enhancing the stability and reliability of the power system.
Smart Images

Figure CN120929732B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of artificial intelligence and time-series data analysis, and in particular to a method for improving the accuracy of smart meter data completion. Background Technology
[0002] The lack of smart meter data (or grid data) can be caused by equipment failure, transmission interruption, network problems, or data acquisition issues. Smart meter data completion aims to restore missing or incomplete real-time monitoring data in the power grid to ensure the stability, optimization, and security of the power system. Because smart meter data is typically multi-dimensional spatiotemporal data, smart meter data completion is a complex task.
[0003] Traditional data completion methods typically rely on statistical methods and machine learning algorithms. Early interpolation methods were widely used to fill in missing data; for example, linear interpolation based on existing data points infers the relationship between missing data points and surrounding data points. While these methods can complete some missing data, they struggle with complex smart meter data, especially in large-scale and complex scenarios, where their completion effectiveness is limited.
[0004] With the rapid development of artificial intelligence technology, the application of deep learning technology is becoming more and more widespread. How to use deep learning technology to improve the data completion effect of smart meters is a problem worth studying. Summary of the Invention
[0005] Therefore, it is necessary to provide a method for improving the accuracy of smart meter data completion, a computer device, a computer-readable storage medium, and a computer program product that can improve the data completion effect, in order to address the above-mentioned technical problems.
[0006] Firstly, this application provides a method for improving the accuracy of smart meter data completion, the method comprising:
[0007] In each round of training, multiple first meter data sequences are sampled to generate a meter sequence matrix and a mask matrix; the mask matrix is used to identify missing positions in the meter sequence matrix.
[0008] Perform multi-path delay embedding transformation on the meter sequence matrix and the mask matrix respectively to obtain the first tensor and the mask tensor;
[0009] The first tensor and the mask tensor are divided into first sub-tensors and mask sub-tensors of multiple time blocks, respectively. For the first sub-tensor corresponding to each time block, the first sub-tensor is decomposed into the corresponding first core sub-tensor and factor matrix based on the mask sub-tensor corresponding to the time block.
[0010] A first target sequence is generated based on multiple first core sub-tensors. The first target sequence and the corresponding position encoding results are input into the Transformer model in this round of completion model to obtain multiple second core sub-tensors with enhanced features output by the Transformer model.
[0011] The second tensor is obtained by inverse tensor decomposition based on multiple second core sub-tensors and factor matrices. The second tensor is then subjected to inverse multipath delay embedding transformation to obtain multiple second meter data sequences.
[0012] The target loss value is determined based on the numerical difference between each second meter data sequence and the corresponding first meter data sequence at the same missing position. The model parameters are adjusted based on the target loss value, and the next round of training is carried out until the training ends, resulting in a completion model for smart meter data completion.
[0013] In one embodiment, for each time block corresponding to a first sub-tensor, the first sub-tensor is decomposed into a corresponding first core sub-tensor and a factor matrix based on the mask sub-tensor corresponding to the time block, including:
[0014] For each time block, calculate the mean of the elements in the non-missing positions of the first subtensor corresponding to the time block;
[0015] Based on the mask subtensor corresponding to the time block, fill the missing positions in the first subtensor corresponding to the time block with the mean value;
[0016] Tensor decomposition is performed on the padded tensor to obtain the corresponding first core sub-tensor and factor matrix.
[0017] In one embodiment, 1 in the mask sub-tensor is used to identify the non-missing position of the first sub-tensor, and 0 in the mask sub-tensor is used to identify the missing position of the first sub-tensor.
[0018] Based on the mask subtensor corresponding to the time block, the missing positions in the first subtensor corresponding to the time block are filled with the mean, including:
[0019] The first product of the first sub-tensor corresponding to the time block and the mask sub-tensor, and the second product of the mean and the missing mask sub-tensor are added to obtain the tensor after the missing position is filled; wherein, the missing mask sub-tensor is obtained by subtracting the mask sub-tensor from 1.
[0020] In one embodiment, the first target sequence includes a first forward sequence and a first reverse sequence; the first forward sequence is generated based on a plurality of first core sub-tensors and a forward sorting of corresponding time blocks; the first reverse sequence is generated based on a plurality of first core sub-tensors and a reverse sorting of corresponding time blocks; the first forward sequence is position-encoded to obtain a forward position-encoded result; the first reverse sequence is position-encoded to obtain a reverse position-encoded result.
[0021] The first target sequence and its corresponding position encoding result are input into the Transformer model in this round of completion model to obtain multiple second core sub-tensors after feature enhancement output by the Transformer model, including:
[0022] Based on the first forward sequence and the corresponding forward position encoding result, a first input feature matrix is generated. The first input feature matrix is then input into the Transformer model to obtain the predicted first feature enhancement result.
[0023] Based on the first inverse sequence and the corresponding inverse position encoding result, a second input feature matrix is generated. The second input feature matrix is then input into the Transformer model to obtain the predicted second feature enhancement result.
[0024] By aggregating the results of the first feature enhancement and the second feature enhancement, multiple second core sub-tensors are obtained.
[0025] In one embodiment, the first forward sequence is obtained by concatenating multiple first feature matrices in forward order, and the first reverse sequence is obtained by concatenating multiple first feature matrices in reverse order; the multiple first feature matrices are generated by expanding each first core sub-tensor using a first mode.
[0026] Based on the first forward sequence and the corresponding forward position encoding result, a first input feature matrix is generated, including: transforming the feature dimension of the first forward sequence to generate a third feature matrix; performing position encoding on the elements in the third feature matrix to obtain a forward position encoding result; and concatenating the third feature matrix and the forward position encoding result to generate the first input feature matrix.
[0027] And / or,
[0028] Based on the first inverse sequence and the corresponding inverse position encoding result, a second input feature matrix is generated, including: transforming the feature dimension of the first inverse sequence to generate a fourth feature matrix; performing position encoding on the elements in the fourth feature matrix to obtain the inverse position encoding result; and concatenating the fourth feature matrix and the inverse position encoding result to generate the second input feature matrix.
[0029] In one embodiment, inputting a first input feature matrix into a Transformer model to obtain a predicted first feature enhancement result includes: inputting the first input feature matrix into a Transformer model, encoding the first input feature matrix based on the first input feature matrix through the encoder in the Transformer model to obtain a first encoding result; and the decoder in the Transformer model depends on the first encoding result to decode and output the first feature enhancement result.
[0030] And / or,
[0031] The second input feature matrix is input into the Transformer model to obtain the predicted second feature enhancement result, including: inputting the second input feature matrix into the Transformer model, encoding the second input feature matrix through the encoder to obtain the second encoding result, and the decoder relying on the second encoding result to decode and output the second feature enhancement result.
[0032] In one embodiment, determining the target loss value based on the numerical difference between each second meter data sequence and the corresponding first meter data sequence at the same missing position includes:
[0033] The first sub-loss is determined based on the numerical difference between the second meter data sequence and the corresponding first meter data sequence at the same missing position.
[0034] The second sub-loss is determined based on the mean and variance differences between the second electricity meter data sequence and the corresponding first electricity meter data sequence.
[0035] The target loss value is determined based on the first sub-loss and the second sub-loss.
[0036] Secondly, this application provides a method for improving the accuracy of smart meter data completion, the method comprising:
[0037] Obtain at least one data sequence of the meter to be completed;
[0038] The first target tensor is obtained by performing multi-path delay embedding transformation on the meter data sequence to be completed using a pre-trained completion model.
[0039] The first target tensor is divided into multiple time blocks of target sub-tensors. The target sub-tensors of multiple time blocks are decomposed into tensors respectively to generate multiple first target core sub-tensors and corresponding target factor matrices.
[0040] A second target sequence to be position-encoded is generated based on multiple first target core sub-tensors. The second target sequence and the corresponding position encoding result are input into the Transformer model in the completion model to obtain multiple second target core sub-tensors with enhanced features output by the Transformer model.
[0041] The second target tensor is obtained by inverse tensor decomposition based on multiple second target core sub-tensors and corresponding target factor matrices. The second target tensor is then subjected to inverse multipath delay embedding transformation to obtain the completed target meter data sequence.
[0042] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps in the embodiments of this application.
[0043] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the steps in the embodiments of this application.
[0044] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the steps in the embodiments of this application.
[0045] The aforementioned methods, computer equipment, computer-readable storage media, and computer program products for improving the accuracy of smart meter data completion implement a scheme that combines low-rank tensor decomposition technology with the Transformer model to train the completion model. This scheme integrates the global temporal modeling capabilities of the Transformer model with the sparse data structuring advantages of low-rank tensor decomposition, while also ensuring the model's robustness to data noise and outliers. Therefore, the trained completion model can fully and accurately capture the temporal and spatial dependencies of meter data, thereby achieving high-precision data completion in high-dimensional scenarios and improving the completion accuracy of large-scale smart meter data. Furthermore, the high-precision completed smart meter data not only provides more reliable data support for the power system but also improves the availability and stability of smart meter data in intelligent scenarios such as power dispatching and energy consumption monitoring, playing a crucial role in the digital transformation and intelligent upgrading of the power system. Attached Figure Description
[0046] Figure 1 This is a flowchart illustrating a method for improving the accuracy of smart meter data completion in one embodiment.
[0047] Figure 2 This is a flowchart illustrating a method for improving the accuracy of smart meter data completion in another embodiment;
[0048] Figure 3 This is a schematic diagram illustrating the principle of a method for improving the accuracy of smart meter data completion in one embodiment;
[0049] Figure 4 This is a structural block diagram of a device for improving the accuracy of smart meter data completion in one embodiment.
[0050] Figure 5 A structural block diagram of a smart meter data completion accuracy improvement device in another embodiment;
[0051] Figure 6 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0052] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0053] It should be understood that, unless otherwise defined, all technical terms used herein have the same meaning as commonly understood by those skilled in the art. The technical terms used herein are for the purpose of describing specific examples only and are not intended to limit the scope of this application.
[0054] like Figure 1 As shown, in one embodiment, a method for improving the accuracy of smart meter data completion is provided. This method is executed by a computer device and specifically includes the following steps:
[0055] S11, in each round of training, multiple first meter data sequences are sampled to generate a meter sequence matrix and a mask matrix; the mask matrix is used to identify missing positions in the meter sequence matrix.
[0056] It should be understood that the process of training the completion model for completing smart meter data is a multi-round iterative training process. In each round of training, a batch of data will be sampled from the original sample set for this round of training, that is, multiple first meter data sequences will be sampled.
[0057] In this system, multiple first-meter data sequences correspond to multiple sample users. Each first-meter data sequence is a time series, including meter data for a single sample user at multiple time points. The meter data may include smart meter-related data such as electricity consumption and power consumption, and can also be referred to as power grid data.
[0058] The meter sequence matrix can be represented as Where n represents n rows, which represent n sample users. Each row in the matrix contains the first meter data sequence corresponding to a sample user. T represents the time dimension, which means that the first meter data sequence includes meter data at T time points.
[0059] The mask matrix can be randomly generated in each training round or generated according to preset rules, and is used to flexibly specify (i.e., identify) missing positions in the meter sequence matrix. Missing positions are the locations in the meter sequence matrix where meter data is missing, while non-missing positions are the locations where there is no missing meter data (i.e., the true value). Essentially, during the training of the completion model, there is no need to specifically prepare meter data sequences with missing data; instead, the missing positions are specified through the mask matrix to achieve the purpose of training the completion model, which is more flexible and reduces the cost of preparing sample data.
[0060] The mask matrix can be represented as M∈{0,1} n×T or The size of the mask matrix corresponds to that of the meter sequence matrix, which is also an n×T matrix. For example, non-missing positions in the meter sequence matrix are assigned a value of 1 in the mask matrix, and missing positions are assigned a value of 0 in the mask subtensor. In other examples, the reverse can also be true, with non-missing positions in the mask matrix assigned a value of 0 and missing positions assigned a value of 1; this is not a limitation.
[0061] S12, perform multi-path delay embedding transformation on the meter sequence matrix and the mask matrix respectively to obtain the first tensor and the mask tensor.
[0062] The multipath delay embedding transformation yields a higher-order first tensor, which can capture spatiotemporal feature structures.
[0063] In some embodiments, the multiplexed delay embedding transformation in step S12 includes the following steps:
[0064] (1) Initialize the replication matrix S∈{0,1} τ(T-τ+1)×T Where τ is the length of the delay window, used to represent the maximum number of times a single element is repeated.
[0065] (2) Based on the replication matrix S, the meter sequence matrix Perform a multipath delay embedding transform to obtain the first tensor. For example, a multipath delay embedding transform can be performed according to the following formula:
[0066] H(X) = fold (n,τ) (XS T );
[0067] In this process, the replication matrix S copies the meter sequence matrix X. This means folding the matrix into a third-order tensor; This is a low-rank block Hankel tensor, i.e., the first tensor. τ is the length of the delay window.
[0068] (3) Based on the copy matrix to the mask matrix The multi-path delay embedding transformation operation yields the mask tensor. For example, it can be processed according to the following formula:
[0069]
[0070] Among them, MS T This indicates that the copy matrix S replicates the mask matrix M.
[0071] S13, divide the first tensor and the mask tensor into first sub-tensors and mask sub-tensors of multiple time blocks respectively. For the first sub-tensor corresponding to each time block, decompose the first sub-tensor into the corresponding first core sub-tensor and factor matrix based on the mask sub-tensor corresponding to the time block.
[0072] In some embodiments, the first tensor can be... The first sub-tensor divided into W time blocks, the first sub-tensor of each time block for: Similarly, the mask tensor can be... It is also divided into mask subtensors of W time blocks, and the mask subtensor of each time block... for:
[0073] Computer devices can base their decisions on the first sub-tensor partitioned for each time block. and mask tensor Perform preliminary tensor completion. The tensor completion process can be transformed into performing low-rank tensor decomposition on the first sub-tensor, that is, preliminary tensor completion is achieved based on low-rank tensor decomposition technology (or low-rank model).
[0074] Specifically, in the low-rank tensor decomposition process, for the first sub-tensor corresponding to each time block, the higher-order first sub-tensor can be decomposed into the corresponding first core sub-tensor and factor matrix based on the mask sub-tensor corresponding to the time block. It should be understood that low-rank tensor decomposition can extract compact spatiotemporal features.
[0075] In some embodiments, low-rank tensor decomposition can be achieved by optimizing the following objective function to decompose the first subtensor. Decomposed into the corresponding first core subtensor Sum of factors:
[0076]
[0077] in, This is the first core subtensor of the Tucker decomposition (a low-rank tensor decomposition method); The factor matrix is the result of Tucker decomposition. This is the first factor matrix. This is the second factor matrix. is the third factor matrix; ×1 is the first modular product of the tensor and the matrix; ×2 is the second modular product of the tensor and the matrix; ×3 is the third modular product of the tensor and the matrix. ⊙ is the Hadamard multiplication. The square of the Frobenius norm of the tensor. Mask tensor. In the process of constraining low-rank tensor decomposition, more attention is paid to the values at non-missing positions, while the values at missing positions are ignored.
[0078] The overall meaning of the above formula can be understood as: based on the mask subtensor So that on the first subtensor In the process of low-rank tensor decomposition, more attention is paid to the first subtensor. Solving for the first core subtensor using the numerical values of the missing positions in the non-core region. And the factor matrix, finally determining the first core subtensor The product of the sum and factor matrices and the first subtensor The difference is minimized. In other words, the final determined first core subtensor... The product of the factor matrix and the reconstructed subtensor is the subtensor that needs to be multiplied by the first subtensor. Closest. It should be understood that the first core subtensor... The subtensor reconstructed from the factor matrix is the tensor without missing values after completion. Therefore, the process of low-rank tensor decomposition is equivalent to achieving preliminary completion to some extent.
[0079] In some embodiments, to further approximate the low-rank form, a regularization term can be added to the objective function to make the first core subtensor... The Frobenius norm of approaches a minimum, as follows:
[0080]
[0081] In the formula, λ>0 is the regularization coefficient, used to balance reconstruction error and low-rank constraint. The three factor matrices of Tucker decomposition. Let m be the m-th factor matrix.
[0082] It should be understood that directly solving the first core subtensor... Since factor matrices are relatively difficult to obtain, the Alternating Least Squares (ALS) method can be used to gradually approximate the optimal solution. The specific processing steps of the least squares method will be described below and will not be discussed here.
[0083] S14: Generate a first target sequence based on multiple first core sub-tensors, and input the first target sequence and the corresponding position encoding result into the Transformer model in this round of completion model to obtain multiple second core sub-tensors with enhanced features output by the Transformer model.
[0084] It should be understood that by splitting the entire first tensor into multiple time blocks and then performing low-rank tensor decomposition on each, a kernel tensor sequence can be formed, which can match the data processing characteristics of the Transformer model. This realizes a new scheme that combines low-rank tensor decomposition with the Transformer model.
[0085] The "complete model in this round" refers to the complete model to be trained in this round. This complete model includes a Transformer model. It should be understood that, based on multiple first core sub-tensors, the multiple second core sub-tensors output by the Transformer model are the result of feature enhancement. This is equivalent to upgrading the input first core sub-tensors using contextual modeling or global modeling capabilities, giving them deeper and higher-order contextual features, which can more accurately reconstruct the complete data subsequently.
[0086] It should be understood that positional encoding of multiple first core subtensors can fully utilize the preceding and following information to refine the details of transformer modeling.
[0087] In some embodiments, the first target sequence is a first forward sequence. That is, the computer device can generate a first forward sequence based on multiple first core sub-tensors and the forward sorting between corresponding time blocks, and obtain a forward position encoding result after position encoding of the first forward sequence. Then, the forward data (i.e., the input data determined based on the first forward sequence and the corresponding forward position encoding result) is input into the Transformer model in this round of completion model, and the first feature enhancement result predicted by the Transformer model based on the input forward data is used as the final feature enhancement result—that is, the multiple second core sub-tensors after completion.
[0088] In other embodiments, the data predicted and completed by combining the forward and inverse positional encoding results can provide more contextual information and improve the accuracy of subsequent predictions by the decoder. Specifically, the first target sequence includes not only the first forward sequence but also the first inverse sequence. That is, the computer device can generate the first inverse sequence based on multiple first core sub-tensors and the inverse sorting between corresponding time blocks, and obtain the inverse positional encoding result by performing positional encoding on the first inverse sequence. In addition to inputting forward data into the Transformer model, inverse data (i.e., input data determined based on the first inverse sequence and the corresponding inverse positional encoding result) can also be input into the Transformer model. Furthermore, the first feature enhancement result predicted by the Transformer model based on the input forward data and the second feature enhancement result predicted based on the inverse data can be fused to obtain the final feature enhancement result.
[0089] In some embodiments, the computer device can generate a first input feature matrix based on a first forward sequence and the corresponding forward position encoding result, and input the first input feature matrix into a Transformer model to obtain a predicted first feature enhancement result. The computer device can also generate a second input feature matrix based on a first inverse sequence and the corresponding inverse position encoding result, and input the second input feature matrix into a Transformer model to obtain a predicted second feature enhancement result. Furthermore, the first feature enhancement result and the second feature enhancement result are aggregated to obtain multiple second core subtensors.
[0090] For a more detailed description of the processing of the data after prediction and completion based on the results of forward and reverse position encoding, please refer to the following description.
[0091] S15. Based on multiple second core sub-tensors and factor matrices, inverse tensor decomposition is performed to obtain the second tensor. The second tensor is then subjected to inverse multipath delay embedding transformation to obtain multiple second meter data sequences.
[0092] Specifically, the computer device can perform inverse tensor decomposition on each second core sub-tensor and its corresponding factor matrix to obtain multiple (W) second sub-tensors corresponding to time blocks. It should be understood that inverse tensor decomposition (such as inverse Tucker decomposition) is the inverse process of tensor decomposition in step S13, used to reconstruct the second sub-tensors corresponding to each time block or time window after feature enhancement. Furthermore, the second sub-tensors corresponding to multiple time blocks are concatenated to form the feature-enhanced second tensor.
[0093] Furthermore, the second tensor can be... Perform an inverse multipath delay embedding transform (such as the inverse transform of the multipath delay embedding transform in step S12) to obtain multiple second meter data sequences (i.e., the completed two-dimensional meter data matrix). For example, multiple second meter data sequences can be obtained through the following steps:
[0094] (1) Initialize the same copy matrix S∈{0,1} as in the multipath delay embedding transform. τ(T-τ+1)×T τ is the length of the delay window, used to represent the maximum number of times a single element is repeated;
[0095] (2) For the second tensor Perform an inverse multiplexed delay embedding transform to obtain the completed data Y (it should be understood that Y is a two-dimensional matrix including multiple second meter data sequences). For example, the inverse multiplexed delay embedding transform can be performed according to the following formula:
[0096]
[0097] Wherein, the copy matrix S will copy the second tensor To perform a copy; `unfold(n,τ)` represents the unfolding operation, used to... This means expanding the tensor into an n×τ(T-τ+1) matrix, which is an n×T matrix.
[0098] S16. Determine the target loss value based on the numerical difference between each second meter data sequence and the corresponding first meter data sequence at the same missing position. Adjust the model parameters based on the target loss value and conduct the next round of training until the training ends, thus obtaining the completion model for smart meter data completion.
[0099] It should be understood that multiple second meter data sequences constitute a reconstructed and completed meter data matrix, corresponding one-to-one with the original meter data matrix formed by the first meter data sequence. The differences between the two meter data matrices generally lie in the values at the missing positions identified by the mask matrix. The values at the missing positions in the original meter data matrix formed by the first meter data sequence are the true values, while the values at the missing positions in the reconstructed and completed meter data matrix from the multiple second meter data sequences are the predicted values. Therefore, the computer equipment can determine the target loss value based on the difference between the true and predicted values corresponding to the same missing position in the two meter data matrices or two meter data sequences.
[0100] In some embodiments, the corresponding loss value can be calculated based on the numerical differences (i.e., the difference between the actual value and the predicted value) corresponding to the same missing position in the first and second electricity meter data sequences, respectively, according to the following formula. For example, the loss function L... MSE as follows:
[0101]
[0102] Where (i,t):M i,t =0 indicates that the index (i,t) (e.g., the i-th row and t-th column, where the t-th column could be the t-th time point) is a missing position, and its corresponding value in the mask matrix is 0. |M=0| represents the total number of missing positions. It should be understood that the mean squared error loss is only calculated for the difference between the predicted value and the true value at the missing position. Y i,t The model prediction value corresponding to the missing position indicated by index (i,t) (which can also be understood as the missing position in the i-th row and t-th column of the meter data matrix formed by the second meter data sequence, where the value at the missing position is Y) i,t ), X i,t The true value corresponding to the missing position indicated by index (i,t) (which can also be understood as the missing position being the i-th row and t-th column of the meter data matrix formed by the first meter data sequence, with the value at that missing position being X). i,t ).
[0103] Computer equipment can directly use the loss value determined by the difference between the actual value and the predicted value corresponding to the same missing position as the target loss value, or it can combine other loss values to jointly determine the target loss value.
[0104] In some embodiments, the computer device may determine a first sub-loss based on the numerical difference between the second electricity meter data sequence and the corresponding first electricity meter data sequence at the same missing position. A second sub-loss may be determined based on the mean difference and variance difference between the second electricity meter data sequence and the corresponding first electricity meter data sequence; and a target loss value may be determined based on the first and second sub-losses.
[0105] Specifically, to enhance the model's generalization ability, a statistical consistency loss (self-supervised loss), also known as the second loss, is introduced. This loss requires that the results generated by the model (i.e., multiple second-meter data sequences) maintain consistency with the real data (i.e., multiple first-meter data sequences) in terms of mean and variance. For example, the formula for the second loss function is as follows:
[0106] L adv =λ adv (||E(Y)-E(X)||2+||Var(Y)-Var(X))||2);
[0107] Where, λ adv To control the weighting coefficients of the self-supervised loss strength, E(Y) is the expected value of multiple second meter data sequences, E(X) is the expected value of multiple first meter data sequences, Var(Y) is the variance of multiple second meter data sequences, and Var(X) is the variance of multiple first meter data sequences.
[0108] Furthermore, the target loss value L = L MSE +L adv ;
[0109] This is equivalent to adding the first and second sub-losses to obtain the target loss value. In other examples, the target loss value can also be obtained by weighted summation of the first and second sub-losses; this is not a limitation. It should be understood that the completion model trained more accurately and quickly based on this target loss value can both ensure that known data is not modified and optimize the completion of missing data.
[0110] Furthermore, after determining the target loss value, learning and backpropagation optimization can be performed based on this target loss value to adjust the model parameters (such as the model parameters of the Transformer model) of the completed model to be trained in this round. If the training termination condition is not met (such as the number of iterations not reaching the maximum set number of iterations or the prediction accuracy of the model not reaching the set accuracy range), the next round of training continues. That is, the next round is taken as the current round, and the model parameter adjustment steps in steps S11 to S16 are returned to be executed until the training termination condition is met, resulting in a completed model for smart meter data completion.
[0111] It should be understood that this completion model has multiple modules, including a multi-path delay embedding transformation module, a time block partitioning module, a low-rank decomposition module, a position encoding module, and a trained Transformer model. When using this completion model for smart meter data completion, the input meter data sequence to be completed can be processed collaboratively based on the collaborative processing of multiple models.
[0112] The above method combines low-rank tensor decomposition (LTD) with the Transformer model to train the completion model. This approach integrates the global temporal modeling capabilities of the Transformer model with the sparse data structuring advantages of LTD, while also ensuring the model's robustness to data noise and outliers. Therefore, the trained completion model can fully and accurately capture the temporal and spatial dependencies of meter data, improving the completion accuracy of large-scale smart meter data.
[0113] In some embodiments, step S13, which decomposes the first sub-tensor into a corresponding first core sub-tensor and factor matrix based on the mask sub-tensor corresponding to the time block, includes: for each time block, calculating the mean of the elements in the non-missing positions of the first sub-tensor corresponding to the time block; filling the missing positions in the first sub-tensor corresponding to the time block with the mean based on the mask sub-tensor corresponding to the time block; and performing tensor decomposition based on the filled tensor to obtain the corresponding first core sub-tensor and factor matrix.
[0114] In some embodiments, 1s in the mask subtensor are used to identify non-missing positions in the first subtensor, and 0s in the mask subtensor are used to identify missing positions in the first subtensor. A computer device can add the first product of the first subtensor corresponding to the time block and the mask subtensor, and the second product of the mean and the missing mask subtensor, to obtain the tensor after missing position filling; wherein the missing mask subtensor is obtained by subtracting the mask subtensor from 1.
[0115] For example, missing values can be filled with the mean using the following formula:
[0116]
[0117] in, The mean, i.e., the first subtensor corresponding to this time block. The global mean of all observed elements in the first subtensor (i.e., all elements at non-missing positions in the first subtensor). The number of all observed elements in the first sub-tensor corresponding to this time block (i.e., the number of non-missing positions); i, j, k are three-dimensional indices used to indicate the location of an element in the first sub-tensor; This is the sum of all observed elements in the first subtensor corresponding to this time block (i.e., the sum of elements at all non-missing positions in the first subtensor). ⊙ represents the Hadamard multiplication. That is, the missing mask subtensor, which is 1 minus the mask subtensor. The above (Equation 1) is equivalent to adding the first product of the original first sub-tensor and the mask sub-tensor corresponding to the same time block, and the second product of the mean and the missing mask sub-tensor, to obtain the first sub-tensor after filling the missing positions.
[0118] Then, tensor decomposition is performed based on the padded first subtensor to obtain the corresponding first core subtensor and factor matrix. The objective function for tensor decomposition can be found in the relevant description in step S13, and will not be repeated here.
[0119] For example, tensor decomposition can be performed using alternating least squares based on the padded first subtensor. Alternatively, tensor decomposition can be performed without alternating least squares; this is not a limitation.
[0120] It should be understood that the alternating least squares method will perform multiple rounds of iterative updates to the first core subtensor and factor matrix. For example, in each round, the core tensor is updated sequentially.
[0121]
[0122] In each round, the three factor matrices are updated sequentially:
[0123]
[0124] After each iteration, the tensor is reconstructed based on the first core sub-tensor and factor matrix updated in this round, and the error between the reconstructed tensor and the first sub-tensor is calculated. If the error is less than a preset threshold or the minimum, the corresponding first core sub-tensor and factor matrix are determined as the final tensor decomposition result.
[0125] As described above, the first target sequence may include a first forward sequence and a first reverse sequence. In some embodiments, the first forward sequence is obtained by concatenating multiple first feature matrices in forward order, and the first reverse sequence is obtained by concatenating multiple first feature matrices in reverse order; the multiple first feature matrices are generated by expanding each first core subtensor using a first mode.
[0126] For example, each first core subtensor can be expressed according to the following formula. Perform a mode-1 (i.e., first mode) expansion to obtain the corresponding first feature matrix Z. w :
[0127]
[0128] Among them, reshape() is the tensor shape reconstruction operation.
[0129] In some examples, the first core subtensor for all windows (i.e., time blocks) w = 1,...,W The corresponding first characteristic matrix Z w By concatenating the sequences according to the forward order of the windows (or time blocks), we obtain the first forward sequence Z:
[0130]
[0131] Here, concat() is the concatenation operation.
[0132] In some examples, the first core subtensor for all windows (i.e., time blocks) w = 1,...,W The corresponding first characteristic matrix Z w By concatenating the sequences according to the reverse order of the windows (or time blocks), we obtain the first reverse sequence Z':
[0133]
[0134] In some embodiments, the computer device may transform the feature dimension of the first forward sequence to generate a third feature matrix; perform position encoding on the elements in the third feature matrix to obtain a forward position encoding result; and concatenate the third feature matrix and the forward position encoding result to generate a first input feature matrix.
[0135] For example, the first forward sequence can be transformed into a feature dimension of L×d through a fully connected layer using the following formula. model Generate the third feature matrix Z proj :
[0136] Z proj =ZW model +b proj
[0137] Where, d model =512, It is the weight matrix of the fully connected layer. This is the bias vector.
[0138] For example, the third characteristic matrix can be obtained using sine and cosine functions. Perform position encoding:
[0139]
[0140] In this matrix, PE(pos,2I) represents the 2I-th dimension (even-numbered dimension) component value at position pos, represented by a sine wave; PE(pos,2I+1) represents the 2I+1-th dimension (odd-numbered dimension) component value at position pos, represented by a cosine wave; and pos represents the positional information. Thus, by encoding the even-numbered and odd-numbered dimension components using sine and cosine functions respectively, the positional encoding matrix corresponding to the entire third feature matrix is obtained. It can also be called the forward positional encoding result.
[0141] Furthermore, Z pos =Z proj +PE, that is, the third characteristic matrix Z proj Adding the forward positional encoding result PE, we obtain the first input feature matrix Z to be input into the Transformer model. pos .
[0142] Similarly, the computer device can transform the feature dimensions of the first inverse sequence to generate the fourth feature matrix Z'. proj Position encoding is performed on the elements of the fourth feature matrix to obtain the inverse position encoding result; the fourth feature matrix and the inverse position encoding result are concatenated to generate the second input feature matrix Z'. pos For the specific calculation principle, please refer to the section above regarding the third characteristic matrix Z. proj and the first input feature matrix Z pos The relevant descriptions will not be repeated here.
[0143] In some embodiments, the computer device can use the first input feature matrix Zpos The input is fed into the Transformer model, where the encoder encodes the first input feature matrix to obtain the first encoding result. The decoder in the Transformer model depends on the first encoding result and decodes to output the first feature enhancement result.
[0144] Specifically, the first input feature matrix Z can be processed based on a self-attention mechanism. pos , will Z pos The mapping is Q, K, V. Q is Z. pos The corresponding query matrix represents the query characteristics of each node; K is the value of Z. pos The corresponding key matrix represents the key features of each node; V is the Z... pos The corresponding value matrix represents the value characteristics of each node.
[0145] For example, attention weights are represented as:
[0146] In the formula, A is the attention weight matrix; `softmax()` is the scaling factor; `softmax()` is the activation function. For example, the activation function can be...
[0147] In addition, H attention heads are set, each with a dimension of d. k Each attention head has a corresponding weight matrix and a corresponding output. The outputs of H attention heads are concatenated; the concatenated result is subjected to a linear transformation (projection matrix W). O Mapping back to the original dimension, the specific formula is as follows:
[0148] MHA(Z pos = Contact(head1,...,head) H W O ;
[0149] Where MHA() represents multi-head attention mechanism, head h =Att(Q,K,V) represents the output of each attention head. For example, H=4, d k =128;
[0150] Furthermore, the output of the multi-head attention mechanism can be connected to the first input feature matrix Z via a residual connection. pos Addition: Z res =MHA(Z) pos )+Z pos .
[0151] Furthermore, the result Z of the residual connection can be analyzed.res The layer normalization is performed using the following formula:
[0152]
[0153] Where γ and β are learnable parameters, and μ and σ are d model Mean and standard deviation in each dimension.
[0154] Furthermore, the result Z after layer normalization can be... norm Nonlinear transformation is performed using a feedforward network. For example, firstly, Z is transformed based on linear transformation parameters W1 (weight matrix 1) and b1 (bias vector 1). norm Projected onto d ffn The dimension is then processed using the ReLU activation function, and then projected back to the original dimension d based on the linear transformation parameters W2 (weight matrix 2) and b2 (bias vector 2). model The specific formula is as follows:
[0155] FFN(Z norm ) = Relu(Z norm W1+b1)W2+b2;
[0156] In the formula, d ffn It is 1024. d model When set to 512, Relu(x) = max(0,x) is an element-wise activation function.
[0157] Furthermore, Z norm With the output FFN(Z) of the feedforward network norm The residual connection results are subjected to layer normalization, and the specific formula is as follows:
[0158] Z r =LayerNorm(Z) norm +FFN(Z norm )).
[0159] It should be understood that the above multi-head attention, feedforward network, and layer normalization operation are stacked in four layers, with the output of each layer serving as the input of the next layer, to obtain the final hidden state Z of the encoder. r .
[0160] Furthermore, Z r After linear transformation and projection onto the original input using a fully connected layer, the encoder output Z is obtained. enc (i.e., the first encoding result), the specific formula is as follows:
[0161] Z enc =Z r W enc +b enc;
[0162] in, It is a learnable weight matrix in the fully connected layer, used to assign weights to the encoder's final hidden state Z. r Projected onto the target dimension space, It is a learnable bias vector in the fully connected layer, which introduces a translation term to the linear transformation, enhancing the model's expressive power.
[0163] Furthermore, after the encoding phase is complete, the decoder can rely on the first encoded result Z. enc Decoding can be performed.
[0164] Specifically, the input feature matrix of the decoder is denoted as Z", which means the input feature matrix of the decoder can be... The transformation feature dimension is L'×d model The specific formula is as follows:
[0165] Z tgt =Z″W tgt +b tgt ;
[0166] in, It is also a weight matrix, used to project Z” onto the target space. Also a bias vector, d model Set to 512. It should be understood that during the encoding and decoding process, weight matrices and bias vectors are involved, and different subscripts are used to distinguish them.
[0167] Furthermore, in the masked self-attention layer, the feature matrix Z after transforming the feature dimension is... tgt The mapping is Q', K', V', and the processing is based on a multi-head attention mechanism. For details on the multi-head attention mechanism described in the encoder module, please refer to the description of the encoder module.
[0168] Furthermore, the data output from the masking attention layer is processed by a feedforward network and subjected to layer normalization (see the description of the encoder module above for details). Further, in the cross-attention layer, the normalized feature matrix is mapped to a query matrix Q', and the first encoded result Z' output by the encoder is... enc The mapping is performed as a key matrix K” and a value matrix V”, and a multi-head attention mechanism is used (for details on the multi-head attention mechanism described in the encoder module).
[0169] Similarly, the data output from the cross-attention layer is processed by a feedforward network and subjected to layer normalization.
[0170] It should be understood that the above multi-head attention, feedforward network and layer normalization operation are stacked in 4 layers, and the output of each layer serves as the input of the next layer.
[0171] Furthermore, the data obtained from the layer normalization operation after the cross-attention layer is subjected to two linear transformations, with ReLU activation function processing in between, to obtain the decoder output Z. dec (i.e., the result of the first feature enhancement).
[0172] In some embodiments, a computer device may input a second input feature matrix into a Transformer model, and an encoder may encode the second input feature matrix to obtain a second encoding result. A decoder may then decode and output a second feature enhancement result based on the second encoding result.
[0173] The second encoding result Z' is obtained enc Second feature enhancement result Z' dec For specific processing details, please refer to the descriptions above regarding obtaining the first encoding result and the first feature enhancement result; these will not be repeated here.
[0174] For example, a computer device can weightedly fuse the first feature enhancement result and the second feature enhancement result to obtain multiple second core sub-tensors. The specific formula is as follows:
[0175] G=ηZ dec +(1-η)Z′ dec ;
[0176] in, Combination weights η∈{0,1} L×D .
[0177] In some embodiments, step S15, which involves performing inverse tensor decomposition based on multiple second core subtensors and factor matrices to obtain a second tensor, includes: performing an expansion operation opposite to the first mode expansion on each second core subtensor to reconstruct multiple third core subtensors; and performing inverse tensor decomposition based on multiple third core subtensors and factor matrices to obtain a second tensor.
[0178] It should be understood that the enhanced multiple second core sub-tensors form a kernel tensor sequence G = {G1,...,G}. W The computer device can decompose the kernel tensor sequence into W second kernel sub-tensors. The second kernel sub-tensors G w With the first core subtensor Correspondingly.
[0179] For the second core subtensor G w By performing an expansion operation opposite to the first mode expansion, we obtain the third core subtensor corresponding to W windows (time blocks). The specific formula is as follows:
[0180]
[0181] In the formula, reshape and the generation of the first feature matrix Z w The tensor shape reconstruction operation used in the formula is the opposite.
[0182] Furthermore, according to the third core subtensor and the corresponding factor matrix Perform inverse Tucker decomposition to reconstruct the feature-enhanced second subtensor. The specific formula is as follows:
[0183]
[0184] Furthermore, all third core subtensors Reconstruct the corresponding second subtensor Then, the reconstructed multiple second subtensors By splicing along the third dimension, we obtain the completed Hankel tensor. (i.e., the second tensor after feature enhancement), the specific formula is as follows:
[0185]
[0186] like Figure 2 As shown, in some embodiments, another method for improving the accuracy of smart meter data completion is provided. This method can be executed by a computer device and specifically includes the following steps:
[0187] S21, Obtain at least one data sequence of the meter to be supplemented.
[0188] like Figure 3 As shown, there are blank or missing positions in the meter data sequence to be completed, and these missing positions need to be filled in using the method in the embodiments of this application.
[0189] S22, the pre-trained completion model performs multi-path delay embedding transformation on the meter data sequence to be completed to obtain the first target tensor, and divides the first target tensor into multiple time blocks of target sub-tensors.
[0190] Figure 3 The 301 in the tensor is used to identify the first target tensor.
[0191] S23, perform tensor decomposition on the target sub-tensors of multiple time blocks respectively to generate multiple first target core sub-tensors and corresponding target factor matrices.
[0192] Figure 3 The 302 in the figure is used to identify multiple first-target core subtensors after low-rank tensor decomposition (such as Tucker decomposition). to The corresponding target factor matrix is
[0193] S24. Generate a second target sequence to be position-encoded based on multiple first target core sub-tensors. Input the second target sequence and the corresponding position encoding result into the Transformer model in the completion model to obtain multiple second target core sub-tensors with enhanced features output by the Transformer model.
[0194] In some embodiments, the second target sequence includes a second forward sequence and a second reverse sequence. Specifically, a computer device can generate a second forward sequence based on multiple first target core sub-tensors and the forward sorting between corresponding time blocks, and perform position encoding on the second forward sequence to obtain the target forward position encoding result (e.g., Figure 3 (As shown); Based on multiple first target core sub-tensors and the reverse sorting between corresponding time blocks, a second reverse sequence is generated, and the second reverse sequence is positionally encoded to obtain the target reverse position encoding result (as shown). Figure 3 (As shown).
[0195] Furthermore, the second forward sequence and the corresponding target forward position encoding result are input into the Transformer model, and the second reverse sequence and the corresponding target reverse position encoding result are input into the Transformer model.
[0196] like Figure 3 As shown, the input data is sequentially processed through an encoder, which includes a self-attention mechanism and a feedforward network, among other layers, to generate a first encoded result and a second encoded result. Then, the decoder, relying on the first and second encoded results and combining their hierarchical structure (including the self-attention mechanism and feedforward network), performs decoding to obtain a predicted positive output (i.e., the first target feature enhancement result) and a predicted negative output (i.e., the second target feature enhancement result). Furthermore, the positive output (i.e., the first target feature enhancement result) and the predicted negative output (i.e., the second target feature enhancement result) can be fused.
[0197] like Figure 3 As shown, by fusing the first target feature enhancement results and the second target feature enhancement results, multiple second target core sub-tensors, namely G'1 to G'303, are obtained after feature enhancement. W .
[0198] S25. Based on multiple second target core sub-tensors and the corresponding target factor matrix, inverse tensor decomposition is performed to obtain the second target tensor. The second target tensor is then subjected to inverse multipath delay embedding transformation to obtain the completed target meter data sequence.
[0199] like Figure 3As shown, it can be based on the second target core subtensor (G'1 to G'). W That is, the corresponding target factor matrix. Perform inverse tensor decomposition (such as Tucker inverse decomposition) to obtain the second target tensor 304. Then, perform inverse multipath delay embedding transformation on the second target tensor 304 to obtain the completed target meter data sequence.
[0200] In the above methods, the completion model can fully and accurately capture the temporal and spatial dependencies of meter data, thereby improving the completion accuracy of large-scale smart meter data.
[0201] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0202] Based on the same inventive concept, this application also provides an accuracy improvement device for implementing the above-mentioned smart meter data completion. The solution provided by this device is similar to the solution described in the above method. Therefore, the specific limitations of one or more embodiments of the smart meter data completion accuracy improvement device provided below can be found in the limitations of the smart meter data completion accuracy improvement method above, and will not be repeated here.
[0203] In one embodiment, such as Figure 4 As shown, a device for improving the accuracy of smart meter data completion is provided. The device includes:
[0204] The sampling module 402 is used to sample multiple first meter data sequences in each round of training to generate a meter sequence matrix and a mask matrix; the mask matrix is used to identify missing positions in the meter sequence matrix.
[0205] The multi-path delay embedding transformation module 404 is used to perform multi-path delay embedding transformation on the meter sequence matrix and the mask matrix respectively to obtain the first tensor and the mask tensor.
[0206] The low-rank tensor decomposition module 406 is used to divide the first tensor and the mask tensor into first sub-tensors and mask sub-tensors of multiple time blocks, respectively. For the first sub-tensor corresponding to each time block, the first sub-tensor is decomposed into the corresponding first core sub-tensor and factor matrix based on the mask sub-tensor corresponding to the time block.
[0207] Prediction module 408 is used to generate a first target sequence based on multiple first core sub-tensors, and input the first target sequence and the corresponding position encoding result into the Transformer model in this round of completion model to obtain multiple second core sub-tensors with enhanced features output by the Transformer model;
[0208] The inverse processing module 410 is used to perform inverse tensor decomposition based on multiple second core sub-tensors and factor matrices to obtain second tensors, and to perform inverse multipath delay embedding transformation on the second tensors to obtain multiple second meter data sequences.
[0209] The parameter training module 412 is used to determine the target loss value based on the numerical difference between each second meter data sequence and the corresponding first meter data sequence at the same missing position, adjust the model parameters based on the target loss value, and perform the next round of training until the training ends, so as to obtain the completion model for smart meter data completion.
[0210] In one embodiment, such as Figure 5 As shown, a device for improving the accuracy of smart meter data completion is provided. The device includes:
[0211] The multi-path delay embedding transformation module 502 is used to acquire at least one meter data sequence to be completed; and to perform multi-path delay embedding transformation on the meter data sequence to be completed using a pre-trained completion model to obtain a first target tensor.
[0212] The low-rank tensor decomposition module 504 is used to divide the first target tensor into multiple time blocks of target sub-tensors, and to perform tensor decomposition on the multiple time blocks of target sub-tensors respectively to generate multiple first target core sub-tensors and corresponding target factor matrices.
[0213] Prediction module 506 is used to generate a second target sequence to be position encoded based on multiple first target core sub-tensors, and input the second target sequence and the corresponding position encoding result into the Transformer model in the completion model to obtain multiple second target core sub-tensors with enhanced features output by the Transformer model;
[0214] The data completion module 508 is used to perform inverse tensor decomposition based on multiple second target core sub-tensors and the corresponding target factor matrix to obtain the second target tensor, and to perform inverse multipath delay embedding transformation on the second target tensor to obtain the completed target meter data sequence.
[0215] The modules in the aforementioned smart meter data completion accuracy improvement device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independently of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the corresponding operations of each module.
[0216] In one embodiment, a computer device is provided, which may be a terminal or a server. The internal structure diagram of the computer device may be as follows: Figure 6 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a method for improving the accuracy of smart meter data completion.
[0217] Those skilled in the art will understand that Figure 6 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0218] In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps in the embodiments of this application.
[0219] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the embodiments of this application.
[0220] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps of the embodiments of this application.
[0221] It should be noted that the user information (including but not limited to user device information, user attribute content, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0222] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, database, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. The processors involved in the embodiments provided in this application can be general-purpose processors, central processing units, graphics processors, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited thereto.
[0223] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0224] The above embodiments are merely illustrative of several implementation methods of this application and should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for improving the accuracy of smart meter data completion, characterized in that, The method includes: In each round of training, multiple first meter data sequences are sampled to generate a meter sequence matrix and a mask matrix; the mask matrix is used to identify missing positions in the meter sequence matrix. Perform multi-path delay embedding transformation on the meter sequence matrix and the mask matrix respectively to obtain the first tensor and the mask tensor; The first tensor and the mask tensor are respectively divided into a first sub-tensor and a mask sub-tensor of multiple time blocks. For the first sub-tensor corresponding to each time block, the first sub-tensor is decomposed into a corresponding first core sub-tensor and a factor matrix based on the mask sub-tensor corresponding to the time block. A first target sequence is generated based on multiple first core sub-tensors. The first target sequence and the corresponding position encoding result are input into the Transformer model in this round of completion model to obtain multiple second core sub-tensors with enhanced features output by the Transformer model. The second tensor is obtained by inverse tensor decomposition based on the multiple second core sub-tensors and the factor matrix. The second tensor is then subjected to inverse multipath delay embedding transformation to obtain multiple second meter data sequences. The target loss value is determined based on the numerical difference between each second meter data sequence and the corresponding first meter data sequence at the same missing position. The model parameters are adjusted based on the target loss value, and the next round of training is carried out until the training ends, thus obtaining the completion model for smart meter data completion.
2. The method according to claim 1, characterized in that, For each time block, the first sub-tensor is decomposed into a corresponding first core sub-tensor and a factor matrix based on the mask sub-tensor corresponding to the time block, including: For each time block, calculate the mean of the elements in the non-missing positions of the first sub-tensor corresponding to the time block; Based on the mask sub-tensor corresponding to the time block, the missing positions in the first sub-tensor corresponding to the time block are filled with the mean; Tensor decomposition is performed on the padded tensor to obtain the corresponding first core sub-tensor and factor matrix.
3. The method according to claim 2, characterized in that, The 1 in the mask sub-tensor is used to identify the non-missing position of the first sub-tensor, and the 0 in the mask sub-tensor is used to identify the missing position of the first sub-tensor. The step of filling missing positions in the first sub-tensor corresponding to the time block with the mean value based on the mask sub-tensor corresponding to the time block includes: The first product of the first sub-tensor corresponding to the time block and the mask sub-tensor, and the second product of the mean and the missing mask sub-tensor are added to obtain the tensor after the missing position is filled; wherein, the missing mask sub-tensor is obtained by subtracting the mask sub-tensor from 1.
4. The method according to claim 1, characterized in that, The first target sequence includes a first forward sequence and a first reverse sequence; the first forward sequence is generated based on the forward sorting of multiple first core sub-tensors and corresponding time blocks; the first reverse sequence is generated based on the reverse sorting of multiple first core sub-tensors and corresponding time blocks; the first forward sequence is position-encoded to obtain a forward position-encoded result; the first reverse sequence is position-encoded to obtain a reverse position-encoded result. The first target sequence and its corresponding position encoding result are input into the Transformer model in this round of completion model to obtain multiple second core sub-tensors with enhanced features output by the Transformer model, including: Based on the first forward sequence and the corresponding forward position encoding result, a first input feature matrix is generated, and the first input feature matrix is input into the Transformer model to obtain the predicted first feature enhancement result; Based on the first inverse sequence and the corresponding inverse position encoding result, a second input feature matrix is generated, and the second input feature matrix is input into the Transformer model to obtain the predicted second feature enhancement result; By aggregating the first feature enhancement result and the second feature enhancement result, the plurality of second core sub-tensors are obtained.
5. The method according to claim 4, characterized in that, The first forward sequence is obtained by concatenating multiple first feature matrices according to the forward sorting, and the first reverse sequence is obtained by concatenating the multiple first feature matrices according to the reverse sorting; the multiple first feature matrices are generated by expanding each first core sub-tensor in a first mode; The step of generating a first input feature matrix based on the first forward sequence and the corresponding forward position encoding result includes: transforming the feature dimension of the first forward sequence to generate a third feature matrix; performing position encoding on the elements in the third feature matrix to obtain the forward position encoding result; and concatenating the third feature matrix and the forward position encoding result to generate the first input feature matrix. And / or, The step of generating a second input feature matrix based on the first inverse sequence and the corresponding inverse position encoding result includes: transforming the feature dimension of the first inverse sequence to generate a fourth feature matrix; performing position encoding on the elements in the fourth feature matrix to obtain the inverse position encoding result; and concatenating the fourth feature matrix and the inverse position encoding result to generate the second input feature matrix.
6. The method according to claim 4, characterized in that, The step of inputting the first input feature matrix into the Transformer model to obtain the predicted first feature enhancement result includes: inputting the first input feature matrix into the Transformer model, encoding the first input feature matrix based on the encoder in the Transformer model to obtain a first encoding result; and the decoder in the Transformer model depends on the first encoding result to decode and output the first feature enhancement result. And / or, The step of inputting the second input feature matrix into the Transformer model to obtain the predicted second feature enhancement result includes: inputting the second input feature matrix into the Transformer model, encoding the second input feature matrix through the encoder to obtain a second encoding result, and the decoder decoding and outputting the second feature enhancement result based on the second encoding result.
7. The method according to any one of claims 1 to 6, characterized in that, The step of determining the target loss value based on the numerical difference between each second meter data sequence and the corresponding first meter data sequence at the same missing position includes: The first sub-loss is determined based on the numerical difference between the second meter data sequence and the corresponding first meter data sequence at the same missing position. The second sub-loss is determined based on the mean difference and variance difference between the second electricity meter data sequence and the corresponding first electricity meter data sequence; The target loss value is determined based on the first sub-loss and the second sub-loss.
8. A method for improving the accuracy of smart meter data completion, characterized in that, The method includes: Obtain at least one data sequence of the meter to be completed; The first target tensor is obtained by performing a multi-path delay embedding transformation on the meter data sequence to be completed using a pre-trained completion model. The first target tensor is divided into multiple time blocks of target sub-tensors. The multiple time blocks of target sub-tensors are decomposed into tensors respectively to generate multiple first target core sub-tensors and corresponding target factor matrices. A second target sequence to be position-encoded is generated based on multiple first target core sub-tensors. The second target sequence and the corresponding position encoding result are input into the Transformer model in the completion model to obtain multiple second target core sub-tensors with enhanced features output by the Transformer model. The second target tensor is obtained by inverse tensor decomposition based on the multiple second target core sub-tensors and the corresponding target factor matrix. The second target tensor is then subjected to inverse multipath delay embedding transformation to obtain the completed target meter data sequence.
9. The method according to claim 8, characterized in that, The second target sequence includes a second forward sequence and a second reverse sequence; The method further includes: Based on the forward sorting of multiple first target core sub-tensors and corresponding time blocks, a second forward sequence is generated, and the second forward sequence is position-encoded to obtain a target forward position encoding result; based on the reverse sorting of multiple first target core sub-tensors and corresponding time blocks, a second reverse sequence is generated, and the second reverse sequence is position-encoded to obtain a target reverse position encoding result. The step of inputting the second target sequence and the corresponding position encoding result into the Transformer model in the completion model to obtain multiple second target core sub-tensors after feature enhancement output by the Transformer model includes: The second forward sequence and the corresponding target forward position encoding result are input into the Transformer model to obtain the predicted first target feature enhancement result; The second inverse sequence and the corresponding target inverse position encoding result are input into the Transformer model to obtain the predicted second target feature enhancement result; By fusing the first target feature enhancement result and the second target feature enhancement result, multiple second target core sub-tensors with enhanced features are obtained.
10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7 or 8 to 9.
Citation Information
Patent Citations
CN118760674A
CN119884718A