A CNN-LSTM short-term wind power forecasting method based on attention mechanism

By introducing the CNN-LSTM model with attention mechanism in short-term wind power power forecasting, and combining CNN and LSTM networks to extract local and time series features of wind power data, the problem of insufficient consideration of time series correlation in the existing technology is solved, and a higher level of performance is achieved. prediction accuracy and training speed.

CN113642225BActive Publication Date: 2024-09-03STATE GRID XINJIANG ELECTRIC POWER CO ECONOMIC TECH RES INST
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110564394.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-24
Publication Date
2024-09-03
Estimated Expiration
2041-05-24

AI Technical Summary

Technical Problem

Existing short-term wind power power prediction methods lack consideration of time series correlation, especially when the characteristics are non-continuous data, the prediction accuracy is not high, and there is a problem of ineffective convergence when there are many training samples.

Method used

A CNN-LSTM short-term wind power power prediction method based on the attention mechanism is proposed. By obtaining the wind power power data of the wind power generation system operation, combined with factors such as weather, wind speed, wind direction, temperature, pressure, humidity, etc., the CNN network is used to extract static features and combined The LSTM network performs feature extraction, uses the Attention mechanism to calculate the hidden layer feature vector, and finally outputs the predicted value through the Dropout layer and the fully connected layer, and uses the error backpropagation method for parameter optimization.

Benefits of technology

The accuracy of wind power power prediction is improved. Through local feature pre-extraction and feature weight allocation, the training speed and accuracy of the prediction model are improved, and the problem of long-term time series data processing is solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113642225B
    Figure CN113642225B
Patent Text Reader

Abstract

The present invention discloses a CNN-LSTM short-term wind power prediction method based on an attention mechanism, which collects historical environmental and historical wind power data, performs data cleaning and normalization and other preprocessing on the data; then builds a CNN-LSTM model containing an attention mechanism and performs training to obtain a prediction model, wherein the CNN network includes a Conv1D layer and a MaxPooling1D layer; the LSTM network includes a basic LSTM layer, an attention layer, a Dropout layer, and a final Dense layer. The present invention adopts a CNN-LSTM short-term wind power prediction model based on an attention mechanism, considers various environmental factors such as weather, wind speed, wind direction, temperature, pressure, humidity, etc., effectively extracts local features and time series features of the data, reasonably allocates feature weights, and can achieve accurate prediction of wind power.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of short-term wind power prediction, and in particular to a CNN-LSTM short-term wind power prediction method based on an attention mechanism. Background Art

[0002] Accurate prediction of wind power is of great significance to the stable and economic operation of the power grid. Good wind power prediction can reduce operating costs, optimize power grid dispatching, and facilitate the arrangement of unit maintenance and overhaul, thereby achieving economic rationality of dispatching.

[0003] The prediction methods mainly include traditional statistical methods and prediction methods based on machine learning. Among them, the statistical methods mainly include multiple linear regression (MLR), time series analysis and Kalman filtering. The principles and modeling of these methods are simple, but when the data sample size is large, the prediction effect is not obvious. Another type of method is based on machine learning algorithms, such as gray systems, artificial neural networks, support vector machines (SVM) and Gaussian processes (GP). Among them, back propagation (BP) neural networks and SVM are the most widely used. However, the above methods lack consideration of time series correlation, and there is a problem of ineffective convergence when there are many training samples.

[0004] In recent years, deep learning algorithms represented by long-term memory (LSTM) networks have achieved good applications in the field of short-term wind power forecasting. LSTM networks can fully explore the intrinsic correlation between time series data, but when the features are non-continuous data, the prediction accuracy is not high. Therefore, the use of CNN networks can automatically extract features and improve prediction accuracy. Summary of the invention

[0005] The present invention proposes a CNN-LSTM short-term wind power prediction method based on the attention mechanism, considering factors such as weather, wind speed, wind direction, temperature, pressure, humidity, historical wind power data, and input vector feature weights. The present invention utilizes deep learning and data mining technology to construct a CNN-LSTM short-term wind power prediction model, which realizes accurate prediction of wind power on the preprocessed data set.

[0006] The technical solution adopted by the present invention is specifically:

[0007] A CNN-LSTM short-term wind power prediction method based on attention mechanism, the method comprises the following steps:

[0008] Step (1) obtaining wind power data of the wind power generation system, cleaning the wind power data, and then comparing the wind power data at different times with corresponding weather, wind speed, wind direction, temperature, pressure, humidity and other features, wherein non-numeric features are one-hot encoded, and then the features of all data are normalized;

[0009] Step (2) constructs an input feature vector at the prediction point, and inputs the preprocessed feature vector into the CNN network. The static features of the input feature vector are extracted through convolution, pooling and other operations of the CNN network. The static features extracted by the CNN network are then input into the hidden layer of the LSTM network for feature extraction. The feature vector extracted by the hidden layer is calculated using the Attention mechanism to obtain the feature weight. The feature weight is then multiplied by the feature vector extracted by the hidden layer and input into the Dropout layer and the fully connected layer of the LSTM to output the predicted wind power prediction value.

[0010] The input feature vector at the prediction point specifically includes: the weather at the prediction point, the wind speed at the prediction point, the wind direction at the prediction point, the pressure at the prediction point, the temperature at the prediction point, the humidity at the prediction point, and the wind power value at the same time of the day before the prediction point.

[0011] The parameters of the CNN network and the LSTM network are obtained by training and optimizing the historical wind power data and its corresponding weather, wind speed, wind direction, temperature, pressure, and humidity data using the error back propagation method.

[0012] Furthermore, the CNN is a one-dimensional convolutional network that can extract static features of the input vector, and its output is:

[0013]

[0014] Among them, x t is the input feature vector at time t; ω j is the convolution kernel weight matrix; b is the bias value; k is the number of convolution kernels.

[0015] Furthermore, the LSTM network specifically includes an LSTM hidden layer, an attention layer, a Dropout layer and a fully connected layer, wherein the process of extracting features in the LSTM hidden layer is:

[0016] i t =σ(W ix X t +W ih h t-1 +b i )

[0017] f t=σ(W fX X t +W fh h t-1 +b f )

[0018] o t =σ(W oX X t +W oh h t-1 +b o )

[0019]

[0020] In the formula, i t is the input gate and the forget gate f t , output gate o t and the current neuron candidate value W iX , W ih , W fX , W fh , W oX , W oh , W CX , W Ch Represent the static features X of the corresponding gate and the current input respectively t and the previous unit output h t-1 The matrix weight obtained by multiplication, b i , b f , b o , b C is the bias term, σ is the sigmoid function;

[0021] New state value C t From the previous state value C t-1 、Forget gate t , input gate i t And the current neuron candidate value Decision, get the new state value C t After that, the output value h of the hidden layer can be obtained t , the calculation formula is:

[0022]

[0023] h t =o t *tanh(C t )

[0024] Where * represents the bitwise product of the elements in each multiplied vector.

[0025] The Attention layer is used to calculate the feature vector extracted by the hidden layer to obtain the feature weight, and then the feature weight is multiplied by the feature vector extracted by the hidden layer:

[0026] Calculate the attention weight a assigned to the elements in the last output sequence of the LSTM hidden layer at the current time t ti , the formula is as follows:

[0027]

[0028] Where i represents the sequence number of the element in the LSTM hidden layer output sequence, T h represents the sequence length in the LSTM hidden layer output sequence, e ti Indicates the matching degree between the element to be encoded and other elements in the LSTM hidden layer output sequence.

[0029] Calculate the feature weight vector, the formula is as follows:

[0030] a′ t,i =H(D,C t , h)

[0031]

[0032] In the formula, H represents the feature weight vector function, h t represents the output sequence of the LSTM hidden layer, h represents the output feature sequence of the last layer of the LSTM hidden layer at all times, and C t Represents the LSTM hidden layer output sequence h t The corresponding hidden layer state of the attention mechanism. a′ t,i Indicates h t The weight of the i-th element in .

[0033] Furthermore, in step 1, the method for cleaning the wind power data is specifically as follows:

[0034] Clustering is used to fill in the missing data by taking the mean of the wind power values ​​at the corresponding time of the three days with the greatest similarity. The clustering features include weather, wind speed, wind direction, temperature, pressure, humidity, etc.

[0035] Check the stability of historical wind power data and fill in the extreme data with the value at the same time of the previous day.

[0036] Preferably, the CNN-LSTM model is implemented in Python, and the short-term wind power prediction model based on CNN-LSTM is implemented using the Keras deep learning library.

[0037] Beneficial technical effects of the present invention:

[0038] 1. This paper proposes a CNN-LSTM short-term wind power prediction method based on the attention mechanism, and designs a corresponding wind power prediction model, which is composed of a CNN-LSTM network and a LightGBM model. In view of the shortcoming of slow training speed of LSTM network, a local feature pre-extraction module is added, and the local features are pre-extracted by the convolutional neural network structure, which is an ideal model for processing long-term time series data problems. At the same time, the attention mechanism can assign different weights to the hidden layer feature vectors, highlight the key features in training, and improve the prediction accuracy.

[0039] 2. The CNN-LSTM short-term wind power prediction method provided by the present invention is based on the CNN-LSTM short-term wind power prediction model and combines the error back propagation law to achieve the optimal solution of parameters. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 This is the flow chart of the CNN-LSTM model based on the attention mechanism;

[0041] Figure 2 It is the CNN network structure;

[0042] Figure 3 It is the LSTM network structure; DETAILED DESCRIPTION

[0043] In order to make the technical solution of the present invention more clear and specific to those skilled in the art, the present invention is further described in detail below in conjunction with the embodiments and drawings, but the embodiments of the present invention are not limited thereto.

[0044] like Figure 1-Figure 3 As shown, the CNN-LSTM short-term wind power forecasting method provided in this implementation is based on the CNN-LSTM forecasting model and combines the error back propagation method to achieve the optimal solution of parameters and improve the forecasting accuracy. Specifically, it includes the following steps:

[0045] Step (1) obtains weather, wind speed, wind direction, temperature, pressure, humidity, wind power and other features at different times, performs one-hot encoding on non-numeric features, and then normalizes the input features and processes them into the tensor form required by the model. The specific steps are:

[0046] 1) Wind power data from January 1, 2020 to July 31, 2020 were selected, with a total of 24,789 data. The training set, validation set, and test set were divided into 19,831, 2,479, and 2,479 data sets in a ratio of 8:1:1.

[0047] 2) In the process of collecting wind power data, there may be data missing and data errors. The data needs to be preprocessed. The processing steps are as follows:

[0048] 2.1) Wind power data has time series characteristics and is generally continuous and smooth. Abnormal data is found by checking the stability of the data. For the processing of abnormal data, the values ​​at the same time every day are similar. Therefore, this embodiment adopts the method of filling the values ​​at the same time of the previous day for processing.

[0049] 2.2) For the missing values ​​of the original data of wind power, the present invention adopts a clustering method, taking the three days with the greatest similarity, and then filling the wind power value at the required time with the average value of the corresponding three days at the corresponding time. The clustering features are other features besides wind power, such as weather, wind speed, wind direction, temperature, pressure, humidity, etc.

[0050] 3) Construct the input feature vector of the CNN-LSTM model and select feature factors, including: weather Wea at the prediction point t , wind speed at the prediction point s t , wind direction Wd at the prediction point t , the pressure pr at the prediction point t , the temperature T at the prediction point t 、 Humidity H at the prediction point t , the wind power value y′ at the same time of the day before the prediction point t For weather information, if non-numeric features appear, one-hot encoding is used for processing. Finally, the input feature vector is represented as x t =[Wea t ,s t , Wd t ,pr t , T t , H t , ...y′ t ].

[0051] 4) Normalize the input features to reduce the amount of computation required for subsequent model processing; specifically, use the min-max normalization method, and the normalized data range is between [0, 1]. The calculation formula is:

[0052]

[0053] In the formula, θ′ is the value of the normalized feature, including weather, wind speed, wind direction, temperature, pressure, humidity, wind power, etc., θ is the value of the feature in the original data, and θ max is the maximum value of this feature in all data, θ minis the minimum value of this feature in all data.

[0054] Step (2) constructs a CNN-LSTM network including an attention mechanism, inputs the preprocessed feature vector into the CNN network for training, extracts the static features of the input vector through operations such as convolution and pooling of the CNN network, inputs the features extracted by the CNN network into the hidden layer of the LSTM network for training, and obtains the trained feature vector. The specific steps are:

[0055] 1) Use CNN structure to pre-extract local features

[0056] Among many neural network structures, CNN is often used to achieve image recognition, image classification, target detection and face recognition. The structure has neurons with learnable weights and bias values, which can increase the low-level features of the data. As the network deepens, the low-level features are combined into multi-level features to guide the subsequent model to learn and adjust such features. Its specific structure is as follows: Figure 3 As shown. The CNN structure compiles specific features into the convolution structure, making the forward transfer function more efficient and reducing the number of parameters in the network. The CNN network structure can realize feature extraction of the time axis, and its output is:

[0057]

[0058] Among them, x t is the input feature vector at time t; ω j is the convolution kernel weight matrix; b is the bias value; k is the number of convolution kernels.

[0059] 2) Using LSTM model to predict wind power

[0060] LSTM has good memory ability and can learn long-term dependency information of time series. When predicting wind power, it can find regular information from historical wind power data. It also solves the gradient disappearance and gradient explosion problems of recurrent neural networks (RNN).

[0061] The LSTM network includes the basic LSTM layer, the attention layer, the Dropout layer, and the final Dense layer. First, the features extracted by the CNN network are input into the LSTM layer for feature extraction. The main function of the LSTM hidden layer is to extract valuable information through continuous learning and training, and forget and discard worthless information. Its specific structure is as follows Figure 3 Compared with the ordinary RNN, three "gates" are added, namely input gate i t 、Forget gate t , output gate o t, these three gates are three coefficients, and their value ranges are all between [0, 1]. The input gate is mainly used to determine which attributes to update and the content of the new attributes. The forget gate is to forget the previous useless state information. The output gate determines what to output. All three gates are based on the output h of the previous unit. t-1 and the current input X t The input gate i t 、Forget gate t , output gate o t and the current neuron candidate value The calculation formula is as follows:

[0062] i t =σ(W iX X t +W ih h t-1 +b i ) (3)

[0063] f t =σ(W fX X t +W fh h t-1 +b f ) (4)

[0064] o t =σ(W oX X t +W oh h t-1 +b o ) (5)

[0065]

[0066] Where W iX , W ih , W fx , W fh , W ox , W oh , W CX , W Ch Represent the static features X of the corresponding gate and the current input respectively t and the previous unit output h t-1 The matrix weight obtained by multiplication, b i , b f , b o , b C is the bias term, σ is the sigmoid function;

[0067] New state value C t From the previous state value C t-1 、Forget gate t , input gate it And the current neuron candidate value Decision, get the new state value C t After that, the output value h of the hidden layer can be obtained t , the calculation formula is:

[0068]

[0069] h t =o t *tanh(C t ) (8)

[0070] Where * represents the bitwise product of the elements in each multiplied vector.

[0071] This model sets the LSTM to 2 layers, and the number of neurons in each layer is 64 and 16 respectively.

[0072] Then, the Attention mechanism is used to calculate the feature vector of the last layer of LSTM to obtain the feature weight. The feature weight is then multiplied by the LSTM feature vector and input into the Dropout layer and the fully connected layer of LSTM to finally output the wind power prediction value y′. t , the specific steps are:

[0073] 1) Use the attention mechanism to calculate the feature weight vector

[0074] The basic idea of ​​the Attention mechanism is to filter out useful information, and the essence of achieving this effect is to calculate the output sequence of the LSTM hidden layer, that is, the output sequence of the last layer of LSTM, to obtain the feature weight vector, find more important influencing factors, and improve the efficiency and accuracy of information processing.

[0075] First, calculate the attention weight a assigned to the elements in the last output sequence of the LSTM hidden layer at the current time t ti , the formula is as follows:

[0076]

[0077] Where i represents the sequence number of the element in the LSTM hidden layer output sequence, T h represents the sequence length in the LSTM hidden layer output sequence, e ti Indicates the matching degree between the element to be encoded and other elements in the LSTM hidden layer output sequence.

[0078] Calculate the feature weight vector, the formula is as follows:

[0079] a′ t,i =H(D,C t ,h) (10)

[0080]

[0081] In the formula, H represents the feature weight vector function, h t represents the output sequence of the LSTM hidden layer, h represents the output feature sequence of the last layer of the LSTM hidden layer at all times, and C t Represents the LSTM hidden layer output sequence h t The corresponding hidden layer state of the attention mechanism. a′ t,i Represents the weight of the i-th element in ht.

[0082] Using the data obtained in step 1, the error back propagation method is used to train the CNN-LSTM network containing the attention mechanism to achieve the optimal solution of the parameters, thereby obtaining a trained wind power prediction model.

[0083] Step (3): After the model is trained, the validation set is used to verify the effect, and finally the test set is predicted. The mean absolute percentage error (MAPE) can be used to evaluate the accuracy of the model, and its calculation formula is:

[0084]

[0085] In the formula, is the predicted value, y i is the true value.

[0086] In summary, the CNN-LSTM short-term wind power prediction model based on the attention mechanism provided by the present invention takes into account various environmental factors such as weather, wind speed, wind direction, temperature, pressure, humidity, etc., can effectively extract the local characteristics and time series characteristics of the data, reasonably allocate feature weights, and realize accurate prediction of short-term wind power.

[0087] The above are only preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. It should be noted that any equivalent replacement or change made by a person skilled in the art based on the technical solution or concept of the present invention shall fall within the scope of protection of the present invention.

Claims

1. A CNN-LSTM short-term wind power prediction method based on attention mechanism, characterized by: The method comprises the following steps: Step (1) obtaining wind power data of the wind power generation system, cleaning the wind power data, and combining the wind power data at different times with corresponding weather, wind speed, wind direction, temperature, pressure, and humidity to form features, wherein non-numeric features are one-hot encoded, and then the features of all data are normalized; Step (2) constructs an input feature vector at the prediction point, and inputs the preprocessed feature vector into the CNN network, extracts the static features of the input feature vector through the convolution and pooling operations of the CNN network, and then inputs the static features extracted by the CNN network into the hidden layer of the LSTM network for feature extraction, and uses the attention mechanism to calculate the feature vector extracted by the hidden layer to obtain the feature weight, and then multiplies the feature weight and the feature vector extracted by the hidden layer and inputs the feature weight into the Dropout layer and the fully connected layer of the LSTM, and outputs the predicted wind power prediction value; the LSTM network specifically includes an LSTM hidden layer, an attention layer, a Dropout layer and a fully connected layer, wherein the process of extracting features by the LSTM hidden layer is as follows: i t =σ(W iX X t +W ih h t-1 +b i ) f t =σ(W fX X t +W fh h t-1 +b f ) o t =σ(W oX X t +W oh h t-1 +b o ) In the formula, i t is the input gate and the forget gate f t , output gate o t and the current neuron candidate value W iX , W ih , W fX , W fh , W oX , W oh , W CX , W Ch Represent the static features X of the corresponding gate and the current input respectively t and the previous unit output h t-1 The matrix weight obtained by multiplication, b i , b f , b o , b C is the bias term, σ is the sigmoid function; New state value C t From the previous state value C t-1 、Forget gate t , input gate i t And the current neuron candidate value Decision, get the new state value C t After that, the output sequence h of the hidden layer can be obtained t , the calculation formula is: h t =o t *tanh(C t ) In the formula, * represents the bitwise product of the elements in each multiplied vector; The process of using the attention layer to calculate the feature vector extracted by the hidden layer to obtain the feature weight, and then multiplying the feature weight and the feature vector extracted by the hidden layer is: Calculate the attention weight a assigned to the elements in the last output sequence of the LSTM hidden layer at the current time t ti , the formula is as follows: In the formula, i represents the sequence number of the element in the LSTM hidden layer output sequence, T h represents the length of the LSTM hidden layer output sequence, e ti Indicates the matching degree between the element to be encoded and other elements in the LSTM hidden layer output sequence; Calculate the feature weight vector, the formula is as follows: a′ t,i =H(D t ,C t ,h) In the formula, H represents the feature weight vector function, h represents the output feature sequence of the last layer of the LSTM hidden layer at all times, and C t Represents the LSTM hidden layer output sequence h t The hidden layer state of the corresponding attention mechanism; a′ t,i Indicates h t The weight of the i-th element in ; The input feature vector at the prediction point specifically includes: the weather at the prediction point, the wind speed at the prediction point, the wind direction at the prediction point, the pressure at the prediction point, the temperature at the prediction point, the humidity at the prediction point, and the wind power value at the same time of the day before the prediction point. The parameters of the CNN network and the LSTM network are obtained by training and optimizing using the historical wind power data and its corresponding weather, wind speed, wind direction, temperature, pressure, and humidity data using the error back propagation method.

2. According to claim 1, a CNN-LSTM short-term wind power prediction method based on attention mechanism is characterized by: The CNN is a one-dimensional convolutional network that can extract static features of the input vector, and its output is: Among them, x t is the input feature vector at time t; ω j is the convolution kernel weight matrix; b is the bias value; k is the number of convolution kernels.

3. The CNN-LSTM short-term wind power prediction method based on the attention mechanism according to claim 1 is characterized by: In step 1, the method for cleaning wind power data is specifically as follows: The clustering method is adopted to take the mean of the wind power value at the corresponding time of the three-day data with the greatest similarity to fill the missing data; the clustering features include weather, wind speed, wind direction, temperature, pressure, and humidity; Check the stability of historical wind power data and fill in the extreme data with the value at the same time of the previous day.