Photovoltaic power generation power prediction method, network structure and device based on two-stage attention mechanism
By adopting a photovoltaic power generation prediction method based on a two-level attention mechanism, combining feature and temporal attention weighting with Bayesian networks, the robustness and interpretability issues of photovoltaic power generation prediction models in complex nonlinear systems are solved, achieving higher prediction accuracy and stability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-03
- Publication Date
- 2026-03-31
AI Technical Summary
Existing photovoltaic power generation prediction models struggle to improve robustness and interpretability while maintaining accuracy when dealing with complex nonlinear systems driven by multiple coupled factors. This is especially true under meteorological abrupt changes such as rapid cloud formations, where prediction accuracy and stability are insufficient.
A photovoltaic power generation prediction method based on a two-level attention mechanism is adopted. By fusing feature attention vector weighting and temporal attention weights, and combining Bayesian networks and KL regularization terms, a photovoltaic power generation prediction network structure is constructed to improve the interpretability and stability of key feature representation and historical time selection.
It improves the accuracy, robustness, and interpretability of photovoltaic power generation prediction, especially under sudden weather changes, and can better suppress noise characteristics and select reliable historical time steps, thereby improving prediction stability and model generalization ability.
Smart Images

Figure CN121769856A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of photovoltaic power generation prediction technology, and in particular to a photovoltaic power generation prediction method, network structure and device based on a two-level attention mechanism. Background Technology
[0002] Photovoltaic power generation forecasting is a crucial foundation for grid dispatching, energy storage coordination, consumption assessment, and power plant operation optimization. However, photovoltaic power generation is simultaneously affected by multiple environmental factors, including global irradiance, diffuse irradiance, humidity, wind speed, and air pressure, as well as their coupling relationships. Furthermore, it exhibits a significant autoregressive correlation with historical power, resulting in power series exhibiting strong nonlinearity, strong correlation, strong time-varying characteristics, and uncertainty. Under meteorological abrupt changes such as rapid cloud formations, short-term and drastic power fluctuations are more likely to induce noise characteristics, affecting the accuracy of forecasts.
[0003] When dealing with complex nonlinear systems like photovoltaic power, which are driven by multiple coupled factors and whose mapping relationships frequently switch under different operating conditions, existing models often require increasing network depth or width to improve fitting ability, leading to parameter inflation, increased risk of overfitting, and difficulty in interpretation. Therefore, there is a lack of a network structure that can provide stronger nonlinear expression and easier interpretation in both the time-series encoding and prediction / regression stages.
[0004] Based on the above problems, there is an urgent need for a new photovoltaic power prediction scheme that can form a more complete interpretable link with the attention mechanism, thereby improving the robustness and interpretability of the model while ensuring accuracy. Summary of the Invention
[0005] The purpose of this invention is to provide a photovoltaic power generation prediction method, network structure, and device based on a two-level attention mechanism to solve the above-mentioned technical problems.
[0006] The preferred technical solutions among the many technical solutions provided by this invention can produce a variety of technical effects, which are described in detail below.
[0007] To achieve the above objectives, the present invention provides the following technical solution: This invention provides a photovoltaic power generation prediction method based on a two-level attention mechanism, comprising the following steps: Extract the feature attention vector of the input features at each time step within the window, and weight the input features with the feature attention vector to obtain a weighted feature attention vector; Obtain the hidden state sequence of the weighted feature attention vector at each time step within the window to obtain dynamic evolution information for characterizing the historical sequence; Calculate contextual information representing the uncertainty or confidence level of the corresponding time step information based on the feature attention vector; Based on the hidden state sequence, the hidden state at the end of the window, and the context information, calculate the temporal attention weights for each time step within the window, and then perform weighted aggregation on the hidden state sequence based on the temporal attention weights to obtain the context vector; The photovoltaic power generation at the target prediction time point is predicted based on the context vector.
[0008] In one or more embodiments, before extracting the feature attention vector of the input features at each time step within the extraction window, the method further includes: Centered on the photovoltaic power generation at the target prediction time node, the contribution of input features to the prediction of photovoltaic power generation at the target prediction node is calculated, and a prior distribution of features is generated based on the prediction contribution.
[0009] In one or more embodiments, the feature prior distribution is further used as a reference distribution, and the feature attention distribution is constrained by a KL divergence regularization term.
[0010] In one or more embodiments, the feature prior distribution is further determined based on a temperature parameter adaptively determined by a Bayesian network prior uncertainty index, wherein the larger the prior uncertainty index, the larger the corresponding temperature parameter. The prior uncertainty index is obtained by resampling the training data or repeatedly learning the Bayesian network parameters using a rolling window approach, and by statistically analyzing the variance of the side coefficient matrix or the width of the confidence interval. Alternatively, the prior uncertainty index is calculated based on the node noise variance obtained from learning the parameters of a continuous Gaussian Bayesian network.
[0011] In one or more embodiments, the input features include a first input feature and a second input feature. The first input feature includes the photovoltaic power generation power of the previous node corresponding to the target prediction time node. The second input feature includes at least two of global irradiance, diffuse irradiance, humidity, wind speed, and air pressure.
[0012] In one or more embodiments, the prediction contribution is predicted by a continuous Gaussian Bayesian network; before predicting the prediction contribution, a scoring search combined with structural constraints is used to force the existence of a positive edge between the first input feature and the photovoltaic power generation at the target prediction time node, and to prohibit a negative edge between the photovoltaic power generation at the target prediction time node and the second input feature.
[0013] In one or more embodiments, the predicted contribution is calculated by a total effect matrix based on the network coefficient matrix, which is learned by a Bayesian network structure based on the first input feature and the second input feature.
[0014] In one or more embodiments, a regression prediction head is used to predict the photovoltaic power generation at the target prediction time point; When training the regression prediction head, the prediction loss is used as the main loss, and KL regularization is used in conjunction for optimization and updating. The coefficients of the KL regularization term adopt the temporal attention weights, and gradient propagation is stopped.
[0015] According to another aspect of the present invention, a photovoltaic power generation prediction network structure based on a two-level attention mechanism is also provided to implement the photovoltaic power generation prediction method based on a two-level attention mechanism described above. The structure includes an input layer, a priori generation branch, a feature attention branch, a temporal encoder, a context-specific temporal attention branch, a temporal convergence unit, a regression prediction branch, and a KL regularized loss bypass. The input layer, feature attention branch, temporal encoder, context-specific temporal attention branch, temporal convergence unit, and regression prediction branch are connected sequentially. The input layer, priori generation branch, and KL regularized loss bypass are connected sequentially. The context-specific temporal attention branch and regression prediction branch are both connected to the KL regularized loss bypass.
[0016] According to another aspect of the present invention, a photovoltaic power generation prediction device based on a two-level attention mechanism is also provided, comprising: The Bayesian network modeling module is used to calculate the contribution of input features to the prediction of photovoltaic power generation at the target prediction time node, with the photovoltaic power generation at the target prediction time node as the center. Importance analysis and prior distribution generation module, used to generate feature prior distributions based on predicted contributions; The feature attention module is used to extract the feature attention vector of the input features at each time step within the window, and to weight the input features with the feature attention vector to obtain a weighted feature attention vector; The KAN temporal coding module is used to obtain the hidden state sequence of the weighted feature attention vector at each time step within the window, so as to obtain dynamic evolution information for characterizing the historical sequence. The context vector calculation module is used to calculate context information representing the uncertainty or confidence of the corresponding time step information based on the feature attention vector; The context-specific temporal attention fusion module is used to calculate the temporal attention weights of each time step within the window based on the hidden state sequence, the hidden state at the end of the window, and the context information, and to perform weighted aggregation on the hidden state sequence based on the temporal attention weights to obtain a context vector. The prediction output module is used to predict the photovoltaic power generation at the target prediction time node based on the context vector.
[0017] Implementing one of the above-described technical solutions of the present invention has the following advantages or beneficial effects: This invention transforms the original multivariate time-series input into a sequence of key features and noise-suppressed features that are adaptively time-bound by weighting the input features and the feature attention vector. Furthermore, through two-level attention and time-series fusion, it simultaneously enhances the representation of key features and the selection of key historical moments, taking into account both short-term fluctuations and medium-term trends, thereby improving prediction accuracy, robustness, and interpretability. Attached Figure Description
[0018] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. In the drawings: Figure 1 This is a flowchart of a photovoltaic power generation prediction method based on a two-level attention mechanism according to an embodiment of the present invention; Figure 2 This is a schematic diagram of a photovoltaic power generation prediction network structure based on a two-level attention mechanism according to an embodiment of the present invention; Figure 3 This is a schematic diagram of a photovoltaic power generation prediction device based on a two-level attention mechanism according to an embodiment of the present invention. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of the present invention clearer, various exemplary embodiments described below will be referenced to the accompanying drawings, which form part of the exemplary embodiments, illustrating various exemplary embodiments that may be used to implement the present invention. Unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. It should be understood that they are merely examples of processes, methods, and apparatuses consistent with some aspects of the present invention disclosed as detailed in the appended claims, and other embodiments may be used, or structural and functional modifications may be made to the embodiments listed herein without departing from the scope and spirit of the present invention.
[0020] In the description of this invention, it should be understood that the terms "center," "longitudinal," "lateral," etc., indicate the orientation or positional relationship based on the accompanying drawings, and are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the referred element must have a specific orientation, or be constructed and operated in a specific orientation. The terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. The term "a plurality" means two or more. The terms "connected" and "linked" should be interpreted broadly, for example, they can refer to fixed connections, detachable connections, integral connections, mechanical connections, electrical connections, communication connections, direct connections, indirect connections through an intermediate medium, and can refer to the internal communication of two elements or the interaction relationship between two elements. The term "and / or" includes any and all combinations of one or more of the related listed items. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.
[0021] To illustrate the technical solution described in this invention, specific embodiments are described below, showing only the parts related to the embodiments of this invention.
[0022] Example 1: As Figure 1 As shown, this invention provides a photovoltaic power generation prediction method based on a two-level attention mechanism, comprising the following steps: S100. Extract the feature attention vector of the input features at each time step within the window, and weight the input features with the feature attention vector to obtain the weighted feature attention vector.
[0023] In this embodiment, a feature attention network is constructed to process each time step within the window. Input feature vector Output feature attention vector And by weighting the input features, we obtain This forms a weighted input sequence. , The time step span of the window. The starting time step of the window. This is the end time step of the window.
[0024] Furthermore, the aforementioned feature attention network can be implemented using one or more perceptrons, with the width of its hidden layer ranging from 16 to 256, preferably from 32 to 128.
[0025] To put it simply, the above method weights the input features with the feature attention vector, transforming the original multivariate time-series input into a sequence of key features and noise-suppressing features that are adaptive at each time step. This sequence is then stabilized under the following prior constraints, thereby simultaneously improving accuracy, robustness, and interpretability.
[0026] Specifically, to improve prediction accuracy: the downstream temporal KAN (Kolmogorov–Arnold Network) encoder receives data that highlights key features. Sequences are more likely to learn a dynamic evolutionary representation related to the target power, thereby improving the power prediction performance in the next time step.
[0027] Regarding improvements in interpretability and stability: Which features to emphasize at each moment can be directly determined by Explanation; plus KL (Kullback-Leibler) regular expressions (see below) Pulling towards BN (Bayesian Network) prior This can reduce weight drift between strongly correlated features and enhance the consistency and credibility of the explanation.
[0028] To improve robustness (especially in scenarios with sudden weather changes or noise): the weighting mechanism can suppress the interference of abnormal or low-value features on the encoder; at the same time, the credibility information formed by the attention entropy enters the second-level temporal attention, making the model more inclined to select more credible historical time steps for convergence, thereby improving unstable predictions under sudden conditions such as cloud changes.
[0029] In one or more embodiments, the above-mentioned input features include a first input feature and a second input feature. The first input feature includes the photovoltaic power generation of the node preceding the target prediction time node, and the second input feature includes at least two of the following: global irradiance, diffuse irradiance, humidity, wind speed, and air pressure.
[0030] In a specific embodiment, the first input feature is an autoregressive feature, preferably historical power. And optionally introduce , Equal lag term or power change rate This enhances the ability to model short-term fluctuations. The second input features also include ambient temperature, component temperature, solar altitude angle, and / or time encoding.
[0031] After obtaining the aforementioned input characteristics of the photovoltaic power station, timestamp alignment and resampling are performed to determine a uniform sampling interval. This generates multivariate time-series data with a uniform sampling interval. Subsequently, the acquired input features undergo data preprocessing, including: imputing or removing missing values, identifying and correcting outliers, and normalizing or standardizing the input features.
[0032] It should be noted that power can be normalized to the rated capacity. Continuous characteristics can be standardized or normalized, for example, irradiance and meteorological characteristics can be standardized with zero mean and unit variance.
[0033] In a specific embodiment, the length of the aforementioned window is: Sliding window length in accordance with The span of historical information to be captured is determined. Preferably, Take values from 6 to 288; for example, when =5min, A value of 12 to 72 can be selected to cover historical information ranging from 60 minutes to 360 minutes; when =15min, Values ranging from 8 to 32 can be used to cover historical information from 120 to 480 minutes. It is understood that these values are for illustrative purposes only and not as limitations; adjustments can be made based on the rate of meteorological change at each station and the quality of the data.
[0034] In a specific embodiment, the sliding window sample is constructed based on the window length. Construct the input sequence , tag as and will Included To enhance autoregressive modeling capabilities.
[0035] In one or more embodiments, before extracting the feature attention vector of the input features at each time step within the window, the method further includes: Centered on the photovoltaic power generation at the target prediction time node, the prediction contribution of input features to the photovoltaic power generation at the target prediction node is calculated, and a feature prior distribution is generated based on the prediction contribution. The feature prior distribution is determined based on the prediction contribution and a temperature parameter adaptively determined by the Bayesian network prior uncertainty index. The larger the prior uncertainty, the larger the temperature parameter, to make the prior distribution smoother and reduce the risk of over-biasing.
[0036] The aforementioned prediction contribution can be the importance weight of the input features to the photovoltaic power generation of the target prediction node, which is calculated through the total effect matrix based on the network coefficient matrix.
[0037] In a specific embodiment, the target node The importance of the input features in predicting the target is calculated around the center, resulting in an importance weight vector. The weight vector is then normalized to generate the feature prior distribution. . Specifically, The total effects matrix is as follows: I is the identity matrix with the same number of rows and columns as the transpose of B.
[0038] Furthermore, the construction of the network coefficient matrix B includes the following steps: Step 1: Prepare training data (multivariate time series samples). Use historical data from photovoltaic power stations for time alignment, resampling, cleaning, and normalization, then construct a sliding window sample: Input sequence: ,Label: and will Included (As an autoregressive feature).
[0039] The input features (input sequence and label) mentioned above include: the first type (autoregressive features), such as historical power. (This can be extended to hysteresis terms, power change rate, etc.); The second category (environmental / meteorological characteristics), such as global irradiance, diffuse irradiance, humidity, wind speed, air pressure, etc., may also include ambient temperature, component temperature, solar altitude angle, time coding, etc.
[0040] Step 2: Learn the Bayesian network structure based on the input sequence and labels.
[0041] Furthermore, a scoring search is used in conjunction with structural constraints, such as: Forced to exist Positive edges; prohibit The reverse edge is used to reduce prior distortion caused by reverse causality.
[0042] This step yields the information about "who is connected to whom" (network topology / DAG structure).
[0043] Step 3: Estimate the edge coefficients on the learned Bayesian network structure. Specifically, the edge coefficients are learned through the parameters of a continuous Gaussian Bayesian network.
[0044] For ease of understanding, each continuous node in a continuous Gaussian Bayesian network can typically be written in the form of "a linear combination of its parent nodes plus Gaussian noise". Parameter learning estimates: the linear coefficients (B) of each edge and the node noise variance (D). Thus, all edge coefficients can be summarized into a network coefficient matrix B.
[0045] Step 4: Calculate the total effect matrix G from the network coefficient matrix B.
[0046] Then extract the input features To the target The absolute value of the total effect is used as an indicator of importance: ; Then use the softmax function (with temperature parameter) The feature prior distribution is obtained.
[0047] For input features Its importance weight is Then add all the features. Collect them to obtain the importance weight vector. .
[0048] Will The feature prior distribution is obtained after softmax normalization: ; Among them, temperature parameter The prior uncertainty index of the Bayesian network is adaptively determined and can be limited to the range of 0.1~10 (preferably 0.5~5) to ensure numerical stability and controllable sharpness of the prior distribution.
[0049] In one or more embodiments, to reduce the dependence on manual parameter tuning due to fixed temperature parameters and to avoid the risk of excessive bias caused by prior distortion, the importance weight vector is obtained by a Bayesian network. Subsequently, the prior uncertainty index of the Bayesian network was further calculated. and according to Adaptive determination of temperature parameters , making The bigger The larger the value, the better. Preferably, the temperature parameter... It can be determined by any one or more of the following monotonically increasing mappings: and / or ; in, For stage functions, For the sigmoid function, , , , These are preset or learnable parameters. Using the above method, when the prior uncertainty of the Bayesian network is large, the temperature parameter... Increasing the temperature parameter makes the prior distribution of the softmax output smoother, thus making the constraint of KL regularization on feature attention more lenient; when the prior uncertainty is small, the temperature parameter... This reduces the prior guidance effect and improves the consistency and interpretability of feature contribution allocation.
[0050] In one embodiment, the aforementioned prior uncertainty index As a parameter uncertainty index, the Bayesian network parameter learning is performed repeatedly by resampling the training data B times (bootstrap) or using a rolling window approach to obtain the set of side coefficient matrices. The variance or confidence interval width of the edge coefficients is statistically analyzed to characterize parameter stability; preferably, only the variance of the edge coefficients related to the target prediction node is analyzed. The variance of the edge coefficients on the relevant edges or reachable paths is obtained by averaging or weighted summation. .
[0051] In one embodiment, the aforementioned prior uncertainty index As a structural uncertainty index, it records the set of candidate structures and their corresponding scores during the structure learning process of the scoring search. Structural stability is calculated based on the score difference between the optimal and suboptimal structures, or based on the frequency of edge occurrence in the candidate structures. The structural stability is then used to obtain... Preferably, the lower the frequency of edge occurrence or the smaller the difference in structural scores, then... The larger.
[0052] In one embodiment, the aforementioned prior uncertainty index The noise uncertainty index is calculated using the node noise variance D obtained from the parameter learning of a continuous Gaussian Bayesian network. Preferably, the node selected is the one that matches the target prediction node. The relevant node noise variances are then weighted and summed to obtain the results. The larger the noise variance, the greater the observation noise or model error. The larger.
[0053] For ease of understanding, temperature parameters Used to adjust the sharpness of the prior distribution. The smaller the prior distribution, the sharper it is, which is used to emphasize a small number of key features; The larger the value, the smoother the prior distribution, which is used to reduce the risk of excessive bias when the features are highly correlated or the side coefficients of BN (Bayesian Network) are unstable.
[0054] Furthermore, the prior distribution needs to be constrained by KL regularization to adjust the feature attention distribution. If the prior is too sharp, it will force feature attention onto a very small number of features, potentially damaging prediction performance; if it is too smooth, it will fail to provide prior guidance. The temperature parameter essentially adjusts this balance.
[0055] Furthermore, this method adaptively determines the temperature parameter η through the prior uncertainty index U, enabling the adjustment process—which dictates that "the more unreliable the prior, the smoother the prior, and the milder the KL constraint"—to be automatically completed data-driven, thereby reducing the prior bias risk during manual adjustment and cross-site migration. Additionally, when feature correlation is strong or the BN (Bayesian network) edge coefficients are unstable, a larger η can reduce the risk of over-biasing, aligning with photovoltaic data scenarios (where meteorological variables are often highly correlated, such as irradiance, temperature, and cloud cover). These are continuous values, and their dimensions and scale will vary depending on the site, variable set, and structure learning results. While direct softmax can normalize, the distribution shape is highly sensitive to scale changes. It's like a scale calibration knob, making priors easier to transfer across different datasets.
[0056] In one or more embodiments, the above-mentioned prediction contribution is predicted by a continuous Gaussian Bayesian network; before predicting the above-mentioned prediction contribution, a scoring search combined with structural constraints is used to force the existence of a positive edge between the first input feature and the photovoltaic power generation at the target prediction time node, and to prohibit the negative edge between the photovoltaic power generation at the target prediction time node and the second input feature.
[0057] To make it easier to understand, structure learning employs a scoring search combined with structural constraints: mandatory existence. Positive edges, and prohibition The reverse edge is used to reduce the risk of prior distortion caused by reverse causality.
[0058] Furthermore, by using the feature prior distribution as a reference distribution and constraining the feature attention distribution through the KL divergence regularization term, the feature attention can be kept consistent with the Bayesian network importance prior while being updated in a data-driven manner, thereby improving the stability and interpretability of feature contribution allocation.
[0059] In a specific embodiment, the above-described feature attention network focuses on each time step within the window. Output , For each time step The input features are unnormalized numerical values, and a weighted input is obtained. .
[0060] During the training phase, a KL regularization constraint is introduced to make... and Alignment: ; in, To predict losses, is the regularization coefficient.
[0061] The gradient descent-type optimization algorithm is used to minimize the loss function. Because time steps with larger temporal attention weights correspond to higher KL divergence regularization weighting coefficients, the feature attention distribution at that time step is subject to stronger prior constraints during training; simultaneously, for Applying a stopping gradient propagation technique can reduce gradient coupling between temporal attention and feature attention, thereby improving training stability.
[0062] The above KL regularization coefficients Desirable ~1, preferred ~ This aims to balance prior guidance with data adaptation. It can improve performance when strong correlations between features cause significant attention drift. When the operating conditions of the site change significantly or the prior knowledge drifts with the seasons, it can be reduced. .
[0063] Can be Employing a priori strength scheduling strategy: prioritizing larger values during the initial training phase. The priors of the BN (Bayesian Network) are quickly aligned and gradually decayed during the later stages of training. This could be to unleash the model's ability to fit the data; or, conversely, to take a smaller value in the early stages of training. To avoid underfitting, improve performance in the later stages of training. To stabilize attention allocation.
[0064] S200. Obtain the hidden state sequence of the weighted feature attention vector at each time step within the window to obtain dynamic evolution information used to characterize the historical sequence.
[0065] In a specific embodiment, the weighted input sequence described above is input into the KAN network to obtain the hidden state sequence h at each time step within the window. 1T = It is used to characterize the dynamic evolution information of historical sequences.
[0066] S300. Calculate contextual information representing the uncertainty or confidence of the corresponding time step information based on the feature attention vector.
[0067] Contextual information is obtained based on feature attention (feature attention network). This is used to reflect the uncertainty / confidence of the input information at this time step. The entropy of the feature attention distribution is preferably used as the uncertainty index. ,in For information entropy functions, Shannon entropy is preferred. When it is necessary to characterize credibility, a monotonically decreasing entropy transformation (e.g., -H( ) or 1-H ( ) / log(d)), where d is the number of input features.
[0068] S400. Based on the hidden state sequence, the hidden state at the end of the window, and the context information, calculate the temporal attention weights for each time step within the window. Then, weight and converge the hidden state sequence according to the temporal attention weights to obtain the context vector.
[0069] It should be noted that the above-mentioned window ends are in a hidden state. It can be a learnable query vector. It is obtained through the following method: Initialization state (e.g., a zero vector or a learnable query vector). For each time step The state is updated recursively and output as follows: , , h 2T = ; in, ( ) represents the state update mapping function based on the KAN network, which is used to map the concatenated vector of the previous state and the current input to the current hidden state. It can be implemented by one or more KAN networks and is not limited to a specific parameterization form. This represents a vector concatenation operation used to concatenate the states from the previous time step. With current input After concatenation by feature dimension, it becomes Input.
[0070] In a specific implementation, the temporal attention weights at each time step within the calculation window are... ,include: , in, Here, tanh is the normalization function, and tanh is the tangent function. The learnable parameter vector for hierarchical attention is used to perform inner product operations on the non-linearly transformed hidden representation, thus obtaining the attention score at the k-th time step. For vectors The transpose of W h W q W u These represent the window's hidden state. Hidden state sequence h 1T Contextual information The corresponding weights, where b is the fitting constant term.
[0071] The hidden state sequence is weighted and converged according to the temporal attention weights to obtain the context vector c: ,in , 。
[0072] S500: Predict the photovoltaic power generation at the target prediction time node based on the context vector.
[0073] In one or more embodiments, predicting the photovoltaic power generation at a target prediction time point based on a context vector includes: Input the context vector into the regression prediction head, and output the power prediction value for the next time node.
[0074] Furthermore, when training the regression prediction head, the prediction loss is used as the main loss, and KL regularization is used in conjunction for optimization and update; the coefficients of the KL regularization use temporal attention weights, and gradient propagation is stopped (stopgrad).
[0075] To put it simply, by using the temporal attention weights as weighting coefficients for the KL divergence regularization term, time steps with larger temporal attention weights can have higher prior alignment weights during optimization. Simultaneously, applying a gradient-stopping effect to this weighting coefficient ensures that the KL regularization term retains its weighted effect based on time step importance without updating the temporal attention branch back through this coefficient. This reduces gradient coupling between the two levels of attention and improves training stability. This approach enhances the prior guidance strength of key time steps, strengthens the targeting of prior constraints, reduces gradient coupling between the two levels of attention branches, decreases the risk of training instability, mitigates the conflict propagation between prior regularization and the prediction target, improves convergence stability, and improves model generalization performance (especially in scenarios with significant weather fluctuations).
[0076] In a specific embodiment, the regression prediction head is a KAN regression network to enhance nonlinear fitting ability and interpretability. Alternatively, a fully connected network or an MLP (Multilayer Perceptron) can also be used.
[0077] Furthermore, the hidden state dimension of the KAN regression network The number of KAN layers can be 16 to 512, preferably 64 to 256; the number of KAN layers can be 1 to 3, preferably 1 to 2; to suppress overfitting, dropout can be set between KAN layers or at the output, with dropout values of, for example, 0.05 to 0.5.
[0078] In summary, this embodiment predicts the contribution importance to form a prior distribution of features by inferring from continuous Gaussian Bayesian networks, and constrains the feature attention distribution by KL regularization, thereby reducing the random drift of attention between strongly correlated features and improving the stability and interpretability of feature contribution allocation. By introducing contextual information composed of feature attention uncertainty through context-specific temporal attention, it is possible to dynamically select a historical time step that is more reliable for the current prediction, thereby improving robustness to sudden weather changes such as cloud cover. By fusing two-level attention with a temporal KAN network, the expression of key features and the selection of key historical moments can be strengthened simultaneously, taking into account both short-term fluctuations and medium-term trends, thereby improving the accuracy of power prediction. By using temporal attention weights to weight the KL regularization term and stopping gradient propagation, important time steps are more aligned with priors and the training process is more stable, thus improving the model's generalization ability.
[0079] Example 2: Figure 2 As shown, this invention also provides a photovoltaic power generation prediction network structure based on a two-level attention mechanism, used to implement the photovoltaic power generation prediction method based on a two-level attention mechanism described in Embodiment 1. It includes an input layer, a priori generation branch, a feature attention branch, a temporal encoder, a context-specific temporal attention branch, a temporal convergence unit, a regression prediction branch, and a KL regularized loss bypass. The input layer, feature attention branch, temporal encoder, context-specific temporal attention branch, temporal convergence unit, and regression prediction branch are connected sequentially. The input layer, priori generation branch, and KL regularized loss bypass are also connected sequentially. The context-specific temporal attention branch and regression prediction branch are both connected to the KL regularized loss bypass. The input layer, feature attention branch, temporal encoder, context-specific temporal attention branch, temporal convergence unit, and regression prediction branch constitute the backbone forward link. The KL regularized loss bypass is connected to the priori generation branch and the feature attention branch, used to construct the joint loss and participate in training optimization. The input layer receives the input features described in Embodiment 1, namely the input history window sequence. , d represents the dimension.
[0080] Prior generation branches, loaded with a continuous Gaussian Bayesian network, output structure and coefficient matrix. Noise variance Calculate the input features' impact on the target based on direct side contributions or total effect contributions. Contribution weight ,Will The prior distribution is obtained and output through softmax normalization. ; The feature attention path is loaded with a KAN network, which is the first-level attention in Example 1. For each time step k, it uses... (Optionally, a small amount of context is concatenated) as input, and the MLP outputs logits (the original output value of the last layer, the unnormalized score vector of feature attention). Then, it is obtained by softmax normalization. ,calculate Output weighted sequence .
[0081] A timing encoder loaded with a KAN network, based on a weighted input sequence. Output timing representation sequence The timing encoder can be implemented in any of the following ways: Recursive update: for ,make and take ; Time-by-time encoding: for ,make .
[0082] Context-specific temporal attention branch, which is the second-level attention in Implementation 1, uses computational context information to generate feature attention. Calculate uncertainty (Optimal Entropy) ), to obtain the sequence ; Calculate the context-specific temporal attention unit input and ,by As a query (or learnable query), calculate the time-scoring sequence. The temporal attention weight sequence is obtained by softmax normalization. Output temporal attention vector .
[0083] Temporal convergence unit, calculates context vector: .
[0084] The regression prediction branch, loaded with a KAN regression network, takes the context vector c as input to the regression prediction head and outputs... .
[0085] The KL regularized loss bypass receives the feature attention distribution and the BN prior distribution during the training phase, and together with the prediction loss, constructs the joint loss. It receives the feature attention distribution during the training phase. Prior distribution of BN Bayesian network Calculate the KL divergence ( The loss is calculated by combining the temporal attention weights with the prediction loss to construct a joint loss L, which is then used for network parameter optimization. Preferably, the temporal attention weights are used as the practical part weighting coefficients of the KL regularization term, and a stopping gradient propagation is applied to the temporal attention weights to reduce gradient coupling between temporal attention branches. The joint loss can be expressed as: .
[0086] in, To predict power for the model, This represents the actual power. The coefficients of the KL regularization term, Let the temporal attention weights be those for the k-th time step. Let be the mean square error function. It is a summation function that represents the accumulation of terms over each historical time step k. This is the operation to stop gradient propagation during forward computation. The value is During backpropagation, the gradient is prevented from propagating back through this location. It is a calculation Compared to The KL divergence.
[0087] It should be noted that the technical features not involved in this embodiment are consistent with those in Embodiment 1.
[0088] Example 3: Figure 3 As shown, the present invention also provides a photovoltaic power generation prediction device based on a two-level attention mechanism, comprising: The Bayesian network modeling module is used to calculate the contribution of input features to the prediction of photovoltaic power generation at the target prediction time node, centered on the photovoltaic power generation at the target prediction time node.
[0089] Importance analysis and prior distribution generation module, which generates feature prior distributions based on predicted contributions.
[0090] The feature attention module is used to extract the feature attention vector of the input features at each time step within the window, and to weight the input features with the feature attention vector to obtain a weighted feature attention vector.
[0091] The KAN temporal coding module is used to obtain the hidden state sequence of the weighted feature attention vector at each time step within the window, thus obtaining dynamic evolution information to represent the historical sequence.
[0092] The context vector calculation module is used to calculate context information representing the uncertainty or confidence of the corresponding time step information based on the feature attention vector.
[0093] The context-specific temporal attention fusion module is used to calculate the temporal attention weights at each time step within the window based on the hidden state sequence, the hidden state at the end of the window, and context information. The hidden state sequence is then weighted and converged according to the temporal attention weights to obtain the context vector.
[0094] The prediction output module is used to predict the photovoltaic power generation at the target prediction time node based on the context vector.
[0095] Furthermore, it also includes: The data acquisition module is used to acquire historical operating condition time-series data and perform time alignment; the operating condition data includes environmental characteristic data and power data.
[0096] The data preprocessing module is used to handle missing or abnormal operating data, normalize the processed operating data, and construct sliding window samples.
[0097] It should be noted that the technical features not involved in this embodiment are consistent with those in Embodiment 1.
[0098] The above description is merely a preferred embodiment of the present invention. Those skilled in the art will understand that various changes or equivalent substitutions can be made to these features and embodiments without departing from the spirit and scope of the present invention. Furthermore, under the teachings of the present invention, these features and embodiments can be modified to adapt to specific situations and materials without departing from the spirit and scope of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed herein, and all embodiments falling within the scope of the claims of this application are within the protection scope of the present invention.
Claims
1. A photovoltaic power generation power prediction method based on a two-level attention mechanism, characterized in that, The method comprises the following steps: extracting a feature attention vector of input features at each time step in a window, weighting the input features with the feature attention vector to obtain a weighted feature attention vector; obtaining a hidden state sequence of the weighted feature attention vector at each time step in the window to obtain dynamic evolution information for representing a history sequence; calculating context information representing information uncertainty or reliability of a corresponding time step according to the feature attention vector; calculating a time sequence attention weight of each time step in the window according to the hidden state sequence, a hidden state at the end of the window and the context information, weighting and converging the hidden state sequence according to the time sequence attention weight to obtain a context vector; predicting the photovoltaic power at the target prediction time node according to the context vector.
2. The photovoltaic power generation power prediction method based on a two-level attention mechanism according to claim 1, characterized in that, Before the step of extracting the feature attention vector of the input features at each time step in the window, the method further comprises: centering on the photovoltaic power at the target prediction time node, calculating a prediction contribution of the input features to the photovoltaic power at the target prediction node, and generating a feature prior distribution according to the prediction contribution.
3. The photovoltaic power prediction method based on a two-stage attention mechanism according to claim 2, characterized in that, The method further comprises taking the feature prior distribution as a reference distribution and constraining a feature attention distribution by a KL divergence regularization term.
4. The photovoltaic power prediction method based on a two-stage attention mechanism according to claim 2, characterized in that, The feature prior distribution is further determined according to a temperature parameter adaptively determined according to a Bayesian network prior uncertainty index, wherein the larger the prior uncertainty index is, the larger the temperature parameter is; The prior uncertainty index is obtained by repeatedly learning parameters of the Bayesian network through resampling of training data or in a rolling window manner, and then calculating a variance or a confidence interval width of an edge coefficient matrix, Or, the prior uncertainty index is calculated according to a node noise variance obtained by learning parameters of a continuous Gaussian Bayesian network.
5. The photovoltaic power generation power prediction method based on a two-level attention mechanism according to claim 2, characterized in that, The input features comprise a first input feature and a second input feature, the first input feature comprises a photovoltaic power at a previous node corresponding to the target prediction time node, and the second input feature comprises at least two of global irradiance, scattered irradiance, humidity, wind speed and air pressure.
6. The photovoltaic power prediction method based on a two-stage attention mechanism according to claim 5, characterized in that, The prediction contribution is predicted by a continuous Gaussian Bayesian network; before predicting the prediction contribution, a score search is adopted and combined with a structure constraint to force a positive edge between the first input feature and the photovoltaic power at the target prediction time node and to prohibit a reverse edge between the photovoltaic power at the target prediction time node and the second input feature.
7. The photovoltaic power generation power prediction method based on a two-level attention mechanism according to claim 6, characterized in that, The prediction contribution is calculated by a total effect matrix based on a network coefficient matrix, and the network coefficient matrix is obtained by learning parameters of a Bayesian network according to the first input feature and the second input feature.
8. The photovoltaic power generation power prediction method based on a two-level attention mechanism according to claim 1, characterized in that, A regression prediction head is used to predict the photovoltaic power at the target prediction time node; When training the regression prediction head, a prediction loss is taken as a main loss, and a KL regularization term is used for optimization and updating; A coefficient of the KL regularization term is the time sequence attention weight, and gradient propagation is stopped.
9. A photovoltaic power generation power prediction network structure based on a two-level attention mechanism, characterized in that, The photovoltaic power prediction method based on a two-stage attention mechanism comprises an input layer, a prior generation branch, a feature attention branch, a time series encoder, a context-specific time series attention branch, a time series aggregation unit, a regression prediction branch, and a KL regularization loss bypass. The input layer, the feature attention branch, the time series encoder, the context-specific time series attention branch, the time series aggregation unit, and the regression prediction branch are sequentially connected, the input layer, the prior generation branch, and the KL regularization loss bypass are sequentially connected, and the context-specific time series attention branch and the regression prediction branch are both connected with the KL regularization loss bypass.
10. A photovoltaic power generation power prediction device based on a two-stage attention mechanism, characterized by, The method comprises the following steps: A Bayesian network modeling module is used to calculate the prediction contribution of input features to the photovoltaic power at a target prediction time node; An importance analysis and prior distribution generation module is used to generate a feature prior distribution according to the prediction contribution; A feature attention module is used to extract a feature attention vector of input features at each time step in a window, and to obtain a weighted feature attention vector by weighting the input features and the feature attention vector; A KAN time series encoding module is used to obtain a hidden state sequence of the weighted feature attention vector at each time step in the window, and to obtain dynamic evolution information for representing a historical sequence; A context vector calculation module is used to calculate context information representing the uncertainty or reliability of information at a corresponding time step according to the feature attention vector; A context-specific time series attention fusion module is used to calculate a time series attention weight at each time step in the window according to the hidden state sequence, the hidden state at the end of the window, and the context information, to weight and aggregate the hidden state sequence according to the time series attention weight, and to obtain a context vector; A prediction output module is used to predict the photovoltaic power at the target prediction time node according to the context vector.
Citation Information
Patent Citations
An Attention LSTM-based photovoltaic power generation power prediction model and a construction method thereof
CN109886492A
Aluminum electrolysis mixing data superheat degree prediction method based on attention mechanism
CN114444811A