A short-term photovoltaic power prediction method based on patching-tcn-transformer
By using the Patching-TCN-Transformer method, which combines the TCN module and the Transformer model, the problems of incomplete data feature capture, high computational complexity, and noise interference in existing short-term photovoltaic power prediction are solved, and efficient and accurate prediction of photovoltaic power is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SICHUAN UNIV
- Filing Date
- 2026-04-03
- Publication Date
- 2026-07-10
AI Technical Summary
Existing short-term photovoltaic power prediction methods suffer from problems such as incomplete data feature capture, lack of local sensitivity, high computational complexity in long-term processing, random noise interference and local semantic loss, and imbalance between long-distance dependence and local feature extraction when dealing with high-dimensional data with high-frequency fluctuations.
The Patching-TCN-Transformer method is adopted. Local features are extracted through the TCN module, causal convolution and dilated convolution are introduced, and temporal patching is combined to divide photovoltaic data into feature patches. Then, global long-range dependency modeling is performed using Transformer to achieve deep and accurate prediction of photovoltaic power.
It improves the accuracy of short-term photovoltaic power forecasting, reduces computational complexity, enhances the macroscopic perception of photovoltaic power curves, and ensures the rigor and efficiency of the forecasting process.
Smart Images

Figure CN122371081A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of short-term photovoltaic power prediction, and specifically to a short-term photovoltaic power prediction method based on Patching-TCN-Transformer. Background Technology
[0002] Given the strong volatility, intermittency, and nonlinearity of photovoltaic power, existing short-term photovoltaic power prediction methods face the following specific technical bottlenecks and challenges when processing high-dimensional data with high-frequency fluctuations:
[0003] Incomplete data feature capture and lack of local sensitivity:
[0004] Existing prediction models struggle to accurately capture the multi-scale, cross-period evolution patterns in photovoltaic power sequences when faced with drastic local fluctuations caused by meteorological factors such as cloud cover and abrupt changes in irradiance. Particularly at inflection points of sudden power changes, models often exhibit significant prediction lag or large deviations, lacking the ability to efficiently extract local nonlinear evolution trends in the power curve.
[0005] Computational complexity and resource bottlenecks of long-running sequential processing:
[0006] With the increase in sampling frequency, the time series length of photovoltaic power increases significantly. When processing such long time series data, the core self-attention mechanism of existing native Transformer models follows a point-based computational logic, resulting in a quadratic increase in computational complexity with the length of the input sequence. This leads to significant computational redundancy and memory overhead during training and real-time inference on large-scale historical datasets, making it difficult to meet the timeliness requirements of power system dispatch for ultra-short-term forecasts.
[0007] High-frequency random noise interference and local semantic loss:
[0008] Photovoltaic power data contains a large number of random high-frequency components and acquisition noise. Traditional point-by-point input methods (such as native Transformer or RNN) treat each sampling point as an independent unit, lacking the ability to aggregate and recognize semantic information within local time periods. This fragmented input method not only easily amplifies the impact of random noise, but also makes it difficult for the model to identify mesoscale features such as the rise and fall edges of the power curve from a macroscopic perspective, thus limiting further improvements in prediction accuracy.
[0009] Imbalance between long-range dependency capture and local feature extraction:
[0010] Existing models often struggle to balance the refined extraction of local features with the macroscopic reconstruction of long-range global dependencies. While recurrent neural networks can extract temporal features, they are poor at capturing long-range correlations and have low computational efficiency; while the native Transformer excels at global modeling, it is weak in extracting local detailed features of sequences. Summary of the Invention
[0011] The purpose of this invention is to overcome the shortcomings of the prior art and provide a short-term photovoltaic power prediction method based on Patching-TCN-Transformer, which improves the accuracy of short-term photovoltaic power prediction.
[0012] This invention achieves the above objectives by adopting the following technical solution: This invention provides a short-term photovoltaic power prediction method based on Patching-TCN-Transformer, comprising:
[0013] S1. Obtain historical power output data of the photovoltaic power station and preprocess the data;
[0014] S2. Local feature extraction is performed using the TCN module;
[0015] The TCN module includes causal convolution, dilated convolution, and residual blocks;
[0016] By processing the input sequence through causal convolution, a causal constraint is introduced: the convolution output at time t is only operated on with the input units at and before time t, and is independent of any future information after time t.
[0017] In the convolutional layer, a dilation factor d is introduced. For the input sequence, the operation of the dilated convolution operator F at element s is as follows:
[0018] ;
[0019] in, Here, k is the convolution kernel function, and k is the kernel size.
[0020] Each residual block contains two layers of dilated causal convolutions, followed by an activation function layer and a weight normalization layer.
[0021] The TCN module, through its stacked residual block structure, enables deep extraction of local nonlinear fluctuation characteristics of photovoltaic power output while ensuring the temporal sequence.
[0022] S3. Perform time-series patching on the features output by the TCN module;
[0023] S4. Model global long-range dependencies using Transformer;
[0024] S5, Multi-step prediction output and inverse normalization, output prediction results.
[0025] Furthermore, in step S1, the preprocessing includes outlier handling and normalization.
[0026] Outlier handling: Perform linear interpolation on missing values in the data, and remove invalid or out-of-limit values caused by sensor malfunctions;
[0027] Normalization: Deviation normalization is used to map the original power data to the [0,1] interval to obtain the normalized sequence.
[0028] Furthermore, step S3 specifically includes: if the length of the feature sequence output by the TCN module is L, the set patch length is P, and the sliding step size is S, the sequence is divided into N patch blocks through a window sliding mechanism. If non-overlapping partitioning is used, the number of patches N = L / P, and each patch... The power fluctuation characteristics encompassing P consecutive time points are expressed as follows:
[0029] ;
[0030] Where D is the feature dimension;
[0031] The partitioned patch blocks are mapped to the same hidden layer dimensions as the subsequent Transformer model through a learnable linear projection layer, as follows:
[0032] ;
[0033] in, Let be the projection weight matrix. This is a bias term.
[0034] Furthermore, step S4 specifically includes:
[0035] Input the generated patch sequence into the Transformer encoder:
[0036] Position encoding: A position encoding vector PE is constructed using sine and cosine functions, and then combined with the patch embedding vector. Perform element-wise addition and add position information to each patch as follows:
[0037] ;
[0038] in, The initial input tensor for entering the self-attention layer;
[0039] Multi-head self-attention mechanism: Using patches as the basic unit, The mapping is represented by a query matrix Q, a key matrix K, and a value matrix V. The association weights between patches in different time periods are calculated in parallel using the following formula.
[0040] ;
[0041] Layer normalization and feedforward networks:
[0042] The output of the self-attention layer, after passing through residual connections and layer normalization, enters the position-by-point feedforward network:
[0043] ;
[0044] By employing a two-layer linear transformation and the ReLU activation function, the model's ability to map nonlinear features is enhanced, ultimately outputting a patch feature matrix containing global dependency information. .
[0045] Step S5 specifically includes:
[0046] Linear mapping involves linearly mapping the encoded feature matrix through a fully connected layer, as follows:
[0047] ;
[0048] in, This represents the normalized prediction sequence for the next M time points;
[0049] The predicted vectors for the next M time steps are directly output through linear mapping;
[0050] Inverse normalization, using the extreme value parameters from step S1, outputs the prediction using the following formula:
[0051] ;
[0052] in, This represents the final output, which is a predicted value of photovoltaic power output with real physical dimensions.
[0053] Finally, the power is converted back to its actual value in physical dimensions, thus completing the prediction.
[0054] The beneficial effects of this invention are as follows:
[0055] This invention introduces causal constraints to ensure the rigor of the photovoltaic prediction process and prevent information leakage.
[0056] This invention introduces a patching mechanism to aggregate consecutive time points into feature patches, significantly reducing the sequence length of the input Transformer and lowering the computational complexity of self-attention from... Reduced to the number of patches This improves the inference efficiency of the model when processing long-sequence photovoltaic data.
[0057] This invention utilizes a temporal patching mechanism to aggregate noisy sampling points into feature blocks with local semantic information. By extracting feature representations at the block level, high-frequency noise is filtered out, enhancing the model's macroscopic perception of the evolution of power curves (such as rising and falling trends).
[0058] While retaining the advantages of TCN in extracting local nonlinear features, this invention uses patched global modeling to enable the model to focus more on capturing inter-time correlations with physical meaning, thereby achieving a deep and accurate reconstruction of photovoltaic power trends and improving the accuracy of short-term and ultra-short-term photovoltaic power prediction. Attached Figure Description
[0059] Figure 1 This is a flowchart of a short-term photovoltaic power prediction method based on Patching-TCN-Transformer provided by an embodiment of the present invention;
[0060] Figure 2 This is a block diagram of the TCN module structure provided in an embodiment of the present invention;
[0061] Figure 3 This is a structural block diagram of the residual block provided in an embodiment of the present invention;
[0062] Figure 4 This is a flowchart of the timing patching process provided in an embodiment of the present invention;
[0063] Figure 5 This is a block diagram of the Transformer encoder structure provided in an embodiment of the present invention. Detailed Implementation
[0064] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings.
[0065] This invention provides a short-term photovoltaic power prediction method based on Patching-TCN-Transformer, such as... Figure 1 As shown, it specifically includes:
[0066] S1. Obtain historical power output data of the photovoltaic power station and preprocess the data;
[0067] Preprocessing includes outlier handling and normalization.
[0068] Outlier handling: Perform linear interpolation on missing values in the data, and remove invalid or out-of-limit values caused by sensor malfunctions;
[0069] Normalization: To eliminate the influence of dimensions and improve the model convergence speed, deviation normalization (Min-MaxNormalization) is used to map the original power data to the [0,1] interval to obtain the normalized sequence.
[0070] S2. Local feature extraction is performed using the TCN module;
[0071] The normalized temporal feature sequence after preprocessing in step S1 is input into the TCN (Temporal Convolutional Network) module.
[0072] like Figure 2 As shown, the TCN module, through a stacked residual block structure, achieves deep extraction of local nonlinear fluctuation characteristics of photovoltaic power output while ensuring the temporal order. The specific implementation scheme is as follows:
[0073] Causal convolution constraint:
[0074] This invention employs one-dimensional causal convolution to process the input sequence. Its core technical feature is that the convolution output at time t is only operated on with the input units at and before time t, and is independent of any future information after time t. This causal constraint ensures the rigor of the photovoltaic prediction process and avoids information leakage.
[0075] Dilated convolution operation based on dilation factor:
[0076] To expand the receptive field without increasing network depth, a dilation factor d is introduced into the convolutional layers for the input sequence. The operation of its dilated convolution operator F at element s is as follows:
[0077] ;
[0078] in, Here, k is the kernel function, k is the kernel size, and the superscript asterisk indicates a common convolution operator in the field of signal processing.
[0079] By setting an expansion factor that increases exponentially with the number of layers (e.g., d=1,2,4,8...), the TCN module can capture the dramatic fluctuations and evolution trends of photovoltaic power output over different time spans across multiple sampling points.
[0080] Residual connectivity and feature mapping:
[0081] like Figure 3 As shown, each residual block contains a dilated causal convolution, followed by a parameter regularization layer, an activation function layer, and a weight normalization layer.
[0082] Feature transformation: The input signal is transformed by the above convolution to obtain a nonlinear feature representation.
[0083] Skip connection: The TCN module passes the original input of the residual block directly across a branch and adds it element-wise with the output after convolution.
[0084] When the input and output dimensions are inconsistent, 1×1 convolution is used for dimension alignment. This residual structure effectively solves the gradient vanishing problem in deep neural networks when processing long-sequence photovoltaic data, ensuring that the model can stably output a feature tensor that incorporates multi-scale local fluctuation information.
[0085] S3. Perform time-series patching on the features output by the TCN module;
[0086] like Figure 4 As shown, the feature tensor with local fluctuation characteristics output in step S3 is subjected to temporal patching. This processing mechanism mimics the block logic in computer vision, aggregating continuous photovoltaic power feature points into feature blocks with "morphological semantics". The specific implementation scheme is as follows:
[0087] Patchwork partitioning of feature sequences:
[0088] If the length of the feature sequence output by the TCN module is L, the set patch length is P, and the sliding step size is S, and the sequence is divided into N patch blocks using a window sliding mechanism, then if non-overlapping partitioning is used, the number of patches N = L / P, and each patch... The power fluctuation characteristics encompassing P consecutive time points are expressed as follows:
[0089] ;
[0090] Where D is the feature dimension;
[0091] This step physically aggregates discrete sampling points together, initially filtering out single-point spike noise caused by sudden environmental changes.
[0092] Patch embedding and linear projection:
[0093] The partitioned patch blocks are mapped to the same hidden layer dimensions as the subsequent Transformer model through a learnable linear projection layer, as follows:
[0094] ;
[0095] in, Let be the projection weight matrix. This is a bias term.
[0096] The linear projection layer performs weighted aggregation of the temporal features within the patch to extract the "macromorphic features" of that period (e.g., the patch represents a period of uniform power increase or a period of violent fluctuations under cloud disturbance).
[0097] This step, through patching, reduces the number of tokens input to the subsequent self-attention mechanism from L to N, thereby reducing the computational complexity from L / N. Reduced to Since N=L / P (typically P≥16), computational overhead is reduced by an order of magnitude. This ensures a significant improvement in the system's online prediction efficiency while maintaining a long backtracking window to capture cross-period dependencies.
[0098] S4. Model global long-range dependencies using Transformer;
[0099] The generated patch sequence is input into the Transformer encoder, which is as follows: Figure 5 As shown.
[0100] Position encoding: A position encoding vector PE is constructed using sine and cosine functions, and then combined with the patch embedding vector. Element-wise addition is performed, and positional information is added to each patch so that the model can recognize the order of patches on the timeline, as follows:
[0101] ;
[0102] in, The initial input tensor for entering the self-attention layer;
[0103] Multi-head self-attention mechanism:
[0104] Using patches as the basic unit, The mapping is represented by a query matrix Q, a key matrix K, and a value matrix V. The correlation weights between patches in different time periods are calculated in parallel using the following formula. For photovoltaic forecasting, this mechanism can accurately capture macroscopic cross-time correlations such as the "early morning power output rise period" and the "afternoon power output decline period".
[0105] ;
[0106] Layer normalization and feedforward networks:
[0107] The output of the self-attention layer, after passing through residual connections and layer normalization, enters the position-by-point feedforward network:
[0108] ;
[0109] By employing a two-layer linear transformation and the ReLU activation function, the model's ability to map nonlinear features is enhanced, ultimately outputting a patch feature matrix containing global dependency information. .
[0110] S5, Multi-step prediction output and inverse normalization, output prediction results.
[0111] Linear mapping involves linearly mapping the encoded feature matrix through a fully connected layer, as follows:
[0112] ;
[0113] in, This represents the normalized prediction sequence for the next M time points;
[0114] The predicted vectors for the next M time steps are directly output through linear mapping;
[0115] Inverse normalization, using the extreme value parameters from step S1, outputs the prediction using the following formula:
[0116] ;
[0117] in, This represents the final output, which is a predicted value of photovoltaic power output with real physical dimensions.
[0118] Finally, the power is converted back to its actual value in physical dimensions, thus completing the prediction.
[0119] The above description is merely a preferred embodiment of the present invention. It should be understood that the present invention is not limited to the forms disclosed herein and should not be construed as excluding other embodiments. It can be used in various other combinations, modifications, and environments, and can be altered within the scope of the concept described herein through the above teachings or related technologies or knowledge. Modifications and variations made by those skilled in the art that do not depart from the spirit and scope of the present invention should be within the protection scope of the appended claims.
Claims
1. A short-term photovoltaic power prediction method based on Patching-TCN-Transformer, characterized in that, include: S1. Obtain historical power output data of the photovoltaic power station and preprocess the data; S2. Local feature extraction is performed using the TCN module; The TCN module includes causal convolution, dilated convolution, and residual blocks; By processing the input sequence through causal convolution, a causal constraint is introduced: the convolution output at time t is only operated on with the input units at and before time t, and is independent of any future information after time t. An expansion factor d is introduced into the convolutional layer for the input sequence. The operation of the dilated convolution operator F at element s is as follows: ; in, Here, k is the kernel function, k is the kernel size, and the superscript asterisk indicates a common convolution operator in the field of signal processing. Each residual block contains two layers of dilated causal convolutions, followed by an activation function layer and a weight normalization layer. The TCN module, through its stacked residual block structure, enables deep extraction of local nonlinear fluctuation characteristics of photovoltaic power output while ensuring the temporal sequence. S3. Perform time-series patching on the features output by the TCN module; S4. Model global long-range dependencies using Transformer; S5, Multi-step prediction output and inverse normalization, output prediction results.
2. The short-term photovoltaic power prediction method based on Patching-TCN-Transformer according to claim 1, characterized in that, In step S1, preprocessing includes outlier handling and normalization. Outlier handling: Perform linear interpolation on missing values in the data, and remove invalid or out-of-limit values caused by sensor malfunctions; Normalization: Deviation normalization is used to map the original power data to the [0,1] interval to obtain the normalized sequence.
3. The short-term photovoltaic power prediction method based on Patching-TCN-Transformer according to claim 1, characterized in that, Step S3 specifically includes: If the length of the feature sequence output by the TCN module is L, the set patch length is P, and the sliding step size is S, the sequence is divided into N patch blocks through a window sliding mechanism. If non-overlapping partitioning is used, the number of patches N = L / P, and each patch... The power fluctuation characteristics encompassing P consecutive time points are expressed as follows: ; Where D is the feature dimension; The partitioned patch blocks are mapped to the same hidden layer dimensions as the subsequent Transformer model through a learnable linear projection layer, as follows: ; in, Let be the projection weight matrix. This is a bias term.
4. The short-term photovoltaic power prediction method based on Patching-TCN-Transformer according to claim 3, characterized in that, Step S4 specifically includes: Input the generated patch sequence into the Transformer encoder: Position encoding: A position encoding vector PE is constructed using sine and cosine functions, and then combined with the patch embedding vector. Perform element-wise addition and add position information to each patch as follows: ; in, This is the initial input tensor for entering the self-attention layer; Multi-head self-attention mechanism: Using patches as the basic unit, The mapping is represented by a query matrix Q, a key matrix K, and a value matrix V. The association weights between patches in different time periods are calculated in parallel using the following formula. ; Layer normalization and feedforward networks: The output of the self-attention layer, after passing through residual connections and layer normalization, enters the position-by-point feedforward network: ; By employing a two-layer linear transformation and the ReLU activation function, the model's ability to map nonlinear features is enhanced, ultimately outputting a patch feature matrix containing global dependency information. .
5. The short-term photovoltaic power prediction method based on Patching-TCN-Transformer according to claim 4, characterized in that, Step S5 specifically includes: Linear mapping involves linearly mapping the encoded feature matrix through a fully connected layer, as follows: ; in, This represents the normalized prediction sequence for the next M time points; The predicted vectors for the next M time steps are directly output through linear mapping; Inverse normalization, using the extreme value parameters from step S1, outputs the prediction using the following formula: ; in, This represents the final output, which is a predicted value of photovoltaic power output with real physical dimensions. Finally, the power is converted back to its actual value in physical dimensions, thus completing the prediction.