A Reservoir Daily Runoff Prediction Method and System Based on Multi-Granularity Feature Decoupling Transformer
By constructing a multi-granularity feature decoupled Transformer model, combined with a conditional diffusion model and various constraints, the problem of poor prediction accuracy of daily runoff in reservoir inflow was solved, achieving higher prediction accuracy and robustness.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CENT CHINA BRANCH OF STATE GRID CORP OF CHINA
- Filing Date
- 2026-04-13
- Publication Date
- 2026-07-10
AI Technical Summary
Existing technologies have poor accuracy in predicting daily runoff in reservoirs, which is difficult to meet actual business needs, especially under small sample constraints and time series entanglement problems, where the improvement in prediction accuracy is limited.
A reservoir daily runoff prediction method based on multi-granularity feature decoupling Transformer is adopted. By constructing a multi-granularity feature decoupling Transformer model, data augmentation is performed by combining it with a conditional diffusion model. The multi-granularity feature decoupling module and the Transformer model are used to predict the daily runoff inflow into the reservoir. This includes the combination of the multi-granularity feature decoupling module and the Transformer model, the use of channel attention mechanism and multi-scale dilated convolution to learn multi-scale temporal characteristics, and the combination of various constraints for prediction.
It significantly improved the accuracy and robustness of reservoir inflow prediction, alleviated the problem of insufficient sample size, and achieved higher prediction accuracy and reliability.
Smart Images

Figure CN122365360A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of hydrological prediction technology, and in particular to a method and system for predicting daily runoff in reservoirs based on multi-granularity feature decoupling Transformer. Background Technology
[0002] Daily runoff forecasting for reservoirs is crucial for water resource allocation and management, flood control and drought relief decision-making, and the optimized operation of hydropower stations. Its accuracy directly impacts watershed water resource utilization efficiency and engineering safety. Traditional daily runoff forecasting primarily relies on conceptual hydrological models or physical distributed hydrological models. While these models possess clear physical mechanisms, they require numerous parameters, such as temperature, soil moisture, soil type, slope, and topography. Furthermore, the complex relationships between these parameters limit the predictive performance of traditional hydrological models.
[0003] In recent years, data-driven methods, represented by Artificial Neural Networks (ANNs), have shown great promise in the field of hydrological forecasting due to their powerful nonlinear mapping capabilities. Among them, Long Short-Term Memory (LSTM) networks and their variants have become the mainstream models for runoff prediction because they can effectively capture long-term dependencies in time series. Researchers have improved LSTM from different perspectives, with some combining stochastic variational inference with LSTM or introducing particle swarm optimization algorithms to optimize LSTM hyperparameters, achieving better results in flood prediction tasks for specific watersheds. Furthermore, the applicability of different model architectures varies across watersheds of different scales. Studies show that LSTM performs best in small watershed prediction and outperforms one-dimensional CNNs in predicting specific flood events, while convolutional neural networks (CNNs) and convolutional LSTMs (ConvLSTMs) are more advantageous in short-term prediction of large watersheds. With the evolution of deep learning technology, the Transformer model has received widespread attention in time series prediction tasks due to its parallel computing architecture and excellent long- and short-term dependency modeling capabilities. The model has been successfully extended to areas such as traffic flow forecasting, power load forecasting, and Yangtze River monthly runoff forecasting, demonstrating its potential to outperform traditional circular network models.
[0004] Although the above studies have greatly promoted the development of data-driven runoff forecasting, problems such as small sample constraints and temporal entanglement have limited the improvement of forecast accuracy and made it difficult to meet actual business needs. Summary of the Invention
[0005] This invention provides a method and system for predicting daily runoff in reservoirs based on multi-granularity feature decoupling Transformer, which addresses the shortcomings of poor accuracy in predicting daily runoff in reservoirs in existing technologies and improves the accuracy and robustness of daily runoff prediction.
[0006] In a first aspect, the present invention provides a method for predicting daily runoff in reservoirs based on multi-granularity feature decoupling Transformer, comprising: Acquire rainfall data from multiple rain gauge stations, flow data from multiple flow stations, and daily runoff data from reservoirs within the target watershed, and perform preprocessing to construct the original dataset; The original dataset was augmented using a conditional diffusion model to construct a training dataset. A multi-granularity feature decoupling Transformer model is constructed, comprising a multi-granularity feature decoupling module and a Transformer model. The multi-granularity feature decoupling module learns the multi-scale temporal characteristics of the input data through channel attention and multi-scale dilated convolution, and fuses them to obtain multi-granularity fused features. The Transformer model outputs the predicted daily runoff inflow to the reservoir based on the multi-granularity fused features. The multi-granularity feature decoupling Transformer model is trained using the training dataset, and the trained multi-granularity feature decoupling Transformer model is used to predict the daily runoff in the reservoir.
[0007] According to the present invention, a reservoir daily runoff prediction method based on multi-granularity feature decoupling Transformer is provided, which involves acquiring rainfall data from multiple rain gauge stations, flow data from multiple flow stations, and daily runoff data from reservoir inflow within a target watershed, and performing preprocessing to construct an original dataset, including: Rainfall data from multiple rain gauge stations, flow data from multiple flow stations, and daily runoff data from reservoir inflows within the target watershed are acquired and aligned by timestamps to construct multivariate time-series data. The multivariate time series data is smoothed and normalized to obtain a multivariate time series; wherein the smoothing process preserves the original values of the first and last moments and the peak moment. The original dataset is constructed based on the multivariate time series.
[0008] According to the present invention, a reservoir daily runoff prediction method based on multi-granularity feature decoupling Transformer is provided, wherein the method uses a conditional diffusion model to augment the original dataset and construct a training dataset, including: In the forward propagation of the conditional diffusion model, Gaussian noise is independently added to each channel of the multivariate time series. In the backward propagation of the conditional diffusion model, joint denoising is performed based on the previous state of the target watershed to learn the spatiotemporal patterns of the original dataset and generate candidate samples. The previous state includes at least the previous accumulated rainfall, soil moisture content, and baseflow level. Based on the original dataset, constraints are established to perform secondary screening of the candidate samples, and an enhanced dataset is formed based on the selected effective enhanced samples. The augmented dataset is merged with the original dataset to construct the training dataset.
[0009] According to the present invention, a reservoir daily runoff prediction method based on multi-granularity feature decoupling Transformer is provided, wherein the multi-granularity feature decoupling module includes a first channel attention module, a multi-scale dilated convolution module and a second channel attention module connected in sequence. The first channel attention module is used to compress the rainfall data of each rain gauge station and the flow data of each flow station into a single-channel representative feature sequence based on the contribution weight of the rainfall data of each rain gauge station and the flow data of each flow station in the adaptive learning input data. The multi-scale dilated convolution module is used to extract multi-scale temporal features from the single-channel representative feature sequence; The second channel attention module is used to adaptively weight and splice the multi-scale temporal characteristics to form multi-granularity fusion features.
[0010] According to the present invention, a reservoir daily runoff prediction method based on multi-granularity feature decoupling Transformer is provided, wherein the multi-scale dilated convolution module includes multiple parallel one-dimensional dilated convolution branches, and the dilation rate of each one-dimensional dilated convolution branch increases exponentially.
[0011] According to the present invention, a method for predicting daily runoff of reservoirs based on multi-granularity feature decoupling Transformer is provided, wherein the Transformer model includes an encoder and a decoder; The encoder is used to add the embedding encoding of the multi-granularity fusion feature and the embedding encoding of the sequence position to obtain an input representation vector, and then encode the input representation vector through a multi-head self-attention mechanism to obtain an encoding information matrix; The decoder is used to perform autoregressive decoding using the encoded information matrix as a condition and a masked multi-head self-attention mechanism to obtain the predicted daily runoff value of the reservoir inflow at the next sequence position. It then performs backpropagation training based on the prediction error of the predicted daily runoff value of the reservoir inflow and outputs the final predicted daily runoff value of the reservoir inflow.
[0012] According to the present invention, a reservoir daily runoff prediction method based on multi-granularity feature decoupling Transformer is provided, wherein the constraints include at least one of statistical feature constraints, flow rate change constraints, and spatiotemporal consistency constraints. The statistical characteristic constraints include at least one of the following: mean constraint, standard deviation constraint, and extreme value distribution constraint. The flow rate change constraint includes the flow rate change during the peak flood period being greater than or equal to a preset rate change threshold. The spatiotemporal consistency constraint includes the requirement that the difference in Frobenius norm between the Pearson correlation coefficient matrix between the candidate samples and the Pearson correlation coefficient matrix between the real samples in the original dataset is less than a preset difference threshold.
[0013] Secondly, the present invention also provides a reservoir daily runoff prediction system based on multi-granularity feature decoupling Transformer, comprising: The preprocessing module is used to acquire rainfall data from multiple rain gauges, flow data from multiple flow stations, and daily runoff data from reservoirs within the target watershed, and to preprocess these data to construct the original dataset. The data augmentation module is used to augment the original dataset using a conditional diffusion model to construct a training dataset; The model building module is used to construct a multi-granularity feature decoupling Transformer model, which includes a multi-granularity feature decoupling module and a Transformer model. The multi-granularity feature decoupling module learns the multi-scale temporal characteristics of the input data through channel attention and multi-scale dilated convolution, and fuses them to obtain multi-granularity fused features. The Transformer model outputs the predicted daily runoff inflow to the reservoir based on the multi-granularity fused features. The runoff prediction module uses the training dataset to train the multi-granularity feature decoupling Transformer model, and uses the trained multi-granularity feature decoupling Transformer model to predict the daily runoff inflow into the reservoir.
[0014] Thirdly, the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the reservoir daily runoff prediction method based on multi-granularity feature decoupling Transformer as described above.
[0015] Fourthly, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the reservoir daily runoff prediction method based on multi-granularity feature decoupling Transformer as described above.
[0016] Fifthly, the present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the reservoir daily runoff prediction method based on multi-granularity feature decoupling Transformer as described above.
[0017] The beneficial effects of the technical solutions provided by some embodiments of the present invention include at least the following: 1) This invention provides a method and system for predicting daily reservoir runoff based on multi-granularity feature decoupling Transformer. It constructs a multi-granularity feature decoupling Transformer model, including a multi-granularity feature decoupling module and a Transformer model. This model first learns the multi-scale temporal characteristics of historical data through the channel attention mechanism and multi-scale dilated convolution of the multi-granularity feature decoupling module, extracting fine-grained local features and coarse-grained global features in parallel, and fusing them to obtain multi-granularity fused features. Each position of these multi-granularity fused features represents the fusion of its multi-scale temporal information, achieving multi-granularity feature decoupling and improving the expressive power of the features. Finally, the Transformer model is used to predict the daily runoff in the reservoir, greatly improving the accuracy and robustness of the daily runoff prediction.
[0018] 2) This invention independently adds noise to each channel of the real samples in the original dataset through forward propagation of the conditional diffusion model, generates multiple candidate samples through conditional joint denoising through backpropagation, and designs multiple types of constraints to perform secondary screening of the generated candidate samples, thereby achieving data augmentation of this quality, effectively alleviating the problem of insufficient sample size, and effectively improving prediction accuracy. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0020] Figure 1 This is a flowchart illustrating the reservoir daily runoff prediction method based on multi-granularity feature decoupling Transformer provided in an embodiment of the present invention. Figure 2 This is a schematic flowchart of the preprocessing procedure provided in an embodiment of the present invention; Figure 3 This is a schematic flowchart of the data augmentation process provided in an embodiment of the present invention; Figure 4 This is a schematic diagram of the structure of the multi-granularity feature decoupling Transformer model provided in the embodiments of the present invention; Figure 5 This is a schematic diagram of the structure of the multi-granularity feature decoupling module provided in an embodiment of the present invention; Figure 6 This is a schematic diagram of the structure of a reservoir daily runoff prediction system based on multi-granularity feature decoupling Transformer provided in an embodiment of the present invention; Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0021] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0022] Please see Figure 1 , Figure 1 One of the flowcharts for a reservoir daily runoff prediction method based on multi-granularity feature decoupling Transformer, provided as an embodiment of the present invention, includes: S101. Obtain rainfall data from multiple rain gauge stations, flow data from multiple flow stations, and daily runoff data from reservoir inflow within the target watershed, and perform preprocessing to construct the original dataset. S102. Use the conditional diffusion model to augment the original dataset and construct the training dataset; S103. Construct a multi-granularity feature decoupling Transformer model that includes a multi-granularity feature decoupling module and a Transformer model; S104. Train a multi-granularity feature decoupling Transformer model using the training dataset, and use the trained multi-granularity feature decoupling Transformer model to predict the daily runoff in the reservoir.
[0023] This invention provides a method and system for predicting daily reservoir runoff based on multi-granularity feature decoupling Transformer. It constructs a multi-granularity feature decoupling Transformer model, including a multi-granularity feature decoupling module and a Transformer model. This model first learns the multi-scale temporal characteristics of historical data through the channel attention mechanism and multi-scale dilated convolution of the multi-granularity feature decoupling module, extracting fine-grained local features and coarse-grained global features in parallel, and fusing them to obtain multi-granularity fused features. Each position of these multi-granularity fused features represents the fusion of its multi-scale temporal information, achieving multi-granularity feature decoupling and improving the expressive power of the features. Finally, the Transformer model is used to predict the daily runoff in the reservoir, greatly improving the accuracy and robustness of the daily runoff prediction.
[0024] In step S101 above, observation data from multiple stations (rain gauges and flow stations) in the target watershed, as well as daily runoff data from the reservoir, are obtained, and a training dataset is constructed based on the data.
[0025] In some possible embodiments, rainfall data from multiple rain gauges, flow data from multiple flow stations, and daily runoff data from reservoir inflows within the target watershed are acquired, preprocessed, and used to construct an original dataset, including: S101-1. Obtain rainfall data from multiple rain gauge stations, flow data from multiple flow stations, and daily runoff data from reservoir inflows within the target watershed, align them by timestamp, and construct multivariate time series data. S101-2. Perform smoothing and normalization on the multivariate time series data to obtain a multivariate time series; among which, the smoothing process retains the original values of the first and last moments and the peak moment. S101-3. Construct the original dataset based on the multivariate time series.
[0026] Specifically, such as Figure 2 The diagram shows a flowchart of the preprocessing procedure provided in an embodiment of the present invention. Rainfall data from multiple rain gauge stations, flow data from multiple flow stations, and daily runoff data from reservoir inflows are aligned by timestamps to construct multivariate time-series data X0∈R. T×M , where T is the time step and M is the feature dimension, i.e. the number of channels in the multivariate time series data X0.
[0027] Considering the rapid changes in daily runoff, smoothing is performed on each channel of the multivariate time series data X0. During smoothing, the original value at the flood peak is retained, while the average value at other times is taken as a three-point average. That is, except for the first, last, and peak times, the flow rate at other times is taken as a three-point average, or the average value of the flow rate at the previous and next times. It is understandable that the flood peak is not processed because the peak flow rate needs to be recorded and compared for result comparison. Then, the smoothed multivariate time series data is normalized using the maximum-minimum method to obtain the multivariate time series X∈R. T×M .
[0028] After completing the above preprocessing such as smoothing and normalization, the resulting multivariate time series X includes preprocessed observation data from rain gauges and flow stations, as well as corresponding preprocessed daily runoff data from reservoirs. The original dataset is constructed using the preprocessed daily runoff data from reservoirs as sample labels.
[0029] In step S102 above, based on the original dataset, conditional data augmentation is performed using a conditional diffusion model. The samples generated by the conditional diffusion model constitute the augmented dataset, and the original dataset and the augmented dataset are merged to form the training dataset.
[0030] In some possible embodiments, the original dataset is augmented using a conditional diffusion model to construct a training dataset, including: S102-1. In the forward propagation of the conditional diffusion model, Gaussian noise is added independently to each channel of the multivariate time series. In the backward propagation of the conditional diffusion model, joint denoising is performed with the previous state of the target watershed as a condition to learn the spatiotemporal patterns of the original dataset and generate candidate samples. S102-2. Based on the original dataset, establish constraints to perform secondary screening of candidate samples, and form an enhanced dataset based on the selected effective enhanced samples. S102-3. Merge the augmented dataset with the original dataset to construct the training dataset.
[0031] Specifically, such as Figure 3 The diagram shown is a schematic flowchart of the data augmentation process provided in an embodiment of the present invention. The process of conditional data augmentation of the initial dataset using a conditional diffusion model in this embodiment can be divided into three stages: Phase 1 - Forward Diffusion: Input multivariate time series X∈R T×M Gaussian noise is added independently to each of the M channels, and the noise is diffused in T steps to obtain a pure noise state while maintaining time synchronization between stations. Phase 2 - Reverse Conditional Denoising: Using the pre-basin state c (pre-basin accumulated rainfall, soil moisture content, baseflow level, etc.) as conditions, noise prediction network ε is used to denoise the data. θ(x t The x, y, c) groups are used for joint denoising to gradually recover candidate samples that conform to the hydrological patterns of the watershed. Here, t represents time, x, c, and c are used for denoising. t Let X be the sequence at time t, and ε be the value of X. θ ( ) is the mapping function for the noise prediction network.
[0032] Phase 3 - Secondary Screening: Based on the original dataset, set constraints and remove invalid samples that deviate from the hydrological patterns of the watershed, thus obtaining the selected effective enhanced samples.
[0033] The augmented dataset, formed by the selected effective augmented samples, is merged with the real samples from the original dataset to form the training dataset. Specifically, the selected effective augmented samples are concatenated with the original dataset along the sample dimension to generate the final training dataset finalData∈R. (1+N')×T×M , where N' is the number of effective augmented samples after screening.
[0034] In some possible embodiments, the constraints include at least one of the following: statistical characteristic constraints, flow rate of change constraints, and spatiotemporal consistency constraints; Among them, statistical characteristic constraints include at least one of mean constraints, standard deviation constraints, and extreme value distribution constraints; The flow rate change constraint includes the runoff change rate during the peak flood period being greater than or equal to a preset change rate threshold; The spatiotemporal consistency constraint includes ensuring that the difference in Frobenius norm between the Pearson correlation coefficient matrix between candidate samples and the Pearson correlation coefficient matrix between real samples in the original dataset is less than a preset difference threshold.
[0035] Specifically, statistical characteristic constraints such as mean μ, standard deviation σ, and extreme value distribution can be set separately. For example, the range [μ-2.5σ, μ+2.5σ] for each channel can be calculated as an extreme value distribution constraint for the flood season (May-September) and the non-flood season, and values exceeding this range can be discarded.
[0036] Furthermore, constraints such as flow rate change and spatiotemporal consistency can be set based on physical rules, such as peak flow monotonicity and station correlation. For example, the flow rate change constraint can be set as follows: during the automatically identified peak flow period (flow Q exceeds the 90th quantile and continues to rise for ≥2 time steps), the runoff change rate should satisfy dQ / dt ≥ -0.05Q, allowing for 5% measurement noise.
[0037] For example, the spatiotemporal consistency constraint can be specifically: the difference in Frobenius norm between the inter-site Pearson correlation coefficient matrix corresponding to the generated candidate sample and the inter-site Pearson correlation coefficient matrix corresponding to the real sample in the original dataset is less than 0.2.
[0038] Invalid samples can be eliminated based on one or more of the above constraints. For example, if any channel exceeds the range of [μ-3σ, μ+3σ], or if abnormal fluctuations that violate physical monotonicity occur during the flood peak, it can be identified as an invalid sample.
[0039] Understandably, the conditional diffusion model and the augmented dataset obtained through secondary screening are only used in the training phase, while the validation and test datasets use only samples from the original dataset to avoid data leakage.
[0040] In step S103 above, a multi-granularity feature decoupling Transformer model is constructed for predicting the daily runoff of the reservoir inflow.
[0041] like Figure 4 As shown, Figure 4 This is a schematic diagram of the structure of a multi-granularity feature decoupling Transformer model provided in an embodiment of the present invention. The multi-granularity feature decoupling Transformer model includes a multi-granularity feature decoupling module and a Transformer model.
[0042] Among them, the multi-granularity feature decoupling module is used to learn the multi-scale temporal characteristics of the input data through the channel attention mechanism and multi-scale dilated convolution, and fuse them to obtain multi-granularity fusion features; the Transformer model is used to output the predicted value of the reservoir inflow daily runoff based on the multi-granularity fusion features.
[0043] For example, the channel attention mechanism can be selected as CMAB (Constant Memory Attention Block) channel attention, which can be applied to time-series processes and is suitable for modeling event sequences, such as the reservoir inflow daily runoff prediction of the present invention.
[0044] In some possible embodiments, the multi-granularity feature decoupling module includes a first channel attention module, a multi-scale dilated convolution module, and a second channel attention module connected in sequence. The first channel attention module is used to compress the rainfall data of each rain gauge station and the flow data of each flow station into a single-channel representative feature sequence based on the contribution weight of the rainfall data of each rain gauge station and the flow data of each flow station in the adaptive learning input data. The multi-scale dilated convolution module is used to extract multi-scale temporal features from a single-channel representative feature sequence; The second channel attention module is used to adaptively weight and splice multi-scale temporal characteristics to form multi-granularity fusion features.
[0045] Specifically, such as Figure 5The diagram shows the structure of the multi-granularity feature decoupling module provided by this invention. It decouples multivariate time series X∈R. n×M The input multi-granularity feature decoupling Transformer model uses a first-channel attention module to adaptively learn the contribution weights of data from each station (rain gauge, flow station) to the daily runoff data of the reservoir inflow. The channel weights α∈R M Satisfying softmax normalization, the channels of each station are weighted and fused to generate a single-channel representative sequence S∈R. n The single-channel representative sequence simultaneously achieves dimensionality reduction of multivariate time series to solve the problems of multi-source data fusion and dimensionality reduction.
[0046] In some possible embodiments, the multi-scale dilated convolution module includes multiple parallel one-dimensional dilated convolution branches, and the dilation rate of each one-dimensional dilated convolution branch increases exponentially.
[0047] Specifically, the multi-scale dilated convolution module takes a single-channel representative sequence S as input, and inputs the single-channel representative sequence S in parallel into k one-dimensional dilated convolution branches, where the dilation rate used in the i-th branch is dilation=2. i-1 A one-dimensional dilated convolution with a kernel size of 3, i=1,2,...,k.
[0048] For example, taking a sequence length seq_len=4, number of stations M=3, and k=3 scales as an example, the single-channel representative sequence S=[s1,s2,s3,s4] generated by the multi-granularity feature decoupling module can have its parameters set as follows: Branch 1 (dilation=1, receptive field 3): Extracts fine-grained local features h1=[h] on a scale of 1-2 days. 11 ,h 12 ,h 13 ,h 14 [Capture the rapid response of the watershed at adjacent time points;] Branch 2 (dilation=2, receptive field 5): Extract medium-grained features on a 3-5 day scale, h2=[h 21 ,h 22 ,h 23 ,h 24 [To capture short- to medium-term watershed evolution;] Branch 3 (dilation=4, receptive field 9): Extract coarse-grained global features on a 7-9 day timescale, h3=[h 31 ,h 32 ,h 33 ,h 34 [ ], to capture the slow evolution trend over a long period of time.
[0049] In this embodiment, the multi-scale dilated convolution module performs multi-granular temporal decomposition on the input single-channel representative sequence S through multiple parallel one-dimensional dilated convolution branches. The small dilation rate branch extracts fine-grained local features (fast response at adjacent time points), the large dilation rate branch extracts coarse-grained global features (slow evolution over long time), and so on.
[0050] The multi-scale dilated convolution module yields k branch features, each with a length of seq_len. These k branch features are then weighted and fused by the second-channel attention module to obtain a multi-granularity fused feature S'∈R with a length still of seq_len. seq_len×d Taking k=3 as an example in this embodiment, the output features h1, h2, h3 ∈ R of each branch are... 4 The second-channel attention module adaptively weights and fuses the features to learn the importance weights β∈R³ of features at different scales. Then, it adaptively weights and fuses the features to form a multi-granularity fused feature S'∈R. 4×d , where d is the dimension of the fused features. The representation of each position in S' fuses the information of that point and its multi-scale temporal neighborhood, achieving decoupling of multi-granularity features.
[0051] Understandably, after the second-channel attention module completes the fusion operation, the activation layer can use the ReLU activation function to activate the features, ensuring that the predicted values are not negative. After processing by the activation layer, the final multi-granularity fused feature S' is obtained, which will subsequently be used as input to the Transformer model.
[0052] In some possible implementations, the Transformer model includes an encoder and a decoder; The encoder is used to add the embedding encoding of multi-granularity fusion features and the embedding encoding of sequence positions to obtain the input representation vector. The input representation vector is then encoded through a multi-head self-attention mechanism to obtain the encoded information matrix. The decoder is used to perform autoregressive decoding with the encoded information matrix as a condition and through a masked multi-head self-attention mechanism to obtain the predicted daily runoff value of the reservoir inflow at the next sequence position. It then performs backpropagation training based on the prediction error of the predicted daily runoff value of the reservoir inflow and outputs the final predicted daily runoff value of the reservoir inflow.
[0053] Specifically, the encoder is used to add the embedding and position encoding to the multi-granularity fusion feature S', and then establish multi-granularity temporal dependencies through a multi-head self-attention mechanism to output the encoded information matrix C; The decoder is used to predict the daily runoff value of the reservoir inflow in future periods by using the encoded information matrix C as a condition and autoregressive decoding through a masked multi-head self-attention mechanism.
[0054] In step S104 above, the multi-granularity feature decoupling Transformer model established in step S103 is trained using the training dataset constructed in step S102, and the daily runoff of the reservoir inflow is predicted based on the trained multi-granularity feature decoupling Transformer model.
[0055] During the training phase, the training process may include the following steps: S104-1. Input the samples in the training dataset into the multi-granularity feature decoupling Transformer model. The multi-granularity feature decoupling Transformer model first decouples the multivariate time series site fusion and multi-granularity through the multi-granularity feature decoupling module to obtain the multi-granularity fusion feature S′. S104-2. The representation vector X is obtained by adding the positional encoding to S′ through embedding encoding. This vector is then fed into the encoder of the Transformer model. After passing through several encoder blocks, the encoding information matrix C for all sequences is obtained. The word vector matrix in the encoding information matrix C is... × This indicates that n is the sequence length and d is the dimension of the vector. The matrix output by each encoder block has the exact same dimensions as the input.
[0056] S104-3. The encoded information matrix C output by the encoder is passed to the decoder. The decoder will obtain the data i+1 of the next position according to the sequence 1~i of the current position.
[0057] During the operation, the data after position i+1 needs to be masked using a masking operation. The decoder receives the encoded information matrix C from the encoder, continuously predicts the data at position i+1, compares it with the original data, calculates the error, and completes the training of the entire model.
[0058] For example, the core code for the training process is: for epoch in tqdm(range(epochs)): train_loss = [] for batch_idx, (src, tgt) inenumerate(Dtr, 0): src, tgt=src.to(args.device), tgt.to(args.device) tgt=torch.cat([src[:, -1:, :], tgt], dim=1) tgt_mask=torch.tril(torch.ones(tgt.size(1), tgt.size(1)), diagonal=0)==0 tgt_mask=tgt_mask.to(args.device) optimizer.zero_grad() y_pred=model(src, tgt, tgt_mask) loss=loss_function(y_pred[:, :-1, 0], tgt[:, 1:, 0]) train_loss.append(loss.item()) loss.backward() optimizer.step() Here, src and tgt are constructed samples, where src represents the input_size variable values from the past seq_len time steps; and tgt represents the input_size variable values from the future output_size time steps. The goal of this invention is to predict the information of all variables from the future output_size time steps using all variable information from the past seq_len time steps.
[0059] In the Transformer model, a start symbol is required as initial input. The information from the previous time step of the current time step tgt is the start symbol. During the decoding process, the first t time steps in tgt only need to be calculated internally and do not involve subsequent time steps. Therefore, a mask tgt_mask can be constructed to feed all the information into the model for training.
[0060] In the prediction phase, the prediction set is predicted based on the trained multi-granularity feature decoupling Transformer model. The input data consists of rainfall data from the reservoir's rain gauge and flow data from the flow station, and the prediction result is the daily runoff inflow into the reservoir for the next time period.
[0061] First, the input data is decoupled and fused using the multi-granularity feature decoupling module of the Transformer model. Then, the resulting multi-granularity fused features are input into the Transformer model. The encoder of the Transformer model encodes the data from the previous seq_len time steps to obtain an encoding information matrix, which is then input into the model to obtain the prediction information for the next time step based on the time encoding.
[0062] Finally, the predicted results are compared with the actual daily runoff, and commonly used hydrological indicators such as the Nash coefficient and the coefficient of determination are calculated based on the predicted results to evaluate the prediction results.
[0063] For example, the core code of the Transformer model prediction process is as follows: for batch_idx, (src, tgt) in enumerate(Dte, 0): target=list(chain.from_iterable(tgt[:, :, 0].numpy().tolist())) y.extend(target) # greedy decode src, tgt=src.to(args.device), tgt.to(args.device) memory = model.encode(src) start_symbol=src[:,-1,:] ys=start_symbol.unsqueeze(1) for k in range(max_len): len_tgt=ys.shape[1] tgt_mask=torch.tril(torch.ones(len_tgt, len_tgt), diagonal=0)==0 tgt_mask=tgt_mask.to(args.device) out=model.decode(tgt=ys, memory=memory, tgt_mask=tgt_mask) out = out[:, -1:, :] ys=torch.cat([ys, out], dim=1) y_pred=ys[:, 1:, 0] y_pred=list(chain.from_iterable(y_pred.data.tolist())) pred.extend(y_pred) y, pred=np.array(y), np.array(pred) The main process is as follows: Encode the data from the previous seq_len time steps (src) to obtain memory; then, input... <bos>To obtain the predicted output for the first position, and <bos>Using the value of the previous time step (tgt) – i.e., the value of the last time step (src) – the decoder is used to obtain the output value, which represents the predicted values of all variables at the first time step. Then, the predicted values are appended to ys and used as the tgt for the next decoding round. This process is repeated continuously, with the last iteration representing the predicted values of all variables for the next output_size time steps – which is the desired predicted value.
[0064] Please see Figure 6 , Figure 6 A schematic diagram of a reservoir daily runoff prediction system based on multi-granularity feature decoupling Transformer, provided as an embodiment of the present invention, is shown. The system includes: The preprocessing module 610 is used to acquire rainfall data from multiple rain gauge stations, flow data from multiple flow stations, and daily runoff data from reservoir inflow within the target watershed, and to preprocess these data to construct the original dataset. Data augmentation module 620 is used to augment the original dataset using a conditional diffusion model to construct a training dataset; The model building module 630 is used to construct a multi-granularity feature decoupling Transformer model, which includes a multi-granularity feature decoupling module and a Transformer model. The multi-granularity feature decoupling module is used to learn the multi-scale temporal characteristics of the input data through channel attention mechanism and multi-scale dilated convolution, and fuse them to obtain multi-granularity fused features. The Transformer model is used to output the predicted daily runoff value of the reservoir inflow based on the multi-granularity fused features. The runoff prediction module 640 uses the training dataset to train the multi-granularity feature decoupling Transformer model, and uses the trained multi-granularity feature decoupling Transformer model to predict the daily runoff inflow into the reservoir.
[0065] The reservoir daily runoff prediction system based on multi-granularity feature decoupling Transformer described above and the reservoir daily runoff prediction method based on multi-granularity feature decoupling Transformer described above can be referred to each other.
[0066] Figure 7 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 7 As shown, the electronic device may include a processor 710, a communications interface 720, a memory 730, and a communication bus 740. The processor 710, communications interface 720, and memory 730 communicate with each other via the communication bus 740. The processor 710 can call logical instructions stored in the memory 730 to execute the reservoir daily runoff prediction method based on multi-granularity feature decoupling Transformer provided in the above-described method embodiments.
[0067] Furthermore, the logical instructions in the aforementioned memory 730 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0068] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer is able to execute a reservoir daily runoff prediction method based on multi-granularity feature decoupling Transformer provided in the above-described method embodiments.
[0069] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, is implemented to perform a reservoir daily runoff prediction method based on multi-granularity feature decoupling Transformer provided by the above methods.
[0070] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0071] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0072] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.< / bos> < / bos>
Claims
1. A method for predicting daily reservoir runoff based on multi-granularity feature decoupling Transformer, characterized in that, include: Acquire rainfall data from multiple rain gauge stations, flow data from multiple flow stations, and daily runoff data from reservoirs within the target watershed, and perform preprocessing to construct the original dataset; The original dataset was augmented using a conditional diffusion model to construct a training dataset. A multi-granularity feature decoupling Transformer model is constructed, comprising a multi-granularity feature decoupling module and a Transformer model. The multi-granularity feature decoupling module learns the multi-scale temporal characteristics of the input data through channel attention and multi-scale dilated convolution, and fuses them to obtain multi-granularity fused features. The Transformer model outputs the predicted daily runoff inflow to the reservoir based on the multi-granularity fused features. The multi-granularity feature decoupling Transformer model is trained using the training dataset, and the trained multi-granularity feature decoupling Transformer model is used to predict the daily runoff in the reservoir.
2. The reservoir daily runoff prediction method based on multi-granularity feature decoupling Transformer according to claim 1, characterized in that, The process involves acquiring rainfall data from multiple rain gauge stations, flow data from multiple flow stations, and daily runoff data from reservoir inflows within the target watershed, and preprocessing these data to construct the original dataset, including: Rainfall data from multiple rain gauge stations, flow data from multiple flow stations, and daily runoff data from reservoir inflows within the target watershed are acquired and aligned by timestamps to construct multivariate time-series data. The multivariate time series data is smoothed and normalized to obtain a multivariate time series; wherein the smoothing process preserves the original values of the first and last moments and the peak moment. The original dataset is constructed based on the multivariate time series.
3. The reservoir daily runoff prediction method based on multi-granularity feature decoupling Transformer according to claim 2, characterized in that, The process of using a conditional diffusion model to augment the original dataset and construct a training dataset includes: In the forward propagation of the conditional diffusion model, Gaussian noise is independently added to each channel of the multivariate time series. In the backward propagation of the conditional diffusion model, joint denoising is performed based on the previous state of the target watershed to learn the spatiotemporal patterns of the original dataset and generate candidate samples. The previous state includes at least the previous accumulated rainfall, soil moisture content, and baseflow level. Based on the original dataset, constraints are established to perform secondary screening of the candidate samples, and an enhanced dataset is formed based on the selected effective enhanced samples. The augmented dataset is merged with the original dataset to construct the training dataset.
4. The reservoir daily runoff prediction method based on multi-granularity feature decoupling Transformer according to claim 1, characterized in that, The multi-granularity feature decoupling module includes a first channel attention module, a multi-scale dilated convolution module, and a second channel attention module connected in sequence. The first channel attention module is used to compress the rainfall data of each rain gauge station and the flow data of each flow station in the multivariate time series used for adaptive learning into a single-channel representative feature sequence based on the contribution weight of the rainfall data of each rain gauge station and the flow data of each flow station to the daily runoff data of the reservoir. The multi-scale dilated convolution module is used to extract multi-scale temporal features from the single-channel representative feature sequence; The second channel attention module is used to adaptively weight and splice the multi-scale temporal characteristics to form multi-granularity fusion features.
5. The reservoir daily runoff prediction method based on multi-granularity feature decoupling Transformer according to claim 4, characterized in that, The multi-scale dilated convolution module includes multiple parallel one-dimensional dilated convolution branches, and the dilation rate of each one-dimensional dilated convolution branch increases exponentially.
6. The reservoir daily runoff prediction method based on multi-granularity feature decoupling Transformer according to claim 1, characterized in that, The Transformer model includes an encoder and a decoder; The encoder is used to add the embedding encoding of the multi-granularity fusion feature and the embedding encoding of the sequence position to obtain an input representation vector, and then encode the input representation vector through a multi-head self-attention mechanism to obtain an encoding information matrix; The decoder is used to perform autoregressive decoding using the encoded information matrix as a condition and a masked multi-head self-attention mechanism to obtain the predicted daily runoff value of the reservoir inflow at the next sequence position. It then performs backpropagation training based on the prediction error of the predicted daily runoff value of the reservoir inflow and outputs the final predicted daily runoff value of the reservoir inflow.
7. The reservoir daily runoff prediction method based on multi-granularity feature decoupling Transformer according to claim 3, characterized in that, The constraints include at least one of the following: statistical characteristic constraints, flow rate change constraints, and spatiotemporal consistency constraints. The statistical characteristic constraints include at least one of the following: mean constraint, standard deviation constraint, and extreme value distribution constraint. The flow rate change constraint includes the flow rate change during the peak flood period being greater than or equal to a preset rate change threshold. The spatiotemporal consistency constraint includes the requirement that the difference in Frobenius norm between the Pearson correlation coefficient matrix between the candidate samples and the Pearson correlation coefficient matrix between the real samples in the original dataset is less than a preset difference threshold.
8. A reservoir daily runoff prediction system based on multi-granularity feature decoupling Transformer, characterized in that, include: The preprocessing module is used to acquire rainfall data from multiple rain gauges, flow data from multiple flow stations, and daily runoff data from reservoirs within the target watershed, and to preprocess these data to construct the original dataset. The data augmentation module is used to augment the original dataset using a conditional diffusion model to construct a training dataset; The model building module is used to construct a multi-granularity feature decoupling Transformer model, which includes a multi-granularity feature decoupling module and a Transformer model. The multi-granularity feature decoupling module learns the multi-scale temporal characteristics of the input data through channel attention and multi-scale dilated convolution, and fuses them to obtain multi-granularity fused features. The Transformer model outputs the predicted daily runoff inflow to the reservoir based on the multi-granularity fused features. The runoff prediction module uses the training dataset to train the multi-granularity feature decoupling Transformer model, and uses the trained multi-granularity feature decoupling Transformer model to predict the daily runoff inflow into the reservoir.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the reservoir daily runoff prediction method based on multi-granularity feature decoupling Transformer as described in any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the reservoir daily runoff prediction method based on multi-granularity feature decoupling Transformer as described in any one of claims 1 to 7.