A training method and a prediction method of a day-ahead short-term photovoltaic power model, and a device
By using the MHATCN-TCN model, which combines a multi-head attention mechanism and a temporal convolutional neural network to process multi-feature photovoltaic data, the problem of low accuracy in day-ahead short-term photovoltaic power prediction has been solved, achieving higher prediction accuracy and precision.
Patent Information
- Application Number
- CN202211550852.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-05
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2042-12-05
AI Technical Summary
Existing day-ahead short-term photovoltaic power forecasting models, such as the MHATCN model, have low accuracy in predicting photovoltaic power for the next day.
The MHATCN-TCN model is adopted, which combines multi-head attention mechanism and temporal convolutional neural network, and combines two-layer TCN network and fully connected neural network to process multi-feature photovoltaic data and establish a mapping relationship between multi-scale input and photovoltaic power.
The accuracy of the near-term photovoltaic power forecast has been improved, with MAE reduced to 1.115, RMSE reduced to 2.399, R2 increased to 0.880, and the accuracy rate reaching 96.28%.
Smart Images

Figure CN116090604B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of day-ahead short-term photovoltaic power prediction technology, specifically to a training method, prediction method, and apparatus for a day-ahead short-term photovoltaic power model. Background Technology
[0002] Photovoltaic power output is highly random and volatile, and its uncertainty brings a series of scheduling and operation problems. Accurate prediction of photovoltaic power output is an effective means to reduce the impact of uncertainty; accurate prediction of photovoltaic power plays a crucial role in power system scheduling.
[0003] Based on the time scale of the forecast, photovoltaic power generation forecasts can be classified into ultra-short-term (intraday) forecasts, short-term (day-ahead) forecasts, and medium-to-long-term forecasts.
[0004] Ultra-short-term power forecasting uses real-time environmental monitoring data, power plant inverter operation data, historical data, and other data sources to build predictive models and then predict the output power for the next 0-4 hours. It employs mathematical statistics, physical statistics, and comprehensive methods and is mainly used for photovoltaic power generation control and power quality assessment. This minute-level forecasting generally does not use numerical weather forecast data. Short-term (day-ahead) forecasting generally has a lead time of 0-72 hours and mainly relies on numerical weather forecasting. Medium- and long-term forecasting is a long-term forecast and is mainly used for system maintenance scheduling and power generation forecasting.
[0005] For models for short-term photovoltaic power forecasting, existing models include CNN, TCN, CNN-LSTM, and MHATCN. The MAE of the four models decreases in that order: CNN, TCN, CNN-LSTM, and MHATCN. Among these four models, the MHATCN model shows the best prediction accuracy, while the TCN model excels in processing time series data. However, the MHATCN or TCN models still do not have high prediction accuracy when forecasting photovoltaic power for the next day. Summary of the Invention
[0006] To address the shortcomings of existing technologies, this invention provides a training method, prediction method, and apparatus for a day-ahead short-term photovoltaic power model, aiming to improve the prediction accuracy of day-ahead short-term photovoltaic power.
[0007] A first aspect of this invention aims to provide a training method for a day-ahead short-term photovoltaic power model, the method comprising:
[0008] After preprocessing the multi-feature photovoltaic data, the processed dataset is constructed into a day-ahead prediction dataset based on time scale division.
[0009] The partitioned dataset is then input into the pre-defined MHATCN-TCN model for training.
[0010] As an optional implementation, the time scale division is specifically as follows: the data start and end time is 3.5 days (336 points), and the label start and end time is 1 day (96 points).
[0011] As an optional embodiment, data preprocessing specifically involves processing missing and outlier values followed by data max-min normalization.
[0012] Furthermore, the current method for constructing the prediction dataset is as follows: First, the processed dataset is converted into three-dimensional data (samples, timesteps, dimensions) using a sliding window operation to adjust it to the input shape required by the proposed model; then, the obtained data is filtered so that the interval between two adjacent samples is 24 hours.
[0013] As an optional embodiment, the MHATCN-TCN model includes an input layer, an MHATCN-TCN module, and an output layer;
[0014] The input layer contains multi-feature data, all of which is output to the first channel of the HATCN-TCN module; the photovoltaic output power (P) data is output to the second channel.
[0015] The MHATCN-TCN module includes a first channel and a second channel. The first channel includes a multi-head attention mechanism (MHA) and a temporal convolutional neural network (TCN). The number of heads in the MHA is equal to the number of input features. Internally, the MHA performs different spatial mappings on Q, K, and V in different heads. Subsequently, the output of the MHA is used as the input to the TCN. The second channel uses a two-layer TCN network. The two-layer TCN network consists of causal convolution, dilated convolution, and residual connections.
[0016] The output layer includes a fully connected neural network (Linear). Finally, the results from the two channels are concatenated and input into the fully connected neural network to establish a mapping relationship between multi-scale input and photovoltaic power.
[0017] In the MHATCN-TCN module, the kernel size of the first channel is set to Kernel_size = 29; the kernel size of the second channel is set to Kernel_size = 15; and Nb_stacks = 2.
[0018] As an optional embodiment, the multi-feature data includes photovoltaic output power (P), total irradiance (Ti), direct normal irradiance (Ni), horizontal diffuse irradiance (Hi), and air pressure (Ap).
[0019] A second aspect of the present invention is to provide a method for predicting day-ahead short-term photovoltaic power, the method comprising:
[0020] Acquire photovoltaic data with multiple features to be tested;
[0021] The photovoltaic data with multiple features to be measured is input into the MHATCN-TCN model obtained by the training method of the day-ahead short-term photovoltaic power model in the above-described embodiment to obtain the photovoltaic predicted power.
[0022] A third aspect of the present invention is an electronic device comprising a memory and a processor; the memory being used to store a computer program; the processor being used, when executing the computer program, to implement the above-described training method for the day-ahead short-term photovoltaic power model, or to implement the above-described day-ahead short-term photovoltaic power prediction method.
[0023] A fourth aspect of the present invention is to provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described training method for the day-ahead short-term photovoltaic power model, or implements the above-described day-ahead short-term photovoltaic power prediction method.
[0024] The beneficial effects achieved by this invention are as follows: The processed multi-feature data is input into the first channel, which employs a combination of a multi-head attention mechanism and a temporal convolutional neural network. The number of heads in the multi-head attention mechanism is equal to the number of input features. Internally, the multi-head attention mechanism performs different spatial mappings on Q, K, and V in different heads. Based on this design, each head may focus on different parts of the input, representing functions more complex than a simple weighted average. The Q, K, and V of the multi-head attention mechanism use the same input, and by default, its output shape is the same as the input shape, which facilitates subsequent input into the TCN. Subsequently, the output of the multi-head attention mechanism is used as the input to the TCN. Simultaneously, the processed photovoltaic power is input into the second channel, which employs a two-layer TCN network. The TCN consists of causal convolution, dilated convolution, and residual connections. The TCN not only possesses the advantages of parallelism and temporal causality but also allows for flexible adjustment of the receptive field, making it well-suited for processing time-series data and fully exploiting the temporal correlation of photovoltaic output power. Finally, the results from the two channels are column-concatenated and input into a fully connected neural network. Specifically, the filters of the aforementioned dual-channel TCN are f1 and f2, and the outputs are (b, f1) and (b, f2). After column concatenation, the result is (b, f), where f is f1 + f2. Column concatenation can extract and enrich the original data features, enhancing the learning ability of the subsequent fully connected neural network. The data is then input into the fully connected neural network, where the Leakyrelu activation function is added to the fully connected layer, and dropout is used to prevent the model from overfitting. The fully connected layer can effectively retain the extracted information, establish a mapping relationship between multi-scale input and photovoltaic power, and obtain a photovoltaic power prediction sequence. Attached Figure Description
[0025] Figure 1 This is a schematic diagram of the data processing flow of the present invention.
[0026] Figure 2 This is a schematic diagram of the MHATCN-TCN model of the present invention.
[0027] Figure 3 This is a schematic diagram of the first channel multi-feature data input of the present invention.
[0028] Figure 4 This is a schematic diagram of the photovoltaic output power (P) data input for the first channel of the present invention.
[0029] Figure 5 This is a graph showing the prediction curves of the MHATCN-TCN model and the MHATCN model.
[0030] Figure 6 This is the MHATCN-TCN model and MHATCN prediction scatter plot of the present invention. Detailed Implementation
[0031] To facilitate understanding of the present invention by those skilled in the art, specific embodiments of the present invention will be described below with reference to the accompanying drawings.
[0032] The first aspect of this application specifically involves dataset processing:
[0033] This study used photovoltaic (PV) power plant data from January 1, 2019 to November 21, 2020, taken from measured data of a power plant in China. The measured data included (PV output power (P), total irradiance (Ti), direct normal irradiance (Ni), horizontal irradiance (Hi), air temperature (At), air pressure (Ap), and relative humidity (Rh)). The measured data included 65,534 sample data points with a sampling interval of 15 minutes and an installed capacity of 30MW (with missing values for some days). 95% of the data was used as the training set (644 days), and the remaining 5% was used as the test set (29 days).
[0034] Preprocess the collected dataset:
[0035] First, outliers and missing values in the dataset are removed. Specifically, box plots are used to remove outliers from the sample data. Then, the upper and lower quartiles are calculated using statistical methods, and outliers outside the range of the upper and lower quartiles are removed. Finally, missing values are set to zero using the fillna function in the NumPy library of Python.
[0036] Then, due to the different units of measurement of different features and in order to facilitate training, the dataset was normalized to the minimum and maximum values. Specifically, the minimum and maximum values were normalized by the preprocessing method of the sklearn library in Python, so that the data in the dataset are located in the interval [0,1].
[0037] Finally, the processed dataset is constructed into a day-ahead prediction dataset. The goal is to use 3.5 days (336 points, ensuring predictions are made before noon each day) of photovoltaic power plant data to predict the photovoltaic power of the next day (96 points). First, a sliding window operation is used to convert the processed dataset into three-dimensional data (samples, timesteps, dimensions) to adjust it to the input shape required by the proposed model. Then, the obtained data is filtered so that the interval between two adjacent samples is 24 hours, which ensures that the corresponding photovoltaic power has a unique value, facilitating the training, evaluation, and visualization of the rolling prediction model. After that, the day-ahead short-term prediction data format is constructed, and the resulting day-ahead prediction data format is shown in Table 1.
[0038] Table 1: Forecast Data
[0039]
[0040] The second aspect of this application specifically involves the construction of an inventive model:
[0041] Since the convolution kernel size of the TCN model is fixed, in order to reduce the difficulty of extracting multi-scale spatiotemporal features from the input sequence, and to enhance the extraction of information on the influence of photovoltaic power at previous times on the current time, and to establish a nonlinear mapping relationship between multi-feature input and photovoltaic power, this invention proposes the MHATCN-TCN model based on the TCN model.
[0042] like Figure 2 The diagram shown is the structure of the MHATCN-TCN model, which includes an input layer, MHATCN-TCN modules, and an output layer.
[0043] The input layer contains multi-feature data (a combination of photovoltaic output power (P) and any of the following: total irradiance (Ti), normal direct irradiance (Ni), horizontal irradiance (Hi), air temperature (At), air pressure (Ap), and relative humidity (Rh)) (the multi-feature data includes these seven items, and the letters are abbreviations of a specific feature in this invention); the multi-feature data is output to the first channel of the MHATCN-TCN module; the separate photovoltaic output power (P) data is output to the second channel; I1 and I2 are the inputs to the dual channels of the MHATCN-TCN model, respectively.
[0044] The MHATCN-TCN module includes a first channel and a second channel.
[0045] The processed multi-feature data is input into the first channel, and the specific data is as follows: Figure 3 As shown, the first channel includes a Multi-Head Attention (MHA) mechanism and a Temporal Convolutional Neural Network (TCN). The number of heads in the MHA mechanism is equal to the number of input features. Internally, the MHA mechanism performs different spatial mappings on Q, K, and V in different heads. Based on this design, each head may focus on different parts of the input, which can represent functions that are more complex than a simple weighted average. The Q, K, and V of the MHA mechanism use the same input, and by default, its output shape is the same as the input shape, which facilitates the subsequent input to the Temporal Convolutional Neural Network (TCN). Subsequently, the output of the MHA mechanism is used as the input to the TCN mechanism, which can be used to summarize, extract, and learn the information input from the MHA mechanism.
[0046] Specifically, the first-channel multi-head attention mechanism (MHA) Each attention head h i The calculation expression for (i = 1, ..., h) is as follows:
[0047]
[0048] Where q (Queries), k (Keys), and v (Values) are the given inputs. For trainable parameters, the attention pooling function f is chosen to be scaled dot product attention.
[0049] The multi-head attention mechanism (MHA) then undergoes another linear transformation before its output is fed into a temporal convolutional neural network (TCN), corresponding to the result of concatenating h heads. Its trainable parameters are: The expression is as follows:
[0050]
[0051] Temporal Convolutional Neural Networks (TCNs) use skip connections, and the TCN expression is as follows:
[0052]
[0053] Where b is the batch size, f1 is the number of convolutional kernels (filters) in the Temporal Convolutional Neural Network (TCN), and F1 is the computation process of the existing TCN network.
[0054] The processed photovoltaic power is input into the second channel; see details below. Figure 4 The second channel employs a dual-layer TCN network. This dual-layer TCN network consists of causal convolutions, dilated convolutions, and residual connections. It not only possesses the advantages of parallelism and temporal causality but also allows for flexible adjustment of the receptive field, making it well-suited for processing time-series data and fully leveraging the temporal correlation of photovoltaic output power. Specifically, the dual-layer TCN network uses skip connections, and its input is... The expression is as follows:
[0055]
[0056] Where f2 is the number of convolution kernels in the two-layer TCN network, and F2 is the computation process of the existing TCN network.
[0057] The output layer of this application includes a fully connected neural network (Linear). The results from the two channels are then column-concatenated and input into the fully connected neural network to establish a mapping relationship between multi-scale input and photovoltaic power. Specifically, the dual-channel temporal convolutional neural network (TCN) filters are set to f1, and the two-layer TCN network filters are set to f2. The outputs are (b, f1) and (b, f2), which are then column-concatenated to (b, f), where f is f1 + f2. Column concatenation extracts and enriches the original data features, enhancing the learning ability of the subsequent fully connected neural network. The output is then input into the fully connected neural network (Linear), using three fully connected layers (with Leakyrelu as the activation function), and dropout prevents overfitting. The fully connected layer effectively preserves the extracted information, establishing a mapping relationship between multi-scale input and photovoltaic power, resulting in a photovoltaic power prediction sequence. Testing shows that the proposed model has good day-ahead short-term photovoltaic power prediction performance.
[0058] Specifically, the calculation expression for the last fully connected layer, i.e., the final output sequence Y, is as follows:
[0059]
[0060] Where s is the number of output sequences set, and C is the result of concatenating columns T1 and T2. f = f1 + f2, and These are trainable parameters.
[0061] The third aspect involves selecting the optimal feature from the multi-feature data input to the MHATCN-TCN model:
[0062] First, the proposed model was tested using different feature combinations to determine the feature combination with the highest accuracy. This dataset contains seven features: photovoltaic output power (P), total irradiance (Ti), direct normal irradiance (Ni), horizontal irradiance (Hi), air temperature (At), air pressure (Ap), and relative humidity (Rh). Table 2 shows the parameter settings for the MHATCN-TCN model when selecting the optimal features.
[0063] Table 2. Parameter settings for the MHATCN-TCN model during optimal feature selection.
[0064]
[0065] Based on the above parameter settings, and in order to represent the general level of each feature combination, this study used seven features in the dataset to conduct five experiments on different feature combinations and took the average value. The experimental results are shown in Table 3.
[0066] Table 3 Test results of optimal feature selection
[0067]
[0068] The results above show that the optimal combination of photovoltaic output power (P), total irradiance (Ti), direct normal irradiance (Ni), horizontal diffuse irradiance (Hi), and air pressure (Ap) is the best combination of characteristics.
[0069] The fourth aspect involves evaluating the performance of the trained model.
[0070] The next step will be to evaluate the performance of the MHATCN model and the MHATCN-TCN model, respectively, based on MAE, RMSE, and R. 2 The experimental results were evaluated from three perspectives; the parameters of the MHATCN model and the MHATCN-TCN model were set respectively, and the specific parameter settings are shown in Table 4.
[0071] Table 4. Specific parameter settings for the MHATCN and MHATCN-TCN models.
[0072]
[0073]
[0074] The final evaluation indexes for the MHATCN-TCN model of this invention were obtained as follows: MAE = 1.115, RMSE = 2.399, and R... 2 =0.880. Based on the accuracy calculation formula, the accuracy of the MHATCN-TCN model is calculated to be 96.28%.
[0075] The MHATCN model evaluation metrics errors are MAE = 1.279, RMSE = 2.585, and R0 = 0. 2 =0.839.
[0076]
[0077] Among them: P Mi Let P be the actual power at time i. Pi Let be the day-ahead short-term power forecast at time i, Cap be the total installed capacity of the photovoltaic power station, and n be the number of samples.
[0078] This invention increases the receptive field by changing the kernel size in the first channel and by changing the kernel size and the number of layers in the temporal convolutional neural network in the second channel. Thus, the proposed model can take into account the impact of the entire input sequence length (three and a half days) on the current output power.
[0079] Specifically, in the MHATCN-TCN model, the kernel size for the first channel is set to Kernel_size = 29; the kernel size for the second channel is set to Kernel_size = 15, and Nb_stacks = 2. This setting expands the receptive field of the TCN layer, ensuring that both channels of the TCN network cover the entire input time step, thus fully extracting the spatiotemporal feature information of the entire time step. Since the Nb_stacks of the first and second channels are different, the kernel size differs by nearly double according to the receptive field calculation formula. The following formula shows the calculation process of the receptive field:
[0080] R field =1+2·(K) size -1)·Nb_stacks·∑d i
[0081] In the formula, Σdi represents the number of dilated convolutional layers stacked in each residual block, and K size wei is the kernel size, d is the dilation coefficient, and Nb_stacks is the number of residual blocks.
[0082] In practical applications, the size of d can be set according to the time dimension of the input data so that the receptive field can cover all the input information; however, the accuracy of the MHATCN model drops sharply when the receptive field is increased to the same size, with an MAE of 1.638; therefore, we adjust the convolution kernel of the MHATCN model to a small size to reduce the difficulty of processing a large amount of information in a single channel at the same time.
[0083] like Figure 5 and Figure 6 The images show partial prediction results and scatter plots of predicted power for the MHATCN and MHATCN-TCN models, respectively, in the test set.
[0084] Depend on Figure 5 The prediction curve and Figure 6 The scatter plot shows that the MHATCN-TCN model has higher prediction accuracy and a better fit to the true value curve. The results shown in the figure are for 3 days. The reason why the MHATCN-TCN model has better prediction performance is that, based on the MHATCN model, the MHATCN-TCN model adds a separate channel to extract photovoltaic output power information, then concatenates it with the MHATCN channel to enhance the original features, and finally connects it with a fully connected neural network. Using the enhanced features, it mines the factors affecting photovoltaic output power, thereby establishing a nonlinear relationship. That is, the specific parallel processing mode of MHATCN-TCN has stronger extraction and learning capabilities when predicting photovoltaic power for the next day from the current short-term photovoltaic data.
[0085] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein; the specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.
[0086] The embodiments of the present invention described above do not constitute a limitation on the scope of protection of the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the claims of the present invention.
Claims
1. A training method for a day-ahead short-term photovoltaic power model, characterized in that, The method includes: After preprocessing the multi-feature photovoltaic data, the processed dataset is constructed into a day-ahead prediction dataset based on time scale division. The partitioned and constructed dataset is then input into the pre-defined MHATCN-TCN model for training. The MHATCN-TCN model includes an input layer, an MHATCN-TCN module, and an output layer. The input layer contains multi-feature data, all of which is output to the first channel of the HATCN-TCN module; the photovoltaic output power P data is output to the second channel. The MHATCN-TCN module includes a first channel and a second channel. The first channel consists of a multi-head attention mechanism (MHA) and a temporal convolutional neural network (TCN). The number of heads in the MHA is equal to the number of input features. Internally, the MHA performs different spatial mappings on Q, K, and V in different heads. Subsequently, the output of the MHA is used as the input to the TCN. The second channel uses a two-layer TCN network. The two-layer TCN network consists of causal convolution, dilated convolution, and residual connections. The output layer includes a fully connected neural network (Linear). Finally, the results from the two channels are concatenated and input into the fully connected neural network to establish a mapping relationship between multi-scale input and photovoltaic power.
2. The training method for a day-ahead short-term photovoltaic power model according to claim 1, characterized in that: The time-scale-based division specifically refers to a data start and end time of 3.5 days and a label start and end time of 1 day.
3. The training method for a day-ahead short-term photovoltaic power model according to claim 1, characterized in that: The data preprocessing specifically involves handling missing and outlier values, followed by data maximum and minimum normalization.
4. The training method for a day-ahead short-term photovoltaic power model according to claim 3, characterized in that: The method for constructing the current-day prediction dataset is as follows: First, the processed dataset is converted into three-dimensional data using a sliding window operation to adjust it to the input shape required by the proposed model; then, the obtained data is filtered so that the interval between two adjacent samples is 24 hours; the three-dimensional data consists of samples, timesteps, and dimensions.
5. The training method for a day-ahead short-term photovoltaic power model according to claim 1, characterized in that: The kernel size for the first channel is set to Kernel_size = 29; the kernel size for the second channel is set to Kernel_size = 15; Nb_stacks = 2.
6. The training method for a day-ahead short-term photovoltaic power model according to claim 1, characterized in that: The multi-feature data includes photovoltaic output power P, total irradiance Ti, normal direct irradiance Ni, horizontal diffuse irradiance Hi, and air pressure Ap.
7. A method for predicting short-term photovoltaic power, characterized in that: Acquire photovoltaic data with multiple features to be tested; The photovoltaic data with multiple features to be tested is input into the MHATCN-TCN model obtained by the training method of the day-ahead short-term photovoltaic power model according to claim 1 to obtain the photovoltaic predicted power.
8. An electronic device, characterized in that, It includes a memory and a processor; the memory is used to store a computer program; the processor is used to implement, when executing the computer program, the training method for the day-ahead short-term photovoltaic power model as described in claim 1, or the day-ahead short-term photovoltaic power prediction method as described in claim 7.
9. A computer-readable storage medium, characterized in that, The storage medium stores a computer program that, when executed by a processor, implements the training method for the day-ahead short-term photovoltaic power model as described in claim 1, or the day-ahead short-term photovoltaic power prediction method as described in claim 7.
Citation Information
Patent Citations
Solar photovoltaic power generation prediction method based on TCN-LSTM
CN110909926A
Power grid load prediction method, related device, equipment and storage medium
CN112288595A