A Runoff Forecasting Method and System Based on Improved Generative Adversarial Networks
By improving the runoff forecasting method using generative adversarial networks, and by reconstructing data using variational autoencoders and combining adversarial training of the generator and discriminator, the training difficulty caused by the complexity of hydrological data is solved, thereby improving the accuracy and precision of runoff forecasting.
Patent Information
- Application Number
- CN202510145627.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-10
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2045-02-10
AI Technical Summary
Existing runoff forecasting models are difficult to train accurately due to the complexity and high randomness of hydrological data.
An improved generative adversarial network approach is adopted, which reconstructs data through variational autoencoders and combines adversarial training of generators and discriminators to build a prediction model. The generator and discriminator are trained using the reconstructed sample set, which enhances the model's ability to understand complex data structures and dynamically model time series data, and optimizes the generative adversarial training process.
It improves the forecast accuracy of runoff forecasting models, enhances the ability to identify complex time-series data and the stability of models, reduces training difficulty, and improves forecast performance.
Smart Images

Figure CN120180858B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the technical field of runoff forecasting, and more specifically, relates to a runoff forecasting method and system based on an improved generative adversarial network. Background Technology
[0002] In the field of runoff forecasting, the accuracy of runoff forecasts is crucial for optimizing reservoir operation strategies. However, the randomness and unpredictability of reservoir runoff pose significant challenges to forecasting models. Traditional statistical and physical models often struggle to capture complex nonlinear relationships and long-term dependencies. To address these challenges, machine learning and deep learning techniques are widely used. These techniques primarily rely on the relationship between input data and observed objects, without incorporating any manually set physical parameters. In recent years, with the continuous development of machine learning technology, learning-based models have become increasingly popular, and their performance has improved significantly.
[0003] However, data-driven learning models typically require a large amount of complete data to support model training, and the prediction accuracy of the model is highly correlated with the specific data in the training dataset. Therefore, how to use limited hydrological data for runoff prediction is of significant research importance. The hydrological data used to train existing runoff prediction models are usually complex in composition and have a high degree of randomness, which makes training the prediction models difficult and makes it challenging to achieve accurate runoff prediction. Summary of the Invention
[0004] In view of the above-mentioned defects or improvement needs of existing technologies, this invention provides a runoff forecasting method and system based on an improved generative adversarial network. This method addresses the problem that the hydrological data used in the training of existing runoff forecasting models are usually complex in composition and have a large degree of randomness, which makes it difficult to train the forecasting models and thus makes it difficult to achieve accurate runoff forecasting.
[0005] To achieve the above objectives, according to one aspect of the present invention, a runoff forecasting method based on an improved generative adversarial network is provided, comprising:
[0006] An initial sample set was established based on historical runoff data;
[0007] The variational autoencoder model is trained using the initial sample set. The trained variational autoencoder model is used to generate reconstructed samples based on the initial samples in the initial sample set. The initial samples and the reconstructed samples are combined to form a reconstructed sample set.
[0008] A prediction model is constructed based on a generative adversarial network, and the prediction model is trained using the reconstructed sample set to obtain the trained prediction model.
[0009] Runoff forecasting is performed using the trained forecasting model.
[0010] The runoff forecasting method based on an improved generative adversarial network provided by the present invention, specifically includes training the variational autoencoder model using the initial sample set as follows:
[0011] The KL divergence obtained during the training process is used to measure the difference between the latent spatial distribution of the encoder output of the variational autoencoder model and the standard normal distribution;
[0012] The reconstruction loss obtained during the training process is used to measure the difference between the reconstructed sample and the initial sample;
[0013] The total loss is obtained based on the KL divergence and reconstruction loss, and the variational autoencoder model is trained using the total loss.
[0014] According to the runoff forecasting method based on improved generative adversarial networks provided by the present invention, KL divergence The calculation formula is:
[0015]
[0016] In the formula, μ i Let represent the mean of the i-th latent variable; Let represent the variance of the i-th latent variable; D represents the dimension of the latent space; log(σ) 2 () represents the logarithmic variance;
[0017] Reconstruction loss The calculation formula is:
[0018]
[0019] In the formula, M is the initial number of samples; N is the number of features in the reconstructed samples; x ij This represents the feature value of the j-th compressed representation of the i-th initial sample; This represents the j-th reconstructed feature value in the reconstructed sample corresponding to the i-th initial sample;
[0020] Total loss The calculation formula is:
[0021]
[0022] According to the runoff forecasting method based on improved generative adversarial networks provided by the present invention, the forecasting model includes a generator and a discriminator, wherein the generator is constructed by a gated recurrent unit and a bidirectional long short-term memory network combined with an attention mechanism, and the discriminator is constructed by a convolutional neural network.
[0023] According to the runoff forecasting method based on improved generative adversarial networks provided by the present invention, the generator is followed by a Dropout layer after the gated recurrent unit and the bidirectional long short-term memory network, and three fully connected layers after the attention mechanism. The generator first processes the input data using a gated recurrent unit, and the output of the gated recurrent unit is passed to the bidirectional long short-term memory network. The output of the bidirectional long short-term memory network integrates the attention mechanism. The features processed by the attention mechanism are gradually mapped and reduced in dimensionality through three fully connected layers, and finally mapped to an output dimension to generate the prediction result.
[0024] The discriminator includes four one-dimensional convolutional layers, a flattening layer, and three fully connected layers. The output of the convolutional layers is flattened by the flattening layer into a one-dimensional tensor suitable for processing by the fully connected layer, and then the discriminant result is output after passing through the three fully connected layers.
[0025] According to the runoff forecasting method based on improved generative adversarial networks provided by the present invention, training the forecasting model using the reconstructed sample set specifically includes:
[0026] The generator is trained using its loss function, which is calculated as follows:
[0027]
[0028] In the formula, P represents the generator loss; g denoted by , where represents the distribution of samples generated by the generator; D(x) represents the score of the discriminator for the input sample x.
[0029] According to the runoff forecasting method based on improved generative adversarial networks provided by the present invention, training the forecasting model using the reconstructed sample set specifically includes:
[0030] The discriminator is trained using its loss function, which is calculated using the following formula:
[0031]
[0032] In the formula, P represents the discriminator loss; r λ represents the distribution of the real data; D(x) represents the score of the discriminator for the input sample x; λ represents the coefficient of the gradient penalty term; Represents the gradient penalty term; This represents maximizing the discriminator's score on the real data; Part Two This represents the score given by the discriminator to the generated data.
[0033] According to the runoff forecasting method based on improved generative adversarial networks provided by the present invention, the gradient penalty term The gradient norm used for the constrained discriminator is given by the following formula:
[0034]
[0035] In the formula, It is the interpolation between the generated sample and the real sample, representing the random interpolation between the generator and the real data; This represents the gradient norm of the discriminator on the interpolated samples; This indicates the distribution of the interpolated samples.
[0036] According to the runoff forecasting method based on improved generative adversarial networks provided by the present invention, the initial sample includes historical runoff data and corresponding feature data. The feature data includes average temperature, maximum temperature, minimum temperature, dew point temperature, rainfall, and multiple data from historical daily runoff of the previous 1 day, 2 days, and 3 days, as well as the maximum and minimum daily runoff of the current day.
[0037] According to another aspect of the present invention, a runoff forecasting system based on an improved generative adversarial network is provided. The system includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to perform the runoff forecasting method based on the improved generative adversarial network described above.
[0038] In summary, compared with the prior art, the runoff forecasting method and system based on improved generative adversarial networks provided by this invention offer the following advantages:
[0039] 1. By constructing a variational autoencoder to reconstruct data and merging the original data into the subsequent forecast model, the model's ability to understand complex data structures is enhanced. This allows for in-depth exploration of the potential distribution patterns of the initial sample data, the discovery of potential correlations between different types of data in the initial sample data, and the generation of reconstructed sample data with the same distribution patterns. The reconstructed sample data can be used to enhance the initial sample data. Therefore, training the forecast model based on the reconstructed sample set helps reduce training difficulty and improve the forecast accuracy of the trained forecast model.
[0040] 2. The forecasting model employs gated recurrent units and bidirectional long short-term memory networks to handle the long- and short-term dependencies in runoff data, enhancing its dynamic modeling capability for time series data. The attention mechanism optimizes the model's ability to focus on important features by weighting key time steps in the input sequence, effectively improving the model's ability to identify key features when processing complex time series data. The discriminator optimizes the generative adversarial training process by judging the generated data, improving the stability of the generative model and thus enhancing the forecasting performance of the runoff forecasting model.
[0041] 3. When applied to runoff prediction, this invention can improve the accuracy of runoff prediction. Attached Figure Description
[0042] Figure 1 This is a diagram of the generative adversarial network structure provided by the present invention;
[0043] Figure 2 This is a structural diagram of the variational autoencoder provided by the present invention;
[0044] Figure 3 This is a flowchart of the runoff forecasting method based on improved generative adversarial networks provided by the present invention;
[0045] Figure 4 This is a structural diagram of the runoff forecasting model generator based on an improved generative adversarial network provided by the present invention;
[0046] Figure 5 This is a structural diagram of the discriminator for the runoff forecasting model based on an improved generative adversarial network provided by the present invention;
[0047] Figure 6 This is a comparison chart of the calculation results of the runoff forecasting model based on the improved generative adversarial network provided by this invention with other prediction models. Detailed Implementation
[0048] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. Furthermore, the technical features involved in the various embodiments of this invention described below can be combined with each other as long as they do not conflict with each other.
[0049] Please see Figure 1 and Figure 2 This embodiment provides a runoff forecasting method based on an improved generative adversarial network (GAN). This method includes:
[0050] An initial sample set was established based on historical runoff data;
[0051] The variational autoencoder model is trained using the initial sample set. The trained variational autoencoder model is used to generate reconstructed samples based on the initial samples in the initial sample set. The initial samples and the reconstructed samples are combined to form a reconstructed sample set.
[0052] A prediction model is constructed based on a generative adversarial network, and the prediction model is trained using the reconstructed sample set to obtain the trained prediction model.
[0053] Runoff forecasting is performed using the trained forecasting model.
[0054] In existing technologies, Generative Adversarial Networks (GANs) are mainly applied in research fields such as image generation, data augmentation, natural language processing, image processing, and speech recognition. Currently, there are few runoff forecasting methods based on improved GANs. This embodiment constructs a forecasting model based on a GAN. During the training of the GAN, the generator and discriminator are trained adversarially, which can ensure the accuracy of the runoff forecast data generated by the generator. Furthermore, this embodiment proposes to construct a variational autoencoder to reconstruct and enhance the initial samples. The variational autoencoder can deeply explore the potential distribution patterns of the initial sample data, better understand the correlation between different types of data in the initial sample data, and generate reconstructed sample data with the same distribution patterns. Using the reconstructed sample data, the initial sample data can be enhanced, expanding the sample data volume. Therefore, training the forecasting model based on the reconstructed sample set helps to reduce the training difficulty and improve the forecasting accuracy of the trained forecasting model.
[0055] In some specific embodiments, the purpose of this embodiment is to propose a runoff forecasting method based on an improved generative adversarial network (GAN). This method introduces a variational autoencoder to learn the latent features of the data, reconstructs the data, and merges the original data into the forecasting model. A fusion attention mechanism is used to weight key time steps in the input sequence. A bidirectional long short-term memory network and a gated recurrent unit are coupled as the generator of the GAN, and four one-dimensional convolutional layers and three fully connected layers serve as the discriminator to predict the runoff. Finally, the simulated runoff output value is compared with the actual runoff to evaluate the merits of the runoff forecasting method. The specific steps are as follows:
[0056] Step 1: Data Loading and Preprocessing. First, load the initial sample set data and divide it into training and test sets at a ratio of 80% and 20%, respectively. To improve the model's generalization ability and stability, normalize the sequence data, i.e., the data in each initial sample.
[0057] Step 2: Construction and training of the Variational Autoencoder (VAE) model, followed by feature enhancement. A variational autoencoder is introduced to enhance the features of the predicted factors. The VAE model consists of an encoder and a decoder. The encoder maps the input feature data (initial sample data) to a latent space, which represents a compressed representation of the input data. Each dimension of the latent space corresponds to a latent variable, and the encoder outputs the mean and log-variance of these latent variables. The decoder reconstructs the feature input data based on the latent variables. During training, the VAE optimizes the model parameters by minimizing the total loss. The total loss consists of two parts: KL divergence loss and reconstruction loss. The Adam optimizer is used for gradient updates during training.
[0058] Training the variational autoencoder model using the initial sample set specifically includes: obtaining the KL divergence loss during training to measure the difference between the latent spatial distribution of the encoder output and the standard normal distribution; obtaining the reconstruction loss during training to measure the difference between the reconstructed samples rebuilt by the decoder and the initial samples. Based on the KL divergence and reconstruction loss, a total loss is obtained, and the variational autoencoder model is trained using the total loss.
[0059] The Adam optimizer is used for training. The KL divergence loss and reconstruction loss are calculated to obtain the total loss. Backpropagation is performed to calculate the gradient and update the model parameters. It is then determined whether the iteration termination condition has been met (either by setting a maximum number of iterations or a total loss threshold). If the termination condition is not met, the next iteration process is restarted. If the termination condition is met, the reconstructed feature data (i.e., the reconstructed samples) and the original feature data (i.e., the initial samples) are input together into the prediction model.
[0060] The KL divergence loss and reconstruction loss are shown in equations (1) to (3); the KL divergence is used to measure the difference between the latent spatial distribution of the encoder output and the standard normal distribution. For each sample data, the formula for calculating the KL divergence is:
[0061]
[0062] In the formula, μ i Let represent the mean of the i-th latent variable; Let represent the variance of the i-th latent variable; D represents the dimension of the latent space, i.e., the total number of latent variables; log(σ) 2 ) represents the logarithmic variance.
[0063] In a variational autoencoder, each initial input sample is a vector x composed of multiple features. i =[x i1 ,x i2 ,…,x iL ], where L is the number of features in the initial sample. Each sample is reconstructed by the decoder to obtain a vector consisting of N features. VAE uses binary cross-entropy to calculate the reconstruction loss. The reconstruction loss formula is:
[0064]
[0065] In the formula, M is the initial number of samples; N is the number of features in the reconstructed samples, and the number of reconstructed features is consistent with the number of latent variables; x ij The feature value of the j-th compressed representation of the i-th initial sample is the value of the j-th latent variable generated by the encoder from the i-th sample. It represents the j-th reconstructed feature value in the reconstructed sample corresponding to the i-th initial sample.
[0066] The total loss function of VAE consists of two parts: reconstruction loss and KL divergence. The formula is as follows:
[0067]
[0068] Step 3: Sliding window data preparation. For example, the window size is set to 3, each input reconstructed sample includes data from the first 3 time steps, and the output is the target value at the 4th time step;
[0069] Step 4: Improved Generative Adversarial Network Model Design and Training. The prediction model includes a generator and a discriminator. The generator is constructed using a gated recurrent unit (GRU) and a bidirectional long short-term memory network (BiLSTM) combined with an attention mechanism. The input data is processed by a GRU layer, and the output of the GRU layer is then passed to a BiLSTM layer with an integrated attention mechanism to generate data.
[0070] Specifically, refer to Figure 4 The generator first processes the input data using a GRU layer. GRU has a strong ability to capture short-term dependencies, effectively extracting local features and temporal dependencies from sequence data. The output of the GRU layer is then passed to a BiLSTM layer. BiLSTM captures long-term dependencies in the sequence by processing the data simultaneously in both the forward and backward directions, thus improving the model's ability to model sequence data.
[0071] To further improve model performance, this invention integrates an attention mechanism on top of the BiLSTM layer output. The workflow of this attention mechanism includes a linear transformation of the BiLSTM output, calculating the attention score for each time step. These scores are then normalized to obtain attention weights. These weights are then used to perform a weighted summation of the BiLSTM output to capture feature information from important time steps.
[0072] First, the attention weights are calculated, and the specific formulas are shown in equations (4) and (5):
[0073] a t =tanh(W a h t +b a (4)
[0074] In the formula, h is the hidden state, h t W is the hidden state of the BiLSTM network at time step t, with dimension d; a It is a learnable weight matrix with dimensions d×d; b a It is a bias term with dimension d; at It is the calculated attention score, with dimension d.
[0075] The score at each time step is mapped to a scalar value through another linear transformation, and then a normalized exponential function (softmax function) is applied to obtain the weights. The attention weights are the contribution proportions at each time step, so the weights of all time steps sum to 1.
[0076]
[0077] In the formula, It is a learnable weight matrix with dimension d×1, used to map the attention score to a scalar. t′ represents all time steps, α t ∑ is the normalized attention weight, representing the proportion of each time step's contribution to the final output. t′ exp(W c a t′ ) is a weighted sum of all time steps, used to standardize all weights.
[0078] The obtained attention weights are then used to perform a weighted summation of the input hidden states to obtain the final weighted output h. att The specific formula is shown in equation (6):
[0079]
[0080] In the formula, h att It is h t The weighted summed output will be passed as the output of the attention mechanism to subsequent layers of the model. α t It is the attention weight at time step t, representing the degree of contribution of time step t to the final output.
[0081] In the specific implementation, both the GRU layer and the bidirectional LSTM layer have 512 hidden units. Both use Dropout layers to prevent overfitting and enhance the model's robustness; that is, a Dropout layer is placed after the gated recurrent unit and the bidirectional long short-term memory network in the generator. The attention mechanism includes a linear layer and a context vector computation layer, responsible for optimizing feature weighting. Finally, three fully connected layers follow the attention mechanism. The features processed by the attention mechanism are progressively mapped and reduced in dimensionality through these three fully connected layers, decreasing from 512 to 128, then to 64, ultimately mapping to a single output dimension to generate the prediction result.
[0082] refer to Figure 5Then, a discriminator is constructed using a convolutional neural network (CNN), and the losses of the generator and discriminator are calculated. During training, the Adam optimizer is used for optimization, and the parameters of the generator and discriminator are updated. The iteration termination condition is checked; if it is not met, the next iteration begins; otherwise, the optimal prediction value is output. Specifically, the discriminator architecture includes four one-dimensional convolutional layers with 32, 64, 128, and 256 convolutional kernels, respectively; followed by a flattening layer and three fully connected layers. The output of the convolutional layers is then flattened into a one-dimensional tensor suitable for processing by the fully connected layers, and finally, the discrimination result is output after passing through three fully connected layers. The fully connected layers consist of three levels with 220, 220, and 1 neuron, respectively.
[0083] Lipschitz continuity is a way of describing the rate of change of a function. For a function f:R n →R m (From an n-dimensional real space to an m-dimensional real space), if there exists a constant L such that for all x, y∈R n All satisfy equation (7):
[0084] ∥f(x)-f(y)∥≤L∥xy∥ (7)
[0085] This function is then called Lipschitz continuous, where L is the Lipschitz constant, which measures the rate of change of the function. When L = 1, the function is said to satisfy the 1-Lipschitz condition. That is, for any two inputs x and y, equation (8) is satisfied:
[0086] ∥f(x)-f(y)∥≤∥xy∥ (8)
[0087] The 1-Lipschitz condition requires that the output of a function cannot change more than the input. This condition has a significant impact on the smoothness of the function, ensuring that the function does not fluctuate drastically, and is often used to guarantee the stability of optimization problems.
[0088] In WGAN-GP, the goal of the generator and discriminator is to minimize the Wasserstein distance, which measures the difference between the two distributions, as shown in equation (9):
[0089]
[0090] In the formula, W(P) r ,P g P represents the Wasserstein distance. r P represents the distribution of the real data. gThis represents the distribution of the generated data. f represents the output of the discriminator; specifically, the value of f(x) indicates the degree to which sample x is classified as real data. ∥f∥ L ≤1 indicates that the function f must satisfy the Lipschitz condition, i.e. This means taking the supremum, that is, choosing the function f that maximizes the expected difference among all functions f that satisfy the Lipschitz condition. That is, for the true data distribution P r The expected value of the function f(x) is calculated for all samples under given conditions; that is, the weighted average of the scores on the true data. x ~ P r Indicates the distribution of real data P r Samples were drawn from the middle. This indicates the distribution of the generated data P. g The expected value of the function f(x) is calculated for all samples under given conditions, which is the weighted average of the scores for the generated data. x ~ P r Indicates the distribution of real data P g Samples were drawn from the middle.
[0091] The training of the generator and discriminator involves two main loss functions: generator loss and discriminator loss. Training the prediction model using the reconstructed sample set specifically includes: training the generator using the generator's loss function and training the discriminator using the discriminator's loss function.
[0092] The discriminator aims to maximize its ability to distinguish between real and generated samples. To ensure the accuracy of the Wasserstein distance, the discriminator needs to satisfy the 1-Lipschitz condition. This condition ensures that the discriminator's gradient is not excessively large, thus avoiding instability during the optimization process.
[0093] The loss function of the discriminator includes the expected value of the real data, the expected value of the generated data, and the gradient penalty term. The specific formulas of the loss function of the discriminator are shown in (10) and (11).
[0094]
[0095] In the formula, This represents the discriminator loss. P r Let represent the distribution of the real data. D(x) represents the score of the discriminator for sample x. λ represents the coefficient of the gradient penalty term. This represents the gradient penalty term. This represents maximizing the discriminator's score on the real data. Part Two This represents minimizing the discriminator's score on the generated data. Wherein, This represents the expected value of the real data, i.e., obtained by analyzing the distribution P of the real data. r The average value of the function D(x) is calculated for all samples. This represents the expected value of the generated data, i.e., the value obtained by analyzing the distribution P of the generated data. g The average value of the function D(x) is calculated for all samples.
[0096] Gradient penalty term The gradient norm of the discriminator is used to constrain the 1-Lipschitz condition, as shown in the following formula:
[0097]
[0098] In the formula, It is the interpolation between the generated sample and the real sample, representing the random interpolation between the generator and the real data. This represents the gradient norm of the discriminator on the interpolated samples. This represents the distribution of the interpolated samples, typically the interpolation distribution between the generated data and the real data.
[0099] The goal of the generator is to generate data that is as realistic as possible, so that the discriminator considers the generated data to be real. Therefore, the generator's loss function aims to maximize the discriminator's score on the generated samples. The specific formula for the generator's loss function is shown in (12):
[0100]
[0101] In the formula, P represents the generator loss. g Let x represent the distribution of samples generated by the generator. Let D(x) represent the score of the discriminator for the input sample x.
[0102] Step 5: Model prediction and evaluation. The trained generative adversarial network is used to predict runoff data, the output prediction values are denormalized, and the results are compared with the original data for evaluation.
[0103] To comprehensively evaluate the predictive performance and computational efficiency of the experimental design model, this embodiment uses five prediction evaluation metrics: Root Mean Square Error (RMSE), Mean Absolute Error (MAE), Mean Absolute Percentage Error (MAPE), Coefficient of Determination (R²), and Pearson correlation coefficient (r), as shown in the following formulas:
[0104]
[0105]
[0106]
[0107]
[0108]
[0109] In the formula, y i , These represent the observed value and the predicted value, respectively. , respectively, represent the mean of observed values and the mean of predicted values; n is the length of the test set.
[0110] This specific embodiment uses hydrological data from the Yichang station on the upper reaches of the Yangtze River as an example to verify the effectiveness of the present invention. Figure 3 The overall flow chart of the runoff forecasting method based on the improved generative adversarial network is shown to demonstrate the effects achieved by this invention.
[0111] The initial sample includes historical runoff data and corresponding feature data. The feature data includes average temperature, maximum temperature, minimum temperature, dew point temperature, rainfall, and multiple data points from the historical daily runoff data for the previous 1, 2, and 3 days, as well as the current day's maximum and minimum daily runoff values. This embodiment uses daily runoff data from Yichang station from January 1, 2007 to December 31, 2021 to construct the initial sample set. The feature data includes average temperature, maximum temperature, minimum temperature, dew point temperature, rainfall, and historical daily runoff data for the previous 1, 2, and 3 days, as well as the current day's maximum and minimum daily runoff values.
[0112] Step 1: Collect daily runoff and characteristic data from Yichang Station from January 1, 2007 to December 31, 2021, removing missing or outlier values to ensure data completeness and accuracy. Normalize all data to ensure they fall within the [0, 1] interval to eliminate the influence of different units of measurement. Divide the dataset into a training set and a test set, with the training set comprising 80% of the data and the remaining 20% as the test set.
[0113] Step 2: Construct a variational autoencoder model. The encoder maps the input to a 5-dimensional latent space through a multi-layer fully connected network, with one latent variable in each dimension. The decoder then maps the representation of the latent space back to the input space. The model employs a reparameterization technique to sample the latent space using an approximate Gaussian distribution. The training objective is the sum of cross-entropy loss and KL divergence loss. The KL divergence term ensures that the latent distribution of the encoder output is as close as possible to a standard normal distribution. Training is performed using the Adam optimizer with a learning rate set to 1×10⁻⁶. -5 The batch size is 128, and the number of training iterations is 300. In each training round, the reconstruction loss and KL divergence of the model are calculated, and the parameters are updated via backpropagation. The trained VAE model is used to enhance the features, generating 5 new feature factors, which are then input into the prediction model along with the 10 feature factors from the original dataset.
[0114] Step 3: Use a sliding window method to convert the time series data into a format suitable for training the forecast model. The sliding window size is set to 3, each input sample includes data from the first 3 time steps, and the output is the target value for the 4th time step.
[0115] Step Four: Reference Figure 4 and Figure 5 The generator uses a GRU and BiLSTM architecture. The input is enhanced feature data, and the output is the predicted target variable. An attention mechanism is used to weight and combine the temporal data, thereby improving prediction accuracy. The output dimension of the GRU layer is 512, and the output dimension of the bidirectional LSTM is 256. After passing through the attention layer, a single target value is finally output through a Linear layer. The discriminator uses a convolutional neural network architecture, employing four convolutional layers to extract local features from the temporal data. The final true / false judgment result is output through a fully connected layer. The number of output channels for the convolutional layers are 32, 64, 128, and 256, respectively, and the true / false judgment result is output through three fully connected layers. The generator and discriminator are updated alternately; the generator is updated once after every five training iterations of the discriminator. The Adam optimizer is used for optimization, with a learning rate of 1×10⁻⁶. -4 The batch size is 128, and the number of training iterations is 100.
[0116] Step 5: Use the trained generator to predict the test set data and generate runoff prediction values. Inverse normalize the predicted latent features and transform them back to the scale of the original data. To evaluate the effectiveness of the prediction model proposed in this invention, this embodiment selects the following models for experimental comparison: Long Short-Term Memory (LSTM); Bidirectional Long Short-Term Memory (BILSTM); Gated Recurrent Unit (GRU); Generative Adversarial Network with Gradient Penalty (WGAN-GP); a fusion of GRU, BILSTM, and Gradient Penalty (GBWGAN-GP); a fusion of GRU, BILSTM, GRU, GRU, and Gradient Penalty (CGBWGAN-GP); and a fusion of GRU, BILSTM, GRU, GRU, GRU, and Gradient Penalty (CGBWGAN-GP-ATT). CGBWGAN-GP-ATT-VAE is the model of the method proposed in this invention, which integrates GRU, BILSTM, GRU, GRU, GRU, GRU, and Gradient Penalty. The prediction results are as follows: Figure 6 As shown in Table 1, the predictive performance of the model was evaluated using indicators such as root mean square error (RMSE), mean absolute error (MAE), mean absolute percentage error (MAPE), coefficient of determination (R²), and Pearson correlation coefficient (r). The calculation results of the runoff forecasting model based on the improved generative adversarial network (GAN) and other prediction models are presented in Table 1. Compared with the CGBWGANGP-ATT model, the model proposed in this invention showed an increase in the coefficient of determination of approximately 0.633% and a decrease in the MAE value of approximately 225.854. During the validation period, compared with the CGBWGANGP-ATT model, the coefficient of determination of the model proposed in this invention decreased by approximately 1.07%, and the MAE value decreased by approximately 296.719. This further confirms the advantages of introducing feature enhancement. Overall, the runoff forecasting method based on the improved GAN demonstrates good performance in runoff forecasting at Yichang station.
[0117] Table 1. Calculation results of the runoff forecasting model based on the improved generative adversarial network compared with other models.
[0118]
[0119]
[0120] This invention also provides a runoff forecasting system based on an improved generative adversarial network. The system includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to perform the runoff forecasting method based on the improved generative adversarial network described above.
[0121] Those skilled in the art will readily understand that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A runoff forecasting method based on an improved generative adversarial network, characterized in that, include: An initial sample set was established based on historical runoff data; The variational autoencoder model is trained using the initial sample set. The trained variational autoencoder model is used to generate reconstructed samples based on the initial samples in the initial sample set. The initial samples and the reconstructed samples are combined to form a reconstructed sample set. A prediction model is constructed based on a generative adversarial network, and the prediction model is trained using the reconstructed sample set to obtain the trained prediction model. Runoff forecasting is performed using the trained forecasting model. The initial sample includes historical runoff data and corresponding feature data. The feature data includes average temperature, maximum temperature, minimum temperature, dew point temperature, rainfall, and multiple data from the historical daily runoff of the previous 1 day, 2 days, and 3 days, as well as the maximum and minimum daily runoff of the current day. The prediction model includes a generator and a discriminator, wherein the generator is constructed from a gated recurrent unit and a bidirectional long short-term memory network combined with an attention mechanism, and the discriminator is constructed from a convolutional neural network; The generator is followed by a Dropout layer after the gated recurrent unit and the bidirectional long short-term memory network, and three fully connected layers after the attention mechanism. The generator first uses a gated recurrent unit to process the input data. The output of the gated recurrent unit is passed to the bidirectional long short-term memory network. The output of the bidirectional long short-term memory network is input to the attention mechanism. The features processed by the attention mechanism are gradually mapped and reduced in dimensionality through three fully connected layers, and finally mapped to an output dimension to generate the prediction result. The discriminator includes four one-dimensional convolutional layers, a flattening layer, and three fully connected layers. The output of the convolutional layers is flattened by the flattening layer into a one-dimensional tensor suitable for processing by the fully connected layer, and then the discriminant result is output after passing through the three fully connected layers.
2. The runoff forecasting method based on improved generative adversarial networks as described in claim 1, characterized in that, Training the variational autoencoder model using the initial sample set specifically includes: The KL divergence obtained during the training process is used to measure the difference between the latent spatial distribution of the encoder output of the variational autoencoder model and the standard normal distribution; The reconstruction loss obtained during the training process is used to measure the difference between the reconstructed sample and the initial sample; The total loss is obtained based on the KL divergence and reconstruction loss, and the variational autoencoder model is trained using the total loss.
3. The runoff forecasting method based on improved generative adversarial networks as described in claim 2, characterized in that, KL divergence The calculation formula is: In the formula, Indicates the first The mean of the 10 latent variables; Indicates the first The variance of each latent variable; The dimension representing the potential space; Represents the logarithmic variance; Reconstruction loss The calculation formula is: In the formula, This is the initial sample size; It is the number of features in the reconstructed sample; Indicates the first The first initial sample Each compressed representation of eigenvalues; Indicates the first The reconstructed sample corresponding to the initial sample is the first one. One reconstructed feature value; Total loss The calculation formula is:
4. The runoff forecasting method based on improved generative adversarial networks as described in any one of claims 1-3, characterized in that, Training the prediction model using the reconstructed sample set specifically includes: The generator is trained using its loss function, which is calculated as follows: In the formula, Indicates generator loss; This represents the distribution of samples generated by the generator; This indicates that the discriminator evaluates the input samples. The rating.
5. The runoff forecasting method based on improved generative adversarial networks as described in claim 4, characterized in that, Training the prediction model using the reconstructed sample set specifically includes: The discriminator is trained using its loss function, which is calculated using the following formula: In the formula, Indicates discriminator loss; Represents the distribution of real data; This indicates that the discriminator evaluates the input samples. The rating; This represents the coefficient of the gradient penalty term; Represents the gradient penalty term; This represents maximizing the discriminator's score on the real data; Part Two This represents the score given by the discriminator to the generated data.
6. The runoff forecasting method based on improved generative adversarial networks as described in claim 5, characterized in that, Gradient penalty term The gradient norm used for the constrained discriminator is given by the following formula: In the formula, It is the interpolation between the generated sample and the real sample, representing the random interpolation between the generator and the real data; This represents the gradient norm of the discriminator on the interpolated samples; This indicates the distribution of the interpolated samples.
7. A runoff forecasting system based on an improved generative adversarial network, characterized in that, The system includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to perform the runoff forecasting method based on the improved generative adversarial network as described in any one of claims 1-6.