An intelligent wind power prediction method based on Transformer and LSTM hybrid model
By combining the Transformer with the LSTM model and the multi-step experience playback algorithm, the problem of the LSTM model forgetting rare scenarios and slow training speed in wind power data prediction is solved, achieving efficient and accurate wind power data prediction, and reducing the risk of "wind power abandonment" phenomenon. occurrence, improving the safety of the power system.
Patent Information
- Application Number
- CN202210414963.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-20
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2042-04-20
AI Technical Summary
Existing LSTM models tend to forget rare scenarios in wind power data prediction, resulting in increased prediction losses, and the training speed is not high, making it difficult to meet the decision-making needs of wind farms.
An intelligent wind power power prediction method based on the Transformer and LSTM hybrid model is adopted. By combining deep learning and reinforcement learning technology, a Transformer and LSTM hybrid model is constructed. The multi-step experience playback algorithm is used to correct the gradient, and the self-attention mechanism and time dimension are combined to perform parallel operations. Calculated to improve forecast accuracy and efficiency.
It achieves better wind power data prediction effect and training efficiency, can accurately predict wind farm data and reduce the occurrence of "wind abandonment" phenomenon, improving the safety of the power system.
Smart Images

Figure CN114841419B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of deep learning and relates to an intelligent wind power prediction method based on a Transformer and LSTM hybrid model. Background Art
[0002] At present, the new energy sector is in the stage of digital transformation, and the construction of smart wind power plants in my country is in its infancy, so my country's wind power forecasting model is not mature. Wind power data forecasting technology is to predict the power output of wind farms and meteorological data (including wind speed, wind direction and temperature) in the future for decision-making and scheduling.
[0003] Wind power data is time series data, which has characteristics such as periodicity, volatility and peaks. That is, wind power data has regularity within a certain time period; wind power data has great volatility, the power is the highest at one moment and the lowest at the next moment; wind power data has many extreme points, which are caused by extreme weather. These characteristics bring great challenges to our wind power data forecasting.
[0004] At present, my country's wind farms have the defects of insufficient local wind power consumption capacity and limited network transmission capacity, which leads to the phenomenon of "wind abandonment". According to the 2021 wind power development statistics table released by my country's National Energy Administration (NEA), the national average "wind abandonment" rate reached 3.6% in 2021, which is a significant improvement compared with the previous average "wind abandonment" rate of 10.74% in 2013, but there is still a lot of room for improvement. Improving the accuracy of wind power can effectively improve the safety of the power system and diagnose the performance of wind turbines, thereby reducing the occurrence of "wind abandonment".
[0005] Wind power conditions and power forecasting are important technical means to ensure wind power generation systems, and have now become a mandatory requirement for the country's wind power control. Wind power conditions and power data have the characteristics of time series. Long short-term memory (LSTM) can "remember" important features in past wind power data and "forget" worthless information, and has high accuracy in the prediction process. However, LSTM can easily "forget" rare scenarios during the prediction process, such as the volatility of wind power, which will lead to increased prediction losses in specific scenarios. If long-term predictions are made, the losses will continue to increase dramatically as the prediction cycle increases, which will cause decision-making deviations among wind farm decision makers, leading to inestimable damage. In addition, the LSTM model requires iterative calculations, that is, the data of one moment must be input for training before the next moment can be input. Therefore, the LSTM model is not efficient.
[0006] Transformer is a model based on a multi-head attention mechanism. It was originally used for machine translation and outperformed RNN and CNN models in machine translation. Transformer can achieve good results using only encoder-decoder and attention mechanisms. In addition, Transformer abandons the shortcomings of slow training caused by iterative training of RNN and LSTM, and adopts self-attention mechanism to achieve fast parallelization. The core of the self-attention mechanism is to capture the correlation between vectors. Compared with RNN, which iteratively obtains the correlation information of time series data, the self-attention mechanism can be realized through parallel matrix operations.
[0007] Compared with the Transformer model of the attention mechanism, the LSTM model has more time dimension, and the prediction accuracy exceeds the Transformer model, but the training speed is not as good as the Transformer model. Therefore, the model of the present invention combines the advantages of the two models, and the input time series data enters the LSTM model and the Transformer model respectively, and the output values of the two models are added as the prediction result of the next moment. Among them, it should be noted that the Transformer model requires the input of information from a large number of past moments, while the LSTM model only inputs data from a small number of past moments. This model is actually a combination of LSTM and Transformer. The Transformer model examines a large amount of historical data in the past, performs parallel calculations, learns the laws of change in a large amount of historical data, and gives a rough trend of change, while the LSTM model only uses a small amount of information in the past for accurate prediction. Summary of the invention
[0008] In order to overcome the problems of poor prediction effect and slow training speed of the existing LSTM model, the present invention proposes an intelligent wind power prediction method based on a hybrid model of Transformer and LSTM, combined with deep learning, reinforcement learning and other technologies, and ultimately provides a theoretical basis and practical experience for the application of deep learning technology in the field of wind farms.
[0009] The technical solutions proposed by the present invention for the above-mentioned technical problems are as follows:
[0010] An intelligent wind power prediction method based on a hybrid model of Transformer and LSTM includes the following steps:
[0011] In step 1, the wind farm s preprocesses the local data, including missing value processing, outlier processing and normalization processing; and builds a hybrid model of Transformer and LSTM.
[0012] Step 2: The wind farm s determines the number m of feature spaces involved in training and prediction.
[0013] Step 3: The wind farm s divides the local data preprocessed in step 1 into a training set and a test set.
[0014] Step 4: Wind farm s uses the training set to train the Transformer and LSTM hybrid model. In order to meet the volatility and peak characteristics of wind power data, the gradient in the training process is corrected using a multi-step experience replay algorithm.
[0015] Step 5: Wind farm s uses the test set to test the error of the Transformer and LSTM hybrid model.
[0016] Step 6: Repeat steps 4 to 5 until the error no longer changes.
[0017] Step 7: The wind farm s saves the model parameters with the smallest error in the test set as the final model parameters.
[0018] In step 1, the steps for constructing the Transformer and LSTM hybrid model are as follows:
[0019] 1.1 Build a basic LSTM model. The dimension of the hidden layer is set to the number of feature spaces m in step 2. It is required that the feature spaces are all related to power, and the number of stacked layers (num_layers) in LSTM is set to 2.
[0020] 1.2 To meet the randomness of wind power data, the output of the last layer of the running result of step 1.1 is mapped through a linear layer, and the dimension is converted from m to 2m. In the 2m dimension, every two values are grouped as a group, which are used as the mean and variance of the normal distribution respectively, and are divided into m groups in total. Each group randomly obtains a value according to the normal distribution, and there are a total of m-dimensional outputs.
[0021] 1.3 Since the goal of the Transformer and LSTM hybrid model is to predict the power of wind power data in a fixed period, in order to reduce the amount of model calculation, only the encoder layer in the Transformer model is constructed, but MASK is added to the attention mechanism. Set the encoder input size to d model , the number of encoder layers is 2, the number of attention mechanism heads is 2, and the activation function uses relu. The first step is to position encode the input wind power data. The specific formula is as follows:
[0022] X′ embedding =X embedding +X pos
[0023]
[0024]
[0025] Among them, X′ embedding is the encoded vector, X embedding is the input wind power data, X pos The position encoding of the current data can be obtained by PE(pos, 2i) and PE(pos, 2i+1); pos represents the time position of the current wind power data, and i (divided into odd and even numbers) represents the dimensional position of the current wind power data. The second step is to input the encoded data into the attention mechanism, in which the same MASK mechanism as the decoder in the Transformer is added. The purpose of adding the MASK is to only consider the time series data to date. The third step is to perform residual connection and standardization operations on the data output in the second step. The fourth step is to pass the data output in the third step into the feedforward network (including only the linear layer and the activation function), and perform residual connection and standardization operations again.
[0026] 1.4 The wind farm inputs a large amount of time series data of the past time l1 to the Transformer model in step 1.3, and inputs a small amount of time series data of the past time l2 to the LSTM model in step 1.2; where l1>>l2.
[0027] 1.5 Weight the output results of the two models in step 1.4 as the final output result.
[0028] 1.6 Add activation function layer, activation function layer and the fully connected layer at the end to ensure efficient training and correct output of the neural network.
[0029] In step 4, the specific steps of the multi-step experience replay algorithm are as follows:
[0030] 4.1 Create an array A of length L, where each element in the array records the gradient information d, the absolute value of the corresponding error |δ|, and the location of the current training data.
[0031] 4.2 Wind farm s training data, obtain the gradient information d1 of the current model training.
[0032] 4.3 Store the gradient information d1 into array A. If array A is full, delete the gradient information with the smallest weight in the array. The weight of the gradient information d1 is The probability of using Softmax to modify the gradient of array A is The rank represents the current gradient in the array according to the absolute value of the error |δ i|'s position (from large to small). The main reason for using the weight q and Softmax in the present invention is to ensure that no gradient information plays a major role. If the error size is used as the weight alone, the probability of extracting the gradient information with a large error is likely to account for the vast majority of the effect, and it is easy to be extracted each time. As a result, other gradient information will be in a hungry state and will never be selected to participate in the experience playback. In addition, the calculation method of the gradient update is to make the current gradient account for the main part and the past experience account for the minor part.
[0033] 4.4 From array A, select the number of cells with probability p i Extract k gradient information {d2, d3, ..., d k+1},make Update the parameters of the model.
[0034] 4.5 Modify the gradient information {d2, d3, ..., d k+1}. For each d j ∈{d2, d3, ..., d k+1}, re-obtain the current training data, and use the Transformer and LSTM hybrid model to predict the error |δ′ j |, modified error |δ j | is |δ′ j |; According to the error |δ′ j |Modify probability p j .
[0035] 4.6 The gradient information {d1, d2, d3, ..., d k+1}Put it back into array A and reorder array A.
[0036] Beneficial effects of the present invention: Compared with other time series prediction models, the present invention designs a prediction model and training method that conforms to the data characteristics of wind farms, which can achieve better training results and make full use of past valuable experience in the training process. The present invention combines the advantages of Transformer and LSTM models, and can accurately predict data and efficiently train data. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 It is a training flow chart based on the hybrid model of Transformer and LSTM provided by the present invention.
[0038] Figure 2 This is the architecture diagram of the Transformer and LSTM hybrid model of the present invention.
[0039] Figure 3 It is a flow chart of the multi-step experience playback algorithm of the present invention.
[0040] Figure 4 It is a schematic diagram of updating the experience playback array of the present invention.
[0041] Figure 5 It is a timing diagram from the overall creation to the application of the Transformer and LSTM hybrid model of the present invention. DETAILED DESCRIPTION
[0042] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the specific implementation modes of the present invention will be described in detail below with reference to the accompanying drawings.
[0043] The wind farm inputs the time series data into the model, and the model gives the predicted values at multiple moments in the future, which can be used for short-term or ultra-short-term predictions. Figure 1 As shown in the figure, the present invention provides a training flow chart based on a hybrid model of Transformer and LSTM, which specifically includes the following steps:
[0044] In step 1, the wind farm s preprocesses the local data, including missing value processing, outlier processing and normalization processing; and builds a hybrid model of Transformer and LSTM.
[0045] Step 2: The wind farm s determines the number of feature spaces involved in training and prediction, including wind power, wind conditions, wind speed, and temperature.
[0046] Step 3: The wind farm s divides the local data preprocessed in step 1, with 70% of the data used as a training set and 30% of the data used as a test set.
[0047] Step 4: Wind farm s uses the training set to train the Transformer and LSTM hybrid model. In order to meet the volatility and peaks of wind power data, the gradient in the training process is corrected using a multi-step experience replay algorithm. The optimization objective function is the mean square error (MSE) between the input value and the predicted value. The Nadam optimizer is selected and the learning rate is set to 0.01. The training is 100 epochs, and the data set is used for testing after each training is completed.
[0048] Step 5: Wind farm s uses the test set to test the error of the Transformer and LSTM hybrid model.
[0049] Step 6: Repeat steps 4 to 5 until the error no longer changes.
[0050] Step 7: The wind farm s saves the model parameters with the smallest error in the test set as the final model parameters.
[0051] like Figure 2This is the architecture diagram of the Transformer and LSTM hybrid model in step 1. The steps for building the Transformer and LSTM hybrid model are as follows:
[0052] 1.1 Build a basic LSTM model. The dimension of the hidden layer is set to the number of feature spaces in step 2, 4, and the feature spaces are required to be power-related, namely wind power, wind speed, temperature, and wind direction. The number of stacked layers (num_layers) in LSTM is set to 2.
[0053] 1.2 In order to meet the randomness of wind power data, the output of the last layer of the running result of step 1.1 is mapped through a linear layer, and the dimension is converted from 4 to 8. In the 8-dimensional, every two values are grouped as the mean and variance of the normal distribution, respectively, and divided into 4 groups. Each group randomly obtains a value according to the normal distribution, and there are 4 dimensions of output in total.
[0054] 1.3 Because the goal of the Transformer and LSTM hybrid model is to predict the power of wind power data in a fixed period, in order to reduce the amount of model calculation, only the encoder layer in the Transformer model is constructed, but MASK is added to the attention mechanism. Set the encoder input size to 4, the number of encoder layers to 2, the number of attention mechanism heads to 2, the activation function to relu, and the other default values. The first step is to position encode the input wind power data. The specific formula is as follows:
[0055] X′ embedding =X embedding +X pos
[0056]
[0057]
[0058] Among them, X′ embedding is the encoded vector, X embedding is the input wind power data, X posThe position encoding of the current data can be obtained by PE(pos, 2i) and PE(pos, 2i+1); pos represents the time position of the current wind power data, and i (divided into odd and even numbers) represents the dimensional position of the current wind power data. The second step is to input the encoded data into the attention mechanism, in which the same MASK mechanism as the decoder in the Transformer is added. The purpose of adding the MASK is to only consider the time series data to date. The third step is to perform residual connection and standardization operations on the data output in the second step. The fourth step is to pass the data output in the third step into the feedforward network (including only the linear layer and the activation function), and perform residual connection and standardization operations again.
[0059] 1.4 The wind farm inputs the time series data of the past 500 moments into the Transformer model in step 1.3, and inputs the time series data of the past 20 moments into the LSTM model in step 1.2.
[0060] 1.5 Weight the output results of the two models in step 1.4 as the final output result.
[0061] 1.6 Add activation function layer, activation function layer and the fully connected layer at the end to ensure efficient training and correct output of the neural network.
[0062] Figure 3 This is a flowchart of the multi-step experience replay algorithm in step 4. The specific steps of the multi-step experience replay algorithm are as follows:
[0063] 4.1 Create an array A of length 200, where each element in the array records the gradient information d, the absolute value of the corresponding error |δ|, and the location of the current training data.
[0064] 4.2 Wind farm s training data, obtain the gradient information d1 of the current model training.
[0065] 4.3 Store the gradient information d1 into array A. If array A is full, delete the gradient information with the smallest weight in the array. The weight of the gradient information d1 is The probability of using Softmax to modify the gradient of array A is The rank represents the current gradient in the array according to the absolute value of the error |δ i |'s ranking (from largest to smallest).
[0066] 4.4 From array A, select the number of cells with probability p i Extract 50 gradient information {d2, d3, ..., d 51}, where the 50 gradient information may be partially the same, let Update the parameters of the model.
[0067] 4.5 Modify the gradient information {d2, d3, ..., d 51}. For each d j ∈{d2, d3, ..., d 51}, re-obtain the current training data and use the model to predict the error |δ′ j |, modified error |δ j | is |δ′ j |. According to the error |δ′ j |Modify probability p j .
[0068] 4.6 The gradient information {d1, d2, d3, ..., d 51}Put it back into array A and reorder array A.
[0069] Figure 4 This is a schematic diagram of the experience playback array update in step 4. Each element in the array records the gradient information d, the absolute value of the corresponding error |δ|, and the location of the current training data. Each time the Transformer and LSTM hybrid model generates a gradient d1, the array uses the Softmax function to obtain the probability of all gradient information for the weight q of all gradient information, and the array randomly selects 50 gradient information {d2, d3, ..., d 51} Correct the gradient d1 generated by the model. It should be noted that the randomly selected gradient information may be partially the same. When the model completes the gradient correction, it is necessary to first correct the error of the current gradient training data and convert all the current gradient information {d1, d2, d3, ..., d 51} is put back into the array, and finally all the elements in the array are reordered. If the array is full, the element with the smallest weight is deleted.
[0070] Figure 5 Create a timing diagram for the application of the Transformer and LSTM hybrid model as a whole. The specific steps are as follows:
[0071] (1) The wind farm obtains data from the application and preprocesses it.
[0072] (2) The wind farm determines the feature space to be processed.
[0073] (3) A Transformer and LSTM hybrid model is created by the wind farm, and the parameters are randomly initialized.
[0074] (4) The wind farm uses a local computer to train the hybrid model established in step (3) until the error on the test set is less than a threshold, i.e., the training is completed.
[0075] (5) Save the model parameters with the smallest error in the test set as the final model parameters.
[0076] (6) Deploy the trained Transformer and LSTM hybrid model to the application.
[0077] The present invention performs short-term or ultra-short-term predictions on wind farm data, and designs a hybrid model of Transformer and LSTM in view of the randomness, volatility and peak of wind farm data. The hybrid model can efficiently train a model with high accuracy, accelerate the digital transformation of the new energy field, and provide a theoretical basis and practical experience for the application of deep learning technology in the field of wind farms.
Claims
1. An intelligent wind power prediction method based on a hybrid model of Transformer and LSTM, characterized in that: The method comprises the following steps: Step 1: The wind farm s preprocesses the local data, including missing value processing, outlier processing and normalization processing; and builds a hybrid model of Transformer and LSTM; Step 2: The wind farm s determines the number m of feature spaces involved in training and prediction; Step 3: The wind farm s divides the local data preprocessed in step 1 into a training set and a test set; Step 4: The wind farm s uses the training set to train the Transformer and LSTM hybrid model. In order to meet the volatility and peak characteristics of wind power data, the gradient in the training process is corrected using a multi-step experience replay algorithm. Step 5: Wind farm s uses the test set to test the error of the Transformer and LSTM hybrid model; Step 6, repeat steps 4 to 5 until the error no longer changes; Step 7: The wind farm s saves the model parameters with the smallest error in the test set as the final model parameters; in step 1, the construction steps of the Transformer and LSTM hybrid model are as follows: 1.1 Build a basic LSTM model; the dimension of the hidden layer is set to the number of feature spaces m in step 2, and the feature spaces are required to be power-related. The number of stacked layers in LSTM is set to 2; 1.2 In order to meet the randomness of wind power data, the output of the last layer of the running result of step 1.1 is mapped through a linear layer, and the dimension is converted from m to 2m; in the 2m dimension, every two values are grouped as a group, which are respectively used as the mean and variance of the normal distribution, and are divided into m groups in total; each group randomly obtains a value according to the normal distribution, and there are a total of m-dimensional outputs; 1.3 Since the goal of the Transformer and LSTM hybrid model is to predict the power of wind power data in a fixed period, in order to reduce the amount of model calculation, only the encoder layer in the Transformer model is constructed, but MASK is added to the attention mechanism. The purpose of adding MASK is to consider only the time series data to date; 1.4 The wind farm inputs a large amount of time series data of the past l1 time to the Transformer model in step 1.3, and inputs a small amount of time series data of the past l2 time to the LSTM model in step 1.2; where l1>>l2; 1.5 Weight the output results of the two models in step 1.4 as the final output result; 1.6 Add activation function layer, activation function layer and the fully connected layer at the end to ensure efficient training and correct output of the neural network.
2. The intelligent wind power prediction method according to claim 1, characterized in that: In step 1.3, set the encoder input size to d model , the number of encoder layers is 2, the number of attention mechanism heads is 2, and the activation function uses relu; the specific steps are as follows: The first step is to position encode the input wind power data. The specific formula is as follows: X′ embedding =X embedding +X pos Among them, X′ embedding is the encoded vector, X embedding is the input wind power data, X pos is the position code of the current data, obtained by PE(pos,2i) and PE(pos,2i+1); pos represents the time position of the current wind power data, and i represents the dimension position of the current wind power data; The second step is to input the encoded data into the attention mechanism, in which the same MASK mechanism as the decoder in Transformer is added; The third step is to perform residual connection and standardization operations on the data output in the second step; In the fourth step, the data output in the third step is passed into the feedforward network, and residual connection and standardization operations are performed again.
3. The intelligent wind power prediction method according to claim 1 or 2, characterized in that: In step 4, the specific steps of the multi-step experience replay algorithm are as follows: 4.1 Create an array A of length L, where each element in the array records the gradient information d, the absolute value of the corresponding error |δ|, and the location of the current training data; 4.2 Wind farm s training data, obtain the gradient information d1 of the current model training; 4.3 Store the gradient information d1 into array A. If array A is full, delete the gradient information with the smallest weight in the array. The weight of the gradient information d1 is The probability of using Softmax to modify the gradient of array A is The rank represents the current gradient in the array according to the absolute value of the error |δ i |'s position; 4.4 From array A, select the number of cells with probability p i Extract k gradient information {d2, d3, …, d k+1 },make Update the parameters of the model; 4.5 Modify the gradient information {d2, d3, …, d k+1 }; For each d j ∈{d2,d3,…,d k+1 }, re-obtain the current training data, and use the Transformer and LSTM hybrid model to predict the error |δ′ j |, modified error |δ j | is |δ′ j |, according to the error |δ′ j |Modify probability p j ; 4.6 The gradient information {d1, d2, d3, …, d k+1 }Put it back into array A and reorder array A.
Citation Information
Patent Citations
Commodity sales volume prediction method and device based on Transformer + LSTM neural network model
CN111626764A
Wind speed prediction method based on variational mode decomposition and attention mechanism
CN114218870A
Method and device for signal processing, computer device, and storage medium
WO2021189642A1
