Runoff prediction method and device, electronic equipment and computer readable storage medium
By combining the self-attention model and the conditional diffusion probability model, the problems of gradient vanishing and the inability of deterministic prediction to quantify uncertainty in runoff forecasting are solved, and accurate prediction and risk assessment of long-series data are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG YUANSUAN TECH CO LTD
- Filing Date
- 2026-05-06
- Publication Date
- 2026-07-14
AI Technical Summary
Existing runoff forecasting techniques suffer from the vanishing gradient problem when processing long-series data, making it difficult to effectively capture the hydrological lag effect over long periods of time. Furthermore, the Transformer architecture model cannot quantify the randomness and uncertainty of the forecast results.
A self-attention model is used to capture long-range hydrological time-series dependencies between different time steps within a historical period, generating global contextual features. Multiple back-diffusion processes are then performed using a conditional diffusion probability model to generate multiple predicted runoff time series. Specified quantiles are calculated to construct confidence intervals to quantify the uncertainty of the prediction results.
It effectively captures the hydrological lag effect over long periods and quantifies the uncertainty of runoff prediction results, providing runoff prediction information that includes risk probability distribution, thereby improving the accuracy and reliability of predictions.
Smart Images

Figure CN122132784B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of hydrological and water resources engineering technology, and in particular to a runoff prediction method, device, electronic equipment, and computer-readable storage medium. Background Technology
[0002] Runoff refers to the volume of water that falls to the ground, such as rainwater and snowmelt, and flows into rivers. Runoff forecasting refers to predicting how much rainwater and snowmelt will fall to the ground each day over the next few days, ultimately flowing into rivers and forming a measurable flow. Runoff forecasting is fundamental to watershed flood control and disaster reduction, optimal reservoir scheduling, and water resource management. Influenced by climate change and altered underlying surface conditions, the rainfall-runoff relationship in watersheds exhibits strong nonlinearity and uncertainty. Accurate runoff forecasts that include risk assessment (i.e., probability distribution) are crucial for ensuring watershed safety.
[0003] Existing runoff prediction technologies are mainly divided into physical causal models (texture models) and data-driven models (deep learning models). Physical causal models have clear mechanisms, but parameter calibration is complex (i.e., parameters are difficult to determine). Data-driven models include recurrent neural networks such as LSTM and GRU, and Transformer architecture models.
[0004] Traditional recurrent networks suffer from the vanishing gradient problem when processing long-sequence data, making it difficult to effectively capture the hydrological lag effect over long periods. For example, if it is shown data from the past 60 days, it will forget data from 30 days ago, resulting in inaccurate predictions.
[0005] Although the Transformer architecture (which belongs to the data-driven model) solves the long-range dependency problem (i.e. remembering long-term series data) through the self-attention mechanism, it is usually used for deterministic point prediction and cannot quantify the randomness and uncertainty of the prediction results. That is, it only gives point predictions and cannot give prediction intervals. Summary of the Invention
[0006] In view of this, the purpose of this application is to provide a runoff prediction method, apparatus, electronic device and computer-readable storage medium to avoid gradient vanishing when processing long sequence data and to output the probability distribution of the prediction results and quantify the uncertainty of the prediction.
[0007] In a first aspect, embodiments of this application provide a runoff prediction method, including:
[0008] Obtain the forecast meteorological time series of the target watershed during the period to be predicted, as well as the historical meteorological time series and historical runoff time series for the historical period;
[0009] The historical meteorological time series and the historical runoff time series are input into the trained self-attention model so that the self-attention model can capture the long-range hydrological time series dependencies between different time steps in the historical period through the self-attention mechanism while avoiding gradient vanishing, and generate global context features that characterize the runoff generation and confluence state of the target watershed in the historical period based on the long-range hydrological time series dependencies.
[0010] The forecast meteorological time series, the global context features, and the initial noise data are input into the trained conditional diffusion probability model. The conditional diffusion probability model is used to perform multiple backdiffusion processes. In each iteration of each backdiffusion process, cross-attention is calculated using the current denoised intermediate feature as the query and the global context features as the key and value to obtain attention enhancement features. Based on the attention enhancement features, the initial noise data is iteratively denoised under the guidance of the runoff generation and confluence state represented by the global context features to generate multiple predicted runoff time series that represent the runoff evolution process of the target watershed during the predicted period.
[0011] Based on multiple predicted runoff time series, a specified quantile is calculated for each moment in the period to be predicted. A confidence interval is constructed with the specified quantile as the edge. The uncertainty of the runoff prediction result is quantified through the confidence interval to obtain runoff prediction information containing the risk probability distribution.
[0012] In conjunction with the first aspect, this application provides a first possible implementation of the first aspect, wherein obtaining the forecast meteorological time series of the target watershed during the period to be predicted, as well as the historical meteorological time series and historical runoff time series during historical periods, includes:
[0013] Acquire forecast meteorological data for the target watershed at every moment within the forecast period, as well as historical meteorological observation data and historical runoff observation data at every moment within the historical period prior to the forecast period;
[0014] For each moment, the day number of that moment in the year is mapped to the sine and cosine values on the unit circle using sine and cosine functions, which serve as the time feature of that moment to characterize the seasonal position.
[0015] The historical runoff observation data were sequentially subjected to non-negative truncation and logarithmic transformation to obtain historical runoff observation data with a smooth distribution.
[0016] The historical runoff observation data, the historical meteorological observation data, and the forecast meteorological data with smooth distribution are respectively standardized.
[0017] The standardized forecast meteorological data, historical meteorological observation data, and historical runoff observation data are combined with the time characteristics of the corresponding time points to construct the initial forecast meteorological time series, the initial historical meteorological time series, and the initial historical runoff time series of the target watershed in the period to be predicted.
[0018] Using a sliding window, the initial historical meteorological time series and the initial historical runoff time series are segmented according to a preset historical sequence length to obtain historical meteorological time series and historical runoff time series; the initial forecast meteorological time series is segmented according to a preset forecast sequence length to obtain forecast meteorological time series.
[0019] In conjunction with the first aspect, this application provides a second possible implementation of the first aspect, wherein the self-attention model includes an input embedding layer, a position encoding layer, and an encoder; the step of inputting the historical meteorological time series and the historical runoff time series into the trained self-attention model, so that the self-attention model captures the long-range hydrological time series dependencies between different time steps within the historical period through the self-attention mechanism while avoiding gradient vanishing, and generates global contextual features characterizing the runoff generation and confluence state of the target watershed within the historical period based on the long-range hydrological time series dependencies, includes:
[0020] The historical meteorological time series and the historical runoff time series are input into the input embedding layer, and the historical input time series vector is obtained through feature concatenation and linear mapping.
[0021] The historical input time series vector is input into the position encoding layer, and the vector of each time step in the historical input time series vector is given temporal position information through position encoding to obtain the position encoded historical input time series vector.
[0022] The location-encoded historical input time series vector is input into the encoder, and the long-range hydrological time series dependency in the historical input time series vector is extracted through the self-attention mechanism in the encoder, and the hidden state sequence is output.
[0023] The global context features are obtained by performing global average pooling along the time dimension on the hidden state sequence using the following formula:
[0024]
[0025] Where C represents the global context feature; L represents the preset historical sequence length; Represents the hidden state sequence; This represents the feature vector corresponding to the k-th time step in the hidden state sequence.
[0026] In conjunction with the first aspect, this application provides a third possible implementation of the first aspect, wherein the conditional diffusion probability model is used to perform multiple backdiffusion processes. In each iteration of each backdiffusion process, cross-attention calculation is performed using the current denoised intermediate feature as the query and the global context feature as the key and value to obtain attention-enhanced features. Based on the attention-enhanced features, the initial noise data is iteratively denoised under the guidance of the runoff generation and confluence state represented by the global context feature, generating multiple predicted runoff time series representing the runoff evolution process of the target watershed during the predicted period, including:
[0027] The conditional diffusion probability model is used to perform multiple back-diffusion processes. In each iteration, a denoising network is used to fuse the noise data of the current time step with the forecast meteorological time series to obtain fused features.
[0028] The fused features are processed sequentially through one-dimensional convolution, batch normalization, and activation function, and then residually connected with the fused features to obtain intermediate features.
[0029] Using the intermediate feature as the query and the global context feature as the key and value, perform cross-attention calculation, and add the attention output to the intermediate feature to obtain the attention-enhanced feature;
[0030] Based on the attention enhancement features, the noise data at the current time step, the current time step, the global context features, and the forecast weather time series, the noise to be removed at the current time step is predicted by the denoising network, and the noise data is updated according to the predicted noise.
[0031] After a preset number of iterations, the noise data obtained from the final update is used as a predicted runoff time series.
[0032] In conjunction with the third possible implementation of the first aspect, this application provides a fourth possible implementation of the first aspect, wherein the step of sequentially processing the fused features through one-dimensional convolution, batch normalization, and activation functions, and then performing a residual connection with the fused features to obtain intermediate features, includes:
[0033] The fused features are processed sequentially using the following formula: one-dimensional convolution, batch normalization, and activation function. The processing results are then residual-connected with the fused features to obtain intermediate features:
[0034]
[0035]
[0036]
[0037]
[0038] in, Indicates fusion characteristics; It is a one-dimensional convolution operator; For batch normalization operators; For activation functions; Linear layer; is the encoded value at time step t; out is the intermediate feature.
[0039] In conjunction with the first possible implementation of the first aspect, this application provides a fifth possible implementation of the first aspect, wherein the iterative denoising of the initial noise data under the guidance of the runoff generation and confluence state characterized by the global context features, generating multiple predicted runoff time series characterizing the runoff evolution process of the target watershed during the predicted period, includes:
[0040] In each back-diffusion process, the initial noise data is iteratively denoised under the guidance of the runoff generation and confluence state characterized by the global context features to generate an initial predicted runoff time series.
[0041] The initial predicted runoff time series is sequentially subjected to inverse standardization, anti-logarithmic transformation, and non-negative correction to obtain a predicted runoff time series that characterizes the runoff evolution process of the target watershed during the predicted period.
[0042] In conjunction with the first aspect, this application provides a sixth possible implementation of the first aspect, wherein the step of calculating a specified quantile at each moment in the period to be predicted based on multiple predicted runoff time series, constructing a confidence interval with the specified quantile as the boundary, and quantifying the uncertainty of the runoff prediction result through the confidence interval to obtain runoff prediction information containing a risk probability distribution includes:
[0043] Based on multiple predicted runoff time series, for each moment in the period to be predicted, the value of that moment in all the predicted runoff time series is extracted to form a sample set.
[0044] Sort the values in the sample set, and calculate the first specified quantile and the second specified quantile of the sample set;
[0045] The confidence interval for this moment is constructed using the first specified quantile as the lower limit of the confidence interval and the second specified quantile as the upper limit of the confidence interval.
[0046] The confidence intervals for all times within the predicted period are combined in chronological order to obtain the runoff prediction information containing the risk probability distribution.
[0047] Secondly, embodiments of this application also provide a runoff prediction device, comprising:
[0048] The acquisition module is used to acquire the forecast meteorological time series of the target watershed during the period to be predicted, as well as the historical meteorological time series and historical runoff time series during historical periods;
[0049] The extraction module is used to input the historical meteorological time series and the historical runoff time series into the trained self-attention model, so that the self-attention model can capture the long-range hydrological time series dependencies between different time steps in the historical period through the self-attention mechanism while avoiding gradient vanishing, and generate global context features representing the runoff generation and confluence state of the target watershed in the historical period based on the long-range hydrological time series dependencies.
[0050] The input module is used to input the forecast meteorological time series, the global context features, and the initial noise data into the trained conditional diffusion probability model. The conditional diffusion probability model performs multiple backdiffusion processes. In each iteration of each backdiffusion process, cross-attention calculation is performed using the current denoised intermediate feature as the query and the global context features as the key and value to obtain attention enhancement features. Based on the attention enhancement features, the initial noise data is iteratively denoised under the guidance of the runoff generation and confluence state represented by the global context features to generate multiple predicted runoff time series that represent the runoff evolution process of the target watershed during the predicted period.
[0051] The calculation module is used to calculate a specified quantile for each moment in the period to be predicted based on multiple predicted runoff time series, construct a confidence interval with the specified quantile as the edge, and quantify the uncertainty of the runoff prediction result through the confidence interval to obtain runoff prediction information containing the risk probability distribution.
[0052] Thirdly, embodiments of this application also provide an electronic device, including: a processor, a memory, and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the memory via the bus, and when the machine-readable instructions are executed by the processor, the steps in any of the possible implementations of the first aspect described above are performed.
[0053] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps in any of the possible implementations of the first aspect described above.
[0054] This application provides a runoff prediction method, apparatus, electronic device, and computer-readable storage medium. Historical meteorological time series and historical runoff time series are input into a trained self-attention model. The self-attention mechanism captures long-range hydrological temporal dependencies between different time steps within a historical period while avoiding gradient vanishing. Because the self-attention mechanism directly calculates attention weights between different time steps within a historical period, without relying on recursive propagation of time steps, it avoids gradient vanishing when processing historical meteorological and runoff time series (long-series data), thus overcoming the gradient vanishing problem inherent in traditional recurrent neural networks. This allows for the effective capture of long-range hydrological temporal dependencies between distant time steps within a historical period. Based on this, the self-attention model generates global contextual features representing the runoff generation and confluence state of the target watershed within a historical period, condensing the captured long-range hydrological temporal dependencies between different time steps into global contextual features. This provides conditional information reflecting the runoff generation and confluence state within a historical period for subsequent runoff prediction.
[0055] To address the issue that the Transformer architecture only outputs deterministic point predictions and cannot quantify the uncertainty of prediction results, this embodiment inputs the forecast meteorological time series, global context features, and initial noise data into a trained conditional diffusion probability model, and performs multiple backdiffusion processes through the conditional diffusion probability model. In each iteration of each backdiffusion process, cross-attention is calculated using the current denoised intermediate feature as the query and the global context feature as the key and value to obtain attention-enhanced features. Based on the attention-enhanced features, the initial noise data is iteratively denoised under the guidance of the runoff generation and confluence state represented by the global context features, generating a predicted runoff time series that represents the runoff evolution process of the target watershed during the predicted period. Since multiple backdiffusion processes start from randomly sampled initial noise data, each predicted runoff time series generated by each backdiffusion process constitutes one possible runoff evolution process of the target watershed during the predicted period. Therefore, multiple predicted runoff time series can be obtained by executing multiple backdiffusion processes. Based on multiple predicted runoff time series, a specified quantile is calculated for each moment in the predicted period, and a confidence interval is constructed with the specified quantile as the boundary. Confidence intervals are directly determined by the specified quantiles of multiple predicted runoff time series at each time step, thereby quantifying the uncertainty of runoff prediction results. The final runoff prediction information includes the risk probability distribution reflected by the confidence intervals, so that the prediction results not only include the possible paths of runoff evolution, but also provide a quantification of the uncertainty of runoff prediction results.
[0056] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0057] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0058] Figure 1 A flowchart of a runoff prediction method provided in an embodiment of this application is shown;
[0059] Figure 2 A schematic diagram of a runoff prediction process provided by an embodiment of this application is shown;
[0060] Figure 3 A schematic diagram of the structure of a runoff prediction device provided in an embodiment of this application is shown;
[0061] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of this application is shown. Detailed Implementation
[0062] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0063] Runoff refers to the volume of water that falls to the ground, such as rainwater and snowmelt, and flows into rivers. Runoff forecasting refers to predicting how much rainwater and snowmelt will fall to the ground each day over the next few days, ultimately flowing into rivers and forming a measurable flow. Runoff forecasting is fundamental to watershed flood control and disaster reduction, optimal reservoir scheduling, and water resource management. Influenced by climate change and altered underlying surface conditions, the rainfall-runoff relationship in watersheds exhibits strong nonlinearity and uncertainty. Accurate runoff forecasts that include risk assessment (i.e., probability distribution) are crucial for ensuring watershed safety.
[0064] Existing runoff prediction technologies are mainly divided into physical causal models (texture models) and data-driven models (deep learning models). Physical causal models have clear mechanisms, but parameter calibration is complex (i.e., parameters are difficult to determine). Data-driven models include recurrent neural networks such as LSTM and GRU, and Transformer architecture models.
[0065] Traditional recurrent networks suffer from the vanishing gradient problem when processing long-sequence data, making it difficult to effectively capture the hydrological lag effect over long periods. For example, if it is shown data from the past 60 days, it will forget data from 30 days ago, resulting in inaccurate predictions.
[0066] Although the Transformer architecture (which belongs to the data-driven model) solves the long-range dependency problem (i.e. remembering long-term series data) through the self-attention mechanism, it is usually used for deterministic point prediction and cannot quantify the randomness and uncertainty of the prediction results. That is, it only gives point predictions and cannot give prediction intervals.
[0067] Based on this, embodiments of this application provide a runoff prediction method, apparatus, electronic device, and computer-readable storage medium. Utilizing the self-attention mechanism of a self-attention model, it captures long-range hydrological time-series dependencies between different time steps within a historical period while avoiding gradient vanishing. Based on these long-range hydrological time-series dependencies, it generates global contextual features characterizing the runoff generation and confluence state of the target watershed within a historical period, solving the problems of gradient vanishing and difficulty in capturing long-term hydrological lag effects in traditional recurrent neural networks when processing long-sequence data. Furthermore, it generates multiple predicted runoff time series by performing multiple back-diffusion processes using a conditional diffusion probability model, and calculates specified quantiles based on these multiple predicted runoff time series to construct confidence intervals. These confidence intervals quantify the uncertainty of the runoff prediction results, solving the problem that deterministic point prediction cannot quantify the uncertainty of the prediction results. The following embodiments describe these methods.
[0068] To facilitate understanding of this embodiment, a runoff prediction method disclosed in this application will first be described in detail. For example... Figure 1 As shown, the process includes the following steps S101-S104:
[0069] S101: Obtain the forecast meteorological time series of the target watershed during the period to be predicted, as well as the historical meteorological time series and historical runoff time series during historical periods.
[0070] In this step, the first step is to identify the target watershed to be predicted. For this target watershed, two types of data are acquired. The first type of data is the forecast meteorological data for each moment (e.g., each day) within the future forecast period (e.g., the next 7 days), which is arranged chronologically to form a forecast meteorological time series. This forecast meteorological time series may include, for example, daily forecast values for precipitation and daily forecast values for snowfall.
[0071] The second type of data is historical observation data, which includes historical meteorological and runoff observation data for the target watershed at every moment (e.g., every day) within a historical period preceding the period to be predicted (e.g., the previous 60 days). These historical observation data are arranged chronologically to form historical meteorological time series and historical runoff time series. Historical meteorological time series may include, for example, daily observations of precipitation and snowfall. Historical runoff time series may include, for example, daily observations of river flow.
[0072] Typically, the period to be predicted and the historical period are two adjacent periods. The historical period is before the current time, for example, 60 days before the current time; the predicted period is after the current time, for example, 7 days after the current time.
[0073] In one possible implementation, when performing step S101, the following steps S1011-S1016 can be specifically performed:
[0074] S1011: Obtain forecast meteorological data for the target watershed at every moment during the forecast period, as well as historical meteorological observation data and historical runoff observation data at every moment during historical periods prior to the forecast period.
[0075] In this embodiment, for a given historical period, historical meteorological observation data and historical runoff observation data for the target watershed are acquired for each past day. Historical meteorological observation data includes at least precipitation and snowfall equivalent. Historical runoff observation data represents the measured flow rate of the river.
[0076] For the period to be predicted, obtain the forecast meteorological data for each day of the target watershed in the future, including at least the forecast values for precipitation and snowfall.
[0077] S1012: For each moment, the day number of that moment in the year is mapped to the sine and cosine values on the unit circle through sine and cosine functions, which serve as the time feature of that moment to characterize the seasonal position.
[0078] In this embodiment, the time characteristics of each moment within the time period to be predicted and each moment within the historical time period are calculated using the following sine and cosine functions:
[0079]
[0080] in, Indicates that time i is the first of the year. The day (ordinal number) ranges from 1 to 366. and The time feature represents the temporal characteristics of time i; the temporal characteristics are used to represent the seasonal position of time i within the year.
[0081] In this step, due to the significant intra-annual periodicity of hydrological processes, discrete dates need to be mapped to continuous unit circle coordinates to enable the model to perceive seasonal changes. Using the aforementioned sine and cosine functions, the linear value of "the day of the year" is transformed into two periodic features that continuously change within the interval [-1, 1]. For example, December 31st and January 1st differ significantly in numerical date, but their sine and cosine feature values are very close, allowing the model to understand that these two time points are seasonally adjacent.
[0082] S1013: Perform non-negative truncation and logarithmic transformation on the historical runoff observation data in sequence to obtain historical runoff observation data with smooth distribution.
[0083] In this step, considering that runoff data is physically nonnegative and its original distribution typically exhibits a long-tailed skewness (i.e., low flow most of the time, with extremely high flow during a few flood events), the historical runoff observation data for each moment within the historical period are first analyzed. Perform nonnegative truncation:
[0084] .
[0085] Subsequently, a logarithmic transformation was performed on the non-negative truncated historical runoff observation data to obtain historical runoff data with a smooth distribution. :
[0086]
[0087] Logarithmic transformation can compress the scale of data, making the distribution more uniform.
[0088] S1014: Standardize the historical runoff observation data, historical meteorological observation data, and forecast meteorological data with smooth distribution respectively.
[0089] In this step, due to the significant differences in the units and numerical ranges of different characteristics (e.g., precipitation is measured in millimeters, while runoff is measured in cubic meters per second), the Z-Score method is used to standardize various types of data (historical runoff observation data, historical meteorological observation data, and forecast meteorological data).
[0090] For any feature sequence (forecast meteorological time series, historical meteorological time series, historical runoff time series), calculate its mean on the training set. and standard deviation Then for each data (Historical runoff observation data, historical meteorological observation data, and forecast meteorological data) are standardized to obtain standardized data. :
[0091]
[0092] The standardized data have a mean of 0 and a variance of 1, and are dimensionless, making them easy to process in the model.
[0093] It should be noted that the mean used in standardization and standard deviation All were calculated from historical data in the training set.
[0094] S1015: Combine the standardized forecast meteorological data, historical meteorological observation data, and historical runoff observation data with the time characteristics of the corresponding time points to construct the initial forecast meteorological time series of the target watershed during the period to be predicted, the initial historical meteorological time series during the historical period, and the initial historical runoff time series during the historical period.
[0095] In this step, the forecast meteorological data and time characteristics of each moment within the predicted period after standardization are spliced together to construct the initial forecast meteorological time series of the target watershed during the predicted period; the historical meteorological observation data and time characteristics of each moment within the historical period after standardization are spliced together to construct the initial historical meteorological time series of the target watershed during the historical period; and the historical runoff observation data and time characteristics of each moment within the historical period after standardization are spliced together to construct the initial historical runoff time series of the target watershed during the historical period.
[0096] Specifically, for each moment in a historical period, its standardized historical meteorological observation data (such as precipitation and snowfall equivalents) are compared with the temporal characteristics of that moment calculated through S1012. , These features are combined to form a feature vector, and the feature vectors of all times are arranged in chronological order to form the initial historical meteorological time series. Similarly, the standardized historical runoff observation data are combined with the time features to form the initial historical runoff time series.
[0097] For the period to be predicted, the standardized forecast meteorological data is combined with time characteristics to form an initial forecast meteorological time series.
[0098] S1016: Using a sliding window, the initial historical meteorological time series and the initial historical runoff time series are segmented according to the preset historical sequence length to obtain the historical meteorological time series and the historical runoff time series; the initial forecast meteorological time series is segmented according to the preset forecast sequence length to obtain the forecast meteorological time series.
[0099] In this embodiment, to generate data that meets the model input requirements, a sliding window technique is used to segment the continuous initial time series. The historical series length L and the predicted series length H are preset. For example, L is set to 60, indicating the use of data from the past 60 days; H is set to 7, indicating the prediction of runoff for the next 7 days.
[0100] For each possible starting time m, extract from the initial historical meteorological time series... to The sequence fragments are used as historical meteorological time series; the same time period is extracted from the initial historical runoff time series. to The sequence fragments are used as historical runoff time series; excerpts are taken from the initial forecast meteorological time series. to The sequence fragments are used as time series for weather forecasting.
[0101] Through the above steps S1011 to S1016, the process of constructing a standardized time series from raw data into a model that can be directly input is completed.
[0102] S102: Input historical meteorological time series and historical runoff time series into the trained self-attention model so that the self-attention model can capture the long-range hydrological time series dependencies between different time steps in the historical period through the self-attention mechanism while avoiding gradient vanishing, and generate global context features representing the runoff generation and confluence status of the target watershed in the historical period based on the long-range hydrological time series dependencies.
[0103] In this embodiment, the self-attention model is built on the Transformer architecture, and its core lies in capturing the dependencies within long sequences of data through a self-attention mechanism. The self-attention model specifically includes an input embedding layer, a positional encoding layer, and an encoder. The encoder consists of multiple identical layers stacked together, each layer containing a multi-head self-attention mechanism and a feedforward neural network.
[0104] In one possible implementation, when performing step S102, the following steps S1021-S1024 can be specifically performed:
[0105] S1021: Input historical meteorological time series and historical runoff time series into the input embedding layer, and obtain the historical input time series vector through feature concatenation and linear mapping.
[0106] In this embodiment, the historical meteorological time series and historical runoff time series obtained after step S101 are jointly input into the input embedding layer of the self-attention model. The function of the input embedding layer is to convert the original numerical time series into a high-dimensional vector representation that the model can process.
[0107] Specifically, for each time step within a historical period, the input embedding layer concatenates the historical meteorological features (e.g., standardized precipitation, snowfall equivalent, and temporal characteristics) and historical runoff features (standardized logarithmic runoff values) corresponding to that time step, and projects them onto a fixed feature dimension space through a linear mapping to obtain the embedding vector for that time step. The embedding vectors of all time steps are arranged in chronological order to form the historical input time series vector. The dimension of this historical input time series vector is L× Where L is the length of the historical sequence, This is the preset embedding dimension.
[0108] S1022: Input the historical input time series vector into the position encoding layer, and assign temporal position information to the vector of each time step in the historical input time series vector through position encoding to obtain the position-encoded historical input time series vector.
[0109] In this embodiment, since the self-attention mechanism itself does not have the ability to perceive the sequence order, that is, the model cannot distinguish which vector corresponds to day 1 and which corresponds to day 60 when processing the input vector, it is necessary to input the historical input time series vector into the position encoding layer. The position encoding is used to assign temporal position information to the vectors of each time step in the historical input time series vector, so as to obtain the position-encoded historical input time series vector.
[0110] The position coding layer generates a position coding vector for each time step using a sine-cosine position coding function, and adds it to the input embedding vector for the corresponding time step. The formula for calculating the position coding is as follows:
[0111]
[0112]
[0113] in, Indicates the position index of the time step in the sequence (value range is 0 to 1). ), where i represents the index of the feature dimension. This is the embedding dimension. In this way, the input vector at each time step carries its absolute position information in the sequence, enabling the subsequent encoder to perceive the temporal order of the data.
[0114] S1023: Input the location-encoded historical input time series vector into the encoder, extract the long-range hydrological time series dependency in the historical input time series vector through the self-attention mechanism in the encoder, and output the hidden state sequence.
[0115] In this embodiment, the historical input time series vector after position encoding is input to the encoder. The encoder is composed of multiple identical layers stacked together (in this embodiment, the number of encoder layers, Nenc, is 2), and each layer contains a multi-head self-attention mechanism module and a feedforward neural network module.
[0116] In each layer, a multi-head self-attention mechanism is first used to calculate the dependencies between different time steps in the historical input time series vector. The multi-head self-attention mechanism module directly establishes the association between different time steps by calculating the attention weights between any two time steps in the historical input time series vector, enabling the self-attention mechanism in the encoder to extract the long-range hydrological temporal dependencies between different time steps in the historical input time series vector. Subsequently, a feedforward neural network module performs a nonlinear transformation on the output of the multi-head self-attention mechanism module to further extract deep features. Each layer employs residual connections and layer normalization techniques, performing residual connections and layer normalization on the input and output of the multi-head self-attention mechanism module, and on the input and output of the feedforward neural network module, to stabilize the training process.
[0117] After being processed sequentially by multiple stacked layers in the encoder, the position-encoded historical input time series vector is mapped to a hidden state sequence. The number of time steps in the hidden state sequence is the same as the number of time steps in the historical input time series vector, both being the preset historical sequence length. However, the feature vector corresponding to each time step in the hidden state sequence has incorporated information from other time steps in the historical input time series vector. The encoder outputs the hidden state sequence.
[0118] S1024: Global average pooling is performed along the time dimension on the hidden state sequence using the following formula to obtain the global context features:
[0119]
[0120] Where C represents the global context feature; L represents the preset historical sequence length; Represents the hidden state sequence; This represents the feature vector corresponding to the k-th time step in the hidden state sequence.
[0121] In this embodiment, a hidden state sequence of length L is compressed into a fixed-dimensional vector, namely the global context feature C, through a global average pooling operation. This global context feature encapsulates the long-range hydrological time-series dependencies between different time steps within a historical period, characterizing the runoff generation and confluence status of the target watershed during that historical period. Specifically, it includes historical precipitation processes, runoff recession processes, and the resulting current watershed status (such as soil moisture levels, runoff generation capacity, etc.).
[0122] Through steps S1021 to S1024, the entire process of inputting historical meteorological time series and historical runoff time series into the self-attention model, and generating global contextual features based on long-range hydrological time series dependencies, is completed. These global contextual features will be used as conditional information input into the conditional diffusion probability model in subsequent steps, guiding the model to generate predicted runoff time series under the guidance of the runoff generation and confluence states represented by the global contextual features.
[0123] In this embodiment, the self-attention model is trained in the following manner:
[0124] Obtain the observed runoff time series of the target watershed in the future sample period, as well as the historical meteorological sample time series of the historical sample periods before the future sample period;
[0125] Historical meteorological time series samples are used as input samples for the initial self-attention model to be trained. The initial self-attention model extracts historical hydrological and meteorological context sample features of the target watershed from the historical meteorological time series samples, and predicts the predicted runoff time series for future sample periods based on the historical hydrological and meteorological context sample features.
[0126] Based on the observed and predicted runoff time series, the loss function value of the initial self-attention model is calculated, and the learnable parameters in the initial self-attention model are updated using the loss function value to obtain the trained self-attention model.
[0127] S103: Input the forecast meteorological time series, global context features, and initial noise data into the trained conditional diffusion probability model. Perform multiple backdiffusion processes through the conditional diffusion probability model. In each iteration of each backdiffusion process, perform cross-attention calculation with the current denoised intermediate feature as the query and the global context feature as the key and value to obtain attention-enhanced features. Based on the attention-enhanced features, iteratively denoise the initial noise data under the guidance of the runoff generation and confluence state represented by the global context features to generate multiple predicted runoff time series that represent the runoff evolution process of the target watershed during the predicted period.
[0128] like Figure 2 As shown, the forecast meteorological time series, initial noise data, and global context features output by the self-attention model are input into the trained conditional diffusion probability model. The conditional diffusion probability model is a generative model based on a denoising network. Its core idea is to gradually recover the target data from pure noise by learning a backdiffusion process. The model includes a forward diffusion process (for training) with a preset number of steps and a backdiffusion process (for generation). In the prediction phase, the backdiffusion process is executed, starting from randomly sampled initial noise data, and after multiple iterations of denoising, a predicted runoff time series that meets the input conditions is finally obtained. In this embodiment, the denoising network of the conditional diffusion probability model adopts a one-dimensional U-Net architecture, including a feature fusion module, a one-dimensional residual block, and a cross-attention block.
[0129] In one possible implementation, when performing step S103, multiple backdiffusion processes are executed using the conditional diffusion probability model. In each iteration of each backdiffusion process, cross-attention calculation is performed using the current denoised intermediate feature as the query and the global context feature as the key and value to obtain attention-enhanced features. Based on the attention-enhanced features, the initial noise data is iteratively denoised under the guidance of the runoff generation and confluence state represented by the global context feature to generate multiple predicted runoff time series representing the runoff evolution process of the target watershed during the predicted period. Specifically, this can be performed according to the following steps S1031-S1035:
[0130] S1031: Multiple back-diffusion processes are performed using a conditional diffusion probability model. In each iteration, a denoising network is used to fuse the noise data of the current time step with the forecast meteorological time series to obtain fused features.
[0131] In this embodiment, in each iteration of the back diffusion process, let the current time step be t (decreasing from the preset total number of steps T to 1), and the noise data at the current time step be denoted as... Noise data at the current time step. and the forecast meteorological time series obtained in step S101 The inputs are fed into the feature fusion module of the denoising network. This module first uses two independent linear layers to... and Mapped to the same feature dimension Then, the mapped results are added element by element to obtain the fused features. ,Right now:
[0132]
[0133] This step explicitly incorporates future forecast meteorological data as a physical constraint into the denoising process, ensuring that the generated runoff sequence matches future rainfall and other meteorological conditions.
[0134] S1032: After the fused features are processed sequentially through one-dimensional convolution, batch normalization and activation function, they are residually connected with the fused features to obtain intermediate features.
[0135] In this embodiment, the fusion features obtained in step S1031 are... The input is fed into a one-dimensional residual block for processing. The structure of the one-dimensional residual block is designed as follows: First, the input is subjected to a one-dimensional convolution ( The process involves extracting local temporal features, followed by batch normalization (BatchNorm) to standardize the feature distribution and accelerate convergence, and then introducing nonlinearity through the SiLU activation function. The output of these operations is denoted as... .
[0136] Then, the time embedding vector corresponding to the current time step t is... After being mapped by a linear layer, it is added to h1 to introduce time step information, thus obtaining... Then, one-dimensional convolution, batch normalization, and SiLU activation function calculation were performed on h2 again to obtain... Finally, Integration features with the original Add them together to obtain intermediate features. The above calculation logic can be expressed as:
[0137]
[0138]
[0139]
[0140]
[0141] in, Indicates fusion characteristics; It is a one-dimensional convolution operator; For batch normalization operators; For activation functions; Linear layer; is the encoded value at time step t; out is the intermediate feature.
[0142] In this embodiment, It can be calculated using the following formula:
[0143]
[0144] in, The total dimension of the temporal embedding vector is a hyperparameter pre-defined before model training. `i` is the dimension index, and `2i` is the even-numbered dimension index of the temporal embedding vector.
[0145] S1033: Use the intermediate feature as the query and the global context feature as the key and value to perform cross-attention calculation. Add the attention output to the intermediate feature to obtain the attention-enhanced feature.
[0146] In this embodiment, the query vector matrix is calculated based on intermediate features of historical runoff observation data using the following formula. Calculate the key vector matrix based on historical hydrological and meteorological context features from historical runoff observation data. Sum value vector matrix Perform cross-attention calculation and output attention-enhanced features:
[0147]
[0148]
[0149]
[0150] in, To query the weight matrix; The weight matrix represents the keys; The weight matrix is a set of values; For the attention dimension; This is the normalization function; To output the weight matrix; is the attention enhancement feature; out is the intermediate feature; C is the global context feature of historical runoff observation data.
[0151] S1034: Based on attention enhancement features, noise data at the current time step, the current time step, global context features, and forecast meteorological time series, a denoising network is used to predict the noise to be removed at the current time step, and the noise data is updated based on the predicted noise.
[0152] In this embodiment, the noise data of the current time step of the historical runoff observation data is used. Current time step t, global context feature C, forecast meteorological time series and attention enhancement features The input is fed into the denoising network, and the predicted noise is calculated using the following formula:
[0153]
[0154]
[0155]
[0156] in, This represents the prediction noise from the previous time step; This represents the noise data at the current time step t; Global contextual features for historical runoff observation data; Forecast meteorological time series based on historical runoff observation data; Indicates the cumulative coefficient; The noise figure is represented by z; z is the random disturbance term, and z = 0 when t = 1. and It is based on a preset noise variance scheduling table. The calculated coefficients.
[0157] With the above update, the noise data at the current time step The previous noisy data was gradually restored to a distribution that more closely resembles the true data distribution. .
[0158] S1035: After a preset number of iterations, the noise data obtained from the final update is used as a predicted runoff time series.
[0159] In this embodiment, the iteration proceeds sequentially from t=T to t=1, ultimately yielding... This is a predicted runoff time series of a target watershed during the period to be predicted.
[0160] Since the back-diffusion process of the conditional diffusion probability model depends on randomly sampled initial noise data... Therefore, for the same set of inputs (i.e., the same forecast meteorological time series and the same global context features), executing the back-diffusion process described in step S103 independently multiple times can yield multiple different predicted runoff time series. These series constitute a set of prediction results, representing multiple possible paths for future runoff under given conditions.
[0161] In one possible implementation, when performing step S103, which involves executing multiple back-diffusion processes using a conditional diffusion probability model and iteratively denoising the initial noise data under the guidance of the runoff generation and confluence state characterized by global context features, to generate multiple predicted runoff time series representing the runoff evolution process of the target watershed during the predicted period, the specific steps S1031-S1032 can be followed:
[0162] S1031: In each back diffusion process, the initial noise data is iteratively denoised under the guidance of the runoff generation and confluence state characterized by the global context features to generate an initial predicted runoff time series.
[0163] In this embodiment, the reverse diffusion process described in step S103 is executed independently multiple times for the same target watershed and the same predicted time period. Each execution starts with randomly sampled initial noise data, undergoes a preset number of iterations for denoising, and finally generates an initial predicted runoff time series. This initial predicted runoff time series is the direct output of the conditional diffusion probability model, and its data scale is still a standardized logarithmic scale, not yet restored to the original physical dimensions. The number of repetitions can be set according to actual needs, for example, 100 times, thereby obtaining 100 initial predicted runoff time series.
[0164] S1032: The initial predicted runoff time series is sequentially subjected to inverse standardization, anti-logarithmic transformation, and non-negative correction to obtain a predicted runoff time series that characterizes the runoff evolution process of the target watershed during the predicted period.
[0165] In this embodiment, in step S1014, to eliminate the influence of different characteristic dimensions, the historical runoff observation data corresponding to each moment within the historical period were standardized to ensure a smooth distribution. In step S1013, to overcome the long-tailed skewness of the runoff data, the historical runoff observation data corresponding to each moment within the historical period were logarithmically transformed and non-negatively truncated. Therefore, the initial predicted runoff time series output by the conditional diffusion probability model is located in the standardized logarithmic space, and its values do not possess the original physical dimensions and have not yet been restored to the original scale. To obtain physically meaningful prediction results, each initial predicted runoff time series needs to be sequentially de-standardized to restore it to the logarithmic scale before standardization, subjected to anti-logarithmic transformation to restore it to the original runoff dimensions, and non-negatively corrected to ensure compliance with the physical non-negativity characteristics of runoff, thereby obtaining multiple predicted runoff time series that can be used for subsequent analysis.
[0166] Specifically, the following post-processing operations are performed sequentially on each initial predicted runoff time series obtained in step S1031:
[0167] First, destandardization is performed. In step S1014, the historical runoff observation data was standardized, using the mean and standard deviation from the training set. Here, for each value in each initial predicted runoff time series, the same mean and standard deviation are used for destandardization, restoring it to its original logarithmic scale value. The calculation formula is:
[0168]
[0169] in The standardized value. and These are the mean and standard deviation of the historical logarithmic runoff values on the training set, respectively. This is the logarithm after destandardization.
[0170] Secondly, an antilogarithmic transformation is performed. The destandardized data remains in logarithmic space and needs to be transformed back to the original runoff dimensions. The formula for the antilogarithmic transformation is:
[0171]
[0172] in The logarithm is the value after destandardization. This is the transformed runoff value. This transformation is the inverse operation of the logarithmic transformation in step S1013.
[0173] Finally, a nonnegation correction is performed. Considering that runoff is physically nonnegative, the runoff values obtained after the antilogarithmic transformation are checked. If a negative value appears (possibly due to numerical calculation errors), it is corrected to 0. .
[0174] After the above post-processing operations, each initial predicted runoff time series is converted into a predicted runoff time series with original physical dimensions and conforming to physical meaning. All series together constitute multiple predicted runoff time series for the target watershed during the period to be predicted, which are used for subsequent statistical analysis.
[0175] S104: Based on multiple predicted runoff time series, calculate the specified quantile for each moment in the period to be predicted, construct a confidence interval with the specified quantile as the edge, and quantify the uncertainty of the runoff prediction results through the confidence interval to obtain runoff prediction information containing the risk probability distribution.
[0176] In this embodiment, after obtaining multiple processed predicted runoff time series, statistical analysis is performed on them to quantify the uncertainty of runoff prediction. By calculating specified quantiles and constructing confidence intervals, the possible fluctuation range of the prediction results is provided to decision-makers.
[0177] In one possible implementation, when performing step S104, the following steps S1041-S1044 can be specifically performed:
[0178] S1041: Based on multiple predicted runoff time series, for each moment in the period to be predicted, extract the value of that moment in all predicted runoff time series to form a sample set.
[0179] In this embodiment, for each moment within the period to be predicted, the value of that moment in all predicted runoff time series is extracted to form a sample set.
[0180] S1042: Sort the values in the sample set and calculate the first specified quantile and the second specified quantile of the sample set.
[0181] The values in the sample set are sorted in ascending order. A first specified quantile and a second specified quantile are determined based on a preset confidence level. In one specific embodiment, the preset confidence level is 95%, so the first specified quantile is set as the 2.5% quantile and the second specified quantile is set as the 97.5% quantile. For each moment within the period to be predicted, the 2.5% quantile and the 97.5% quantile of the sample set at that moment are calculated.
[0182] S1043: Construct the confidence interval for this moment using the first specified quantile as the lower limit of the confidence interval and the second specified quantile as the upper limit of the confidence interval.
[0183] For each moment within the forecast period, the first specified quantile calculated in step S1041 is used as the lower limit of the confidence interval, and the second specified quantile is used as the upper limit, thus forming the confidence interval for that moment. Combining the confidence intervals for all moments in chronological order yields the complete confidence interval for runoff prediction in the target watershed within the forecast period. This confidence interval reflects the range within which future runoff may fall with a specified probability, given historical information and future meteorological conditions.
[0184] S1044: Combine the confidence intervals of all times within the period to be predicted in chronological order to obtain runoff prediction information that includes the risk probability distribution.
[0185] In this embodiment, after constructing the confidence interval for each moment within the prediction period in step S1043, the confidence intervals for all moments within the prediction period are arranged and combined sequentially in chronological order to form a sequence of confidence intervals covering the entire prediction period. Each moment in this sequence of confidence intervals corresponds to a numerical range defined by the first and second specified quantiles of that moment, and this numerical range characterizes the possible fluctuation range of the predicted runoff value at a given confidence level at that moment.
[0186] Since this confidence interval sequence is obtained by calculating statistical quantiles from multiple predicted runoff time series, its width directly reflects the dispersion of the multiple predicted runoff time series at each time point. Therefore, this confidence interval sequence is runoff prediction information containing a risk probability distribution obtained after quantifying the uncertainty of the runoff prediction results through confidence intervals. This runoff prediction information containing the risk probability distribution also provides the central tendency and fluctuation range of the runoff prediction, providing a risk assessment basis for flood control, disaster reduction, and water resource allocation decisions.
[0187] In another possible implementation, the arithmetic mean of each moment in the period to be predicted can be calculated based on multiple predicted runoff time series, and this result can be used as a deterministic prediction result, which is output together with the confidence interval to meet different decision-making needs.
[0188] Based on the same technical concept, embodiments of this application also provide a runoff prediction device, such as... Figure 3 As shown, it includes:
[0189] The acquisition module 301 is used to acquire the forecast meteorological time series of the target watershed during the period to be predicted, as well as the historical meteorological time series and historical runoff time series during historical periods;
[0190] Extraction module 302 is used to input the historical meteorological time series and the historical runoff time series into the trained self-attention model, so that the self-attention model can capture the long-range hydrological time series dependency between different time steps in the historical period through the self-attention mechanism while avoiding gradient vanishing, and generate global context features representing the runoff generation and confluence state of the target watershed in the historical period based on the long-range hydrological time series dependency.
[0191] The input module 303 is used to input the forecast meteorological time series, the global context features, and the initial noise data into the trained conditional diffusion probability model. The conditional diffusion probability model performs multiple back diffusion processes. In each iteration of each back diffusion process, cross-attention calculation is performed using the current denoised intermediate feature as the query and the global context features as the key and value to obtain attention enhancement features. Based on the attention enhancement features, the initial noise data is iteratively denoised under the guidance of the runoff generation and confluence state represented by the global context features to generate multiple predicted runoff time series that represent the runoff evolution process of the target watershed during the predicted period.
[0192] The calculation module 304 is used to calculate a specified quantile for each moment in the period to be predicted based on multiple predicted runoff time series, construct a confidence interval with the specified quantile as the edge, and quantify the uncertainty of the runoff prediction result through the confidence interval to obtain runoff prediction information containing the risk probability distribution.
[0193] Optionally, when acquiring the forecast meteorological time series of the target watershed during the period to be predicted, and the historical meteorological time series and historical runoff time series during historical periods, the acquisition module 301 is specifically used for:
[0194] Acquire forecast meteorological data for the target watershed at every moment within the forecast period, as well as historical meteorological observation data and historical runoff observation data at every moment within the historical period prior to the forecast period;
[0195] For each moment, the day number of that moment in the year is mapped to the sine and cosine values on the unit circle using sine and cosine functions, which serve as the time feature of that moment to characterize the seasonal position.
[0196] The historical runoff observation data were sequentially subjected to non-negative truncation and logarithmic transformation to obtain historical runoff observation data with a smooth distribution.
[0197] The historical runoff observation data, the historical meteorological observation data, and the forecast meteorological data with smooth distribution are respectively standardized.
[0198] The standardized forecast meteorological data, historical meteorological observation data, and historical runoff observation data are combined with the time characteristics of the corresponding time points to construct the initial forecast meteorological time series, the initial historical meteorological time series, and the initial historical runoff time series of the target watershed in the period to be predicted.
[0199] Using a sliding window, the initial historical meteorological time series and the initial historical runoff time series are segmented according to a preset historical sequence length to obtain historical meteorological time series and historical runoff time series; the initial forecast meteorological time series is segmented according to a preset forecast sequence length to obtain forecast meteorological time series.
[0200] Optionally, the self-attention model includes an input embedding layer, a location encoding layer, and an encoder; the extraction module 302, when inputting the historical meteorological time series and the historical runoff time series into the trained self-attention model, so that the self-attention model can capture the long-range hydrological time series dependencies between different time steps within the historical period through the self-attention mechanism while avoiding gradient vanishing, and generate global contextual features representing the runoff generation and confluence state of the target watershed within the historical period based on the long-range hydrological time series dependencies, is specifically used for:
[0201] The historical meteorological time series and the historical runoff time series are input into the input embedding layer, and the historical input time series vector is obtained through feature concatenation and linear mapping.
[0202] The historical input time series vector is input into the position encoding layer, and the vector of each time step in the historical input time series vector is given temporal position information through position encoding to obtain the position encoded historical input time series vector.
[0203] The location-encoded historical input time series vector is input into the encoder, and the long-range hydrological temporal dependencies in the historical input time series vector are extracted through the self-attention mechanism in the encoder, and the hidden state sequence is output.
[0204] The global context features are obtained by performing global average pooling along the time dimension on the hidden state sequence using the following formula:
[0205]
[0206] Where C represents the global context feature; L represents the preset historical sequence length; Represents the hidden state sequence; This represents the feature vector corresponding to the k-th time step in the hidden state sequence.
[0207] Optionally, the input module 303, when performing multiple backdiffusion processes through the conditional diffusion probability model, performs cross-attention calculation in each iteration of each backdiffusion process, using the current denoised intermediate feature as the query and the global context feature as the key and value, to obtain attention-enhanced features, and iteratively denoises the initial noise data based on the attention-enhanced features under the guidance of the runoff generation and confluence state represented by the global context features, to generate multiple predicted runoff time series representing the runoff evolution process of the target watershed during the predicted period, is specifically used for:
[0208] The conditional diffusion probability model is used to perform multiple back-diffusion processes. In each iteration, a denoising network is used to fuse the noise data of the current time step with the forecast meteorological time series to obtain fused features.
[0209] The fused features are processed sequentially through one-dimensional convolution, batch normalization, and activation function, and then residually connected with the fused features to obtain intermediate features.
[0210] Using the intermediate feature as the query and the global context feature as the key and value, perform cross-attention calculation, and add the attention output to the intermediate feature to obtain the attention-enhanced feature;
[0211] Based on the attention enhancement features, the noise data at the current time step, the current time step, the global context features, and the forecast weather time series, the noise to be removed at the current time step is predicted by the denoising network, and the noise data is updated according to the predicted noise.
[0212] After a preset number of iterations, the noise data obtained from the final update is used as a predicted runoff time series.
[0213] Optionally, when the input module 303 processes the fused features sequentially through one-dimensional convolution, batch normalization, and activation functions, and then performs a residual connection with the fused features to obtain intermediate features, it is specifically used for:
[0214] The fused features are processed sequentially using the following formula: one-dimensional convolution, batch normalization, and activation function. The processing results are then residual-connected with the fused features to obtain intermediate features:
[0215]
[0216]
[0217]
[0218]
[0219] in, Indicates fusion characteristics; It is a one-dimensional convolution operator; For batch normalization operators; For activation functions; Linear layer; is the encoded value at time step t; out is the intermediate feature.
[0220] Optionally, when the input module 303 iteratively denoises the initial noise data under the guidance of the runoff generation and confluence state characterized by the global context features, and generates multiple predicted runoff time series representing the runoff evolution process of the target watershed during the predicted period, it is specifically used for:
[0221] In each back-diffusion process, the initial noise data is iteratively denoised under the guidance of the runoff generation and confluence state characterized by the global context features to generate an initial predicted runoff time series.
[0222] The initial predicted runoff time series is sequentially subjected to inverse standardization, anti-logarithmic transformation, and non-negative correction to obtain a predicted runoff time series that characterizes the runoff evolution process of the target watershed during the predicted period.
[0223] Optionally, when the calculation module 304 is used to calculate a specified quantile for each moment in the period to be predicted based on multiple predicted runoff time series, construct a confidence interval with the specified quantile as the boundary, and quantify the uncertainty of the runoff prediction result through the confidence interval to obtain runoff prediction information containing the risk probability distribution, it is specifically used for:
[0224] Based on multiple predicted runoff time series, for each moment in the period to be predicted, the value of that moment in all the predicted runoff time series is extracted to form a sample set.
[0225] Sort the values in the sample set, and calculate the first specified quantile and the second specified quantile of the sample set;
[0226] The confidence interval for this moment is constructed using the first specified quantile as the lower limit of the confidence interval and the second specified quantile as the upper limit of the confidence interval.
[0227] The confidence intervals for all times within the predicted period are combined in chronological order to obtain the runoff prediction information containing the risk probability distribution.
[0228] Figure 4 A schematic diagram of an electronic device provided in this application embodiment includes: a processor 401, a memory 402, and a bus 403. The memory 402 stores machine-readable instructions executable by the processor 401. When the electronic device runs the above-described information processing method, the processor 401 and the memory 402 communicate through the bus 403. The processor 401 executes the machine-readable instructions to perform the steps of the method described in Embodiment 1.
[0229] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps described in Embodiment 1.
[0230] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the devices, electronic devices, and computer-readable storage media described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0231] In the several embodiments provided in this application, it should be understood that the disclosed methods, apparatuses, electronic devices, and computer-readable storage media can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or modules may be electrical, mechanical, or other forms.
[0232] 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 units can be selected to achieve the purpose of this embodiment according to actual needs.
[0233] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0234] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion 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 this application. 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.
[0235] Finally, it should be noted that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit them. The scope of protection of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this application. Such modifications, changes, 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 this application, and should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of protection of the claims.
Claims
1. A runoff prediction method, characterized in that, include: Obtain the forecast meteorological time series of the target watershed during the period to be predicted, as well as the historical meteorological time series and historical runoff time series for the historical period; The historical meteorological time series and the historical runoff time series are input into the trained self-attention model so that the self-attention model can capture the long-range hydrological time series dependencies between different time steps in the historical period through the self-attention mechanism while avoiding gradient vanishing, and generate global context features that characterize the runoff generation and confluence state of the target watershed in the historical period based on the long-range hydrological time series dependencies. The forecast meteorological time series, the global context features, and the initial noise data are input into the trained conditional diffusion probability model. The conditional diffusion probability model is used to perform multiple backdiffusion processes. In each iteration of each backdiffusion process, cross-attention is calculated using the current denoised intermediate feature as the query and the global context features as the key and value to obtain attention enhancement features. Based on the attention enhancement features, the initial noise data is iteratively denoised under the guidance of the runoff generation and confluence state represented by the global context features to generate multiple predicted runoff time series that represent the runoff evolution process of the target watershed during the predicted period. Based on multiple predicted runoff time series, a specified quantile is calculated for each moment in the period to be predicted. A confidence interval is constructed with the specified quantile as the edge. The uncertainty of the runoff prediction result is quantified through the confidence interval to obtain runoff prediction information containing the risk probability distribution.
2. The method according to claim 1, characterized in that, The acquisition of the forecast meteorological time series of the target watershed during the period to be predicted, as well as the historical meteorological time series and historical runoff time series for historical periods, includes: Acquire forecast meteorological data for the target watershed at every moment within the forecast period, as well as historical meteorological observation data and historical runoff observation data at every moment within the historical period prior to the forecast period; For each moment, the day number of that moment in the year is mapped to the sine and cosine values on the unit circle using sine and cosine functions, which serve as the time feature of that moment to characterize the seasonal position. The historical runoff observation data were sequentially subjected to non-negative truncation and logarithmic transformation to obtain historical runoff observation data with a smooth distribution. The historical runoff observation data, the historical meteorological observation data, and the forecast meteorological data with smooth distribution are respectively standardized. The standardized forecast meteorological data, historical meteorological observation data, and historical runoff observation data are combined with the time characteristics of the corresponding time points to construct the initial forecast meteorological time series, the initial historical meteorological time series, and the initial historical runoff time series of the target watershed in the period to be predicted. Using a sliding window, the initial historical meteorological time series and the initial historical runoff time series are segmented according to a preset historical sequence length to obtain historical meteorological time series and historical runoff time series; the initial forecast meteorological time series is segmented according to a preset forecast sequence length to obtain forecast meteorological time series.
3. The method according to claim 1, characterized in that, The self-attention model includes an input embedding layer, a location encoding layer, and an encoder. The historical meteorological time series and the historical runoff time series are input into the trained self-attention model so that the model, through a self-attention mechanism, captures the long-range hydrological temporal dependencies between different time steps within the historical period while avoiding gradient vanishing. Based on these long-range hydrological temporal dependencies, it generates global contextual features characterizing the runoff generation and confluence status of the target watershed within the historical period, including: The historical meteorological time series and the historical runoff time series are input into the input embedding layer, and the historical input time series vector is obtained through feature concatenation and linear mapping. The historical input time series vector is input into the position encoding layer, and the vector of each time step in the historical input time series vector is given temporal position information through position encoding to obtain the position encoded historical input time series vector. The location-encoded historical input time series vector is input into the encoder, and the long-range hydrological temporal dependencies in the historical input time series vector are extracted through the self-attention mechanism in the encoder, and the hidden state sequence is output. The global context features are obtained by performing global average pooling along the time dimension on the hidden state sequence using the following formula: Where C represents the global context feature; L represents the preset historical sequence length; Represents the hidden state sequence; This represents the feature vector corresponding to the k-th time step in the hidden state sequence.
4. The method according to claim 1, characterized in that, The process involves performing multiple backdiffusion processes using the conditional diffusion probability model. In each iteration of each backdiffusion process, cross-attention is calculated using the current denoised intermediate feature as the query and the global context feature as the key and value to obtain attention-enhanced features. Based on these attention-enhanced features, and guided by the runoff generation and confluence state represented by the global context feature, the initial noise data is iteratively denoised to generate multiple predicted runoff time series representing the runoff evolution process of the target watershed during the predicted period, including: The conditional diffusion probability model is used to perform multiple back-diffusion processes. In each iteration, a denoising network is used to fuse the noise data of the current time step with the forecast meteorological time series to obtain fused features. The fused features are processed sequentially through one-dimensional convolution, batch normalization, and activation function, and then residually connected with the fused features to obtain intermediate features. Using the intermediate feature as the query and the global context feature as the key and value, perform cross-attention calculation, and add the attention output to the intermediate feature to obtain the attention-enhanced feature; Based on the attention enhancement features, the noise data at the current time step, the current time step, the global context features, and the forecast weather time series, the noise to be removed at the current time step is predicted by the denoising network, and the noise data is updated according to the predicted noise. After a preset number of iterations, the noise data obtained from the final update is used as a predicted runoff time series.
5. The method according to claim 4, characterized in that, The intermediate features are obtained by sequentially processing the fused features through one-dimensional convolution, batch normalization, and activation functions, and then performing residual connections with the fused features, including: The fused features are processed sequentially using the following formula: one-dimensional convolution, batch normalization, and activation function. The processing results are then residual-connected with the fused features to obtain intermediate features: in, Indicates fusion characteristics; It is a one-dimensional convolution operator; For batch normalization operators; For activation functions; Linear layer; is the encoded value at time step t; out is the intermediate feature.
6. The method according to claim 2, characterized in that, Guided by the runoff generation and confluence state characterized by the global context features, the initial noise data is iteratively denoised to generate multiple predicted runoff time series representing the runoff evolution process of the target watershed during the predicted period, including: In each back-diffusion process, the initial noise data is iteratively denoised under the guidance of the runoff generation and confluence state characterized by the global context features to generate an initial predicted runoff time series. The initial predicted runoff time series is sequentially subjected to inverse standardization, anti-logarithmic transformation, and non-negative correction to obtain a predicted runoff time series that characterizes the runoff evolution process of the target watershed during the predicted period.
7. The method according to claim 1, characterized in that, The process involves calculating a specified quantile for each moment in the predicted runoff period based on multiple predicted runoff time series, constructing a confidence interval using the specified quantile as edges, and quantifying the uncertainty of the runoff prediction results through the confidence interval to obtain runoff prediction information containing a risk probability distribution, including: Based on multiple predicted runoff time series, for each moment in the period to be predicted, the value of that moment in all the predicted runoff time series is extracted to form a sample set. Sort the values in the sample set, and calculate the first specified quantile and the second specified quantile of the sample set; The confidence interval for this moment is constructed using the first specified quantile as the lower limit of the confidence interval and the second specified quantile as the upper limit of the confidence interval. The confidence intervals for all times within the predicted period are combined in chronological order to obtain the runoff prediction information containing the risk probability distribution.
8. A runoff prediction device, characterized in that, include: The acquisition module is used to acquire the forecast meteorological time series of the target watershed during the period to be predicted, as well as the historical meteorological time series and historical runoff time series during historical periods; The extraction module is used to input the historical meteorological time series and the historical runoff time series into the trained self-attention model, so that the self-attention model can capture the long-range hydrological time series dependencies between different time steps in the historical period through the self-attention mechanism while avoiding gradient vanishing, and generate global context features representing the runoff generation and confluence state of the target watershed in the historical period based on the long-range hydrological time series dependencies. The input module is used to input the forecast meteorological time series, the global context features, and the initial noise data into the trained conditional diffusion probability model. The conditional diffusion probability model performs multiple backdiffusion processes. In each iteration of each backdiffusion process, cross-attention calculation is performed using the current denoised intermediate feature as the query and the global context features as the key and value to obtain attention enhancement features. Based on the attention enhancement features, the initial noise data is iteratively denoised under the guidance of the runoff generation and confluence state represented by the global context features to generate multiple predicted runoff time series that represent the runoff evolution process of the target watershed during the predicted period. The calculation module is used to calculate a specified quantile for each moment in the period to be predicted based on multiple predicted runoff time series, construct a confidence interval with the specified quantile as the edge, and quantify the uncertainty of the runoff prediction result through the confidence interval to obtain runoff prediction information containing the risk probability distribution.
9. An electronic device, characterized in that, include: The device includes a processor, a memory, and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is in operation, the processor communicates with the memory via the bus, and the machine-readable instructions, when executed by the processor, perform the steps of the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the method as described in any one of claims 1 to 7.