Power waveform zero crossing point detection method and system under wide-frequency-domain harmonic waves
By using the Transformer model to predict the zero crossing point of power timing waveforms, combined with multivariate fusion and mask processing technology, the accuracy of zero crossing point detection in the wide frequency domain harmonic environment in the existing technology is solved, and higher detection accuracy and system stability are achieved.
Patent Information
- Application Number
- CN202411621765.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-14
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2044-11-14
AI Technical Summary
The prior art cannot accurately detect the zero crossing point of the power waveform in a wide frequency domain harmonic environment, resulting in the impact of the accuracy of frequency detection.
The Transformer model is used to predict the zero-crossing point of the power timing waveform, and the input sequence is established through multivariate fusion of data samples, ambient temperature and humidity, and mask processing and noise processing are used to improve the generalization ability and robustness of the model.
The accuracy and stability of power waveform zero crossing point detection in a wide frequency domain harmonic environment is achieved, which reduces prediction errors and improves the stability and prediction capabilities of the power system.
Smart Images

Figure CN119534980A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of power quality detection, and in particular, relates to a method and system for detecting zero-crossing points of electric power waveforms under the influence of wide-frequency domain harmonics. Background Art
[0002] With the comprehensive construction of new power systems and the comprehensive development of large-scale grid-connected distributed energy, the number of power electronic devices with impact, nonlinear and unbalanced characteristics in the power system has increased rapidly, and the grid harmonics have gradually shown new characteristics such as widening of the harmonic frequency domain and increasing medium and high frequency harmonic content, which makes the signal jitter and causes the existence of multiple zero crossings, affecting the accuracy of frequency detection. On the other hand, nonlinear electrical equipment in residents' daily lives has high power fluctuations and distortion, which has a serious impact on the accuracy of electric energy measurement.
[0003] In the prior art, frequency detection methods include Fourier transform method, filter design algorithm, phase-locked loop method and optimal estimation method with complex algorithms, but frequency detection methods cannot meet the measurement requirements. Zero-crossing detection is the basis of frequency detection, and zero-crossing detection can be directly used for frequency estimation. When the zero-crossing point of the AC signal is accurately detected, the frequency information of the signal is obtained by measuring the time interval of continuous zero-crossing points. The existing zero-crossing detection method mainly relies on the principle of mathematical statistics. By performing numerical statistics and threshold judgment on multi-point data near the zero point of the signal, the accurate position of the signal zero-crossing point and the accuracy of the single-point signal value are ignored, so the performance in suppressing signal noise and interference is poor. The digital sinusoidal signal frequency measurement based on the univariate linear regression theory is based on the basic principle that the sinusoidal signal can be approximately linearized near the zero-crossing point. After roughly detecting the zero-crossing position of the signal, the signal value near the zero-crossing point is subjected to univariate linear regression analysis to obtain the intercept of the signal on the time axis coordinate, which is the zero-crossing moment of the signal. The signal period can be accurately calculated by using the time difference between different zero-crossing moments of the signal, and then the frequency can be obtained. This method relies on the approximate linearization of the sinusoidal signal near the zero-crossing point. For high-frequency noise or other high-frequency harmonic components, the zero-crossing point of the signal may no longer appear linear, resulting in an increase in the error of the regression analysis result. For the zero-crossing detection of the amplitude-phase interlaced signal, a narrowband filter is applied to effectively filter out the high-order and low-order harmonics in the signal, so that the signal is normalized to eliminate the interference of harmonics, noise and amplitude mutation on phase detection. In order to improve the detection accuracy and speed of the signal zero-crossing moment, the judgment domain value is set: only when the sampling point falls into the area and there is no jitter phenomenon (i.e. continuous jump) within the specified time range, the point is determined as the zero-crossing moment. Artificially designed filters and thresholds are used in specific application environments, but when facing different application environments, this fixed design scheme is difficult to adapt, resulting in the selection of filters and thresholds becoming the key, affecting the versatility and effectiveness of the algorithm in different environments. Summary of the invention
[0004] In order to solve the deficiencies in the prior art, the present invention provides a method and system for detecting the zero-crossing point of an electric power waveform under wide-frequency domain harmonics, which predicts the zero-crossing point of an electric energy time series waveform based on a Transformer model, thereby solving the technical problems in this field such as the large amount of data labeling and the poor artificial threshold effect and generalization ability of existing algorithms with poor performance.
[0005] The present invention adopts the following technical solution.
[0006] The present invention proposes a method for detecting zero-crossing points of electric power waveforms under wide-frequency domain harmonics, comprising:
[0007] Step 1: within a detection cycle, sampling the power signal source at a set sampling frequency to obtain multiple data samples;
[0008] Step 2, collecting the actual value of the ambient temperature and the actual value of the ambient relative humidity, and performing quantization processing to obtain the quantized value of the ambient temperature and the quantized value of the ambient relative humidity;
[0009] Step 3: divide the data sample into multiple data unit vectors, and the number of data samples in each data unit vector is the same; use a word embedding method to process the quantized value of the ambient temperature and the quantized value of the ambient relative humidity into a quantized embedding vector of the ambient temperature and a quantized embedding vector of the ambient relative humidity respectively;
[0010] Step 4, using a learnable position embedding method to determine the position encoding of the data unit vector, the quantized embedding vector of the ambient temperature, and the quantized embedding vector of the ambient relative humidity;
[0011] Step 5, establishing an input sequence by using a weighted sum of a data unit vector, a quantized embedding vector of an ambient temperature, a quantized embedding vector of an ambient relative humidity, and a position code;
[0012] Step 6: According to the set mask processing ratio and noise processing ratio, replace any unit segment in the input sequence with different types of noise and input it into the Transformer model for training; according to the set mask processing ratio and noise processing ratio, replace the unit segment containing the zero crossing point of the power waveform in the input sequence with different types of noise and input it into the trained Transformer model, and use the starting point position of the unit segment containing the zero crossing point of the power waveform as the label value of the input sequence; the output sequence of the trained Transformer model includes: the predicted data of the unit segment containing the zero crossing point of the power waveform in the input sequence, and the label value of the output sequence is the predicted value of the distance from the starting point position of the unit segment containing the zero crossing point of the power waveform to the zero crossing point of the power waveform; the sum of the label value of the input sequence and the label value of the output sequence is used as the predicted value of the zero crossing point of the power waveform.
[0013] Preferably, in step 3, the size of the embedding dictionary corresponding to the quantized value of the ambient temperature is defined as 20, the size of the embedding dictionary corresponding to the quantized value of the ambient relative humidity is defined as 16, and a benchmark word embedding vector with a dimension of 32 is used to embed the quantized value of the ambient temperature and the quantized value of the ambient relative humidity.
[0014] Preferably, the input sequence satisfies the following relationship:
[0015] X=α×Q+β×T+θ×H+ε×P
[0016] Where X is the input sequence, Q and α are the data unit vectors and their corresponding weight parameters, T and β are the quantized embedding vectors of ambient temperature and their corresponding weight parameters, H and θ are the quantized embedding vectors of ambient relative humidity and their corresponding weight parameters, and P and ε are the position codes and their corresponding weight parameters;
[0017] It satisfies θ+β+θ+ε=1, and α, β, θ, and ε are not 0.
[0018] Preferably, the Transformer model comprises: a Transformer encoder layer;
[0019] The encoder of Transformer is composed of multiple identical layers stacked together, each of which has two sub-layers. The first sub-layer structure includes a multi-head self-attention sub-layer, a normalization layer, and a residual connection, and the second sub-layer structure includes a position-based feedforward network sub-layer, a normalization layer, and a residual connection.
[0020] Preferably, step 6 comprises:
[0021] Step 6.1, divide the input sequence into D units of the same length; D is a positive integer greater than or equal to 10;
[0022] Step 6.2, according to the set mask processing ratio τ, mask processing is performed on any D·τ unit segments, including: 1 The unit segments are replaced with different types of noise, retaining D·τ·(1-τ 1 ) unit segments remain unchanged; among them, τ 1 is the noise processing ratio; different types of noise include: noise of data unit vector and its corresponding weight parameter, noise of quantized embedded vector of ambient temperature and its corresponding weight parameter, noise of quantized embedded vector of ambient relative humidity and its corresponding weight parameter, and noise of position code and its corresponding weight parameter;
[0023] Step 6.3: Input the input sequence processed in step 6.2 into the Transformer model for training; the output sequence of the Transformer model has the same format as the input sequence, including: any D·τ·τ in the input sequence 1 Prediction data for each unit segment;
[0024] Step 6.4, according to the set mask processing ratio τ, mask processing is performed on the D·τ unit segments containing the zero-crossing point of the power waveform, including: masking the D·τ·τ unit segments containing the zero-crossing point of the power waveform 1 The unit segments are replaced with different types of noise, retaining D·τ·(1-τ 1 ) unit segments remain unchanged; and the starting point positions of D·τ unit segments containing the zero-crossing points of the power waveform are used as label values of the input sequence;
[0025] Step 6.5: Input the input sequence processed in step 6.4 into the Transformer model trained in step 6.3. The output sequence of the Transformer model has the same format as the input sequence, including: D·τ·τ containing the zero-crossing point of the power waveform in the input sequence 1 The prediction data of D·τ unit segments; the label value of the output sequence of the Tr6nsformer model is the predicted value of the distance from the starting point of D·τ unit segments including the zero-crossing point of the power waveform to the zero-crossing point of the power waveform;
[0026] Step 6.6, taking the sum of the label value of the input sequence and the label value of the output sequence as the predicted value of the zero-crossing point of the power waveform.
[0027] Preferably, the mask processing ratio τ is no more than 25%, and the noise processing ratio τ is 1 The value is not less than 90%.
[0028] The present invention also proposes a power waveform zero-crossing point detection system under wide frequency domain harmonics, comprising:
[0029] The acquisition module is used to sample the power signal source at a set sampling frequency within a detection cycle to obtain multiple data samples; collect the actual value of the ambient temperature and the actual value of the ambient relative humidity, and perform quantization processing to obtain the quantized value of the ambient temperature and the quantized value of the ambient relative humidity;
[0030] A vector division module is used to divide the data sample into a plurality of data unit vectors, and the number of data samples in each data unit vector is the same; a word embedding method is used to process the quantized value of the ambient temperature and the quantized value of the ambient relative humidity into a quantized embedding vector of the ambient temperature and a quantized embedding vector of the ambient relative humidity respectively;
[0031] A position encoding module, used to determine the position encoding of the data unit vector, the quantized embedding vector of the ambient temperature, and the quantized embedding vector of the ambient relative humidity by using a learnable position embedding method;
[0032] An input sequence establishment module, used to establish an input sequence by using a weighted sum of a data unit vector, a quantized embedding vector of an ambient temperature, a quantized embedding vector of an ambient relative humidity, and a position code;
[0033] The power waveform zero-crossing prediction module is used to replace any unit segment in the input sequence with different types of noise according to the set mask processing ratio and noise processing ratio, and then input it into the Transformer model for training; according to the set mask processing ratio and noise processing ratio, replace the unit segment containing the power waveform zero-crossing point in the input sequence with different types of noise and then input it into the trained Transformer model, and use the starting point position of the unit segment containing the power waveform zero-crossing point as the label value of the input sequence; the output sequence of the trained Transformer model includes: the prediction data of the unit segment containing the power waveform zero-crossing point in the input sequence, and the label value of the output sequence is the predicted value of the distance from the starting point position of the unit segment containing the power waveform zero-crossing point to the power waveform zero-crossing point; the sum of the label value of the input sequence and the label value of the output sequence is used as the predicted value of the power waveform zero-crossing point.
[0034] The power waveform zero-crossing prediction module includes:
[0035] An input sequence division unit, used to divide the input sequence into D unit segments of the same length; D is a positive integer greater than or equal to 10;
[0036] The model training unit is used to perform mask processing on any D·τ unit segments according to the set mask processing ratio τ, including: 1 The unit segments are replaced with different types of noise, retaining D·τ·(1-τ 1 ) unit segments remain unchanged; among them, τ1 is the noise processing ratio; different types of noise include: noise of data unit vector and its corresponding weight parameter, noise of quantized embedding vector of ambient temperature and its corresponding weight parameter, noise of quantized embedding vector of ambient relative humidity and its corresponding weight parameter, and noise of position encoding and its corresponding weight parameter; the masked input sequence is input into the Transformer model for training; the output sequence of the Transformer model has the same format as the input sequence, including: any D·τ·τ in the input sequence 1 Prediction data for each unit segment;
[0037] The zero-crossing prediction unit is used to perform mask processing on D·τ unit segments containing the zero-crossing points of the power waveform according to the set mask processing ratio τ, including: 1 The unit segments are replaced with different types of noise, retaining D·τ·(1-τ 1 ) unit segments remain unchanged; and the starting point positions of D·τ unit segments containing the zero-crossing point of the power waveform are used as the label values of the input sequence; the masked input sequence is input into the trained Transformer model, and the output sequence of the Transformer model has the same format as the input sequence, including: the D·τ·τ unit segments containing the zero-crossing point of the power waveform in the input sequence 1 The prediction data of D·τ unit segments are collected; the label value of the output sequence of the Transformer model is the predicted value of the distance from the starting point of D·τ unit segments containing the zero-crossing point of the power waveform to the zero-crossing point of the power waveform; the sum of the label value of the input sequence and the label value of the output sequence is taken as the predicted value of the zero-crossing point of the power waveform.
[0038] The present invention also provides a terminal, comprising a processor and a storage medium; the storage medium is used to store instructions; the processor is used to operate according to the instructions to execute the steps of the method.
[0039] The present invention also provides a computer-readable storage medium on which a computer program is stored, and the program implements the steps of the method when executed by a processor.
[0040] The beneficial effect of the present invention lies in that, compared with the prior art, at least the method proposed in the present invention uses the Transformer model to perform zero-crossing detection on the power signal, utilizes multiple data without time series, and based on the sequence modeling capability of the Transformer model to capture the time series relationship in the data, and based on the captured time series relationship, the insertion positions of parameters such as temperature and humidity are self-learned, thereby realizing effective encoding of data samples, temperature, and humidity, which can not only accurately predict the zero-crossing position of the electric energy waveform and its changing trend, but also achieve lower prediction error and stronger generalization ability, and improve the measurement accuracy and stability with strong noise and interference suppression ability, thereby improving the stability and prediction ability of the power system. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 It is a flow chart of the method for detecting the zero-crossing point of an electric power waveform under wide-frequency domain harmonics proposed by the present invention. DETAILED DESCRIPTION
[0042] In order to make the purpose, technical scheme and advantages of the present invention clearer, the technical scheme of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. The embodiments described in this application are only embodiments of a part of the present invention, rather than all embodiments. Based on the spirit of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work belong to the protection scope of the present invention.
[0043] The present invention proposes a method for detecting zero-crossing points of electric power waveforms under wide frequency domain harmonics. Figure 1 As shown, including:
[0044] Step 1: within a detection cycle, the power signal source is sampled at a set sampling frequency to obtain a plurality of data samples.
[0045] The power signal source outputs a power timing waveform. In the embodiment, under real working conditions, a recording device is used to record the power timing waveform at a sampling frequency f 1 Sample the signal source, the power frequency f 0 ∈[50-δ, 50+δ], where δ∈[-1,1] represents the frequency fluctuation range of the power frequency. By setting the sampling frequency f 1 , collect data samples of n sampling points from the signal source, and these data samples do not have time series characteristics. The collected data will be used to analyze the frequency fluctuation characteristics under working conditions and subsequent signal processing to support the algorithm optimization and practical application of high-precision power sensing devices. In the embodiment, the sampling frequency f 1 =12.8kHz, the power frequency of the signal source is f 0 =50Hz, take 3 cycles of waveform data, a total of 768 sampling points.
[0046] Each data sample corresponds to a sampling moment and has a moment characteristic.
[0047] Step 2: collect the actual value of the ambient temperature and the actual value of the ambient relative humidity, and perform quantization processing to obtain the quantized value of the ambient temperature and the quantized value of the ambient relative humidity.
[0048] Considering that the ambient temperature and humidity have an impact on the sampling components and will affect the sampling value, the temperature, humidity and other information are also taken into account when determining the input data sequence. The actual value of the ambient temperature and the actual value of the ambient relative humidity are quantified, including:
[0049] 1) The actual value of the ambient temperature of the actual meter application is T∈[-40℃, 80℃], with the minimum unit scale of 2℃. The quantified value of the ambient temperature is T C ∈[0,60), where the mathematical symbol Indicates rounding up, y is the quantized value of the ambient temperature, and x is the actual value of the ambient temperature. When the actual value of the ambient temperature is 37.3℃, the quantized value of the actual value of the ambient temperature is 39.
[0050] 2) The actual relative humidity of the environment in which the meter is actually used is G∈[10%RH, 90%RH], with the minimum unit scale being 5%RH. The quantified value of ambient humidity is H C ∈[0,16), where the mathematical symbol Indicates rounding up, y is the quantified value of the ambient relative humidity, and x is the actual value of the ambient relative humidity. When the actual value of the ambient relative humidity is 50%RH, the quantified value of the ambient relative humidity is 8.
[0051] Step 3: Divide the data samples into multiple data unit vectors, and the number of data samples in each data unit vector is the same; use the word embedding method to process the quantized value of the ambient temperature and the quantized value of the ambient relative humidity into the quantized embedding vector of the ambient temperature and the quantized embedding vector of the ambient relative humidity, respectively.
[0052] However, the quantized value of the ambient temperature and the quantized value of the ambient relative humidity have time characteristics and remain unchanged within a certain time period, while the lengths of the certain time period corresponding to the temperature and the certain time period corresponding to the humidity are different, and the data samples collected in step 1 are also different within the certain time period corresponding to the temperature and the certain time period corresponding to the humidity. In the prior art, the temperature and humidity are often fused with the data samples based on the sampling time, but the fused data cannot accurately reflect the impact of temperature and humidity on power data, so it is necessary to determine the time series correspondence between the temperature, humidity and the data samples.
[0053] In the embodiment, if the number of data samples in each data unit vector is the same, then the length of each data unit vector is the same. The present invention proposes to divide the data samples into multiple data unit vectors of the same length to realize the transformation from data samples with time characteristics to data unit vectors, so as to keep consistent with the time period characteristics of the quantized value of the ambient temperature and the quantized value of the ambient relative humidity, and also facilitate the embedding and integration of the quantized value of the ambient temperature and the quantized value of the ambient relative humidity.
[0054] In a detection cycle, the word embedding method is used to convert the high-dimensional quantized values of ambient temperature and ambient relative humidity into low-dimensional vectors. When the word embedding method is used, the time period characteristics of the quantized values of ambient temperature and ambient relative humidity are actually removed, thereby improving the generalization ability, making the input sequence model obtained subsequently a more general model. Then, when processing power data influencing parameters other than ambient temperature and ambient relative humidity, the input sequence model has extremely high accuracy and reliability. In the embodiment, the size of the embedding dictionary corresponding to the quantized value of ambient temperature is defined as 20, which means that the quantized value of ambient temperature will be divided into 20 categories; the size of the embedding dictionary corresponding to the quantized value of ambient relative humidity is 16, that is, the quantized value of ambient relative humidity will be divided into 16 categories; for each quantized category, a reference word embedding vector with a dimension of 32 is used to implement the embedding processing of the quantized value of ambient temperature and the quantized value of ambient relative humidity, fully capturing the temporal differences between ambient temperature and ambient relative humidity.
[0055] Step 4: Use a learnable position embedding method to determine the position encoding of the data unit vector, the quantized embedding vector of the ambient temperature, and the quantized embedding vector of the ambient relative humidity.
[0056] Position embedding is a technique for encoding the position information of elements in a sequence. It can distinguish different positions in the sequence to better interpret the sequence structure, and strengthen the dependencies in the sequence through position information to improve the integrity of the sequence. In the Transformer model, each element in the input sequence is mapped to a vector representation in a high-dimensional space. However, the traditional self-attention mechanism does not contain position information, so additional position embedding is required to supplement this information. In the learnable position embedding method of the embodiment, the position embedding is usually a learnable parameter matrix, which is initialized to a tensor of [sequence_length, embedding_dim], and this tensor is updated by back propagation during the subsequent Transformer model training process.
[0057] The position encoding determined by the learnable position embedding method is used to dynamically learn the importance of each position between the data unit vector, the quantized embedding vector of the ambient temperature, and the quantized embedding vector of the ambient relative humidity. The expression of the position information is adaptively adjusted according to different sequence data, further enhancing the generalization ability of the input sequence model.
[0058] Step 5: Create an input sequence using the weighted sum of the data unit vector, the quantized embedding vector of the ambient temperature, the quantized embedding vector of the ambient relative humidity, and the position code.
[0059] The input sequence satisfies the following relationship:
[0060] X=α×Q+β×T+θ×H+ε×P
[0061] Where X is the input sequence, Q and α are the data unit vectors and their corresponding weight parameters, T and β are the quantized embedding vectors of ambient temperature and their corresponding weight parameters, H and θ are the quantized embedding vectors of ambient relative humidity and their corresponding weight parameters, and P and ε are the position codes and their corresponding weight parameters.
[0062] It satisfies α+β+θ+ε=1, and α, β, θ, ε are all not 0.
[0063] Each weight coefficient is used to adjust the contribution of power data, temperature, humidity and position encoding to the input sequence. Since power data, temperature and humidity contribute differently to model prediction, learnable weight parameters α, β, θ and ε are introduced for each part so that the model can automatically adjust the weight of each type of information during training, ensuring that the model can give appropriate weights to different inputs according to the actual situation of the data.
[0064] Step 6: According to the set mask processing ratio and noise processing ratio, replace any unit segment in the input sequence with different types of noise and input it into the Transformer model for training; according to the set mask processing ratio and noise processing ratio, replace the unit segment containing the zero crossing point of the power waveform in the input sequence with different types of noise and input it into the trained Transformer model, and use the starting point positions of D·τ unit segments containing the zero crossing point of the power waveform as the label value of the input sequence; the output sequence of the trained Transformer model includes: the predicted data of the unit segment containing the zero crossing point of the power waveform in the input sequence, and the label value of the output sequence is the predicted value of the distance from the starting point position of the unit segment containing the zero crossing point of the power waveform to the zero crossing point of the power waveform; the sum of the label value of the input sequence and the label value of the output sequence is used as the predicted value of the zero crossing point of the power waveform.
[0065] The method proposed in the present invention applies natural language processing to the field of power timing waveform detection, which also brings many changes to the training of the Transformer model.
[0066] In the embodiment, the Transformer model includes: a Transformer encoder layer. The Transformer encoder is composed of multiple identical layers stacked together, each layer has two sublayers, wherein the first sublayer structure includes a multi-head self-attention sublayer, a normalization layer, and a residual connection, and the second sublayer structure includes a position-based feedforward network sublayer, a normalization layer, and a residual connection.
[0067] Specifically, the Multi-Head Self-Attention Layer can calculate multiple attention heads in parallel based on the multi-head self-attention mechanism, and pay attention to different parts of the input sequence through different projections. The input sequence is linearly transformed to generate the query vector Qr, key vector K and value vector V, and the weighted sum is calculated by calculating the attention weight. The formula is as follows:
[0068]
[0069] In the formula, Attention(Qr,K,V) is the attention weight, d k is the dimension of the key vector.
[0070] The multi-head self-attention mechanism concatenates the outputs of the attention heads and obtains the final output through linear transformation. The formula is as follows:
[0071] MultiHead(Qr,K,V)=Concat(head 1 ,head 2 ,…,head h )W O
[0072] In the formula, MultiHead(Qr,K,V) is multi-head self-attention, W i Qr , W O is the learned parameter matrix.
[0073] Specifically, the normalization layer and residual connection (Layer Normalization and ResidualConnection):
[0074] Each sub-layer is followed by a normalization layer (LayerNorm) to standardize the output of the sub-layer.
[0075] At the same time, a residual connection is used to add the input directly to the output of the sublayer, satisfying the following relationship:
[0076] SubLayerOutput=LayerNorm(X+SubLayer(X))
[0077] Where SubLayerOutput is the output of the sublayer, X is the input of the sublayer, SubLayer(X) is the output of the sublayer, and LayerNorm() is the transfer function of the normalization layer.
[0078] Specifically, the position-wise feed-forward network sublayer (Positionwise Feed-Forward NetworkLayer) consists of two linear transformations and an activation function, which is used to perform independent nonlinear transformations on the vectors at each position, satisfying the following relationship:
[0079] FFN(x)=max(0,xW 1 +b 1 )W 2 +b 2
[0080] Where W 1 ,W 2 and b 1 ,b 2 is the learned parameter matrix and bias term.
[0081] The Transformer encoder satisfies the following relationship:
[0082] EncoderLayer(x)=LayerNorm(FFN(LayerNorm(MultiHead(X,X,X))+X)+(MultiHead(X,X,X)+X)
[0083] Among them, EncoderLayer(x) is the output of a single-layer encoder, FFN represents the feedforward network layer, MultiHead represents the multi-head self-attention layer, LayerNorm represents the normalization layer, and the final encoder output is obtained after N layers are stacked.
[0084] Specifically, step 6 includes:
[0085] Step 6.1, divide the input sequence into D unit segments of length L; D is a positive integer greater than or equal to 10;
[0086] Step 6.2, according to the set mask processing ratio τ, mask processing is performed on any D·τ unit segments, including: 1 The unit segments are replaced with different types of noise, retaining D·τ·(1-τ 1 ) unit segments remain unchanged; among them, τ 1 is the noise processing ratio; different types of noise include: noise of data unit vector and its corresponding weight parameter, noise of quantized embedded vector of ambient temperature and its corresponding weight parameter, noise of quantized embedded vector of ambient relative humidity and its corresponding weight parameter, and noise of position code and its corresponding weight parameter;
[0087] In the embodiment, the mask processing ratio τ is not greater than 25%, and the noise processing ratio τ 1 The value is not less than 90%;
[0088] In traditional electric energy waveform prediction methods, only a single electric power time series data is often considered as input data, and only the noise of the electric power data is used during model training. However, the present invention also introduces a quantized embedded vector of ambient temperature, a quantized embedded vector of ambient relative humidity, a learnable positional encoding, and various weight parameters to form an input sequence. The input sequence is masked and different types of noise are added before inputting into the Transformer model. The model can be trained without labeling the input sequence. The model autonomously learns the temporal correlation between the variables and the contribution of each variable to the input sequence, and optimizes the weight parameters corresponding to each variable to obtain an input sequence that is more in line with the actual situation. After iterative training, the accuracy of the Transformer model's prediction of the input sequence is significantly improved. This method of fusing multiple variables to form an input sequence not only enhances the prediction performance of the model, but also expands its potential for application in multiple fields.
[0089] Step 6.3: Input the input sequence processed in step 6.2 into the Transformer model for training; the output sequence of the Transformer model has the same format as the input sequence, including: any D·τ·τ in the input sequence 1 Prediction data for each unit segment;
[0090] Step 6.4, according to the set mask processing ratio τ, mask processing and labeling processing are performed on the D·τ unit segments containing the zero-crossing points of the power waveform, wherein the mask processing includes: masking the D·τ·τ unit segments containing the zero-crossing points of the power waveform 1 The unit segments are replaced with different types of noise, retaining D·τ·(1-τ 1 ) unit segments remain unchanged; the labeling process includes: the label value of the input sequence is the starting point position of D·τ unit segments containing the zero-crossing point of the power waveform;
[0091] Step 6.5: Input the input sequence processed in step 6.4 into the Transformer model trained in step 6.3. The output sequence of the Transformer model has the same format as the input sequence, including: D·τ·τ containing the zero-crossing point of the power waveform in the input sequence 1 The prediction data of D·τ unit segments; the label value of the output sequence of the Transformer model is the predicted value of the distance from the starting point of D·τ unit segments including the zero-crossing point of the power waveform to the zero-crossing point of the power waveform;
[0092] Step 6.6, taking the sum of the label value of the input sequence and the label value of the output sequence as the predicted value of the zero-crossing point of the power waveform.
[0093] The method proposed in the present invention focuses on the area near the zero crossing point, and the data masking method of the training model is to randomly select data areas for masking so that the model can learn the overall characteristics of the data. However, when the model predicts the zero crossing point, the masked area of the training data set will be mainly concentrated near the zero crossing point. The zero crossing point is an important feature point of the sinusoidal waveform. The waveform in these areas is easily affected by noise and distortion. Therefore, the focused training of data near the zero crossing point can significantly improve the prediction accuracy of the model in these key areas. Masking within a certain number of sampling points before and after the zero crossing fluctuation area can enable the model to focus on learning how to denoise and correct near the fluctuation, thereby improving the robustness and accuracy of the model.
[0094] In order to further improve the practicality and promotion of the model, the present invention adopts a self-supervised learning method for model training. Self-supervised learning is trained by constructing the supervision signal of the data itself, without the need for a large amount of manually labeled data. This method not only reduces the cost and difficulty of data annotation, but also enables the model to extract useful information from a large amount of unlabeled data, improves the generalization ability and robustness of the model, and thus better serves subsequent downstream tasks such as anomaly detection and denoising.
[0095] The present invention also proposes a power waveform zero-crossing point detection system under wide frequency domain harmonics, comprising:
[0096] The acquisition module is used to sample the power signal source at a set sampling frequency within a detection cycle to obtain multiple data samples; collect the actual value of the ambient temperature and the actual value of the ambient relative humidity, and perform quantization processing to obtain the quantized value of the ambient temperature and the quantized value of the ambient relative humidity;
[0097] A vector division module is used to divide the data sample into a plurality of data unit vectors, and the number of data samples in each data unit vector is the same; a word embedding method is used to process the quantized value of the ambient temperature and the quantized value of the ambient relative humidity into a quantized embedding vector of the ambient temperature and a quantized embedding vector of the ambient relative humidity respectively;
[0098] A position encoding module, used to determine the position encoding of the data unit vector, the quantized embedding vector of the ambient temperature, and the quantized embedding vector of the ambient relative humidity by using a learnable position embedding method;
[0099] An input sequence establishment module, used to establish an input sequence by using a weighted sum of a data unit vector, a quantized embedding vector of an ambient temperature, a quantized embedding vector of an ambient relative humidity, and a position code;
[0100] The power waveform zero-crossing prediction module is used to replace any unit segment in the input sequence with different types of noise according to the set mask processing ratio and noise processing ratio, and then input it into the Transformer model for training; according to the set mask processing ratio and noise processing ratio, replace the unit segment containing the power waveform zero-crossing point in the input sequence with different types of noise and then input it into the trained Transformer model, and use the starting point position of the unit segment containing the power waveform zero-crossing point as the label value of the input sequence; the output sequence of the trained Transformer model includes: the prediction data of the unit segment containing the power waveform zero-crossing point in the input sequence, and the label value of the output sequence is the predicted value of the distance from the starting point position of the unit segment containing the power waveform zero-crossing point to the power waveform zero-crossing point; the sum of the label value of the input sequence and the label value of the output sequence is used as the predicted value of the power waveform zero-crossing point.
[0101] The power waveform zero-crossing prediction module includes:
[0102] An input sequence division unit, used to divide the input sequence into D unit segments of the same length; D is a positive integer greater than or equal to 10;
[0103] The model training unit is used to perform mask processing on any D·τ unit segments according to the set mask processing ratio τ, including: 1 The unit segments are replaced with different types of noise, retaining D·τ·(1-τ 1 ) unit segments remain unchanged; among them, τ 1is the noise processing ratio; different types of noise include: noise of data unit vector and its corresponding weight parameter, noise of quantized embedding vector of ambient temperature and its corresponding weight parameter, noise of quantized embedding vector of ambient relative humidity and its corresponding weight parameter, and noise of position encoding and its corresponding weight parameter; the masked input sequence is input into the Transformer model for training; the output sequence of the Transformer model has the same format as the input sequence, including: any D·τ·τ in the input sequence 1 Prediction data for each unit segment;
[0104] The zero-crossing prediction unit is used to perform mask processing on D·τ unit segments containing the zero-crossing points of the power waveform according to the set mask processing ratio τ, including: 1 The unit segments are replaced with different types of noise, retaining D·τ·(1-τ 1 ) unit segments remain unchanged; and the starting point positions of D·τ unit segments containing the zero-crossing point of the power waveform are used as the label values of the input sequence; the masked input sequence is input into the trained Transformer model, and the output sequence of the Transformer model has the same format as the input sequence, including: the D·τ·τ unit segments containing the zero-crossing point of the power waveform in the input sequence 1 The prediction data of D·τ unit segments are collected; the label value of the output sequence of the Transformer model is the predicted value of the distance from the starting point of D·τ unit segments containing the zero-crossing point of the power waveform to the zero-crossing point of the power waveform; the sum of the label value of the input sequence and the label value of the output sequence is taken as the predicted value of the zero-crossing point of the power waveform.
[0105] The present disclosure may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present disclosure.
[0106] Computer readable storage medium can be a tangible device that can hold and store instructions used by an instruction execution device. Computer readable storage medium can be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination thereof. More specific examples (non-exhaustive lists) of computer readable storage medium include: portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), static random access memories (SRAM), portable compact disk read-only memories (CD-ROM), digital versatile disks (DVD), memory sticks, floppy disks, mechanical encoding devices, such as punch cards or convex structures in grooves on which instructions are stored, and any suitable combination thereof. Computer readable storage medium used here is not interpreted as a transient signal itself, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagated by waveguides or other transmission media (e.g., light pulses by optical fiber cables), or electrical signals transmitted by wires.
[0107] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0108] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.
[0109] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents, and any modifications or equivalent replacements that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A method for detecting zero-crossing points of electric power waveforms under wide frequency domain harmonics, characterized in that: include: Step 1: within a detection cycle, sampling the power signal source at a set sampling frequency to obtain multiple data samples; Step 2, collecting the actual value of the ambient temperature and the actual value of the ambient relative humidity, and performing quantization processing to obtain the quantized value of the ambient temperature and the quantized value of the ambient relative humidity; Step 3: divide the data sample into multiple data unit vectors, and the number of data samples in each data unit vector is the same; use a word embedding method to process the quantized value of the ambient temperature and the quantized value of the ambient relative humidity into a quantized embedding vector of the ambient temperature and a quantized embedding vector of the ambient relative humidity respectively; Step 4, using a learnable position embedding method to determine the position encoding of the data unit vector, the quantized embedding vector of the ambient temperature, and the quantized embedding vector of the ambient relative humidity; Step 5, establishing an input sequence by using a weighted sum of a data unit vector, a quantized embedding vector of an ambient temperature, a quantized embedding vector of an ambient relative humidity, and a position code; Step 6: According to the set mask processing ratio and noise processing ratio, replace any unit segment in the input sequence with different types of noise and input it into the Transformer model for training; according to the set mask processing ratio and noise processing ratio, replace the unit segment containing the zero-crossing point of the power waveform in the input sequence with different types of noise and input it into the trained Transformer model, and use the starting point position of the unit segment containing the zero-crossing point of the power waveform as the label value of the input sequence; The output sequence of the trained Transformer model includes: the predicted data of the unit segment containing the zero crossing point of the power waveform in the input sequence, and the label value of the output sequence is the predicted value of the distance from the starting point of the unit segment containing the zero crossing point of the power waveform to the zero crossing point of the power waveform; the sum of the label value of the input sequence and the label value of the output sequence is used as the predicted value of the zero crossing point of the power waveform.
2. The method for detecting zero-crossing point of electric power waveform under wide-frequency harmonics according to claim 1, characterized in that: In step 3, the size of the embedding dictionary corresponding to the quantized value of the ambient temperature is defined as 20, the size of the embedding dictionary corresponding to the quantized value of the ambient relative humidity is defined as 16, and a benchmark word embedding vector with a dimension of 32 is used to embed the quantized value of the ambient temperature and the quantized value of the ambient relative humidity.
3. The method for detecting zero-crossing point of electric power waveform under wide-frequency harmonics according to claim 1, characterized in that: The input sequence satisfies the following relationship: X=α×Q+β×T+θ×H+ε×P Where X is the input sequence, Q and α are the data unit vectors and their corresponding weight parameters, T and β are the quantized embedding vectors of ambient temperature and their corresponding weight parameters, H and θ are the quantized embedding vectors of ambient relative humidity and their corresponding weight parameters, and P and ε are the position codes and their corresponding weight parameters; It satisfies α+β+θ+ε=1, and α, β, θ, ε are all not 0.
4. The method for detecting zero-crossing point of electric power waveform under wide-frequency harmonics according to claim 1, characterized in that: The Transformer model includes: Transformer encoder layer; The encoder of Transformer is composed of multiple identical layers stacked together, each of which has two sub-layers. The first sub-layer structure includes a multi-head self-attention sub-layer, a normalization layer, and a residual connection, and the second sub-layer structure includes a position-based feedforward network sub-layer, a normalization layer, and a residual connection.
5. The method for detecting zero-crossing point of electric power waveform under wide-frequency harmonics according to claim 1, characterized in that: Step 6 includes: Step 6.1, divide the input sequence into D units of the same length; D is a positive integer greater than or equal to 10; Step 6.2, according to the set mask processing ratio τ, mask processing is performed on any D·τ unit segments, including: replacing any D·τ·τ1 unit segments with different types of noise, and keeping D·τ·(1-τ1) unit segments unchanged; wherein τ1 is the noise processing ratio; different types of noise include: noise of data unit vectors and their corresponding weight parameters, noise of quantized embedded vectors of ambient temperature and their corresponding weight parameters, noise of quantized embedded vectors of ambient relative humidity and their corresponding weight parameters, and noise of position codes and their corresponding weight parameters; Step 6.3, input the input sequence processed in step 6.2 into the Transformer model for training; the output sequence of the Transformer model has the same format as the input sequence, including: the prediction data of any D·τ·τ1 unit segments in the input sequence; Step 6.4, according to the set mask processing ratio τ, mask processing is performed on the D·τ unit segments containing the zero-crossing point of the power waveform, including: replacing the D·τ·τ1 unit segments containing the zero-crossing point of the power waveform with different types of noise, and retaining the D·τ·(1-τ1) unit segments containing the zero-crossing point of the power waveform unchanged; and taking the starting point position of the D·τ unit segments containing the zero-crossing point of the power waveform as the label value of the input sequence; Step 6.5, input the input sequence processed by step 6.4 into the Transformer model trained in step 6.3, and the output sequence of the Transformer model has the same format as the input sequence, including: the predicted data of D·τ·τ1 unit segments in the input sequence containing the zero-crossing point of the power waveform; the label value of the output sequence of the Transformer model is the predicted value of the distance from the starting point position of the D·τ unit segments containing the zero-crossing point of the power waveform to the zero-crossing point of the power waveform; Step 6.6, taking the sum of the label value of the input sequence and the label value of the output sequence as the predicted value of the zero-crossing point of the power waveform.
6. The method for detecting zero-crossing point of electric power waveform under wide-frequency harmonics according to claim 5, characterized in that: The mask processing ratio τ is set to be no greater than 25%, and the noise processing ratio τ1 is set to be no less than 90%.
7. A power waveform zero-crossing detection system under wide frequency domain harmonics, characterized in that: include: The acquisition module is used to sample the power signal source at a set sampling frequency within a detection cycle to obtain multiple data samples; The actual value of the ambient temperature and the actual value of the ambient relative humidity are collected and quantified to obtain the quantified value of the ambient temperature and the quantified value of the ambient relative humidity; A vector division module is used to divide the data sample into a plurality of data unit vectors, and the number of data samples in each data unit vector is the same; a word embedding method is used to process the quantized value of the ambient temperature and the quantized value of the ambient relative humidity into a quantized embedding vector of the ambient temperature and a quantized embedding vector of the ambient relative humidity respectively; A position encoding module, used to determine the position encoding of the data unit vector, the quantized embedding vector of the ambient temperature, and the quantized embedding vector of the ambient relative humidity by using a learnable position embedding method; An input sequence establishment module, used to establish an input sequence by using a weighted sum of a data unit vector, a quantized embedding vector of an ambient temperature, a quantized embedding vector of an ambient relative humidity, and a position code; The power waveform zero-crossing prediction module is used to replace any unit segment in the input sequence with different types of noise according to the set mask processing ratio and noise processing ratio, and then input it into the Transformer model for training; according to the set mask processing ratio and noise processing ratio, replace the unit segment containing the zero-crossing point of the power waveform in the input sequence with different types of noise and then input it into the trained Transformer model, and use the starting point position of the unit segment containing the zero-crossing point of the power waveform as the label value of the input sequence; The output sequence of the trained Transformer model includes: the predicted data of the unit segment containing the zero crossing point of the power waveform in the input sequence, and the label value of the output sequence is the predicted value of the distance from the starting point of the unit segment containing the zero crossing point of the power waveform to the zero crossing point of the power waveform; the sum of the label value of the input sequence and the label value of the output sequence is used as the predicted value of the zero crossing point of the power waveform.
8. The power waveform zero-crossing detection system under wide-frequency harmonics according to claim 7, characterized in that: The power waveform zero-crossing prediction module includes: An input sequence division unit, used to divide the input sequence into D unit segments of the same length; D is a positive integer greater than or equal to 10; A model training unit is used to perform mask processing on any D·τ unit segments according to a set mask processing ratio τ, including: replacing any D·τ·τ1 unit segments with different types of noise, and keeping D·τ·(1-τ1) unit segments unchanged; wherein τ1 is the noise processing ratio; different types of noise include: noise of data unit vectors and their corresponding weight parameters, noise of quantized embedded vectors of ambient temperature and their corresponding weight parameters, noise of quantized embedded vectors of ambient relative humidity and their corresponding weight parameters, and noise of position encoding and their corresponding weight parameters; inputting the masked input sequence into the Transformer model for training; the output sequence of the Transformer model has the same format as the input sequence, including: prediction data of any D·τ·τ1 unit segments in the input sequence; A zero-crossing prediction unit is used to perform mask processing on D·τ unit segments containing the zero-crossing point of the power waveform according to a set mask processing ratio τ, including: replacing the D·τ·τ1 unit segments containing the zero-crossing point of the power waveform with different types of noise, and retaining the D·τ·(1-τ1) unit segments containing the zero-crossing point of the power waveform unchanged; and taking the starting point positions of the D·τ unit segments containing the zero-crossing point of the power waveform as the label values of the input sequence; inputting the masked input sequence into a trained Transformer model, the output sequence of the Transformer model has the same format as the input sequence, including: prediction data of the D·τ·τ1 unit segments containing the zero-crossing point of the power waveform in the input sequence; the label value of the output sequence of the Transformer model is the predicted value of the distance from the starting point position of the D·τ unit segments containing the zero-crossing point of the power waveform to the zero-crossing point of the power waveform; and taking the sum of the label value of the input sequence and the label value of the output sequence as the predicted value of the zero-crossing point of the power waveform.
9. A terminal comprising a processor and a storage medium; characterized in that: The storage medium is used to store instructions; The processor is configured to operate according to the instructions to execute the steps of the method according to any one of claims 1 to 6.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Artificial neural network short-circuit current zero point prediction method and prediction terminal
CN115389812A
Wind power prediction method based on non-stationary Transform model
CN117154680A
Short-circuit current zero point prediction method and system based on fading Kalman filtering
CN118607440A
High-speed communication link transmitter modeling method based on Transform decoder
CN118826961A
Pole zero analyzer accompanying phase characteristic
JP1989049099A