Wind power prediction method, device and equipment and storage medium
By using distillation operation and masked multi-head self-attention mechanism in wind power prediction model, long-time series problems in wind power prediction are solved, memory and computing time efficiency problems are achieved, and efficient wind power prediction is achieved.
Patent Information
- Application Number
- CN202411510128.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-28
- Publication Date
- 2025-02-07
AI Technical Summary
The existing wind power power prediction methods take up a lot of memory and calculation time when processing long-term input and output sequences, and the secondary complexity is high, resulting in inefficiency.
A wind power power prediction method is adopted to obtain the current wind speed data sequence and the air pressure data sequence and input it into the preset wind power power prediction model. The model includes a wind pressure and wind speed prediction module and a wind power prediction module, which uses an encoder and decoder for distillation operations and masks a multi-head self-attention mechanism to reduce sequence length and computational complexity.
It effectively reduces the time dimension of the input sequence, reduces the computation time complexity, improves prediction speed, and solves the efficiency of memory usage and computing time.
Smart Images

Figure CN119397905A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of wind power technology, and in particular to a wind power prediction method, device, equipment and storage medium. Background Art
[0002] The accurate prediction results of medium- and long-term wind power can provide an important basis for the distribution plan, energy storage allocation plan and medium- and long-term power generation plan after wind power is connected to the grid. Existing wind power prediction methods mainly include physical methods, statistical methods, machine learning methods and hybrid methods. The physical method predicts wind power generation by predicting wind speed based on weather conditions. Statistical and machine learning methods achieve long-term prediction based on historical values and measured values of wind power combined with weather and meteorological data. Artificial neural networks such as convolutional networks, deep learning networks, long short-term memory (LSTM), and Transformer have powerful learning capabilities and can handle dynamic, nonlinear, and complex time series wind characteristics. However, existing methods cannot solve the problem that long-term input and output sequences occupy a large amount of memory and have a large quadratic complexity in computing time. Summary of the invention
[0003] The present invention provides a wind power prediction method, device, equipment and storage medium to solve the technical problems that existing methods cannot solve that long-term input and output sequences occupy a large amount of memory and have a large quadratic complexity in calculation time.
[0004] In order to solve the above technical problems, an embodiment of the present invention provides a wind power prediction method, comprising:
[0005] Get the current wind speed data sequence and air pressure data sequence;
[0006] Inputting the wind speed data sequence and the air pressure data sequence into a preset wind power prediction model, so that the wind power prediction model predicts the wind power at a future time according to the wind speed data sequence and the air pressure data sequence, and outputs the wind power prediction sequence corresponding to the future time;
[0007] Wherein, the wind power prediction model includes: a wind pressure and wind speed prediction module and a wind power prediction module; the wind power prediction module includes: an encoder and a decoder;
[0008] The wind pressure and wind speed prediction module is used to predict the wind speed and air pressure at a future time according to the current wind speed data sequence and air pressure data sequence, generate a wind speed prediction data sequence and an air pressure prediction data sequence corresponding to the future time, and input the wind speed prediction data sequence and the air pressure prediction data sequence into the wind power prediction module;
[0009] The encoder is used to perform a distillation operation on the wind speed prediction data sequence and the air pressure prediction data sequence, perform a one-dimensional convolution process and a maximum pooling process on the wind speed prediction data sequence and the air pressure prediction data sequence, reduce the sequence length of the wind speed prediction data sequence and the air pressure prediction data sequence, and generate an input sequence of the decoder according to the data features of the retained wind speed prediction data sequence and the air pressure prediction data sequence;
[0010] The decoder is used to generate a wind power prediction sequence corresponding to a future moment at one time according to the masked multi-head self-attention mechanism and the input sequence.
[0011] As a preferred solution, a distillation operation is performed on the wind speed prediction data sequence and the air pressure prediction data sequence, and the wind speed prediction data sequence and the air pressure prediction data sequence are subjected to one-dimensional convolution processing and maximum pooling processing to reduce the sequence length of the wind speed prediction data sequence and the air pressure prediction data sequence, and an input sequence of the decoder is generated according to the data features of the retained wind speed prediction data sequence and the air pressure prediction data sequence, including:
[0012] Performing a distillation operation on the wind speed prediction data sequence and the air pressure prediction data sequence, performing one-dimensional convolution processing and maximum pooling processing on the wind speed prediction data sequence and the air pressure prediction data sequence, halving the wind speed prediction data sequence and the air pressure prediction data sequence through convolution and maximum pooling in each convolution layer, gradually reducing the feature layer, and thereby reducing the sequence length of the wind speed prediction data sequence and the air pressure prediction data sequence;
[0013] A corresponding hidden state vector is generated according to the data features of the retained wind speed prediction data sequence and the air pressure prediction data sequence, and the hidden state vector is used as the input sequence of the decoder.
[0014] As a preferred solution, the method of generating a wind power prediction sequence corresponding to a future moment at one time according to the masked multi-head self-attention mechanism and the input sequence includes:
[0015] According to the masked multi-head self-attention mechanism, the hidden state vector and the preset time mark, each time step only focuses on the time step of the current moment and the time step of the historical moment, and generates a wind power prediction sequence corresponding to the future moment at one time; wherein the time mark includes: a start mark and a target placeholder mark.
[0016] As a preferred solution, according to the masked multi-head self-attention mechanism, the hidden state vector and the preset time mark, each time step only focuses on the time step of the current moment and the time step of the historical moment, and generates the wind power prediction sequence corresponding to the future moment at one time, including:
[0017] According to the hidden state vector and a preset time mark, the hidden state vector is mapped to a preset high-dimensional vector space to generate a corresponding embedding vector;
[0018] Generate a query vector, a key vector, and a value vector corresponding to each embedding vector, and obtain a corresponding attention weight according to the dot product between the query vector and the key vector;
[0019] Performing a softmax function normalization process on the attention weights to obtain the corresponding attention distribution, and calculating the KL divergence between the attention distribution corresponding to each query vector and the uniform distribution;
[0020] The KL divergence values are sorted in descending order, and the query vectors corresponding to the first preset number of KL divergences are used as active queries, and the query vectors corresponding to the remaining KL divergences are used as lazy queries;
[0021] For each active query, the corresponding attention weight is multiplied by the corresponding value vector according to the masked multi-head self-attention mechanism, and the product is weighted summed; for each lazy query, the average value of the corresponding value vector is calculated;
[0022] According to the weighted sum result corresponding to all active queries and the average value result corresponding to all lazy queries, the weighted sum result and the average value result are concatenated to generate a wind power prediction sequence corresponding to the future moment.
[0023] Based on the above embodiment, another embodiment of the present invention provides a device, including: a data acquisition module and a wind power prediction module;
[0024] The data acquisition module is used to acquire the current wind speed data sequence and air pressure data sequence;
[0025] The wind power prediction module is used to input the wind speed data sequence and the air pressure data sequence into a preset wind power prediction model, so that the wind power prediction model predicts the wind power at a future time according to the wind speed data sequence and the air pressure data sequence, and outputs the wind power prediction sequence corresponding to the future time; wherein the wind power prediction model includes: a wind pressure and wind speed prediction module and a wind power prediction module; the wind power prediction module includes: an encoder and a decoder; the wind pressure and wind speed prediction module is used to predict the wind speed and air pressure at a future time according to the current wind speed data sequence and the air pressure data sequence, and generate a wind speed prediction data sequence and an air pressure prediction sequence corresponding to the future time data sequence, and input the wind speed prediction data sequence and the air pressure prediction data sequence into the wind power prediction module; the encoder is used to perform a distillation operation on the wind speed prediction data sequence and the air pressure prediction data sequence, perform one-dimensional convolution processing and maximum pooling processing on the wind speed prediction data sequence and the air pressure prediction data sequence, reduce the sequence length of the wind speed prediction data sequence and the air pressure prediction data sequence, and generate an input sequence of the decoder according to the data features of the retained wind speed prediction data sequence and the air pressure prediction data sequence; the decoder is used to generate a wind power prediction sequence corresponding to a future moment at one time according to the masked multi-head self-attention mechanism and the input sequence.
[0026] As a preferred solution, a distillation operation is performed on the wind speed prediction data sequence and the air pressure prediction data sequence, and the wind speed prediction data sequence and the air pressure prediction data sequence are subjected to one-dimensional convolution processing and maximum pooling processing to reduce the sequence length of the wind speed prediction data sequence and the air pressure prediction data sequence, and an input sequence of the decoder is generated according to the data features of the retained wind speed prediction data sequence and the air pressure prediction data sequence, including:
[0027] Performing a distillation operation on the wind speed prediction data sequence and the air pressure prediction data sequence, performing one-dimensional convolution processing and maximum pooling processing on the wind speed prediction data sequence and the air pressure prediction data sequence, halving the wind speed prediction data sequence and the air pressure prediction data sequence through convolution and maximum pooling in each convolution layer, gradually reducing the feature layer, and thereby reducing the sequence length of the wind speed prediction data sequence and the air pressure prediction data sequence;
[0028] A corresponding hidden state vector is generated according to the data features of the retained wind speed prediction data sequence and the air pressure prediction data sequence, and the hidden state vector is used as the input sequence of the decoder.
[0029] As a preferred solution, the method of generating a wind power prediction sequence corresponding to a future moment at one time according to the masked multi-head self-attention mechanism and the input sequence includes:
[0030] According to the masked multi-head self-attention mechanism, the hidden state vector and the preset time mark, each time step only focuses on the time step of the current moment and the time step of the historical moment, and generates a wind power prediction sequence corresponding to the future moment at one time; wherein the time mark includes: a start mark and a target placeholder mark.
[0031] As a preferred solution, according to the masked multi-head self-attention mechanism, the hidden state vector and the preset time mark, each time step only focuses on the time step of the current moment and the time step of the historical moment, and generates the wind power prediction sequence corresponding to the future moment at one time, including:
[0032] According to the hidden state vector and a preset time mark, the hidden state vector is mapped to a preset high-dimensional vector space to generate a corresponding embedding vector;
[0033] Generate a query vector, a key vector, and a value vector corresponding to each embedding vector, and obtain a corresponding attention weight according to the dot product between the query vector and the key vector;
[0034] Performing a softmax function normalization process on the attention weights to obtain the corresponding attention distribution, and calculating the KL divergence between the attention distribution corresponding to each query vector and the uniform distribution;
[0035] The KL divergence values are sorted in descending order, and the query vectors corresponding to the first preset number of KL divergences are used as active queries, and the query vectors corresponding to the remaining KL divergences are used as lazy queries;
[0036] For each active query, the corresponding attention weight is multiplied by the corresponding value vector according to the masked multi-head self-attention mechanism, and the product is weighted summed; for each lazy query, the average value of the corresponding value vector is calculated;
[0037] According to the weighted sum result corresponding to all active queries and the average value result corresponding to all lazy queries, the weighted sum result and the average value result are concatenated to generate a wind power prediction sequence corresponding to the future moment.
[0038] Based on the above embodiments, another embodiment of the present invention provides an electronic device, which includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and when the processor executes the computer program, the wind power prediction method described in the above embodiments of the invention is implemented.
[0039] Based on the above embodiment, another embodiment of the present invention provides a storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the storage medium is located is controlled to execute the wind power prediction method described in the above invention embodiment.
[0040] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0041] The present invention provides a wind power prediction method, which obtains the current wind speed data sequence and air pressure data sequence; inputs the wind speed data sequence and air pressure data sequence into a preset wind power prediction model, so that the wind power prediction model predicts the wind power at a future time according to the wind speed data sequence and the air pressure data sequence, and outputs the wind power prediction sequence corresponding to the future time.
[0042] Among them, the wind power prediction model includes: a wind pressure and wind speed prediction module and a wind power prediction module; the wind power prediction module includes: an encoder and a decoder; the wind pressure and wind speed prediction module is used to predict the wind speed and air pressure at future times based on the current wind speed data sequence and air pressure data sequence, generate the wind speed prediction data sequence and air pressure prediction data sequence corresponding to the future time, and input the wind speed prediction data sequence and air pressure prediction data sequence into the wind power prediction module. The encoder is used to perform a distillation operation on the wind speed prediction data sequence and the air pressure prediction data sequence, perform one-dimensional convolution processing and maximum pooling processing on the wind speed prediction data sequence and the air pressure prediction data sequence, reduce the sequence length of the wind speed prediction data sequence and the air pressure prediction data sequence, and generate the input sequence of the decoder according to the data features of the retained wind speed prediction data sequence and the air pressure prediction data sequence; the encoder can reduce the sequence length and retain the main features through one-dimensional convolution and maximum pooling operations, thereby reducing the time dimension of the input sequence, reducing the time complexity of subsequent calculations, solving the problem of long-term input and output sequences occupying a large amount of memory, and reducing the computational time complexity. The decoder is used to generate the wind power prediction sequence corresponding to the future moment at one time according to the masked multi-head self-attention mechanism and the input sequence, directly generate the entire prediction sequence in parallel at one time through the self-attention mechanism, avoid the delay of step-by-step generation, thereby greatly improving the prediction speed, and can reduce unnecessary calculations, solving the problem of large quadratic complexity of computational time. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 It is a flow chart of a wind power prediction method provided by an embodiment of the present invention;
[0044] Figure 2It is a schematic diagram of the multi-step Informer long sequence time prediction framework;
[0045] Figure 3 It is a structural schematic diagram of a wind power prediction device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0047] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by technicians in the technical field to which this application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" in the specification and claims of this application and the above-mentioned figure descriptions and any variations thereof are intended to cover non-exclusive inclusions.
[0048] In the description of the embodiments of the present application, the technical terms "first", "second", etc. are only used to distinguish different objects, and cannot be understood as indicating or implying relative importance or implicitly indicating the number, specific order or primary and secondary relationship of the indicated technical features. In the description of the embodiments of the present application, the meaning of "multiple" is more than two, unless otherwise clearly and specifically defined.
[0049] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0050] In the description of the embodiments of the present application, the term "and / or" is only a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0051] In the description of the embodiments of the present application, the term "multiple" refers to more than two (including two). Similarly, "multiple groups" refers to more than two groups (including two groups), and "multiple pieces" refers to more than two pieces (including two pieces).
[0052] In the description of the embodiments of the present application, unless otherwise clearly specified and limited, technical terms such as "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, and it can be the internal connection of two elements or the interaction relationship between two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the embodiments of the present application can be understood according to the specific circumstances.
[0053] Embodiment 1
[0054] Please refer to Figure 1 , is a flow chart of a wind power prediction method provided by an embodiment of the present invention, comprising the following specific steps:
[0055] S1. Obtain the current wind speed data sequence and air pressure data sequence;
[0056] Specifically, first obtain the current meteorological data - wind speed data series and air pressure data series. These are the most critical input parameters, because wind power generation is directly related to wind speed and air pressure. Specifically, they include:
[0057] Wind speed data series: usually input into the model in the form of a time series, reflecting the changes in wind speed at different time points;
[0058] Air pressure data series: Also in the form of a time series, changes in air pressure also affect wind flow and power generation.
[0059] Time information: The input data usually includes a timestamp (such as date, time, etc.) to mark data in different time periods.
[0060] S2. Inputting the wind speed data sequence and the air pressure data sequence into a preset wind power prediction model, so that the wind power prediction model predicts the wind power at a future time according to the wind speed data sequence and the air pressure data sequence, and outputs a wind power prediction sequence corresponding to the future time;
[0061] Wherein, the wind power prediction model includes: a wind pressure and wind speed prediction module and a wind power prediction module; the wind power prediction module includes: an encoder and a decoder;
[0062] The wind pressure and wind speed prediction module is used to predict the wind speed and air pressure at a future time according to the current wind speed data sequence and air pressure data sequence, generate a wind speed prediction data sequence and an air pressure prediction data sequence corresponding to the future time, and input the wind speed prediction data sequence and the air pressure prediction data sequence into the wind power prediction module;
[0063] The encoder is used to perform a distillation operation on the wind speed prediction data sequence and the air pressure prediction data sequence, perform a one-dimensional convolution process and a maximum pooling process on the wind speed prediction data sequence and the air pressure prediction data sequence, reduce the sequence length of the wind speed prediction data sequence and the air pressure prediction data sequence, and generate an input sequence of the decoder according to the data features of the retained wind speed prediction data sequence and the air pressure prediction data sequence;
[0064] The decoder is used to generate a wind power prediction sequence corresponding to a future moment at one time according to the masked multi-head self-attention mechanism and the input sequence.
[0065] Preferably, a distillation operation is performed on the wind speed prediction data sequence and the air pressure prediction data sequence, and the wind speed prediction data sequence and the air pressure prediction data sequence are subjected to one-dimensional convolution processing and maximum pooling processing to reduce the sequence length of the wind speed prediction data sequence and the air pressure prediction data sequence, and the input sequence of the decoder is generated according to the data features of the retained wind speed prediction data sequence and the air pressure prediction data sequence, including: a distillation operation is performed on the wind speed prediction data sequence and the air pressure prediction data sequence, and the wind speed prediction data sequence and the air pressure prediction data sequence are subjected to one-dimensional convolution processing and maximum pooling processing to halve the wind speed prediction data sequence and the air pressure prediction data sequence through convolution and maximum pooling in each layer of convolution, and the feature layers are gradually reduced, thereby reducing the sequence length of the wind speed prediction data sequence and the air pressure prediction data sequence; a corresponding hidden state vector is generated according to the data features of the retained wind speed prediction data sequence and the air pressure prediction data sequence, and the hidden state vector is used as the input sequence of the decoder.
[0066] Preferably, the wind power prediction sequence corresponding to the future moment is generated at one time according to the masked multi-head self-attention mechanism and the input sequence, including: according to the masked multi-head self-attention mechanism, the hidden state vector and the preset time mark, each time step only pays attention to the time step of the current moment and the time step of the historical moment, and the wind power prediction sequence corresponding to the future moment is generated at one time; wherein the time mark includes: a start mark and a target placeholder mark.
[0067] Preferably, according to the masked multi-head self-attention mechanism, the hidden state vector and the preset time mark, each time step only pays attention to the time step of the current moment and the time step of the historical moment, and generates the wind power prediction sequence corresponding to the future moment at one time, including: according to the hidden state vector and the preset time mark, mapping the hidden state vector to a preset high-dimensional vector space to generate a corresponding embedding vector; generating a query vector, a key vector and a value vector corresponding to each embedding vector, and obtaining a corresponding attention weight according to the dot product between the query vector and the key vector; performing softmax function normalization on the attention weight to obtain a corresponding attention distribution, and calculating the corresponding The KL divergence between the attention distribution and the uniform distribution; sorting the values of the KL divergence in descending order, taking the query vectors corresponding to the first preset number of KL divergences as active queries, and taking the query vectors corresponding to the remaining KL divergences as lazy queries; for each active query, multiplying the corresponding attention weight with the corresponding value vector according to the masked multi-head self-attention mechanism, and weighted summing the products; for each lazy query, calculating the average value of the corresponding value vector; according to the weighted summation results corresponding to all active queries and the average value results corresponding to all lazy queries, the weighted summation results and the average value results are spliced to generate a wind power prediction sequence corresponding to the future moment.
[0068] Then the acquired wind speed data sequence and air pressure data sequence are input into a preset wind power prediction model, and the wind power prediction model predicts the wind power at future moments according to the wind speed data sequence and air pressure data sequence, and outputs the wind power prediction sequence corresponding to the future moments. The generation process of the wind power prediction model is as follows:
[0069] 1. Construct a multi-step Informer long-sequence time prediction framework as a wind power prediction module:
[0070] Please refer to Figure 2 , is a schematic diagram of the multi-step Informer long sequence temporal prediction framework. The Informer network consists of an encoder and a decoder. The encoder processes long input sequences and reduces the overall time complexity and memory overhead through a multi-head masked probabilistic sparse self-attention mechanism. Adding a distillation operation to the self-attention mechanism reduces the output dimension and the number of network parameters, and highlights the dominant attention to reduce the temporal dimension of long input sequences.
[0071] The generative decoder solves the problem of reduced prediction speed. The result in the generative decoder is generated in one step, not step by step. The generative decoder is an improvement based on the Transformer. In the classic Transformer, the input of the decoder is the prediction result of the current time step, and then this result is recursively used as the input of the next step to gradually generate the entire sequence. In the present invention, the sparse self-attention mechanism proposed by Informer is an improvement on the traditional self-attention mechanism, which aims to capture long-distance features more efficiently. The sparse self-attention mechanism reduces unnecessary calculations by only calculating the attention weights related to the "active query", thereby efficiently capturing key long-distance features in long sequences.
[0072] The generative decoder of the Informer network is different from the traditional method. It adopts the strategy of generating all prediction results at one time, that is, generating the entire prediction sequence through a one-time forward propagation. The specific process is as follows:
[0073] First, the encoder processes the input data of the long time series and generates a hidden state vector; then, the decoder receives the hidden state output of the encoder and a specific time mark (such as the start mark X token and the target placeholder X phol ), generating the entire prediction sequence at once.
[0074] During the prediction process, the masked multi-head self-attention mechanism is used to ensure that each time step only focuses on the current and previous time steps instead of using future information. This effectively avoids the problem of information leakage and enables the model to complete the prediction of all time steps at one time.
[0075] Traditional recursive networks (RNN, LSTM, etc.) rely on the output of the previous time step and must be calculated in sequence, which reduces the speed of long time series prediction. The generative encoder abandons this recursive structure and directly generates the entire prediction sequence in parallel at one time through the self-attention mechanism, avoiding the delay of step-by-step generation. Through parallelization and masked self-attention mechanism, the decoder can process multiple time steps at the same time, thereby greatly improving the prediction speed. The specific operation is as follows:
[0076] Informer uses KL divergence (Kul lback-Leibler divergence) to measure the distribution distance. The larger the relative entropy, the greater the probability that it is an important part. KL divergence is used to measure the difference between two probability distributions. In the sparse self-attention mechanism, KL divergence is used to select active queries and lazy queries. The Informer network determines which query vectors are active and which are lazy by calculating the KL divergence between the attention distribution and the uniform distribution of the query vector. Active queries mean that their dot product value with the key vector plays a key role in the attention weight, while lazy queries have less impact on the overall attention distribution, so approximate calculations can be used to reduce computational costs.
[0077] Assume there are n input data {x1,x2,...,x n}, for each input x i ,The processing steps in the Informer framework are as follows: ,Overall calculation process:
[0078] For each input x i First, the input data is mapped to a high-dimensional vector space through the embedding layer. Assume that x i Mapped to the embedding vector h i , then the entire input sequence becomes:
[0079] H=[h1,h2,...,h n ];
[0080] Among them, H∈R n×d , where d is the embedding dimension.
[0081] For each embedding vector h i , generate the corresponding query vector Q i , key vector K i Sum value vector V i These vectors are connected by the learned weight matrix W q , W k , W v get:
[0082]
[0083] These vectors are used for subsequent self-attention mechanism calculations.
[0084] Calculate the query vector Q i , key vector K i The dot product between them to get the attention weight:
[0085]
[0086] Then all the e ijThe result is normalized by the softmax function to obtain the attention distribution α ij :
[0087]
[0088] Calculate each query vector Q i The KL divergence between the attention distribution and the uniform distribution:
[0089]
[0090] Among them, P(α ij ) is the attention distribution obtained from softmax, U(α ij ) is uniformly distributed (i.e. 1 / n).
[0091] According to the value of KL divergence, the first u query vectors with the largest distance are selected as active queries. For active queries, dot product calculation and attention mechanism are continued to be used. For lazy queries, the exact attention distribution is not calculated, but the value vector V is used instead. i The average value of is used to calculate , to approximate its contribution to the output.
[0092] For each active query Q i , perform the standard attention mechanism calculation, and normalize the attention weight α ij The corresponding value vector V j Multiply and weighted sum:
[0093]
[0094] For lazy queries, the dot product result is directly replaced by the average of the value vector. i After the sparse self-attention mechanism is calculated, the output z is obtained i , concatenate all outputs to form the overall output matrix Z.
[0095] The distillation operation is a key step in the encoder, which is used to reduce the temporal dimension of the input sequence. Through one-dimensional convolution and maximum pooling operations, the sequence length is halved, the main features are retained, and the time complexity of subsequent calculations is reduced. Through convolution and maximum pooling operations, the distillation layer gradually halves the length of the input sequence, but retains the most important temporal features. Therefore, although the input sequence is long, the model actually only processes the simplified sequence, while capturing long-distance global information.
[0096] The distillation operation processes the input feature Z layer by layer, abbreviating the sequence length. The feature F after distillation i+1 is the input of the next encoder layer:
[0097] F i+1=MaxPool(ELU(Convld([F i ] PSA )));
[0098] Among them [F i ] PSA Perform the basic operation of multi-head probe self-attention. Convld is the convolution of the time series, and the activation function RELU is used. Each layer halves the input sequence through convolution and maximum pooling, gradually reducing the feature layer to achieve the reduction of the input sequence. This F i+1 It is the intermediate result of each layer of the encoder. It gradually extracts important features in the input sequence through the multi-head sparse self-attention mechanism, convolution layer and maximum pooling layer. After the encoder completes the calculation of all layers, the output of the last layer is the final hidden representation of the encoder, which is then passed to the decoder as the basis for the decoder to generate prediction results.
[0099] In the decoder structure, a standard decoder is added, which consists of two multi-head self-attention layers. The first multi-head self-attention layer uses the sparse self-attention mechanism, while the second multi-head self-attention layer uses the standard self-attention mechanism. The input of the decoder includes the output of the encoder and the embedded input sequence. The embedded input sequence is the representation of the original time series data (such as wind speed, air pressure, etc.) after being projected into the high-dimensional vector space by the embedding layer. This embedded representation is used as the input of the decoder to help the model capture complex time series features and patterns. The input sequence is divided into two parts: the start mark (X i ) and the target placeholder In the decoder, timestamps are padded with zeros to keep the dimensions consistent when predicting sequence inputs. The decoder applies a masked multi-head self-attention mechanism to mask future information. That is, by:
[0100]
[0101] in represents the input sequence of the decoder, X i Indicates the start sign. It is the target placeholder, preventing each position from paying attention to the subsequent position, thus avoiding autoregression. Finally, the output of the decoder is passed to the fully connected layer to predict the power generation at future moments.
[0102] 3. Multi-step training framework
[0103] The multi-step informer network incorporates meteorological parameters such as wind speed and air pressure into wind power forecasting. First, the wind power, wind speed, and air pressure are predicted separately through the informer network. Then, the prediction results of wind speed and air pressure are combined using a convolutional layer to correct the wind power forecast. Specifically, the entire multi-step forecasting process includes the following steps:
[0104] Pre-training stage: First, use the Informer network to pre-train the historical wind speed and air pressure data to obtain the corresponding wind pressure and wind speed prediction module. This step aims to allow the model to learn the time series characteristics of meteorological parameters first.
[0105] Joint modeling stage: The pre-trained wind speed and air pressure informer models are applied to the multi-step informer network to combine the prediction results of meteorological parameters with wind power generation prediction.
[0106] Training the entire model: Based on joint modeling, the entire multi-step informer network is trained using historical wind speed, air pressure, and wind power generation data. Through this process, the model can simultaneously capture the complex relationship between meteorological parameters and wind power generation, and ultimately output power generation forecasts for future moments.
[0107] 3. Model training and optimization:
[0108] The multi-step Informer network model is trained using the training data set, and the model parameters are optimized by minimizing the difference between the predicted results and the actual load data. Commonly used loss functions can be mean square error (MSE) or mean absolute error (MAE). The training objective function is:
[0109]
[0110] Hyperparameter settings: learning rate lr = 0.001, optimizer is Adam, batch size = 32.
[0111] Embodiment 2
[0112] Please refer to Figure 3 , is a schematic diagram of the structure of a wind power prediction device provided by an embodiment of the present invention, the device comprising: a data acquisition module and a wind power prediction module;
[0113] The data acquisition module is used to acquire the current wind speed data sequence and air pressure data sequence;
[0114] The wind power prediction module is used to input the wind speed data sequence and the air pressure data sequence into a preset wind power prediction model, so that the wind power prediction model predicts the wind power at a future time according to the wind speed data sequence and the air pressure data sequence, and outputs the wind power prediction sequence corresponding to the future time; wherein the wind power prediction model includes: a wind pressure and wind speed prediction module and a wind power prediction module; the wind power prediction module includes: an encoder and a decoder; the wind pressure and wind speed prediction module is used to predict the wind speed and air pressure at a future time according to the current wind speed data sequence and the air pressure data sequence, and generate a wind speed prediction data sequence and an air pressure prediction sequence corresponding to the future time data sequence, and input the wind speed prediction data sequence and the air pressure prediction data sequence into the wind power prediction module; the encoder is used to perform a distillation operation on the wind speed prediction data sequence and the air pressure prediction data sequence, perform one-dimensional convolution processing and maximum pooling processing on the wind speed prediction data sequence and the air pressure prediction data sequence, reduce the sequence length of the wind speed prediction data sequence and the air pressure prediction data sequence, and generate an input sequence of the decoder according to the data features of the retained wind speed prediction data sequence and the air pressure prediction data sequence; the decoder is used to generate a wind power prediction sequence corresponding to a future moment at one time according to the masked multi-head self-attention mechanism and the input sequence.
[0115] Preferably, a distillation operation is performed on the wind speed prediction data sequence and the air pressure prediction data sequence, and the wind speed prediction data sequence and the air pressure prediction data sequence are subjected to one-dimensional convolution processing and maximum pooling processing to reduce the sequence length of the wind speed prediction data sequence and the air pressure prediction data sequence, and the input sequence of the decoder is generated according to the data features of the retained wind speed prediction data sequence and the air pressure prediction data sequence, including: a distillation operation is performed on the wind speed prediction data sequence and the air pressure prediction data sequence, and the wind speed prediction data sequence and the air pressure prediction data sequence are subjected to one-dimensional convolution processing and maximum pooling processing to halve the wind speed prediction data sequence and the air pressure prediction data sequence through convolution and maximum pooling in each layer of convolution, and the feature layers are gradually reduced, thereby reducing the sequence length of the wind speed prediction data sequence and the air pressure prediction data sequence; a corresponding hidden state vector is generated according to the data features of the retained wind speed prediction data sequence and the air pressure prediction data sequence, and the hidden state vector is used as the input sequence of the decoder.
[0116] Preferably, the wind power prediction sequence corresponding to the future moment is generated at one time according to the masked multi-head self-attention mechanism and the input sequence, including: according to the masked multi-head self-attention mechanism, the hidden state vector and the preset time mark, each time step only pays attention to the time step of the current moment and the time step of the historical moment, and the wind power prediction sequence corresponding to the future moment is generated at one time; wherein the time mark includes: a start mark and a target placeholder mark.
[0117] Preferably, according to the masked multi-head self-attention mechanism, the hidden state vector and the preset time mark, each time step only pays attention to the time step of the current moment and the time step of the historical moment, and generates the wind power prediction sequence corresponding to the future moment at one time, including: according to the hidden state vector and the preset time mark, mapping the hidden state vector to a preset high-dimensional vector space to generate a corresponding embedding vector; generating a query vector, a key vector and a value vector corresponding to each embedding vector, and obtaining a corresponding attention weight according to the dot product between the query vector and the key vector; performing softmax function normalization on the attention weight to obtain a corresponding attention distribution, and calculating the corresponding The KL divergence between the attention distribution and the uniform distribution; sorting the values of the KL divergence in descending order, taking the query vectors corresponding to the first preset number of KL divergences as active queries, and taking the query vectors corresponding to the remaining KL divergences as lazy queries; for each active query, multiplying the corresponding attention weight with the corresponding value vector according to the masked multi-head self-attention mechanism, and weighted summing the products; for each lazy query, calculating the average value of the corresponding value vector; according to the weighted summation results corresponding to all active queries and the average value results corresponding to all lazy queries, the weighted summation results and the average value results are spliced to generate a wind power prediction sequence corresponding to the future moment.
[0118] It should be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the accompanying drawings of the device embodiments provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. A person of ordinary skill in the art may understand and implement it without paying any creative effort.
[0119] Those skilled in the art can clearly understand that, for the sake of convenience and brevity, the specific working process of the device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0120] Embodiment 3
[0121] Accordingly, an embodiment of the present invention provides an electronic device, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the wind power prediction method described in the above-mentioned embodiment of the invention when executing the computer program.
[0122] The electronic device may be a computing device such as a desktop computer, a notebook, a palm computer, a cloud server, etc. The device may include, but is not limited to, a processor and a memory.
[0123] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the device, and various interfaces and lines are used to connect various parts of the entire device.
[0124] Embodiment 4
[0125] Accordingly, an embodiment of the present invention provides a storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the storage medium is located is controlled to execute the wind power prediction method described in the above embodiment of the invention.
[0126] The memory can be used to store the computer program, and the processor realizes various functions of the device by running or executing the computer program stored in the memory and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required for a function, etc.; the data storage area can store data created according to the use of the mobile phone, etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0127] The storage medium is a computer-readable storage medium, and the computer program is stored in the computer-readable storage medium. When the computer program is executed by the processor, the steps of each method embodiment described above can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0128] The above is a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A wind power prediction method, characterized in that: include: Get the current wind speed data sequence and air pressure data sequence; Inputting the wind speed data sequence and the air pressure data sequence into a preset wind power prediction model, so that the wind power prediction model predicts the wind power at a future time according to the wind speed data sequence and the air pressure data sequence, and outputs the wind power prediction sequence corresponding to the future time; Wherein, the wind power prediction model includes: a wind pressure and wind speed prediction module and a wind power prediction module; the wind power prediction module includes: an encoder and a decoder; The wind pressure and wind speed prediction module is used to predict the wind speed and air pressure at a future time according to the current wind speed data sequence and air pressure data sequence, generate a wind speed prediction data sequence and an air pressure prediction data sequence corresponding to the future time, and input the wind speed prediction data sequence and the air pressure prediction data sequence into the wind power prediction module; The encoder is used to perform a distillation operation on the wind speed prediction data sequence and the air pressure prediction data sequence, perform a one-dimensional convolution process and a maximum pooling process on the wind speed prediction data sequence and the air pressure prediction data sequence, reduce the sequence length of the wind speed prediction data sequence and the air pressure prediction data sequence, and generate an input sequence of the decoder according to the data features of the retained wind speed prediction data sequence and the air pressure prediction data sequence; The decoder is used to generate a wind power prediction sequence corresponding to a future moment at one time according to the masked multi-head self-attention mechanism and the input sequence.
2. The wind power prediction method according to claim 1, characterized in that: The wind speed prediction data sequence and the air pressure prediction data sequence are subjected to a distillation operation, and the wind speed prediction data sequence and the air pressure prediction data sequence are subjected to a one-dimensional convolution process and a maximum pooling process to reduce the sequence length of the wind speed prediction data sequence and the air pressure prediction data sequence, and an input sequence of the decoder is generated according to the data features of the retained wind speed prediction data sequence and the air pressure prediction data sequence, including: Performing a distillation operation on the wind speed prediction data sequence and the air pressure prediction data sequence, performing one-dimensional convolution processing and maximum pooling processing on the wind speed prediction data sequence and the air pressure prediction data sequence, halving the wind speed prediction data sequence and the air pressure prediction data sequence through convolution and maximum pooling in each convolution layer, gradually reducing the feature layer, and thereby reducing the sequence length of the wind speed prediction data sequence and the air pressure prediction data sequence; A corresponding hidden state vector is generated according to the data features of the retained wind speed prediction data sequence and the air pressure prediction data sequence, and the hidden state vector is used as the input sequence of the decoder.
3. The wind power prediction method according to claim 2, characterized in that: The method of generating a wind power prediction sequence corresponding to a future moment at one time according to the masked multi-head self-attention mechanism and the input sequence includes: According to the masked multi-head self-attention mechanism, the hidden state vector and the preset time mark, each time step only focuses on the time step of the current moment and the time step of the historical moment, and generates a wind power prediction sequence corresponding to the future moment at one time; wherein the time mark includes: a start mark and a target placeholder mark.
4. The wind power prediction method according to claim 3, characterized in that: According to the masked multi-head self-attention mechanism, the hidden state vector and the preset time mark, each time step only focuses on the time step of the current moment and the time step of the historical moment, and generates the wind power prediction sequence corresponding to the future moment at one time, including: According to the hidden state vector and a preset time mark, the hidden state vector is mapped to a preset high-dimensional vector space to generate a corresponding embedding vector; Generate a query vector, a key vector, and a value vector corresponding to each embedding vector, and obtain a corresponding attention weight according to the dot product between the query vector and the key vector; Performing a softmax function normalization process on the attention weights to obtain the corresponding attention distribution, and calculating the KL divergence between the attention distribution corresponding to each query vector and the uniform distribution; The KL divergence values are sorted in descending order, and the query vectors corresponding to the first preset number of KL divergences are used as active queries, and the query vectors corresponding to the remaining KL divergences are used as lazy queries; For each active query, the corresponding attention weight is multiplied by the corresponding value vector according to the masked multi-head self-attention mechanism, and the product is weighted summed; for each lazy query, the average value of the corresponding value vector is calculated; According to the weighted sum result corresponding to all active queries and the average value result corresponding to all lazy queries, the weighted sum result and the average value result are concatenated to generate a wind power prediction sequence corresponding to the future moment.
5. A wind power prediction device, characterized in that: include: Data acquisition module and wind power prediction module; The data acquisition module is used to acquire the current wind speed data sequence and air pressure data sequence; The wind power prediction module is used to input the wind speed data sequence and the air pressure data sequence into a preset wind power prediction model, so that the wind power prediction model predicts the wind power at a future time according to the wind speed data sequence and the air pressure data sequence, and outputs the wind power prediction sequence corresponding to the future time; wherein the wind power prediction model includes: a wind pressure and wind speed prediction module and a wind power prediction module; the wind power prediction module includes: an encoder and a decoder; the wind pressure and wind speed prediction module is used to predict the wind speed and air pressure at a future time according to the current wind speed data sequence and the air pressure data sequence, and generate a wind speed prediction data sequence and an air pressure prediction sequence corresponding to the future time data sequence, and input the wind speed prediction data sequence and the air pressure prediction data sequence into the wind power prediction module; the encoder is used to perform a distillation operation on the wind speed prediction data sequence and the air pressure prediction data sequence, perform one-dimensional convolution processing and maximum pooling processing on the wind speed prediction data sequence and the air pressure prediction data sequence, reduce the sequence length of the wind speed prediction data sequence and the air pressure prediction data sequence, and generate an input sequence of the decoder according to the data features of the retained wind speed prediction data sequence and the air pressure prediction data sequence; the decoder is used to generate a wind power prediction sequence corresponding to a future moment at one time according to the masked multi-head self-attention mechanism and the input sequence.
6. The wind power prediction device according to claim 5, characterized in that: The wind speed prediction data sequence and the air pressure prediction data sequence are subjected to a distillation operation, and the wind speed prediction data sequence and the air pressure prediction data sequence are subjected to a one-dimensional convolution process and a maximum pooling process to reduce the sequence length of the wind speed prediction data sequence and the air pressure prediction data sequence, and an input sequence of the decoder is generated according to the data features of the retained wind speed prediction data sequence and the air pressure prediction data sequence, including: Performing a distillation operation on the wind speed prediction data sequence and the air pressure prediction data sequence, performing one-dimensional convolution processing and maximum pooling processing on the wind speed prediction data sequence and the air pressure prediction data sequence, halving the wind speed prediction data sequence and the air pressure prediction data sequence through convolution and maximum pooling in each convolution layer, gradually reducing the feature layer, and thereby reducing the sequence length of the wind speed prediction data sequence and the air pressure prediction data sequence; A corresponding hidden state vector is generated according to the data features of the retained wind speed prediction data sequence and the air pressure prediction data sequence, and the hidden state vector is used as the input sequence of the decoder.
7. The wind power prediction device according to claim 6, characterized in that: The method of generating a wind power prediction sequence corresponding to a future moment at one time according to the masked multi-head self-attention mechanism and the input sequence includes: According to the masked multi-head self-attention mechanism, the hidden state vector and the preset time mark, each time step only focuses on the time step of the current moment and the time step of the historical moment, and generates a wind power prediction sequence corresponding to the future moment at one time; wherein the time mark includes: a start mark and a target placeholder mark.
8. The wind power prediction device according to claim 7, characterized in that: According to the masked multi-head self-attention mechanism, the hidden state vector and the preset time mark, each time step only focuses on the time step of the current moment and the time step of the historical moment, and generates the wind power prediction sequence corresponding to the future moment at one time, including: According to the hidden state vector and a preset time mark, the hidden state vector is mapped to a preset high-dimensional vector space to generate a corresponding embedding vector; Generate a query vector, a key vector, and a value vector corresponding to each embedding vector, and obtain a corresponding attention weight according to the dot product between the query vector and the key vector; Performing a softmax function normalization process on the attention weights to obtain the corresponding attention distribution, and calculating the KL divergence between the attention distribution corresponding to each query vector and the uniform distribution; The KL divergence values are sorted in descending order, and the query vectors corresponding to the first preset number of KL divergences are used as active queries, and the query vectors corresponding to the remaining KL divergences are used as lazy queries; For each active query, the corresponding attention weight is multiplied by the corresponding value vector according to the masked multi-head self-attention mechanism, and the product is weighted summed; for each lazy query, the average value of the corresponding value vector is calculated; According to the weighted sum result corresponding to all active queries and the average value result corresponding to all lazy queries, the weighted sum result and the average value result are concatenated to generate a wind power prediction sequence corresponding to the future moment.
9. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the wind power prediction method according to any one of claims 1 to 4 when executing the computer program.
10. A storage medium, characterized in that: The storage medium includes a stored computer program, wherein when the computer program is running, the device where the storage medium is located is controlled to execute the wind power prediction method according to any one of claims 1 to 4.