A method and device for compensating data error of an electric energy meter
By using a working condition classification network and an error compensation network, the problems of imprecise reverse error calculation and insufficient accuracy under complex working conditions in electricity meter calibration are solved. This achieves high-precision error compensation for electricity meters and safety in on-site operation, adapts to dynamic changes in the power grid environment, and improves the reliability and traceability of metering results.
Patent Information
- Application Number
- CN202511688820.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-18
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2045-11-18
AI Technical Summary
Existing electricity meter calibration technologies suffer from problems such as imprecise reverse error calculation methods, insufficient accuracy under complex operating conditions, high on-site operational risks, and a lack of intelligence and adaptive capabilities.
By employing a working condition classification network and an error compensation network, input feature vectors are constructed by collecting voltage and current sequences. A deep learning model is used to predict the prior and confidence of the working conditions. The forward or backward error calculation method is selected, and error compensation is achieved by combining data preprocessing and frequency domain analysis. Furthermore, the accuracy and adaptability of the model are improved through edge-cloud collaborative training.
It solves the problems of imprecise calculation of reverse error and insufficient accuracy under complex operating conditions, reduces on-site operation risks, improves the reliability and traceability of metering results, adapts to dynamic changes in the power grid environment, and meets the stability requirements of metering and settlement.
Smart Images

Figure CN121144825B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of calibration and error verification of electric energy meters, and in particular to an electric energy meter data error compensation method and device. BACKGROUND
[0002] Electric energy meters are core metering equipment for commercial settlement and operation monitoring of power systems, and their accuracy is directly related to the economic interests of power enterprises and the reliability of power grid operation. The existing electric energy meter calibration process usually includes laboratory verification and on-site verification, and the basic principle is to compare the readings (Et) of the tested meter with the readings (Er) of the high-precision standard meter, and then calculate the error.
[0003] However, with the continuous expansion of the power grid and the access of distributed power sources and a large number of nonlinear loads, the existing calibration technology gradually exposes its limitations, mainly in the following aspects:
[0004] (1) Defects in mathematical processing of reverse calibration
[0005] Forward calibration is used for electric energy from top to bottom, i.e. from source side to load side typical working conditions, to ensure the measurement accuracy of power purchase side, distribution network to user side, to support electricity settlement, line loss assessment and operation monitoring; reverse calibration is aimed at power flow reverse, i.e. load side to grid scenario, such as photovoltaic grid connection, energy storage return, V2G and segmented reverse, to ensure the accurate measurement of on-grid power and feedback power, to meet the compliance requirements of net metering and two-way settlement. In the traditional electric meter calibration method, the forward error value is calculated by the reading of the standard meter during forward calibration; however, for reverse error, the commonly used method in the industry is to take the opposite number of the forward error value. However, since the calculation basis (i.e. formula denominator) of forward and reverse error is different, this processing method is not mathematically correct, resulting in distortion of error calculation results. This error will be amplified step by step in the process of quantity transmission, eventually causing systematic deviation of the electric power metering system.
[0006] (2) Challenge of complex power grid conditions to accuracy
[0007] With the large number of nonlinear loads such as frequency converters, switching power supplies, uninterruptible power supplies (UPS), new energy inverters and the like being connected to the power grid, the harmonic pollution of the power grid is becoming increasingly serious. Under non-ideal conditions such as low power factor, high harmonic content, voltage transient and bidirectional power flow, the traditional method approximates the voltage and current waveforms to a single fundamental sine wave and calculates the error using a fixed frequency / phase relationship. However, the real power grid has been affected by a large number of nonlinear and grid-connected power sources such as frequency converters, switching power supplies, photovoltaic / energy storage inverters, etc., resulting in waveforms containing significant harmonics and interharmonics, DC bias, three-phase imbalance and frequency deviation. The power factor is no longer equal to the cosine of the fundamental wave, and the phase and amplitude between harmonics dynamically change with the load and operating mode, making it difficult to ensure accuracy and stability. The resulting deviation directly affects the reliability of the measurement data.
[0008] (3) Low calibration operation efficiency and high risk
[0009] Forward and reverse calibration require a change in the physical input direction. For example, reverse calibration requires the real energy meter to actually experience current reversal, phase inversion and other actual operating conditions to test its measurement performance under reverse power flow. Traditional devices use one-way power supplies and fixed wiring, lack programmable bidirectional sources or automatic switching devices, and therefore must manually change the wiring to physically reverse the current polarity, phase sequence and other parameters to ensure that the energy flow and meter response are truly in the reverse direction. This process is not only tedious, but also prone to errors such as phase reversal and polarity misconnection, which can cause faults. Troubleshooting and handling of such problems often requires a lot of time, reducing calibration efficiency. Although some methods attempt to identify abnormal wiring through data analysis, the calculation complexity is high and it is difficult to meet the real-time and automation requirements.
[0010] (4) Lack of intelligence and adaptive ability
[0011] Most of the algorithms of existing calibration devices are statically designed and cannot fully utilize historical calibration data for model optimization, nor can they adapt to the dynamic changes in the power grid operating environment or the gradual degradation of energy meter performance. Therefore, such devices have insufficient adaptability under new power grid conditions.
[0012] The above problems are mutually superimposed, forming a negative chain caused by mathematical errors, model limitations and operational risks. The result is that incorrect calibration standards can affect the accuracy of the entire measurement value transfer system and be further amplified under complex power grid operating conditions. Especially in the context of rapid development of distributed energy and frequent power market transactions, measurement deviation can easily lead to economic losses and commercial disputes. SUMMARY
[0013] The technical problems to be solved by the present application are that the reverse error calculation method in the existing electric energy meter calibration technology is not rigorous, the precision is insufficient under complex working conditions, the on-site operation risk is high, and the intelligentization and self-adaptive ability are lacking.
[0014] The present application solves the above technical problems by the following technical means: an electric energy meter data error compensation method, comprising:
[0015] S1, collecting voltage sequence and current sequence in a time window;
[0016] S2, preprocessing the voltage sequence and the current sequence to construct an input feature vector;
[0017] S3, stacking the input feature vector in the time window to construct an input tensor, inputting the input tensor into a working condition classification network, and predicting the output working condition priori, confidence and context representation;
[0018] S4, splicing the input tensor, its corresponding working condition priori and context representation to construct an extended input sequence, taking the extended input sequence as the input of the error compensation network, and outputting the mean value of the compensation amount; when the working condition priori is a forward standard working condition or a forward high harmonic working condition, the error compensation network adopts a forward error calculation method to calculate the basic error; when the working condition priori is a reverse standard working condition or a reverse high harmonic working condition, the error compensation network adopts a reverse error calculation method to calculate the basic error; the basic error and the mean value of the compensation amount are added to obtain a synthetic error for error compensation; when the working condition priori is phase reverse connection or polarity error, or the confidence is less than a preset value, the error compensation network suspends compensation;
[0019] S5, training the model composed of the working condition classification network and the error compensation network, and using the trained model to compensate the electric energy error.
[0020] Further, the S2 comprises:
[0021] S21, introducing a window function, multiplying the window function with the voltage sequence and the current sequence respectively, mapping to the frequency domain through fast Fourier transform to obtain voltage frequency domain components and current frequency domain components;
[0022] S22, calculating the mean square value of the voltage sequence and the current sequence respectively to obtain voltage time domain components and current time domain components ;
[0023] S23, calculating active power , reactive power , apparent power and power factor ;
[0024] S24, calculating the total harmonic distortion of voltage using the voltage frequency domain component , calculating total harmonic distortion of current by using current frequency domain components ;
[0025] S25, constructing input feature vector , wherein, represents the th harmonic amplitude of the voltage sequence, represents the th harmonic amplitude of the current sequence, is the fundamental phase difference between the voltage sequence and the current sequence, is the crest factor and , represents the maximum instantaneous amplitude of the voltage waveform in the measurement time window compared with zero potential.
[0026] Further, the S3 comprises:
[0027] S31, stacking the input feature vector in a time window with length L to form an input tensor , wherein, represents the input feature vector at time t; define a classification target set reflecting the working condition or wiring state , wherein, respectively represent the forward standard working condition, the reverse standard working condition, the forward high harmonic working condition, the reverse high harmonic working condition, the phase reverse connection, and the polarity error;
[0028] S32, constructing a working condition classification network, the working condition classification network comprises first to third convolutional blocks, the first to third convolutional blocks are sequentially connected and then globally average-pooled to obtain a context representation, and then a classification head is used to output the probability that the current input tensor belongs to each working condition, the working condition or wiring state corresponding to the maximum probability value is taken as the working condition prior, the maximum probability value is taken as the confidence, the working condition classification network receives the input tensor, and outputs the working condition prior, the confidence, and the context representation.
[0029] Further, the first to third convolutional blocks have the same structure, except that the number of channels is different, and the first convolutional module is composed of a one-dimensional convolutional layer, a batch normalization layer, a first ReLU activation function, and a one-dimensional pooling operation which are sequentially connected.
[0030] Further, the classification head is composed of a first fully connected layer, a second ReLU activation function, a Dropout operation, a second fully connected layer, and a Softmax function which are sequentially connected.
[0031] Furthermore, the error compensation network includes a first LSTM layer and a second LSTM layer. The first LSTM layer receives the extended input sequence. After the first LSTM layer undergoes a dropout operation, it is connected to the second LSTM layer. The second LSTM layer takes the hidden state at the last time step as input to the third fully connected layer. The third fully connected layer outputs two-dimensional data, which are the mean and logarithmic variance of the compensation amount. The logarithmic variance is used to construct the loss function of the error compensation network.
[0032] Furthermore, S4 includes:
[0033] When the load condition classification network predicts the load condition prior... At that time, the basic error , Indicates positive error. For standard meter readings, The reading of the test table; when the prior operating condition is predicted by the operating condition classification network. At that time, the basic error , Indicates the inverse error; when the load classification network predicts the load prior, the error is... or At that time, compensation was suspended and the situation was set aside. =0 and output an alarm flag. Indicates the confidence level. This represents the mean of the compensation amount;
[0034] Synthesis error is defined as In order to meet the constraints of the operating procedures on the magnitude of a single correction, for Use the clip function to truncate the amplitude. = clip( , 5%, 5%);
[0035] Calculate correction coefficients using synthesis error ;
[0036] The error is compensated by using a correction factor to obtain the corrected reading. .
[0037] Furthermore, S4 also includes:
[0038] To meet the requirements for error source tracing, the error compensation network calculates the overall uncertainty. in, Yes Measurement of uncertainty, obtaining expanded uncertainty The error compensation network determines that the true error falls within the range of... This interval records simultaneously And the model version number.
[0039] Furthermore, S5 includes:
[0040] When the server connects to multiple clients, and each client deploys a model, each client uses global parameters as a reference and employs a client-side local optimization strategy to update the model's parameters. At the same time, a server-side weighted fusion strategy is used to update the global parameters of each client, thereby training the model until a preset number of iterations is reached, at which point training stops, and the trained models are obtained.
[0041] Furthermore, the client-side local optimization strategy includes:
[0042] Assume each server communicates with k clients, and the local dataset corresponding to the kth client is... The expected value of the local dataset corresponding to the k-th client is obtained by weighted summation of the classification cross-entropy loss of the working condition classification network and the negative log-likelihood loss of the error compensation network. This is used as the local empirical risk for the k-th client. The squared L2 norm of the difference between the parameters of the model deployed on the k-th client and the global parameters, multiplied by the preset proximal coefficient, divided by 2, and added to the local empirical risk, is used as the optimization objective function to adjust the model parameters. When the optimization objective function reaches its minimum value, the updated model parameters are obtained. = The model's parameters are the combined parameters of the load condition classification network and the error compensation network. The parameters of the model deployed on the k-th client in the (t+1)-th iteration. To optimize the model parameters that minimize the objective function, The model parameters are: At that time, the gradient of the local experience risk of the k-th client, The pre-defined proximal coefficient, This represents the global parameters of the t-th iteration. This represents the learning rate of the model during training.
[0043] Furthermore, the calculation process for the classification cross-entropy loss of the aforementioned working condition classification network is as follows:
[0044]
[0045] in, Represents the classification cross-entropy loss. This indicates the prior knowledge of the current operating condition. This represents the actual value for the current operating condition category. Represents the input feature vector The current output of the working condition prior is The predicted probability of the situation.
[0046] Furthermore, the calculation process for the negative log-likelihood loss of the error compensation network is as follows:
[0047]
[0048] in, This represents the negative log-likelihood loss. This represents the logarithmic variance of the compensation amount. Indicates residual label and , Indicates reference error. This is the weight decay coefficient. The parameters of the error compensation network, This represents the square of the L2 norm.
[0049] Furthermore, the server-side weighted fusion strategy includes:
[0050] Suppose there are M servers, each server corresponds to a subset of clients. The client subset Includes the local dataset of each client connected to the Mth server; in the t-th iteration, a subset of clients is selected. The selected client subset After the k1th client completes its local optimization, it sends the parameter increment back to the server. The parameter increment is defined as follows: ,in, This represents the parameter increment returned by the k1-th client after completing local optimization in the t-th iteration; the weight of the parameter increment. ,in, Let be the sum of the sample sizes in the t-th iteration and , This represents the sample size of the j-th client subset. The sample size of the k1-th client corresponding to the selected client subset; global increment. , where m is the total number of clients corresponding to the selected client subset; using the formula Update global parameters. This represents the global parameters of the (t+1)th iteration.
[0051] The present invention also provides an electrical energy error compensation device, comprising:
[0052] The data acquisition module is used to acquire voltage and current sequences within a time window;
[0053] The data preprocessing feature engineering module is used to preprocess voltage and current sequences to construct input feature vectors;
[0054] The intelligent working condition classification module is used to stack the input feature vectors within a time window to construct an input tensor, input the input tensor into the working condition classification network, and predict the output working condition prior, confidence, and context representation.
[0055] The adaptive error compensation module is used to construct an extended input sequence by concatenating the input tensor, its corresponding prior operating conditions, and context representation. This extended input sequence is then used as the input to the error compensation network, which outputs the mean of the compensation amount. When the prior operating conditions are a positive standard operating condition or a positive high harmonic operating condition, the error compensation network uses a forward error calculation method to calculate the basic error. When the prior operating conditions are a reverse standard operating condition or a reverse high harmonic operating condition, the error compensation network uses a reverse error calculation method to calculate the basic error. The basic error is added to the mean of the compensation amount to obtain the composite error for error compensation. When the prior operating conditions are a phase reversal or polarity error, or when the confidence level is less than a preset value, the error compensation network suspends compensation.
[0056] The edge-cloud collaborative update module is used to train a model consisting of an operating condition classification network and an error compensation network, and to perform power error compensation using the trained model.
[0057] Furthermore, the data preprocessing feature engineering module is also used for:
[0058] S21. Introduce a window function, multiply the window function by the voltage sequence and the current sequence respectively, and map them to the frequency domain through fast Fourier transform to obtain the voltage frequency domain component and the current frequency domain component.
[0059] S22. Calculate the mean square values of the voltage and current sequences respectively to obtain the voltage time-domain components. and current time domain components ;
[0060] S23. Calculate active power reactive power Apparent power and power factor ;
[0061] S24. Calculate the total harmonic distortion of voltage using voltage frequency domain components. Calculate the total harmonic distortion of current using current frequency domain components. ;
[0062] S25. Constructing the input feature vector ,in, Representing voltage sequences Second harmonic amplitude Representing a current sequence Second harmonic amplitude This represents the phase difference between the fundamental frequencies of the voltage and current sequences. The peak factor and , It represents the maximum instantaneous amplitude of the voltage waveform relative to zero potential within the measurement time window.
[0063] Furthermore, the intelligent working condition classification module is also used for:
[0064] S31. Stack the input feature vectors using time windows of length L to form the input tensor. ,in, Represent the input feature vector at time t; define the set of classification targets reflecting the operating conditions or wiring status. ,in, These represent the forward standard operating condition, the reverse standard operating condition, the forward high harmonic operating condition, the reverse high harmonic operating condition, the phase reversal, and the polarity error, respectively.
[0065] S32. Construct a working condition classification network. The working condition classification network includes a first convolutional block to a third convolutional block. After the first convolutional block to the third convolutional block are connected in sequence, global average pooling is performed to obtain the context representation. Then, the current input tensor is output through the classification head, showing the probability that it belongs to each working condition. The encoding of the working condition or wiring state corresponding to the maximum probability is used as the working condition prior, and the maximum probability is used as the confidence level. The working condition classification network receives the input tensor and outputs the working condition prior, confidence level, and context representation.
[0066] Furthermore, the first to third convolutional blocks have the same structure, only the number of channels is different. The first convolutional module consists of a sequentially connected one-dimensional convolutional layer, a batch normalization layer, a first ReLU activation function, and a one-dimensional pooling operation.
[0067] Furthermore, the classification head consists of a first fully connected layer, a second ReLU activation function, a Dropout operation, another fully connected layer, and a Softmax function, connected in sequence.
[0068] Furthermore, the error compensation network includes a first LSTM layer and a second LSTM layer. The first LSTM layer receives the extended input sequence. After the first LSTM layer undergoes a dropout operation, it is connected to the second LSTM layer. The second LSTM layer takes the hidden state at the last time step as input to the third fully connected layer. The third fully connected layer outputs two-dimensional data, which are the mean and logarithmic variance of the compensation amount. The logarithmic variance is used to construct the loss function of the error compensation network.
[0069] Furthermore, the adaptive error compensation module is also used for:
[0070] When the load condition classification network predicts the load condition prior... At that time, the basic error , Indicates positive error. For standard meter readings, The reading of the test table; when the prior operating condition is predicted by the operating condition classification network. At that time, the basic error , Indicates the inverse error; when the load classification network predicts the load prior, the error is... or At that time, compensation was suspended and the situation was set aside. =0 and output an alarm flag. Indicates the confidence level. This represents the mean of the compensation amount;
[0071] Synthesis error is defined as In order to meet the constraints of the operating procedures on the magnitude of a single correction, for Use the clip function to truncate the amplitude. = clip( , 5%, 5%);
[0072] Calculate correction coefficients using synthesis error ;
[0073] The error is compensated by using a correction factor to obtain the corrected reading. .
[0074] Furthermore, the adaptive error compensation module is also used for:
[0075] To meet the requirements for error source tracing, the error compensation network calculates the overall uncertainty. in, Yes Measurement of uncertainty, obtaining expanded uncertainty The error compensation network determines that the true error falls within the range of... This interval records simultaneously And the model version number.
[0076] Furthermore, the edge-cloud collaborative update module is also used for:
[0077] When the server connects to multiple clients, and each client deploys a model, each client uses global parameters as a reference and employs a client-side local optimization strategy to update the model's parameters. At the same time, a server-side weighted fusion strategy is used to update the global parameters of each client, thereby training the model until a preset number of iterations is reached, at which point training stops, and the trained models are obtained.
[0078] Furthermore, the client-side local optimization strategy includes:
[0079] Assume each server communicates with k clients, and the local dataset corresponding to the kth client is... The expected value of the local dataset corresponding to the k-th client is obtained by weighted summation of the classification cross-entropy loss of the working condition classification network and the negative log-likelihood loss of the error compensation network. This is used as the local empirical risk for the k-th client. The squared L2 norm of the difference between the parameters of the model deployed on the k-th client and the global parameters, multiplied by the preset proximal coefficient, divided by 2, and added to the local empirical risk, is used as the optimization objective function to adjust the model parameters. When the optimization objective function reaches its minimum value, the updated model parameters are obtained. = The model's parameters are the combined parameters of the load condition classification network and the error compensation network. The parameters of the model deployed on the k-th client in the (t+1)-th iteration. To optimize the model parameters that minimize the objective function, The model parameters are: At that time, the gradient of the local experience risk of the k-th client, The pre-defined proximal coefficient, This represents the global parameters of the t-th iteration. This represents the learning rate of the model during training.
[0080] Furthermore, the calculation process for the classification cross-entropy loss of the aforementioned working condition classification network is as follows:
[0081]
[0082] in, Represents the classification cross-entropy loss. This indicates the prior knowledge of the current operating condition. This represents the actual value for the current operating condition category. Represents the input feature vector The current output of the working condition prior is The predicted probability of the situation.
[0083] Furthermore, the calculation process for the negative log-likelihood loss of the error compensation network is as follows:
[0084]
[0085] in, This represents the negative log-likelihood loss. This represents the logarithmic variance of the compensation amount. Indicates residual label and , Indicates reference error. This is the weight decay coefficient. The parameters of the error compensation network, This represents the square of the L2 norm.
[0086] Furthermore, the server-side weighted fusion strategy includes:
[0087] Suppose there are M servers, each server corresponds to a subset of clients. The client subset Includes the local dataset of each client connected to the Mth server; in the t-th iteration, a subset of clients is selected. The selected client subset After the k1th client completes its local optimization, it sends the parameter increment back to the server. The parameter increment is defined as follows: ,in, This represents the parameter increment returned by the k1-th client after completing local optimization in the t-th iteration; the weight of the parameter increment. ,in, Let be the sum of the sample sizes in the t-th iteration and , This represents the sample size of the j-th client subset. The sample size of the k1-th client corresponding to the selected client subset; global increment. , where m is the total number of clients corresponding to the selected client subset; using the formula Update global parameters. This represents the global parameters of the (t+1)th iteration.
[0088] The advantages of this invention are:
[0089] (1) This invention utilizes a working condition classification network to predict the prior working condition, and selects either the forward error calculation method or the reverse error calculation method to calculate the basic error based on the prior working condition. This avoids the imprecise problem of the prior technology, which directly calculates the reverse error by taking the opposite of the forward error value. Furthermore, the intelligence and adaptability of the model are improved through training. At the same time, the model is trained to improve its accuracy and solve the problem of insufficient accuracy under complex working conditions. The switching between forward and reverse calibration modes does not rely on manual wiring and software configuration, but directly calls the forward error calculation method or the reverse error calculation formula, thus reducing the risk of on-site operation.
[0090] (2) The present invention defines the positive and negative errors with their respective reference denominators, and explicitly prohibits the direct negation of the negative error with the positive error, thereby eliminating systematic deviations from the source; this constitutes the calculation caliber benchmark of the whole scheme and the unified reference for subsequent compensation.
[0091] (3) The present invention uses a working condition classification network to identify working conditions such as “forward / reverse + standard / high harmonic” and “wiring abnormal (phase / polarity)” online. The classification result determines the correct denominator of the basic error and interrupts the compensation and issues an alarm when abnormal wiring is detected, thus avoiding invalid or harmful corrections in the process.
[0092] (4) This invention introduces a deep learning error compensation network on top of the basic error, outputs the mean and logarithmic variance of the compensation amount, and quantifies the uncertainty; finally, according to... The generated composite error, along with the uncertainty, is used for credibility and auditing. This value and the uncertainty dual output improve the traceability of measurement results.
[0093] (5) Step S2 of the present invention, namely the data preprocessing feature engineering module, simultaneously introduces time domain (RMS, phase, peak factor, waveform impulse) and frequency domain (fundamental / harmonic / interharmonic spectrum, THD) features, and considers frequency offset and window function processing to truly characterize high harmonics and non-stationary disturbances. It can adapt to calibration requirements under non-ideal working conditions, so the overall solution can maintain high accuracy under non-ideal working conditions such as high harmonics and low power factor, which meets the stability requirements of actual measurement and settlement scenarios.
[0094] (6) This invention implements constrained model optimization locally for the training data of the client. For cloud weights, it integrates on-site data from multiple client devices to achieve comprehensive and long-term adaptive evolution, and improves model accuracy through cloud-edge collaboration. Attached Figure Description
[0095] Figure 1 This is a flowchart of a method for compensating for data errors in an energy meter as disclosed in Embodiment 1 of the present invention;
[0096] Figure 2 This is a schematic diagram of the operating condition classification network in the energy meter data error compensation method disclosed in Embodiment 1 of the present invention;
[0097] Figure 3 This is a schematic diagram of the structure of an electrical energy error compensation device disclosed in Embodiment 2 of the present invention. Detailed Implementation
[0098] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below in conjunction with the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0099] Example 1
[0100] like Figure 1 As shown, Embodiment 1 of the present invention provides a method for compensating for data errors in electricity meters. At the method level, it solidifies precise and non-reciprocal mathematical definitions for forward and reverse calibration errors, strictly distinguishes the reference standards and denominator calibers for the two operating conditions, and avoids from the source the systematic deviation caused by simply treating the reverse error as the opposite of the forward error. It also provides a unified calculation caliber for subsequent compensation and uncertainty assessment. Specifically, it includes the following steps:
[0101] S1. Acquire voltage and current sequences within the time window; the specific process is as follows:
[0102] To ensure the consistency and traceability of subsequent model inputs, this invention uses a unified time window. With fixed sampling interval Synchronous acquisition of voltage sequence Current sequence Where n represents the nth sampling point, and N represents the total number of sampling points.
[0103] S2. Preprocess the voltage and current sequences to construct the input feature vector; the specific process is as follows:
[0104] S21. Introducing Window Functions , window function Multiplying the voltage and current sequences respectively and mapping them to the frequency domain via Fast Fourier Transform, the harmonics and power quality characteristics are extracted to obtain the voltage frequency domain component. and current frequency domain components ; The physical meaning is the complex spectrum at the h-th frequency point of the voltage sequence. The physical meaning is the complex spectrum at the h-th frequency point of the current sequence. The above process serves as the data entry point for this invention, enabling the characterization of on-site operating conditions with minimal prior assumptions and maximum information fidelity.
[0105] S22. Calculate the mean square values of the voltage and current sequences respectively to obtain the voltage time-domain components. and current time domain components ;
[0106] S23. Calculate active power reactive power Apparent power and power factor ;in, Active power reactive power Apparent power and power factor The calculation methods used are all existing technologies, such as active power. reactive power The definition is as follows
[0107]
[0108]
[0109] This represents the phase at the h-th frequency point of a voltage or current sequence. This represents the phase of the first frequency point in a voltage or current sequence. This represents the complex spectrum of the voltage sequence at the first frequency point. This represents the complex spectrum of the first frequency point of the current sequence.
[0110] Apparent power The formula is .
[0111] S24. Calculate the total harmonic distortion of voltage using voltage frequency domain components. Calculate the total harmonic distortion of current using current frequency domain components. Here, because the total harmonic distortion does not include the fundamental frequency, therefore, Starting from 2, the values are taken from, This indicates the upper limit of the harmonic sequence number.
[0112] S25. Constructing the input feature vector ,in, Representing voltage sequences Second harmonic amplitude Representing a current sequence Subharmonic amplitude (e.g.) =3,5,7,11,13,…). This represents the phase difference between the fundamental frequencies of the voltage and current sequences. The peak factor and , It represents the maximum instantaneous amplitude of the voltage waveform relative to zero potential within the measurement time window.
[0113] The input feature vector originates from the joint extraction of time and frequency domain information, and can fully reflect the influence of factors such as harmonics, power factor, phase, and impulsive loads on measurement errors without relying on the ideal sine assumption. Through the aforementioned feature engineering, the high-dimensional, time-varying original waveform is compressed into a feature vector with high information density and moderate dimensionality. This allows the subsequent deep learning model to focus directly on the nonlinear mapping between operating conditions and errors, without having to "learn from scratch" basic electrical quantities. In the method flow of this invention, this is explicitly fixed as "preprocessing and feature engineering" and seamlessly integrated with the subsequent intelligent classification and error compensation module (the feature vector serves as classification input and compensation prior), ensuring end-to-end consistency.
[0114] S3. A working condition classification network is set up to perform real-time analysis of the input feature vectors, autonomously identifying the current operating mode (e.g., forward / reverse, standard / high harmonic, etc.) and wiring status (e.g., whether the phase / polarity is abnormal). Based on this, a context representation and working condition prior are generated for compensation calculation. In this embodiment, the input feature vectors are stacked within a time window to construct an input tensor. The input tensor is then input into the working condition classification network to predict the output working condition prior, confidence level, and context representation. The specific process is as follows:
[0115] S31. To obtain accurate scene context before entering compensation calculation, this invention automatically classifies the feature sequence within each sliding time window. Let the input feature vector obtained at time t after "feature engineering and data preprocessing," i.e., steps S1 and S2, be... (the t-th sampling point) The input tensor is a d-dimensional real space stacked with time windows of length L. Where the feature dimension d=20 and the time window length L=256, Represent the input feature vector at time t; define the set of classification targets reflecting the operating conditions or wiring status. ,in, These represent the forward standard operating condition, the reverse standard operating condition, the forward high harmonic operating condition, the reverse high harmonic operating condition, the phase reversal, and the polarity error, respectively.
[0116] S32. Construct a working condition classification network. This network consists of three convolutional blocks (first to third). These blocks are sequentially concatenated and then subjected to global average pooling to obtain a context representation. The classification head then outputs the probability that the current input tensor belongs to each working condition. The encoding of the working condition or wiring state corresponding to the highest probability is used as the working condition prior, and the highest probability is used as the confidence level. The working condition classification network receives the input tensor and outputs the working condition prior, confidence level, and context representation. (Example...) Figure 2 As shown, the details are as follows:
[0117] First convolutional block: One-dimensional convolutional layer Conv1D (64 channels, 5 kernels, 1 stride, same padding) → Batch normalization layer BatchNorm → ReLU → One-dimensional pooling operation MaxPool1D.
[0118] Second convolutional block: One-dimensional convolutional layer Conv1D (128 channels, 5 kernels, 1 stride, same padding) → BatchNorm normalization layer → ReLU → one-dimensional pooling operation MaxPool1D.
[0119] Third convolutional block: One-dimensional convolutional layer Conv1D (128 channels, 3 kernels, 1 stride, same padding) → Batch normalization layer BatchNorm → ReLU → One-dimensional pooling operation MaxPool1D.
[0120] After three one-dimensional pooling operations, the time dimension of the condition classification network is reduced from 256 to 128, 64, and 32 respectively, with a channel count of 128. Global average pooling is then performed to obtain the context representation. The classification head consists of a first fully connected layer, a second ReLU activation function, a Dropout operation, a second fully connected layer, and a Softmax function, connected in sequence. That is, the first fully connected layer Dense(128) → ReLU → Dropout(0.20) → the second fully connected layer Dense(6) → Softmax, where the data dimension is in parentheses.
[0121] The calculation process for the classification cross-entropy loss of the working condition classification network is as follows:
[0122] The parameters of the condition classification network are: The probability output by the Softmax function of the classification head is
[0123] .
[0124] in, Let exp() be the category space of the current working condition, p() be the calculation of the exponential function, and p() be the conditional probability. Indicates that in a given and parameters In this case, the sample belongs to the prior of the current working condition. The posterior probability, The table classifies the working conditions of the network for input. The logits vector, Represents the logits vector Prior to the current working condition The amount on, The first category in the category space representing the working condition Various working conditions Represents the logits vector In category The components on the label are predicted. (That is, the prior knowledge of the working conditions predicted by the working condition classification network) and the confidence level Defined respectively
[0125]
[0126] in, Represents the input feature vector The current output of the working condition prior is The predicted probability of the condition is calculated. The confidence threshold is set to 0.70. When q < 0.70, the system outputs "Unknown condition", enters the conservative processing path, and triggers a prompt.
[0127] Classification cross-entropy loss , ,in, Represents the classification cross-entropy loss. This indicates the prior knowledge of the current operating condition. This represents the actual value for the current operating condition category.
[0128] To enable subsequent error compensation, the output of the load condition classification network is in the following format:
[0129] Prior to operation This value, through one-hot encoding, indicates the current operating condition. This represents a vector with a dimension of 6, with values ranging from 0 to 1, corresponding to 6 different working conditions.
[0130] Confidence This indicates the reliability of the current operating condition, obtained by taking the maximum probability after softmax.
[0131] Context representation The high-dimensional semantic vector extracted by the convolutional network over the entire time window contains the amount of information extracted during feature engineering.
[0132] S4. An error compensation network is set up to output a nonlinear compensation amount for correcting the basic error, based on real-time measurement features and historical error information, under the constraint of classification results. Simultaneously, a quantitative uncertainty index for this compensation amount is provided to improve the traceability and credibility of the results, meeting the audit and compliance requirements of metrological applications. In this embodiment, the input tensor, its corresponding operating condition prior, and context representation are concatenated to construct an extended input sequence. This extended input sequence is used as the input to the error compensation network, outputting the mean of the compensation amount. When the operating condition prior is a positive standard operating condition or a positive high harmonic operating condition, the error compensation network uses a forward error calculation method to calculate the basic error. When the operating condition prior is a reverse standard operating condition or a reverse high harmonic operating condition, the error compensation network uses a reverse error calculation method to calculate the basic error. The mean of the basic error and the compensation amount is added together as the composite error for error compensation. When the operating condition prior is a phase reversal or polarity error, or the confidence level is less than a preset value, the error compensation network pauses compensation. The specific process is as follows:
[0133] (1) Definition of input and output of error compensation network
[0134] Within the sliding time window, let the input tensor... (Corresponding to the 20-dimensional features obtained in S2 above, with a time window length of 256). The working condition classification network outputs a one-hot encoding of the categories. Confidence level With context representation vector To incorporate prior operating conditions and contextual representations into sequence modeling, an extended input sequence is defined.
[0135]
[0136] The error compensation network outputs two scalars: the mean of the compensation amount. , .
[0137] (2) Error Compensation Network Architecture and Forward Mapping
[0138] The error compensation network employs two LSTM layers and a linear head. Specifically, the error compensation network includes a first LSTM (64-dimensional) layer and a second LSTM layer (32-dimensional). The first LSTM layer receives the extended input sequence, and after a dropout operation, it is connected to the second LSTM layer. The second LSTM layer takes the hidden state at the last time step as input to a third fully connected layer (2-dimensional). The third fully connected layer outputs 2D data. , ], where are the mean and logarithmic variance of the compensation amount, respectively. This structure learns the temporal correlation of "operating condition-feature-residual" in a sequential manner. The Dropout operation is used to suppress overfitting and to assist in uncertainty modeling. The logarithmic variance is used to construct the loss function of the error compensation network.
[0139] (3) Basic error caliber and compensation synthesis
[0140] When the load condition classification network predicts the load condition prior... At that time, the basic error , Indicates positive error. For standard meter readings, The reading of the test table; when the prior operating condition is predicted by the operating condition classification network. At that time, the basic error , Indicates the inverse error; when the load classification network predicts the load prior, the error is... or At that time, it enters a conservative path, suspends compensation, and sets... =0 and output an alarm flag. The above interface ensures that the classification caliber is consistent with the denominator of the error formula, avoiding systematic deviations introduced by errors in directionality and reference benchmarks.
[0141] Synthesis error is defined as In order to meet the constraints of the operating procedures on the magnitude of a single correction, for Use the clip function to truncate the amplitude. = clip( , 5%, 5%);
[0142] Calculate correction coefficients using synthesis error ;
[0143] The error is compensated by using a correction factor to obtain the corrected reading. .
[0144] (4) Training objectives of error compensation network
[0145] The calculation process for the negative log-likelihood loss of the error compensation network is as follows:
[0146]
[0147] in, This represents the negative log-likelihood loss. Indicates residual label and , Indicates reference error. This is the weight decay coefficient, in this embodiment , The parameters of the error compensation network, This represents the square of the L2 norm.
[0148] To meet the requirements for error source tracing, the error compensation network calculates the overall uncertainty. in, Yes Measurement of uncertainty, obtaining expanded uncertainty The error compensation network determines that the true error falls within the range of... This interval records simultaneously Include the model version number to meet subsequent traceability requirements. Defined as
[0149]
[0150] in for The function form is replaced with the corresponding formula based on the forward and reverse calibers. for Standard uncertainty, for Standard uncertainty, The correlation coefficient between the two is... To determine the sign of the partial derivative. The formula for calculating standard uncertainty is based on existing technology. For details, please refer to the literature "BIPM, IEC, IFCC, et al. Evaluation of measurement data -- Guide to the expression of uncertainty in measurement [J]. Biotechniques, 2008".
[0151] S5. A model consisting of a training condition classification network and an error compensation network is used for power error compensation. This step proposes an adaptive learning mechanism based on a cloud-edge collaborative model update and transfer learning process. This enables the system to continuously optimize model parameters and generalization ability using new field data, achieving long-term adaptive accuracy maintenance and iterative improvement. The above mechanism is not limited to specific hardware form and can be implemented on a general-purpose platform with computing power, without being limited by any specific circuit structure. When the server communicates with multiple clients, and each client deploys a model, each client uses global parameters as a reference and updates the model parameters using a client-side local optimization strategy. At the same time, a server-side weighted fusion strategy is used to update the global parameters of each client, thereby training the model until a preset number of iterations is reached, at which point training stops, and the trained models are obtained. Specifically, the client-side local optimization strategy includes:
[0152] Assume each server communicates with k clients, and the local dataset corresponding to the kth client is... The expected value of the local dataset corresponding to the k-th client is obtained by weighted summation of the classification cross-entropy loss of the working condition classification network and the negative log-likelihood loss of the error compensation network, and is used as the local empirical risk of the k-th client. The formula is as follows:
[0153]
[0154] in, Labels to reflect actual working conditions; The parameters of the operating condition classification network, For input The parameters are The result obtained by calculation The parameters of the error compensation network, These are weighting coefficients; For input The parameters are Calculated under the circumstances . In the input The parameters are Calculated under the circumstances . This represents the mathematical expectation of the local dataset corresponding to the k-th client.
[0155] The objective function is the squared L2 norm of the difference between the parameters of the model deployed on the k-th client and the global parameters, multiplied by the preset near-end coefficient, divided by 2, and then plus the local empirical risk. Adjust the model parameters When the objective function is optimized to its minimum value, that is, when the objective function is optimized to its minimum value, the objective function is optimized to its minimum value. To obtain the updated parameters of the model = The model's parameters are the combined parameters of the load condition classification network and the error compensation network. The parameters of the model deployed on the k-th client in the (t+1)-th iteration. To optimize the model parameters that minimize the objective function, The model parameters are: At that time, the gradient of the local experience risk of the k-th client, These are preset proximal coefficients used to suppress client-side result drift caused by local solutions deviating from the global solution. This represents the global parameters of the t-th iteration. This represents the learning rate of the model during training.
[0156] The server-side weighted fusion strategy includes:
[0157] Suppose there are M servers, each server corresponds to a subset of clients. The client subset Includes the local dataset of each client connected to the Mth server; in the t-th iteration, a subset of clients is selected. The selected client subset After the k1th client completes its local optimization, it sends the parameter increment back to the server. The parameter increment is defined as follows: ,in, This represents the parameter increment returned by the k1th client after completing local optimization in the t-th iteration;
[0158] Weight of parameter increment ,in, Let be the sum of the sample sizes in the t-th iteration and , This represents the sample size of the j-th client subset. The sample size of the k1th client corresponding to the selected client subset;
[0159] Global increment , where m is the total number of clients corresponding to the selected client subset;
[0160] Using formula Update global parameters. This represents the global parameters of the (t+1)th iteration.
[0161] The above method enables synchronous updates between the edge and the cloud.
[0162] Through the above technical solutions, this invention synchronously samples voltage and current signals within a unified time window and constructs a feature sequence using window function preprocessing and fast frequency domain analysis. Without limiting any dedicated hardware, it achieves end-to-end measurement error identification and compensation through a software process. First, based on the non-reciprocity principle, forward and reverse calibration errors are defined and calculated using their respective reference readings, ensuring that the denominator remains consistent across different power flow directions. This denominator serves as both the sole criterion for calculating the basic error and a unified reference for subsequent compensation and uncertainty assessment.
[0163] Subsequently, multi-dimensional measurement features such as amplitude, power, harmonics, phase, and waveform morphology are organized into a feature sequence with a fixed time window and input into the operating condition classification network. The designed operating condition classification network is a one-dimensional convolutional structure, consisting of three convolutional, normalization, activation, and pooling sequences, along with a fixed-dimensional classification head. It can stably distinguish wiring abnormalities such as "positive / reverse × standard / high harmonics" and "phase reversal / polarity error" within a finite delay. The classification output drives the denominator selection of the basic error formula in the form of labels, and provides context for the subsequent error compensation network with one-hot priors and intermediate representation vectors. When the classification confidence is lower than the threshold or an abnormal wiring is identified, the process enters a conservative branch, suspends compensation, and issues an alarm, thus avoiding invalid or harmful corrections at the process level.
[0164] After obtaining the correct baseline error, the error compensation network uses sequence modeling to achieve nonlinear correction for complex operating conditions. Preferably, a structure of two layers of long short-term memory neural networks superimposed with a linear output head is adopted, jointly encoding the feature sequence, classification prior, and historical residuals, outputting the compensation amount for a single measurement and its corresponding uncertainty index. The system combines these two with the baseline error to synthesize the final error and proportionally corrects the reading of the tested table. Simultaneously, it records audit information such as the compensation value, confidence level, combined uncertainty, and model version to meet settlement-level traceability and verification requirements. To ensure engineering usability, upper / lower limits are set for the compensation amount, and an anomaly bypass strategy is implemented to avoid over-correction in extreme scenarios.
[0165] To achieve long-term adaptability and cross-site generalization, a federated learning mechanism of "edge-cloud collaboration" is adopted to update the model periodically: the cloud maintains global parameters and distributes them to the online edge in rounds; the edge performs local optimization with near-end regularization on local data to suppress non-IID drift, and then aggregates the weighted updates into new global parameters through secure aggregation; the above process is limited by methods and interfaces, and is not limited by any specific circuit or device form, and can be directly implemented on platforms with general computing capabilities.
[0166] Example 2
[0167] like Figure 3 As shown in Embodiment 1, Embodiment 2 of the present invention also provides an energy error compensation device, comprising:
[0168] The data acquisition module is used to acquire voltage and current sequences within a time window;
[0169] The data preprocessing feature engineering module is used to preprocess voltage and current sequences to construct input feature vectors;
[0170] The intelligent working condition classification module is used to stack the input feature vectors within a time window to construct an input tensor, input the input tensor into the working condition classification network, and predict the output working condition prior, confidence, and context representation.
[0171] The adaptive error compensation module is used to construct an extended input sequence by concatenating the input tensor, its corresponding prior operating conditions, and context representation. This extended input sequence is then used as the input to the error compensation network, which outputs the mean of the compensation amount. When the prior operating conditions are a positive standard operating condition or a positive high harmonic operating condition, the error compensation network uses a forward error calculation method to calculate the basic error. When the prior operating conditions are a reverse standard operating condition or a reverse high harmonic operating condition, the error compensation network uses a reverse error calculation method to calculate the basic error. The basic error is added to the mean of the compensation amount to obtain the composite error for error compensation. When the prior operating conditions are a phase reversal or polarity error, or when the confidence level is less than a preset value, the error compensation network suspends compensation.
[0172] The edge-cloud collaborative update module is used to train a model consisting of an operating condition classification network and an error compensation network, and to perform power error compensation using the trained model.
[0173] Specifically, the data preprocessing feature engineering module is also used for:
[0174] S21. Introduce a window function, multiply the window function by the voltage sequence and the current sequence respectively, and map them to the frequency domain through fast Fourier transform to obtain the voltage frequency domain component and the current frequency domain component.
[0175] S22. Calculate the mean square values of the voltage and current sequences respectively to obtain the voltage time-domain components. and current time domain components ;
[0176] S23. Calculate active power reactive power Apparent power and power factor ;
[0177] S24. Calculate the total harmonic distortion of voltage using voltage frequency domain components. Calculate the total harmonic distortion of current using current frequency domain components. ;
[0178] S25. Constructing the input feature vector ,in, Representing voltage sequences Second harmonic amplitude Representing a current sequence Second harmonic amplitude This represents the phase difference between the fundamental frequencies of the voltage and current sequences. The peak factor and , It represents the maximum instantaneous amplitude of the voltage waveform relative to zero potential within the measurement time window.
[0179] Specifically, the intelligent working condition classification module is also used for:
[0180] S31. Stack the input feature vectors using time windows of length L to form the input tensor. ,in, Represent the input feature vector at time t; define the set of classification targets reflecting the operating conditions or wiring status. ,in, These represent the forward standard operating condition, the reverse standard operating condition, the forward high harmonic operating condition, the reverse high harmonic operating condition, the phase reversal, and the polarity error, respectively.
[0181] S32. Construct a working condition classification network. The working condition classification network includes a first convolutional block to a third convolutional block. After the first convolutional block to the third convolutional block are connected in sequence, global average pooling is performed to obtain the context representation. Then, the current input tensor is output through the classification head, showing the probability that it belongs to each working condition. The encoding of the working condition or wiring state corresponding to the maximum probability is used as the working condition prior, and the maximum probability is used as the confidence level. The working condition classification network receives the input tensor and outputs the working condition prior, confidence level, and context representation.
[0182] More specifically, the first to third convolutional blocks have the same structure, only the number of channels is different. The first convolutional module consists of a sequentially connected one-dimensional convolutional layer, a batch normalization layer, a first ReLU activation function, and a one-dimensional pooling operation.
[0183] More specifically, the classification head consists of a first fully connected layer, a second ReLU activation function, a Dropout operation, another fully connected layer, and a Softmax function connected in sequence.
[0184] Specifically, the error compensation network includes a first LSTM layer and a second LSTM layer. The first LSTM layer receives the extended input sequence. After the first LSTM layer undergoes a dropout operation, it is connected to the second LSTM layer. The second LSTM layer takes the hidden state at the last time step as input to the third fully connected layer. The third fully connected layer outputs two-dimensional data, which are the mean and logarithmic variance of the compensation amount. The logarithmic variance is used to construct the loss function of the error compensation network.
[0185] More specifically, the adaptive error compensation module is also used for:
[0186] When the load condition classification network predicts the load condition prior... At that time, the basic error , Indicates positive error. For standard meter readings, The reading of the test table; when the prior operating condition is predicted by the operating condition classification network. At that time, the basic error , Indicates the inverse error; when the load classification network predicts the load prior, the error is... or At that time, compensation was suspended and the situation was set aside. = 0 and output an alarm flag, Indicates the confidence level. This represents the mean of the compensation amount;
[0187] Synthesis error is defined as In order to meet the constraints of the operating procedures on the magnitude of a single correction, for Use the clip function to truncate the amplitude. =clip( , 5%, 5%);
[0188] Calculate correction coefficients using synthesis error ;
[0189] The error is compensated by using a correction factor to obtain the corrected reading. .
[0190] More specifically, the adaptive error compensation module is also used for:
[0191] To meet the requirements for error source tracing, the error compensation network calculates the overall uncertainty. in, Yes Measurement of uncertainty, obtaining expanded uncertainty The error compensation network determines that the true error falls within the range of... This interval records simultaneously And the model version number.
[0192] More specifically, the edge-cloud collaborative update module is also used for:
[0193] When the server connects to multiple clients, and each client deploys a model, each client uses global parameters as a reference and employs a client-side local optimization strategy to update the model's parameters. At the same time, a server-side weighted fusion strategy is used to update the global parameters of each client, thereby training the model until a preset number of iterations is reached, at which point training stops, and the trained models are obtained.
[0194] More specifically, the client-side local optimization strategy includes:
[0195] Assume each server communicates with k clients, and the local dataset corresponding to the kth client is... The expected value of the local dataset corresponding to the k-th client is obtained by weighted summation of the classification cross-entropy loss of the working condition classification network and the negative log-likelihood loss of the error compensation network. This is used as the local empirical risk for the k-th client. The squared L2 norm of the difference between the parameters of the model deployed on the k-th client and the global parameters, multiplied by the preset proximal coefficient, divided by 2, and added to the local empirical risk, is used as the optimization objective function to adjust the model parameters. When the optimization objective function reaches its minimum value, the updated model parameters are obtained. = The model's parameters are the combined parameters of the load condition classification network and the error compensation network. The parameters of the model deployed on the k-th client in the (t+1)-th iteration. To optimize the model parameters that minimize the objective function, The model parameters are: At that time, the gradient of the local experience risk of the k-th client, The pre-defined proximal coefficient, This represents the global parameters of the t-th iteration. This represents the learning rate of the model during training.
[0196] More specifically, the calculation process of the classification cross-entropy loss of the working condition classification network is as follows:
[0197]
[0198] in, Represents the classification cross-entropy loss. This indicates the prior knowledge of the current operating condition. This represents the actual value for the current operating condition category. Represents the input feature vector The current output of the working condition prior is The predicted probability of the situation.
[0199] More specifically, the calculation process of the negative log-likelihood loss of the error compensation network is as follows:
[0200]
[0201] in, This represents the negative log-likelihood loss. This represents the logarithmic variance of the compensation amount. Indicates residual label and , Indicates reference error. This is the weight decay coefficient. The parameters of the error compensation network, This represents the square of the L2 norm.
[0202] More specifically, the server-side weighted fusion strategy includes:
[0203] Suppose there are M servers, each server corresponds to a subset of clients. The client subset Includes the local dataset of each client connected to the Mth server; in the t-th iteration, a subset of clients is selected. The selected client subset After the k1th client completes its local optimization, it sends the parameter increment back to the server. The parameter increment is defined as follows: ,in, This represents the parameter increment returned by the k1-th client after completing local optimization in the t-th iteration; the weight of the parameter increment. ,in, Let be the sum of the sample sizes in the t-th iteration and , This represents the sample size of the j-th client subset. The sample size of the k1-th client corresponding to the selected client subset; global increment. , where m is the total number of clients corresponding to the selected client subset; using the formula Update global parameters. This represents the global parameters of the (t+1)th iteration.
[0204] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for compensating for data errors in an electricity meter, characterized in that, include: S1. Acquire voltage and current sequences within the time window; S2. Preprocess the voltage and current sequences to construct the input feature vector; S3. Stack the input feature vectors within the time window to construct an input tensor. Input the input tensor into the working condition classification network to predict the output working condition prior, confidence, and context representation. S4. Concatenate the input tensor, its corresponding prior operating conditions, and context representation to construct an extended input sequence. Use this extended input sequence as the input to the error compensation network and output the mean of the compensation amount. When the prior operating conditions are a positive standard operating condition or a positive high harmonic operating condition, the error compensation network uses the forward error calculation method to calculate the basic error. When the prior operating conditions are a reverse standard operating condition or a reverse high harmonic operating condition, the error compensation network uses the reverse error calculation method to calculate the basic error. The basic error is added to the mean of the compensation amount as the synthetic error for error compensation. When the prior operating conditions are a phase reversal or polarity error, or when the confidence level is less than the preset value, the error compensation network suspends compensation. S5 is a model consisting of a training condition classification network and an error compensation network. The trained model is used for power error compensation.
2. The method for compensating for data errors in an electricity meter according to claim 1, characterized in that, S2 includes: S21. Introduce a window function, multiply the window function by the voltage sequence and the current sequence respectively, and map them to the frequency domain through fast Fourier transform to obtain the voltage frequency domain component and the current frequency domain component. S22. Calculate the mean square values of the voltage and current sequences respectively to obtain the voltage time-domain components. and current time domain components ; S23. Calculate active power reactive power Apparent power and power factor ; S24. Calculate the total harmonic distortion of voltage using voltage frequency domain components. Calculate the total harmonic distortion of current using current frequency domain components. ; S25. Constructing the input feature vector ,in, Representing voltage sequences Second harmonic amplitude Representing a current sequence Second harmonic amplitude This represents the phase difference between the fundamental frequencies of the voltage and current sequences. The peak factor and , It represents the maximum instantaneous amplitude of the voltage waveform relative to zero potential within the measurement time window.
3. The method for compensating for data errors in an electricity meter according to claim 1, characterized in that, S3 includes: S31. Stack the input feature vectors using time windows of length L to form the input tensor. ,in, Represent the input feature vector at time t; define the set of classification targets reflecting the operating conditions or wiring status. ,in, These represent the forward standard operating condition, the reverse standard operating condition, the forward high harmonic operating condition, the reverse high harmonic operating condition, the phase reversal, and the polarity error, respectively. S32. Construct a working condition classification network. The working condition classification network includes a first convolutional block to a third convolutional block. After the first convolutional block to the third convolutional block are connected in sequence, global average pooling is performed to obtain the context representation. Then, the current input tensor is output through the classification head, showing the probability that it belongs to each working condition. The encoding of the working condition or wiring state corresponding to the maximum probability is used as the working condition prior, and the maximum probability is used as the confidence level. The working condition classification network receives the input tensor and outputs the working condition prior, confidence level, and context representation.
4. The method for compensating for data errors in an electricity meter according to claim 3, characterized in that, The first to third convolutional blocks have the same structure, only the number of channels is different. The first convolutional module consists of a sequentially connected one-dimensional convolutional layer, a batch normalization layer, a first ReLU activation function, and a one-dimensional pooling operation.
5. The method for compensating for data errors in an electricity meter according to claim 3, characterized in that, The classification head consists of a first fully connected layer, a second ReLU activation function, a Dropout operation, a second fully connected layer, and a Softmax function, connected in sequence.
6. The method for compensating for data errors in an electricity meter according to claim 1, characterized in that, The error compensation network includes a first LSTM layer and a second LSTM layer. The first LSTM layer receives the extended input sequence. After the first LSTM layer undergoes a dropout operation, it is connected to the second LSTM layer. The second LSTM layer takes the hidden state at the last time step as input to the third fully connected layer. The third fully connected layer outputs two-dimensional data, which are the mean and logarithmic variance of the compensation amount. The logarithmic variance is used to construct the loss function of the error compensation network.
7. The method for compensating for data errors in an electricity meter according to claim 3, characterized in that, S4 includes: When the load condition classification network predicts the load condition prior... At that time, the basic error , Indicates positive error. For standard meter readings, The reading of the test table; when the prior operating condition is predicted by the operating condition classification network. At that time, the basic error , Indicates the inverse error; when the load classification network predicts the load prior, the error is... or At that time, compensation was suspended and the situation was set aside. =0 and output an alarm flag. Indicates the confidence level. This represents the mean of the compensation amount; Synthesis error is defined as In order to meet the constraints of the operating procedures on the magnitude of a single correction, for Use the clip function to truncate the amplitude. = clip( , 5%, 5%); Calculate correction coefficients using synthesis error ; The error is compensated by using a correction factor to obtain the corrected reading. .
8. The method for compensating for data errors in an electricity meter according to claim 7, characterized in that, S4 further includes: To meet the requirements for error source tracing, the error compensation network calculates the overall uncertainty. ,in, Yes Measurement of uncertainty, obtaining expanded uncertainty The error compensation network determines that the true error falls within the range of... This interval records simultaneously And the model version number.
9. A method for compensating for data errors in an electricity meter according to claim 7, characterized in that, S5 includes: When the server connects to multiple clients, and each client deploys a model, each client uses global parameters as a reference and employs a client-side local optimization strategy to update the model's parameters. At the same time, a server-side weighted fusion strategy is used to update the global parameters of each client, thereby training the model until a preset number of iterations is reached, at which point training stops, and the trained models are obtained.
10. A method for compensating for data errors in an electricity meter according to claim 9, characterized in that, The client-side local optimization strategy includes: Assume each server communicates with k clients, and the local dataset corresponding to the kth client is... The expected value of the local dataset corresponding to the k-th client is obtained by weighted summation of the classification cross-entropy loss of the working condition classification network and the negative log-likelihood loss of the error compensation network. This is used as the local empirical risk for the k-th client. The squared L2 norm of the difference between the parameters of the model deployed on the k-th client and the global parameters, multiplied by the preset proximal coefficient, divided by 2, and added to the local empirical risk, is used as the optimization objective function to adjust the model parameters. When the optimization objective function reaches its minimum value, the updated model parameters are obtained. = The model's parameters are the combined parameters of the load condition classification network and the error compensation network. The parameters of the model deployed on the k-th client in the (t+1)-th iteration. To optimize the model parameters that minimize the objective function, The model parameters are: At that time, the gradient of the local experience risk of the k-th client, The pre-defined proximal coefficient, This represents the global parameters of the t-th iteration. This represents the learning rate of the model during training.
11. A method for compensating for data errors in an electricity meter according to claim 10, characterized in that, The calculation process for the classification cross-entropy loss of the working condition classification network is as follows: in, Represents the classification cross-entropy loss. This indicates the prior knowledge of the current operating condition. This represents the actual value for the current operating condition category. Represents the input feature vector The current output of the working condition prior is The predicted probability of the situation.
12. The method for compensating for data errors in an electricity meter according to claim 10, characterized in that, The calculation process for the negative log-likelihood loss of the error compensation network is as follows: in, This represents the negative log-likelihood loss. This represents the logarithmic variance of the compensation amount. Indicates residual label and , Indicates reference error. This is the weight decay coefficient. The parameters of the error compensation network, This represents the square of the L2 norm.
13. The method for compensating for data errors in an electricity meter according to claim 10, characterized in that, The server-side weighted fusion strategy includes: Suppose there are M servers, each server corresponds to a subset of clients. The client subset Includes the local dataset of each client connected to the Mth server; in the t-th iteration, a subset of clients is selected. The selected client subset After the k1th client completes its local optimization, it sends the parameter increment back to the server. The parameter increment is defined as follows: ,in, This represents the parameter increment returned by the k1-th client after completing local optimization in the t-th iteration; the weight of the parameter increment. ,in, Let be the sum of the sample sizes in the t-th iteration and , This represents the sample size of the j-th client subset. The sample size of the k1-th client corresponding to the selected client subset; global increment. , where m is the total number of clients corresponding to the selected client subset; using the formula Update global parameters. This represents the global parameters of the (t+1)th iteration.
14. An apparatus employing the electricity meter data error compensation method according to any one of claims 1-13, characterized in that, include: The data acquisition module is used to acquire voltage and current sequences within a time window; The data preprocessing feature engineering module is used to preprocess voltage and current sequences to construct input feature vectors; The intelligent working condition classification module is used to stack the input feature vectors within a time window to construct an input tensor, input the input tensor into the working condition classification network, and predict the output working condition prior, confidence, and context representation. The adaptive error compensation module is used to construct an extended input sequence by concatenating the input tensor, its corresponding prior operating conditions, and context representation. This extended input sequence is then used as the input to the error compensation network, which outputs the mean of the compensation amount. When the prior operating conditions are a positive standard operating condition or a positive high harmonic operating condition, the error compensation network uses a forward error calculation method to calculate the basic error. When the prior operating conditions are a reverse standard operating condition or a reverse high harmonic operating condition, the error compensation network uses a reverse error calculation method to calculate the basic error. The basic error is added to the mean of the compensation amount to obtain the composite error for error compensation. When the prior operating conditions are a phase reversal or polarity error, or when the confidence level is less than a preset value, the error compensation network suspends compensation. The edge-cloud collaborative update module is used to train a model consisting of an operating condition classification network and an error compensation network, and to perform power error compensation using the trained model.
Citation Information
Patent Citations
Conveying control method and system for electric energy meter tray
CN120706814A