Harmonic source modeling method based on Bi-LSTM and transfer learning
By employing a harmonic source modeling method based on Bi-LSTM and transfer learning, and utilizing voltage and current waveform energy for data clustering and standardization, a voltage-current mapping model is constructed. This solves the problems of long processing time and low accuracy in existing harmonic source modeling, and achieves efficient and accurate harmonic source modeling.
Patent Information
- Application Number
- CN202411007077.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-25
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2044-07-25
AI Technical Summary
Existing harmonic source modeling methods are time-consuming to train, have insufficient fitting accuracy, and are highly complex, making it difficult to adapt to the dynamic changes of power grid harmonic sources.
A harmonic source modeling method based on Bi-LSTM and transfer learning is adopted. By monitoring the energy of voltage and current waveforms, a Bi-LSTM model is constructed using DBSCAN clustering analysis and data standardization. A voltage-current mapping transfer model is then established using transfer learning.
It reduces the complexity of harmonic source modeling, improves the model's adaptability and generalization ability, shortens training time, and enhances fitting accuracy and prediction accuracy.
Smart Images

Figure CN119046702A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of power grid harmonic source modeling, and specifically relates to a design of a harmonic source modeling method based on Bi-LSTM and transfer learning. Background Art
[0002] The massive access to renewable energy and the gradual adoption of AC / DC hybrid networks have become two major features of modern power systems, and the resulting grid harmonic problems are becoming increasingly prominent. In this context, the difficult problem of harmonic source modeling methods has received increasing attention from academia and industry. Harmonic source modeling plays an important role in harmonic component analysis, interaction analysis, and responsibility division. An appropriate and accurate harmonic source model can simplify the complexity of the analysis and reduce the analysis error. However, there is no universal harmonic source modeling method so far, and different types of modeling methods have different performances in different application scenarios. At present, according to the modeling ideas, harmonic source modeling methods can be divided into two categories: mechanistic modeling methods and data-driven modeling methods, and each category can be divided into two subcategories: time domain modeling methods and frequency domain modeling methods.
[0003] The mechanistic modeling method starts from the specific circuit topology, based on the basic circuit principles, and uses wavelet analysis, timing analysis and other methods to obtain an analytical expression between input and output (usually a UI relationship). The harmonic source based on the cross-frequency admittance matrix is not suitable for situations where the harmonic source conditions change frequently or the harmonic source has strong randomness. The harmonic source modeling based on the circuit mechanism has clear physical meanings of the parameters in its analytical expression and good interpretability. However, the mechanistic modeling method requires full knowledge of the circuit topology and other information, which is sometimes difficult to achieve in actual engineering. In addition, when the circuit topology changes, the modeling work needs to be completed again, and the versatility is not strong.
[0004] The data-driven harmonic source model is a modeling method that has gradually entered people's field of vision with the development of smart grids. This type of modeling method does not need to know the specific topological structure and can be applied to complex systems. As a universal modeling method, the data-driven frequency domain modeling method can implicitly reflect the coupling relationship between harmonics of each frequency, and can adapt to dynamic changes. It has fast calculation speed and is easy to use. At present, the neural network modeling of harmonic sources mainly uses radial basis function neural network (RBFNN) for related modeling work, but the harmonic source modeling based on neural network requires a large-scale data set and takes a long time to train, so it is not suitable for real-time modeling. Summary of the invention
[0005] The purpose of the present invention is to solve the problems that the existing harmonic source modeling methods take a long time to train, the fitting accuracy is not high enough, and the complexity of the harmonic source modeling problem is high. A harmonic source modeling method based on Bi-LSTM and transfer learning is proposed.
[0006] The technical solution of the present invention is: a harmonic source modeling method based on Bi-LSTM and transfer learning, comprising the following steps:
[0007] S1. Collect voltage waveform data and current waveform data through the monitoring device, calculate the energy of each phase voltage waveform, and calculate the total energy of the three-phase voltage waveform according to the energy of each phase voltage waveform;
[0008] S2. Use the DBSCAN clustering algorithm to perform cluster analysis on the total energy of the three-phase voltage waveform, and divide the voltage waveform data and the current waveform data into multiple voltage-current data sets under different operating conditions;
[0009] S3. Preprocessing and standardizing the voltage-current data set to obtain a standardized voltage-current data set;
[0010] S4. Build a Bi-LSTM model, and select a standardized voltage-current data set under an operating condition based on the Bi-LSTM model to establish a training data set;
[0011] S5. Train the Bi-LSTM model using the training data set, and optimize the network structure and hyperparameters of the Bi-LSTM model to obtain a voltage-current Bi-LSTM benchmark model;
[0012] S6. Using the transfer learning method, some parameters in the voltage-current Bi-LSTM benchmark model are migrated to the voltage-current dataset that is not involved in the model training, and a voltage-current mapping migration model is established to complete the harmonic source modeling.
[0013] The beneficial effects of the present invention are:
[0014] 1. The present invention effectively divides the operating conditions and eliminates abnormal data by introducing waveform energy and DBSCAN cluster analysis; adopts Bi-LSTM neural network for benchmark model training, and uses transfer learning method to establish transfer model, thereby improving the adaptability and generalization ability of the model.
[0015] 2. The present invention reduces the complexity of the harmonic source modeling problem and establishes a harmonic source model, that is, a mapping relationship between voltage and current waveforms, using only the original voltage and current waveform monitoring data. The established voltage-current waveform Bi-LSTM neural network model can well fit the current waveform of each working condition of the monitoring point.
[0016] 3. The transferred model established by the transfer learning method has a short training time, high fitting accuracy, and small prediction error. By further optimizing the non-transferred layer structure and parameters of the transferred model, a transferred model with higher fitting accuracy can be obtained.
[0017] Preferably, the voltage waveform energy in step S1 represents the square sum of the amplitudes of all sampling points of the periodic discrete voltage waveform in one period, and the specific calculation method is:
[0018] S11. Sampling the continuous voltage signal at a fixed sampling frequency f s Sampling is performed to obtain a discrete signal v(n);
[0019] S12. Extract a data segment of a cycle from the discrete signal v(n);
[0020] S13. Perform a square operation on the amplitude of each sampling point in a data segment of a cycle to obtain the square value v(n) of the amplitude of each sampling point. 2 ;
[0021] S14. The square values of the amplitudes of all sampling points in one cycle are accumulated to obtain the voltage waveform energy E. The calculation formula of the voltage waveform energy E is:
[0022]
[0023] Where n represents the nth sampling point, and N represents the total number of sampling points in one cycle.
[0024] Preferably, the calculation formula for the total energy of the three-phase voltage waveform in step S1 is:
[0025] E ABC =E A +E B +E C
[0026] Among them, E ABC Represents the total energy of the three-phase voltage waveform; E A Indicates the voltage waveform energy of phase A; E B Indicates the voltage waveform energy of phase B; E C Indicates the energy of phase C voltage waveform.
[0027] The beneficial effects of the above preferred solution are:
[0028] Waveform energy is an important indicator that describes the overall characteristics of the power waveform. Waveform energy helps to accurately analyze and process waveform data and ensure the stability and reliability of the system.
[0029] Preferably, the step S2 specifically comprises the following steps:
[0030] S21. The total energy E of the three-phase voltage waveform ABC All data is marked as pending;
[0031] S22. The total energy E of the three-phase voltage waveform ABC The position of each data P in is the center of the circle, and E is set ps Draw a circle with the radius as the radius to obtain a circular domain containing different numbers of objects;
[0032] S23. Determine whether the number of objects contained in the circular domain of data P is less than the preset minimum number min P ts If yes, then mark the data P as a boundary point or a noise point and execute step S25; if no, execute step S24;
[0033] S24. Mark data P as core data points and establish cluster C i , the unclassified data points in the data P circle are classified into cluster C i ;
[0034] S25. Determine the total energy E of the three-phase voltage waveform ABC Whether all data points in have been classified, if so, the operating condition classification result is output and the process ends, if not, returns to step S22.
[0035] The beneficial effects of the above preferred solution are:
[0036] The DBSCAN clustering algorithm is used to perform cluster analysis on the total energy of the three-phase voltage waveform, which realizes the effective classification of voltage waveform data and current waveform data, and can accurately detect changes in system operating status. At the same time, the anomaly detection capability of DBSCAN can effectively eliminate abnormal data and ensure the accuracy and reliability of the analysis results.
[0037] Preferably, the calculation formula for the standardization process in step S3 is:
[0038]
[0039] Among them, x represents the original data, x′ represents the standardized data, and x max Represents the maximum value in the original data sequence, x min Represents the minimum value in the original data sequence.
[0040] The beneficial effects of the above preferred solution are:
[0041] Through standardization, the convergence speed of gradient descent during Bi-LSTM model training can be accelerated.
[0042] Preferably, the Bi-LSTM model in step S4 includes an input layer, a forward LSTM layer, a backward LSTM layer and an output layer; the input layer is connected to the forward LSTM layer and the backward LSTM layer respectively; the output layer is connected to the forward LSTM layer and the backward LSTM layer respectively;
[0043] The forward LSTM layer and the backward LSTM layer respectively include a plurality of LSTM units connected in series, and the LSTM units include a forget gate, an update gate and an output gate connected in sequence;
[0044] The calculation formula of the LSTM unit is:
[0045]
[0046] Among them, Γ f represents the output parameter of the forget gate; Γ u represents the output parameter of the update gate; Γ o represents the output parameter of the output gate; σ(·) represents the nonlinear activation function; x (t) Represents the input of the LSTM unit at the current moment; c (t-1) Represents the memory unit of the previous moment; c (t) The memory unit representing the current moment; Indicates the memory representation corresponding to the input information at the current moment; a (t-1) Represents the output of the LSTM unit at the previous moment; a (t) represents the output of the LSTM unit at the current moment; tanh(·) represents the hyperbolic tangent function; W fa Represents the output a of the LSTM unit at the last moment of the forget gate (t-1) The weight matrix W fx Represents the input x of the LSTM unit of the forget gate at the current moment (t) The weight matrix W ua Represents the output a of the LSTM unit at the last moment of the update gate (t-1) The weight matrix W ux Represents the input x of the LSTM unit at the current moment of the update gate (t) The weight matrix W oa Represents the output a of the LSTM unit at the previous moment of the output gate (t-1) The weight matrix W ox Represents the input x of the LSTM unit at the current moment of the output gate (t) The weight matrix W ca Indicates c (t-1) The output a of the LSTM unit at the previous moment (t-1) The weight matrix W cx Indicates c (t-1) The input x of the LSTM unit at the current moment(t) The weight matrix of f represents the bias matrix of the forget gate; b u represents the bias matrix of the update gate; b o represents the bias matrix of the output gate; b c Indicates c (t-1) The bias matrix of .
[0047] The beneficial effects of the above preferred solution are:
[0048] The Bi-LSTM model can effectively learn the long-term dependencies of different time series data and better handle the gradient problems that may exist during neural network training. At the same time, it adds an LSTM layer for reverse data transmission. The output is jointly determined by the forward LSTM layer and the backward LSTM layer, which takes into account the correlation between future moment data and current moment output.
[0049] Preferably, the optimization of the network structure of the Bi-LSTM model in step S5 includes optimizing the number of network layers and the number of neurons in each layer;
[0050] The optimization of the hyperparameters of the Bi-LSTM model includes optimization of the activation function, the loss function, the optimization algorithm and the learning rate.
[0051] Preferably, the loss function selects mean square error, and its calculation formula is:
[0052]
[0053] in, represents the mean square error; m represents the number of training samples; y represents the true value; represents the predicted value; y i Represents the true value of the i-th training sample; Represents the predicted value of the i-th training sample.
[0054] Preferably, the optimization algorithm selects an adaptive moment estimation optimization algorithm, and its calculation formula is:
[0055]
[0056] Among them, θ is the parameter to be optimized; t represents the number of updates of θ; α t represents the learning rate when the number of updates is t; α represents the initial learning rate; β 1 , β 2 and ε are both adjustable hyperparameters, V t represents the first-order moment estimate of the gradient; S t Represents the second moment estimate of the gradient.
[0057] The beneficial effects of the above preferred solution are:
[0058] The adaptability and generalization ability of the Bi-LSTM model are improved by optimizing the number of network layers, the number of neurons in each layer, the activation function, the loss function, the optimization algorithm and the learning rate.
[0059] Preferably, when establishing the voltage-current mapping migration model in step S6, the maximum mean deviation distance between the source domain and the target domain calculated based on the maximum mean deviation is used as a starting indicator for migration learning;
[0060] The calculation formula of the maximum mean deviation is:
[0061]
[0062] in, represents the square form of the maximum mean deviation; k(·,·) represents the kernel function in the RKHS space; X T represents the target domain feature space; X S(k) represents the candidate source domain feature space; N T represents the number of samples in the target domain; x i represents the i-th sample in the target domain; x j represents the jth sample in the target domain; N S(k) Indicates the number of candidate source domain samples; represents the jth sample in the candidate source domain; represents the i-th sample in the candidate source domain.
[0063] The beneficial effects of the above preferred solution are:
[0064] The essence of the maximum mean deviation calculation is to map the sample data features in the source domain and the target domain from the original feature space to the RKHS space, and calculate the distance between the mean values of the target domain and the source domain data in the new space after mapping, thereby reducing the complexity of the calculation. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] Figure 1 Shown is a flowchart of a harmonic source modeling method based on Bi-LSTM and transfer learning. DETAILED DESCRIPTION
[0066] Now, exemplary embodiments of the present invention will be described in detail with reference to the accompanying drawings. It should be understood that the embodiments shown and described in the accompanying drawings are only exemplary and are intended to explain the principles and spirit of the present invention, rather than to limit the scope of the present invention.
[0067] Embodiment 1, as Figure 1 As shown, a harmonic source modeling method of a bidirectional long short-term memory neural network (Bi-LSTM) and transfer learning includes the following steps:
[0068] S1. Collect voltage waveform data and current waveform data through the monitoring device, calculate the energy of each phase voltage waveform, and calculate the total energy of the three-phase voltage waveform according to the energy of each phase voltage waveform;
[0069] S2. Use the density-based spatial clustering algorithm (DBSCAN) to perform cluster analysis on the total energy of the three-phase voltage waveform, and divide the voltage waveform data and the current waveform data into multiple voltage-current data sets under different operating conditions;
[0070] S3. Preprocessing and standardizing the voltage-current data set to obtain a standardized voltage-current data set;
[0071] S4. Build a Bi-LSTM model, and select a standardized voltage-current data set under an operating condition based on the Bi-LSTM model to establish a training data set;
[0072] S5. Train the Bi-LSTM model using the training data set, and optimize the network structure and hyperparameters of the Bi-LSTM model to obtain a voltage-current Bi-LSTM benchmark model;
[0073] S6. Using the transfer learning method, some parameters in the voltage-current Bi-LSTM benchmark model are migrated to the voltage-current dataset that is not involved in the model training, and a voltage-current mapping migration model is established to complete the harmonic source modeling.
[0074] In this embodiment, the voltage waveform energy described in step S1 represents the square sum of the amplitudes of all sampling points of the periodic discrete voltage waveform in one cycle, reflecting the total energy of the voltage waveform in one cycle. The period of the signal is T, and the sampling frequency is f s When the number of sampling points in one cycle is N = T*f s , the specific calculation method of voltage waveform energy is:
[0075] S11. Sampling the continuous voltage signal at a fixed sampling frequency f s Sampling is performed to obtain a discrete signal v(n);
[0076] S12. Extract a data segment of a cycle from the discrete signal v(n);
[0077] S13. Perform a square operation on the amplitude of each sampling point in a data segment of a cycle to obtain the square value v(n) of the amplitude of each sampling point. 2 ;
[0078] S14. The square values of the amplitudes of all sampling points in one cycle are accumulated to obtain the voltage waveform energy E. The calculation formula of the voltage waveform energy E is:
[0079]
[0080] Where n represents the nth sampling point, and N represents the total number of sampling points in one cycle.
[0081] In this embodiment, the calculation formula of the total energy of the three-phase voltage waveform in step S1 is:
[0082] E ABC =E A +E B +E C
[0083] Among them, E ABC Represents the total energy of the three-phase voltage waveform; E A Indicates the voltage waveform energy of phase A; E B Indicates the voltage waveform energy of phase B; E C Indicates the energy of phase C voltage waveform.
[0084] In this embodiment, the DBSCAN algorithm is used to calculate the radius of the object E. ps and the minimum number min P ts Under the condition of ABC Whether the data points meet the conditions, effectively separating the data clusters of voltage waveform energy under different working conditions, the step S2 specifically includes the following steps:
[0085] S21. The total energy E of the three-phase voltage waveform ABC All data is marked as pending;
[0086] S22. The total energy E of the three-phase voltage waveform ABC The position of each data P in is the center of the circle, and E is set ps Draw a circle with the radius as the radius to obtain a circular domain containing different numbers of objects;
[0087] S23. Determine whether the number of objects contained in the circular domain of data P is less than the preset minimum number min P ts If yes, then mark the data P as a boundary point or a noise point and execute step S25; if no, execute step S24;
[0088] S24. Mark data P as core data points and establish cluster C i , the unclassified data points in the data P circle are classified into cluster C i ;
[0089] S25. Determine the total energy E of the three-phase voltage waveformABC Whether all data points in have been classified, if so, the operating condition classification result is output and the process ends, if not, returns to step S22.
[0090] In this embodiment, the sum of squared errors (SSE) is used as the evaluation index of clustering effect. The sum of squared errors is calculated by calculating the Euclidean distance d from all subclasses to the corresponding cluster center. SSE To evaluate the clustering effect, the d SSE The calculation formula is:
[0091]
[0092] Where L represents the number of cluster partitions, c i represents the cluster center of cluster χ, d(c i ,χ) represents the Euclidean distance between vectors. The clustering effect is closely related to L. As L increases from 1 to the number of real scenes in the same time period k, d SSE will decrease accordingly; when the L value exceeds the k value and then increases, d SSE It will tend to be flat and may increase slightly, and the inflection point will be taken as the best clustering location.
[0093] In this embodiment, the calculation formula for the normalization process in step S3 is:
[0094]
[0095] Among them, x represents the original data, x′ represents the standardized data, and x max Represents the maximum value in the original data sequence, x min Represents the minimum value in the original data sequence.
[0096] In this embodiment, the Bi-LSTM model in step S4 includes an input layer, a forward LSTM layer, a backward LSTM layer and an output layer; the input layer is connected to the forward LSTM layer and the backward LSTM layer respectively; the output layer is connected to the forward LSTM layer and the backward LSTM layer respectively;
[0097] The forward LSTM layer and the backward LSTM layer respectively include a plurality of LSTM units connected in series, and the LSTM units include a forget gate, an update gate and an output gate connected in sequence; the three-gate structure takes the input x at the current moment as (t) and the output a at the previous moment (t-1) The output value of the forget gate structure is controlled between 0 and 1 through the Sigmoid function. The output value of the forget gate will be consistent with the neuron state c at the previous moment. (t-1) Multiply by tanh(·) to achieve the effect of forgetting part of the memory at the previous moment; the output value of the update gate is equal to the output value of the tanh(·) function Multiply and then add to the neuron state function that has passed the forget gate to add the current input information to the neuron state; the output gate is used to control the output at the current moment.
[0098] The calculation formula of the LSTM unit is:
[0099]
[0100] Among them, Γ f represents the output parameter of the forget gate; Γ u represents the output parameter of the update gate; Γ o represents the output parameter of the output gate; σ(·) represents the nonlinear activation function; x (t) Represents the input of the LSTM unit at the current moment; c (t-1) Represents the memory unit of the previous moment; c (t) The memory unit representing the current moment; Indicates the memory representation corresponding to the input information at the current moment; a (t-1) Represents the output of the LSTM unit at the previous moment; a (t) represents the output of the LSTM unit at the current moment; tanh(·) represents the hyperbolic tangent function; W fa Represents the output a of the LSTM unit at the last moment of the forget gate (t-1) The weight matrix W fx Represents the input x of the LSTM unit of the forget gate at the current moment (t) The weight matrix W ua Represents the output a of the LSTM unit at the last moment of the update gate (t-1) The weight matrix W ux Represents the input x of the LSTM unit at the current moment of the update gate (t) The weight matrix W oa Represents the output a of the LSTM unit at the previous moment of the output gate (t-1) The weight matrix W ox Represents the input x of the LSTM unit at the current moment of the output gate (t) The weight matrix W ca Indicates c (t-1) The output a of the LSTM unit at the previous moment (t-1) The weight matrix W cx Indicates c (t-1) The input x of the LSTM unit at the current moment (t) The weight matrix of f represents the bias matrix of the forget gate; b u represents the bias matrix of the update gate; b o represents the bias matrix of the output gate; b c Indicates c (t-1) The bias matrix of .
[0101] In this embodiment, the optimization of the network structure of the Bi-LSTM model in step S5 includes optimizing the number of network layers and the number of neurons in each layer;
[0102] The optimization of the hyperparameters of the Bi-LSTM model includes optimization of the activation function, loss function, optimization algorithm and learning rate; the activation function includes Sigmoid function, Tanh function and ReLU function, etc.
[0103] In this embodiment, the loss function selects mean square error, and its calculation formula is:
[0104]
[0105] in, represents the mean square error; m represents the number of training samples; y represents the true value; represents the predicted value; y i Represents the true value of the i-th training sample; Represents the predicted value of the i-th training sample.
[0106] In this embodiment, the optimization algorithm selects an adaptive moment estimation optimization algorithm, and its calculation formula is:
[0107]
[0108] Among them, θ is the parameter to be optimized; t represents the number of updates of θ; α t represents the learning rate when the number of updates is t; α represents the initial learning rate; β 1 , β 2 Both ε and β are adjustable hyperparameters, usually 1 =0.9,β 2 = 0.999 and ε = 1 × 10 -8 ; V t represents the first-order moment estimate of the gradient; S t Represents the second moment estimate of the gradient.
[0109] In this embodiment, transfer learning is defined as: given a source domain D s ={X s ,P(X s )}、The learning task T corresponding to the source domain s = {Y s , f s (·)}, target domain D t ={X t , Q(X t )} and the learning task T corresponding to the target domain t = {Y t , ft (·)}, the purpose of transfer learning is to obtain the source domain D s and learning task T s The implicit knowledge in the target domain D t The prediction function f t (·) learning efficiency, where D s ≠D t or T s ≠T t .
[0110] When the voltage-current mapping migration model is established in step S6, the maximum mean deviation distance between the source domain and the target domain calculated based on the maximum mean deviation (MMD) is used as the starting indicator of the migration learning; the distance measurement method based on the maximum mean deviation can measure the distribution P(X) in the reproducing kernel Hilbert space (RKHS) T ) and P(X S(k) ) between the two;
[0111] The calculation formula of the maximum mean deviation is:
[0112]
[0113] in, It is the feature mapping function from the original feature space to the RKHS space; represents the RKHS norm. In the RKHS space, the kernel function Therefore, the calculation formula for the maximum mean deviation can be written as:
[0114]
[0115] in, represents the square form of the maximum mean deviation; k(·,·) represents the kernel function in the RKHS space; X T represents the target domain feature space; X S(k) represents the candidate source domain feature space; N T represents the number of samples in the target domain; x i represents the i-th sample in the target domain; x j represents the jth sample in the target domain; N S(k) Indicates the number of candidate source domain samples; represents the jth sample in the candidate source domain; represents the i-th sample in the candidate source domain.
[0116] The smaller the difference between the two distributions, the higher the value of MMD. The closer it is to 0, the greater it is. If and only if the two distributions are the same, is 0.
[0117] Example 2, a simulation model of VSC access to the AC power grid was built using MATLAB / Simulink software, and the simulation time was set to 24s. The multi-operating condition voltage and current waveform data of PCC1 point were simulated and obtained by injecting disturbances at the 6th, 12th and 18th seconds respectively. The simulation generated four-stage data divided into three operating conditions, each stage lasting 6 seconds, and the operating condition clustering results based on waveform energy were obtained. In order to accelerate the convergence speed of gradient descent during network training, the voltage and current waveform data were standardized, and their data values were linearly transformed to 0-1.
[0118] Based on the requirements of Bi-LSTM model training on input and output data size, this embodiment uses a three-phase voltage waveform amplitude data sequence at a certain moment with a sequence length of 128 as input, and uses a three-phase current waveform amplitude data at a corresponding moment with a sequence length of 128 as output. The sampling interval is taken as one data point, and the voltage-current time series after standardization is sampled by sliding window, and finally 184320 pairs of input and output data are obtained.
[0119] The dataset is divided into a training set (50%, 92160 pairs), a validation set (20%, 36864 pairs) and a test set (30%, 55296 pairs). The training set data is used to train the network model; the validation set data is used to evaluate whether the network model has overfitting or underfitting problems; the test set data is used to verify the generalization ability of the network model.
[0120] The computer hardware configuration used is: CPU is 12th Gen intel(R)Core(TM)i5-12400F, memory is 16GB. PyTorch deep learning framework is used for neural network training and verification, version is PyTorch-2.2.1, programming language is Python 3.11.8.
[0121] The voltage waveform three-phase data is used as input, and the corresponding current waveform three-phase data is used as output to form a voltage-current data set. Multiple neural network trainings are performed using different network structures and hyperparameter settings to obtain the neural network model with the best fitting effect, which is the working condition I1 benchmark model. Its model structure and hyperparameter values are shown in Table 1 and Table 2, respectively.
[0122] Table 1. Baseline model structure
[0123]
[0124] Table 2. Hyperparameter values of the benchmark model
[0125]
[0126] The three-layer Bi-LSTM layer in the working condition I1 model is designated as the migration layer, and the migration layer parameters are migrated to the corresponding layer of the network to be trained. The network structure and hyperparameters of the non-migrated layer are considered to be optimized and optimized respectively. The data set composed of voltage and current waveform data under other working conditions is trained with multiple neural networks, and the mapping model with the best fitting effect is selected to construct the migrated model, as listed in Table 3, the migrated model 1 and the migrated model 2. Compared with the migrated model 1, the network structure and hyperparameters of the non-migrated layer of the migrated model 2 are further optimized.
[0127] In addition, without using the transfer learning method, the data set composed of voltage and current waveform data of other working conditions is directly trained with multiple neural networks, and the mapping model with the best fitting effect is selected to establish two control models, such as control model 1 and control model 2 listed in Table 3. Control model 1 and control model 2 respectively adopt the network structure and hyperparameter settings of the corresponding transferred model 1 and transferred model 2 to compare the influence of the transfer learning method on the training time and training results of the neural network model. It is worth noting that in order to explore the influence of the data volume on the method proposed in the present invention, the data volume of the transferred models and control models of other working conditions, except for the baseline model, is set to be 1 / 4 of the data volume of the baseline model, namely the training set (50%, 23040 pairs), the validation set (20%, 9216 pairs) and the test set (30%, 13824 pairs).
[0128] In this embodiment, the results of the benchmark model are analyzed. One of the prerequisites for the application of transfer learning is that the established benchmark model should be able to better reflect the mapping relationship between data. The quality of the benchmark model's fitting effect on the data mapping relationship will directly affect the fitting effect of the transferred model on similar data mapping relationships.
[0129] By simulating the training process of the operating condition I1 benchmark model, it can be found that the loss function of the I1 benchmark model has converged to a smaller value, and there is no overfitting or underfitting problem; the predicted current waveform based on the operating condition I1 benchmark model is in good agreement with the measured current waveform; the prediction error range of the benchmark model is -0.15 to 0.14; 78.74% and 92.58% of the prediction data errors in the I1 model are between -0.3 and 0.3 and -0.5 to 0.5, respectively.
[0130] The results of the migrated model are analyzed, and the neural network model and its training results are shown in Table 3. As can be seen from Table 3, when the neural network structure and hyperparameter settings are the same, the training time of the migrated model trained by the transfer learning method is greatly shortened compared with the directly trained control model. This is because the migrated model directly migrates the parameters of the migration layer that have been trained in the benchmark model, greatly reducing the number of parameters to be trained. Taking the working condition I3 in Table 3 as an example, the directly trained I3-3 control model has 466755 parameters to be trained and the required training time is 25.4s. The I3-1 migrated model, due to the migration of the 3-layer Bi-LSTM layer parameters that have been trained in the I1 benchmark model, only needs to train Dense 1, Dense 2 and the output layer, a total of 10563 parameters, and the training time is 3.7s, which is about 1 / 7 of the original training time.
[0131] Table 3 Neural network models and their training results
[0132]
[0133] For the transferred model 1 and the control model 1, according to Table 3, the final loss function value of the transferred model trained by the transfer learning method is smaller than that of the control model not trained by the transfer learning method, indicating that the fitting effect of the transferred model is better than that of the control model. This phenomenon can be attributed to the fact that in the parameter migration process, when the structure of the transferred network is exactly the same as that of the benchmark model, all parameters of the benchmark model can be migrated to the transferred network (including non-migrated layers), and only the parameters of the migration layer are frozen, and the remaining layers are trained with the migrated parameters as the initial parameters of the model. Compared with the control model, the network parameters of the transferred model have undergone a similar model pre-training process. At this time, the values of the parameters to be trained in the transferred model are closer to the optimal solution than the values of the randomly initialized parameters. Therefore, the fitting effect of the transferred model is better than that of the control model.
[0134] For the transferred model 2 and the transferred model 1, according to Table 3, the fitting effect of the transferred model 2 is better than that of the transferred model 1. This is because compared with the transferred model 1, the non-transferred layer network structure and hyperparameters of the transferred model 2 have been further optimized, making it more suitable for the fitting of the voltage-current waveform mapping relationship of this working condition. Taking working condition I3 as an example, compared with the constructed transferred model 1 (i.e., I3-1 model), the number of neurons in the non-transferred layer (i.e., Dense 1, Dense 2, and output layer) of the transferred model 2 (i.e., I3-2 model) are optimized from 64, 64, and 1 to 96, 96, and 1, respectively, and the number of training steps is optimized from 20 to 100. Therefore, the fitting effect of the transferred model 2 is better.
[0135] For the migrated model 2 and the control model 2, further comparison according to Table 3 shows that compared with the control model 2, the migrated model 2 has a wider parameter optimization space. Taking working condition I3 as an example, when the training step number of I3-2 is optimized to 100 steps, the model fitting effect is better, and the training time is 31.7s, while the training step number of the control model 2 is only 20 steps, and the model training time has reached 20.1s. It is known that when the network structure and other hyperparameter settings are consistent, the training time of the model is proportional to the number of training steps. Under the same number of training steps, the time cost of optimizing the network structure and hyperparameters of the control model 2 is large. Therefore, compared with the control model 2, the migrated model 2 has a wider parameter optimization space.
[0136] Those skilled in the art will appreciate that the embodiments described herein are intended to help readers understand the principles of the present invention, and should be understood that the protection scope of the present invention is not limited to such specific statements and embodiments. Those skilled in the art can make various other specific variations and combinations that do not deviate from the essence of the present invention based on the technical revelations disclosed by the present invention, and these variations and combinations are still within the protection scope of the present invention.
Claims
1. A harmonic source modeling method based on Bi-LSTM and transfer learning, characterized in that: The following steps are involved: S1. Collect voltage waveform data and current waveform data through the monitoring device, calculate the energy of each phase voltage waveform, and calculate the total energy of the three-phase voltage waveform according to the energy of each phase voltage waveform; S2. Use the DBSCAN clustering algorithm to perform cluster analysis on the total energy of the three-phase voltage waveform, and divide the voltage waveform data and the current waveform data into multiple voltage-current data sets under different operating conditions; S3. Preprocessing and standardizing the voltage-current data set to obtain a standardized voltage-current data set; S4. Build a Bi-LSTM model, and select a standardized voltage-current data set under an operating condition based on the Bi-LSTM model to establish a training data set; S5. Train the Bi-LSTM model using the training data set, and optimize the network structure and hyperparameters of the Bi-LSTM model to obtain a voltage-current Bi-LSTM benchmark model; S6. Using the transfer learning method, some parameters in the voltage-current Bi-LSTM benchmark model are migrated to the voltage-current dataset that is not involved in the model training, and a voltage-current mapping migration model is established to complete the harmonic source modeling.
2. The harmonic source modeling method based on Bi-LSTM and transfer learning according to claim 1, characterized in that: The voltage waveform energy described in step S1 represents the square sum of the amplitudes of all sampling points of the periodic discrete voltage waveform in one cycle, and the specific calculation method is: S11. Sampling the continuous voltage signal at a fixed sampling frequency f s Sampling is performed to obtain a discrete signal v(n); S12. Extract a data segment of a cycle from the discrete signal v(n); S13. Perform a square operation on the amplitude of each sampling point in a data segment of a cycle to obtain the square value v(n) of the amplitude of each sampling point. 2 ; S14. The square values of the amplitudes of all sampling points in one cycle are accumulated to obtain the voltage waveform energy E. The calculation formula of the voltage waveform energy E is: Where n represents the nth sampling point, and N represents the total number of sampling points in one cycle.
3. The harmonic source modeling method based on Bi-LSTM and transfer learning according to claim 1, characterized in that: The calculation formula of the total energy of the three-phase voltage waveform in step S1 is: AND ABC =And A +E B +E C Among them, E ABC Represents the total energy of the three-phase voltage waveform; E A Indicates the voltage waveform energy of phase A; E B Indicates the voltage waveform energy of phase B; E C Indicates the energy of phase C voltage waveform.
4. The harmonic source modeling method based on Bi-LSTM and transfer learning according to claim 1, characterized in that: The step S2 specifically includes the following steps: S21. The total energy E of the three-phase voltage waveform ABC All data is marked as pending; S22. The total energy E of the three-phase voltage waveform ABC The position of each data P in is the center of the circle, and E is set ps Draw a circle with the radius as the radius to obtain a circular domain containing different numbers of objects; S23. Determine whether the number of objects contained in the circular domain of data P is less than the preset minimum number min P ts If yes, then mark the data P as a boundary point or a noise point and execute step S25; if no, execute step S24; S24. Mark data P as core data points and establish cluster C i , the unclassified data points in the data P circle are classified into cluster C i ; S25. Determine the total energy E of the three-phase voltage waveform ABC Whether all data points in have been classified, if so, the operating condition classification result is output and the process ends, if not, returns to step S22.
5. The harmonic source modeling method based on Bi-LSTM and transfer learning according to claim 1, characterized in that: The calculation formula for the standardization process in step S3 is: Among them, x represents the original data, x′ represents the standardized data, and x max Represents the maximum value in the original data sequence, x min Represents the minimum value in the original data sequence.
6. The harmonic source modeling method based on Bi-LSTM and transfer learning according to claim 1, characterized in that: The Bi-LSTM model in step S4 includes an input layer, a forward LSTM layer, a backward LSTM layer and an output layer; the input layer is connected to the forward LSTM layer and the backward LSTM layer respectively; the output layer is connected to the forward LSTM layer and the backward LSTM layer respectively; The forward LSTM layer and the backward LSTM layer respectively include a plurality of LSTM units connected in series, and the LSTM units include a forget gate, an update gate and an output gate connected in sequence; The calculation formula of the LSTM unit is: Among them, Γ f represents the output parameter of the forget gate; Γ u represents the output parameter of the update gate; Γ o represents the output parameter of the output gate; σ(·) represents the nonlinear activation function; x (t) Represents the input of the LSTM unit at the current moment; c (t-1) Represents the memory unit of the previous moment; c (t) The memory unit representing the current moment; Indicates the memory representation corresponding to the input information at the current moment; a (t-1) Represents the output of the LSTM unit at the previous moment; a (t) represents the output of the LSTM unit at the current moment; tanh(·) represents the hyperbolic tangent function; W fa Represents the output a of the LSTM unit at the last moment of the forget gate (t-1) The weight matrix W fx Represents the input x of the LSTM unit of the forget gate at the current moment (t) The weight matrix W ua Represents the output a of the LSTM unit at the previous moment of the update gate (t-1) The weight matrix W ux Represents the input x of the LSTM unit at the current moment of the update gate (t) The weight matrix W oa Represents the output a of the LSTM unit at the previous moment of the output gate (t-1) The weight matrix W ox Represents the input x of the LSTM unit at the current moment of the output gate (t) The weight matrix W ca Indicates c (t -1) The output a of the LSTM unit at the previous moment (t-1) The weight matrix W cx Indicates c (t-1) The input x of the LSTM unit at the current moment (t) The weight matrix of f represents the bias matrix of the forget gate; b u represents the bias matrix of the update gate; b o represents the bias matrix of the output gate; b c Indicates c (t-1) The bias matrix of .
7. The harmonic source modeling method based on Bi-LSTM and transfer learning according to claim 1, characterized in that: The optimization of the network structure of the Bi-LSTM model in step S5 includes optimizing the number of network layers and the number of neurons in each layer; The optimization of the hyperparameters of the Bi-LSTM model includes optimization of the activation function, the loss function, the optimization algorithm and the learning rate.
8. The harmonic source modeling method based on Bi-LSTM and transfer learning according to claim 7, characterized in that: The loss function selects the mean square error, and its calculation formula is: in, represents mean square error; m represents the number of training samples; y represents the true value; represents the predicted value; y i Represents the true value of the i-th training sample; Represents the predicted value of the i-th training sample.
9. The harmonic source modeling method based on Bi-LSTM and transfer learning according to claim 7, characterized in that: The optimization algorithm selects the adaptive moment estimation optimization algorithm, and its calculation formula is: Among them, θ is the parameter to be optimized; t represents the number of updates of θ; α t represents the learning rate when the number of updates is t; α represents the initial learning rate; β1, β2 and ε are all adjustable hyperparameters, V t represents the first-order moment estimate of the gradient; S t Represents the second moment estimate of the gradient.
10. The harmonic source modeling method based on Bi-LSTM and transfer learning according to claim 1, characterized in that: When the voltage-current mapping migration model is established in step S6, the maximum mean deviation distance between the source domain and the target domain calculated based on the maximum mean deviation is used as a starting indicator for migration learning; The calculation formula of the maximum mean deviation is: in, represents the square form of the maximum mean deviation; k(·,·) represents the kernel function in the RKHS space; X T represents the target domain feature space; X S(k) represents the candidate source domain feature space; N T represents the number of samples in the target domain; x i represents the i-th sample in the target domain; x j represents the jth sample in the target domain; N S(k) Indicates the number of candidate source domain samples; represents the jth sample in the candidate source domain; represents the i-th sample in the candidate source domain.
Citation Information
Patent Citations
Method for diagnosing faults of three-level inverters on basis of empirical mode decomposition and decision-making tree RVM (relevant vector machines)
CN106682303A
Power amplifier harmonic prediction method based on transfer learning
CN116596061A
Automatic control loop fault diagnosis method and system based on clustering and transfer learning
CN117369405A
Intelligent data reconstruction method and system for sensor
WO2023088355A1
Cited By
Large-scale circuit division method based on artificial intelligence adaptive weight distribution
CN120297229A
Large-scale circuit partitioning method based on artificial intelligence adaptive weight distribution
CN120297229B
