LSTM flood routing method and system based on adaptive weight distribution, storage medium and product
By adjusting the learning weights for high and low flow periods in the LSTM model through an adaptive weight allocation mechanism, the problem of insufficient accuracy of traditional LSTM models during flood peaks and high flow periods is solved, achieving higher flood prediction accuracy and stability.
Patent Information
- Application Number
- CN202511138694.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-14
- Publication Date
- 2025-11-07
AI Technical Summary
Traditional LSTM-based flood evolution models lack accuracy during flood peaks and adjacent high-flow periods. Furthermore, due to the large proportion of low-flow samples, the models tend to learn low-flow characteristics, affecting the overall accuracy of flood prediction.
An adaptive weight allocation mechanism is adopted. By regularizing the prediction error of each flood subsequence, the weight coefficients are calculated to construct a weight allocation matrix, which is then embedded into the mean square error loss function. This enhances the learning weight during high-flow periods, reduces the focus on low-flow periods, and optimizes the model training stability and accuracy.
It improves the accuracy of flood evolution during peak and high-flow periods, enhances the prediction stability and accuracy of the entire flood process, and significantly improves the model's ability to capture flood change trends.
Smart Images

Figure CN120911295A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the field of flood routing, and more particularly, relates to an LSTM flood routing method based on adaptive weight assignment, a system, a storage medium and a product. BACKGROUND
[0002] Precise river flood routing is of great significance for flood control scheduling, disaster risk assessment and emergency response strategy formulation in a basin. Existing flood routing methods can be divided into three categories: hydrology methods, hydrodynamic models and data-driven methods. Common flood routing methods based on hydrology include the Muskingum method and the lagged routing method. These methods are simple to calculate, but they cannot fully reflect the hydraulic characteristics of the river channel and are difficult to represent the nonlinear relationship between channel storage and flow. Flood routing methods based on hydrodynamic models directly calculate the numerical solution based on the Saint-Venant equations, such as the water surface curve model and the one-dimensional hydrodynamic model. These models have high simulation accuracy, but the solving process is complex, the parameter dependence is strong, and the calculation is time-consuming, making it difficult to meet the real-time warning requirements. In recent years, data-driven deep learning models have provided a new paradigm for flood prediction. Time series models represented by LSTM can implicitly learn the nonlinear dynamic correlation between upstream and downstream flood processes due to their long-range dependence modeling capabilities, high computational efficiency and ease of expansion, significantly improving the accuracy of flood prediction. As a variant of recurrent neural networks, LSTM can overcome the gradient dispersion or gradient explosion problem of recurrent neural networks by introducing a "memory cell" structure, and can effectively learn the time dependence and long-term time series information between sequences. For this reason, LSTM is widely used in rainfall prediction, runoff prediction, flood prediction and other time series tasks.
[0003] Many studies have shown that the accuracy of flood process simulation mainly depends on the accurate depiction of flood peaks and their adjacent high-flow intervals. However, traditional LSTM-based flood routing models usually use mean squared error (MSE) as the global loss function, and this optimization strategy based on overall error minimization can easily lead to overfitting of low-flow intervals. In addition, due to the large proportion of low-flow samples in the time series, the model parameter calibration process will systematically favor the extraction of low-flow hydrological characteristics, resulting in low accuracy in the evolution of flood peaks and their adjacent high-flow intervals. SUMMARY
[0004] In view of the above defects or improvement needs of the prior art, the present application provides an LSTM flood routing method based on adaptive weight assignment, a system, a storage medium and a product, which aims to enhance the model's learning of flood characteristics during high-flow periods, improve the accuracy of flood prediction, and optimize the overall flood evolution effect.
[0005] To achieve the above object, according to the first aspect of the present application, a LSTM flood routing method based on adaptive weight distribution is provided, comprising the following steps:
[0006] The evolution model is trained by a training set, and flood routing prediction is realized based on the trained evolution model;
[0007] The training set comprises upstream flood samples and corresponding downstream flood measured values; the evolution model comprises an LSTM feature extraction network, a fully connected layer prediction network and an adaptive weight distribution module;
[0008] The LSTM feature extraction network extracts features from the upstream flood samples; the fully connected layer prediction network obtains a first prediction value of the downstream flood based on the extracted features, and constructs a mean square error loss function based on the first prediction value and the downstream flood measured value; the adaptive weight distribution module obtains a second prediction value of the downstream flood based on the extracted features, constructs a weight distribution matrix based on the prediction error of the second prediction value through regularization, and embeds the weight matrix into the mean square error loss function as a model loss function.
[0009] As a further preferred, the calculation formula of the weight distribution matrix W is as follows:
[0010]
[0011]
[0012] Wherein, Q u is an upstream flood flow sequence, is the i-th sub-sequence of Q u , and N is the number of flood samples; is the flood flow value at the t-th, (t+1)-th and (t+k-1)-th period; R i is the corresponding downstream flood prediction error, φ LSTM (·) is an LSTM feature extraction network, and φ e (·) is a prediction network of the adaptive weight distribution module; is the i-th sub-sequence of the downstream flood flow sequence Q d at the (t+k)-th period, is a two-norm; W i is an element in the weight distribution matrix W corresponding to the i-th sub-sequence, R max and R min are the maximum prediction error value and the minimum prediction error value of the adaptive weight distribution module, respectively.
[0013] As a further preferred, the model loss function The calculation formula is as follows:
[0014]
[0015] Among them, L mse Let be the mean squared error loss function, and ⊙ be the Hadamard product; For based on The first predicted value of downstream flood for the (t+k)th time period is φ. f (·) represents the prediction network for the fully connected layer.
[0016] As a further preferred embodiment, the method for constructing the training set includes: performing max-min normalization processing on the upstream and downstream historical flood data to obtain multiple upstream flood samples and corresponding downstream flood measured values as the training set.
[0017] As a further preferred embodiment, the upstream and downstream historical flood data includes upstream flood flow sequences and downstream flood flow sequences. Sliding window sampling is used to sample the normalized upstream and downstream flood flow sequences to extract flood subsequences, thereby obtaining upstream flood samples and corresponding downstream flood measured values.
[0018] According to a second aspect of the present invention, an LSTM flood evolution system based on adaptive weight allocation is provided, comprising a processor for executing the above-described LSTM flood evolution method based on adaptive weight allocation.
[0019] According to a third aspect of the present invention, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the above-described LSTM flood evolution method based on adaptive weight allocation.
[0020] According to a fourth aspect of the present invention, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the above-described LSTM flood evolution method based on adaptive weight allocation.
[0021] In summary, compared with the prior art, the above-described technical solutions conceived by this invention mainly possess the following technical advantages:
[0022] Compared with the global optimization strategy of the traditional LSTM flood evolution model, the flood evolution accuracy of the flood peak and its adjacent period is insufficient, and the flood evolution method based on adaptive weight distribution LSTM is proposed: by regularizing the error between the predicted value and the measured value of each flood subsequence, the weight coefficient of each subsequence is adaptively calculated in the training stage, and the weight distribution matrix is constructed, so as to adjust the flood feature learning weight of the high flow period and the low flow period, realize the adaptive increase of the high flow learning weight and the adaptive reduction of the low flow learning weight, and improve the flood evolution accuracy of the flood peak and the high flow period; and the weight distribution matrix is locally integrated into the mean square error loss function, which effectively improves the stability of the model training, effectively captures the flood change trend of the high flow period, improves the prediction accuracy of the flood subsequence, and the whole process of the flood is more stable. BRIEF DESCRIPTION OF DRAWINGS
[0023] Figure 1 The flow chart of the flood evolution method based on adaptive weight distribution LSTM of the embodiment of the application is shown in the figure.
[0024] Figure 2 The research area diagram of the embodiment of the application is shown in the figure.
[0025] Figure 3 The loss convergence curve comparison diagram in the model training process of the embodiment of the application is shown in the figure.
[0026] Figure 4 The evolution value and measured value comparison curve of the test set No. 1 flood of the embodiment of the application is shown in the figure.
[0027] Figure 5 The evolution value and measured value comparison curve of the test set No. 2 flood of the embodiment of the application is shown in the figure. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical scheme and advantages of the application clearer, the application is further described in detail below in combination with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the application and do not limit the application. In addition, the technical features involved in each embodiment of the application described below can be combined with each other as long as they do not conflict with each other.
[0029] Because the traditional LSTM flood routing model adopts a global optimization strategy, the model has insufficient accuracy in flood routing for flood peaks and high flow periods. The application proposes an adaptive weight distribution mechanism based on flood subsequence prediction error. First, by regularizing the error between the predicted value and the measured value of each flood subsequence, the weight coefficient of each subsequence is adaptively calculated in the training stage, and a weight distribution matrix is constructed. Second, the weight distribution matrix is locally integrated into the mean square error loss function based model to achieve adaptive increase of high flow learning weights and adaptive reduction of low flow learning weights, thereby improving the prediction accuracy of the flood subsequence and optimizing the flood routing effect. As shown in Figure 1 The application specifically comprises the following steps:
[0030] (1) Data processing.
[0031] The historical flood sequence data of the upstream and downstream intervals is obtained, the historical flood sequence data is normalized, and the historical flood sequence data is divided into training segments and test segments. Then, the upstream and downstream flood sequences are sampled by the sliding window sampling technology to obtain the upstream flood samples and the corresponding downstream flood measured values; a part of the upstream flood samples and the corresponding downstream flood measured values are combined as a training set to provide data input for model training; the remaining upstream flood samples and the corresponding downstream flood measured values are used as a test set to provide data input for model verification.
[0032] Specifically, to extract effective time series information from historical flood events, the historical upstream flood flow sequence Q u will be divided into multiple subsequences with a length of k, and the formula is as follows:
[0033]
[0034] Wherein, N is the number of subsequences, i.e. the number of samples; is the upstream flood subsequence; is the flood flow value of the i-th subsequence of the upstream at the t-th time period.
[0035] (2) Model architecture.
[0036] The routing model including the LSTM feature extraction network, the fully connected layer prediction network and the adaptive weight distribution module is constructed, and the neurons in the network are randomly initialized.
[0037] Specifically, the LSTM feature extraction network extracts features of the upstream flood sample; the fully connected layer prediction network obtains a first prediction value of the downstream flood based on the extracted features, and an error loss function is constructed based on the first prediction value and the measured value of the downstream flood; the adaptive weight distribution module obtains a second prediction value of the downstream flood based on the extracted features, constructs a weight distribution matrix based on the prediction error of the second prediction value through regularization, and embeds the weight matrix into the error loss function as a model loss function.
[0038] (3) Model training.
[0039] The evolution model is trained by using the training set: the flood sub-sequences in the training set are sequentially input into the model, the weight of each flood sub-sequence is adaptively calculated and added to the model loss function, and then the loss is back propagated by the Adam optimizer and the network parameters are updated; as the number of training iterations increases, when the model loss function value converges to a stable state, the optimal model parameters are saved, and a trained evolution model is obtained.
[0040] Specifically, the sub-sequence The first prediction value of the flood flow of the downstream flow at the (t+k) period is predicted by the fully connected layer prediction network According to the sum of all real values And the prediction value The mean square error between them is taken as the loss constraint, and the whole network is further back propagated so as to update the network parameters, and the mean square error loss function formula is as follows:
[0041]
[0042] Where, φ LSTM (·) is the LSTM feature extraction network, and φ f (·) is the fully connected layer prediction network.
[0043] The traditional mean square error loss learns the prediction error of each sub-sequence equally, and the optimizer adjusts the network parameters according to the error size to reduce the overall error. However, due to the large proportion of low-flow period samples, the values are small and the fluctuations are relatively flat, the model can fully learn the low-flow hydrological characteristics and give a relatively accurate prediction result. On the contrary, the flood samples of the flood peak and high-flow period have a small proportion, the values are large and the fluctuations are relatively significant. Under the strategy of global optimization, the traditional LSTM deep learning model cannot effectively capture the trend of flow change in the flood peak and high-flow period in the early learning, which ultimately leads to poor overall flood prediction performance. Therefore, the present application proposes an adaptive weight distribution module φ e (·) to calculate a weight W i based on the prediction error R i for each sub-sequence Q i, the calculation formula is as follows:
[0044]
[0045] Wherein, is the i-th flood sub-sequence; is the downstream flood flow sequence Q d The flood true value in the (t+k) period; is the two norm; R max , R min is the maximum prediction error value based on the second prediction value, the minimum prediction error value.
[0046] The greater the flood sub-sequence of the prediction error, the greater the corresponding learning weight value, and vice versa. Therefore, the weight is further integrated into the model loss function, so that the model can adaptively enhance the flood feature learning of the high flow interval, that is, a larger weight coefficient is given; At the same time, adaptively reduce the attention to the flood sub-sequence of the low flow period, that is, a smaller weight coefficient is allocated, and the reconstructed model loss function The calculation formula is as follows:
[0047]
[0048] The weight obtained after the prediction error of each sub-sequence is regularized will be redistributed to the improved mean square error loss, and the subsequent model will pay more attention to the sub-sequence with larger prediction error value fluctuation in each iteration optimization training, so as to effectively fit the flood peak and high flow period in the flood evolution. In addition, this mechanism is a module that can be directly embedded in the network, which realizes end-to-end accurate flood evolution by sharing parameters with the conventional LSTM-based fully connected prediction layer.
[0049] (4) Model test.
[0050] In the model test stage, the optimal model parameters obtained by training are imported into the test framework, and then the flood sub-sequence data in the test set is input for forward calculation, and the prediction result is output and the model performance is evaluated.
[0051] Specifically, in order to evaluate the effectiveness of the model, Nash efficiency coefficient (Nash-Sutcliffe Efficiency, NSE), relative error of flood peak (Relative error of flood peak, REP) and relative error of flood volume (Relative error of flood volume, REV) are used as model evaluation indexes. The specific calculation formula is as follows:
[0052]
[0053] wherein, is the mean of the measured flood flow; is the predicted flood peak flow value; q p is the measured flood peak flow value.
[0054] The following are specific embodiments:
[0055] The Hanjiang River is the largest tributary in the middle reaches of the Yangtze River. The river channel between Huangzhuang Station and Xiantao Station in the lower reaches of the Hanjiang River is selected as the research object. Huangzhuang Station is located in Jingzhong Town, Zhongxiang City, Hubei Province, and Xiantao Station is located in Xiantao City, Hubei Province. The length of the river channel from Huangzhuang to Xiantao is 225 km, and the research area is shown in Figure 2 The real flood data of Huangzhuang and Xiantao hydrological stations in 2018, 2020 and 2021 are used as the data basis. The flood data in 2018 and 2020 are used for model training, and the flood data in 2021 are used for model testing.
[0056] To ensure the fairness and consistency of the model comparison test, the proposed method and the traditional LSTM method are both stacked with two layers of LSTM units, and the number of units in each layer is 128. The prediction part is three fully connected layers, and the input and output of each layer are (128, 128), (128, 32) and (32, 1) respectively. There is a deactivation layer between the LSTM layer and the prediction layer, and the deactivation rate is set to 0.3. The flood sequence is sampled by the sliding window technique, and the sampling window size is set to 48, i.e. k = 48. The model parameter optimizer is Adam, and the learning rate is 0.001. The batch size of the training sample set is 32. The number of training iterations is 500. To reduce the influence of random errors, all experimental results are the average value of ten repeated tests.
[0057] The model loss convergence process can reflect the speed of parameter updating and whether the prediction performance is stable. With the increase of the number of model iterations, the smaller the model loss value and the smaller the numerical fluctuation amplitude, the better the model parameter convergence and the better the overall performance. Figure 3 The model loss convergence curves of the traditional LSTM model and the proposed method on the training set during training are given. The results show that during the model training, the loss value of the traditional LSTM-based flood evolution model is finally around 0.01, and the loss value fluctuation is obvious. The proposed method can train the model more quickly and stably, the model loss value is less than 0.005, and the loss value fluctuation is relatively stable. It is proved that the adaptive weight distribution mechanism proposed in the invention can effectively improve the ability of the model to capture the trend of the flood subsequence flow change and improve the overall flood evolution performance.
[0058] After the model is trained based on the training data until the model converges, two large floods in the test set are simulated and verified. Table 1 gives the results of the evaluation indexes of each model when the flood data of Huangzhuang Station evolves to Xiantao Station. As can be seen from Table 1, under the condition that only the flow data of Huangzhuang Station is used as the input condition, the Nash coefficients of the evolution method based on LSTM for No. 1 and No. 2 floods are 0.92 and 0.91, respectively. In comparison, the Nash coefficients of the proposed method for No. 1 and No. 2 floods are 0.96 and 0.92, respectively, which has a significant improvement effect. In addition, the proposed method has a significant improvement in the peak error and flood volume error indicators. For No. 1 flood, the peak error and flood volume error of the proposed method are 1.54% and -1.10%, respectively, while the peak error and flood volume error of the LSTM method are -11.97% and -5.55%, respectively. This is because the LSTM-based flood evolution method generally learns all flood sub-sequences evenly during the training process, and the ability to capture the flow trend of the flood peak and its adjacent period, which has a small sample proportion and large numerical fluctuations, is insufficient, resulting in poor learning effect of the overall flood time series information. Similarly, for No. 2 flood sequence, the peak error and flood volume error of the proposed method are 6.22% and 1.18%, respectively, and the overall performance is also better than the LSTM-based flood evolution method.
[0059] Table 1 Index evaluation results of the proposed method and the comparative method
[0060]
[0061] To more clearly show the difference between the flood evolution results of the proposed method and LSTM, Figure 4 and Figure 5 The flood hydrograph of the two large floods in the test set is given, and the evolution accuracy of the proposed model at low flow is basically the same as that of LSTM, but the simulation accuracy of the flood peak and its adjacent period is significantly improved. Therefore, the proposed method performs more stably throughout the flood process. In summary, it can be proved that the adaptive weight distribution LSTM neural network flood evolution method proposed in the present application significantly improves the learning ability of the mapping relationship between upstream and downstream flood flows, and has good overall flood evolution performance.
[0062] The present application proposes a flood evolution method based on adaptive weight distribution LSTM to solve the problem of low simulation accuracy of flood peak and high flow period caused by the balanced learning strategy of traditional LSTM model during flood evolution. The experimental results show that:
[0063] (1) The method adjusts the flood feature learning weight of high flow period and low flow period through an adaptive weight distribution module to improve the flood evolution accuracy of flood peak and high flow period.
[0064] (2) The method effectively improves the stability of model training by embedding the weight assignment matrix into the mean square error loss function of the model, and can effectively capture the flood change trend in high flow period compared with traditional LSTM, and the whole process flood is more stable.
[0065] Those skilled in the art will easily understand that the above description is only the preferred embodiment of the present application, and is not used to limit the present application, any modification, equivalent replacement and improvement made within the spirit and principle of the present application should be included in the protection scope of the present application.
Claims
1. An LSTM flood routing method based on adaptive weight distribution, characterized in that, The method comprises the following steps: training the evolution model through a training set, and realizing flood evolution prediction based on the trained evolution model; the training set comprises upstream flood samples and corresponding downstream flood measured values; the evolution model comprises an LSTM feature extraction network, a fully connected layer prediction network and an adaptive weight distribution module; the LSTM feature extraction network extracts features from the upstream flood samples; the fully connected layer prediction network obtains a first prediction value of downstream flood based on the extracted features, and constructs a mean square error loss function based on the first prediction value and the downstream flood measured value; the adaptive weight distribution module obtains a second prediction value of downstream flood based on the extracted features, constructs a weight distribution matrix based on the prediction error of the second prediction value through regularization, and embeds the weight matrix into the mean square error loss function as a model loss function.
2. The LSTM flood routing method based on adaptive weight distribution of claim 1, wherein, The calculation formula of the weight distribution matrix W is as follows: wherein Q u is an upstream flood flow sequence, is the i-th sub-sequence of Q u , and N is the number of flood samples; is the i-th sub-sequence of Q is the flood flow value at the t-th, (t+1)-th, and (t+k-1)-th period; R i is the i-th sub-sequence of Q is the corresponding downstream flood prediction error, φ LSTM (·) is an LSTM feature extraction network, φ e (·) is a prediction network of the adaptive weight assignment module; is the i-th sub-sequence of the downstream flood flow sequence Q d is the flood measured value at the (t+k)-th period of the i-th sub-sequence of Q is a two-norm; W i is an element in the weight assignment matrix W corresponding to the i-th sub-sequence, R max , R min are the maximum and minimum prediction error values of the adaptive weight assignment module, respectively.
3. The LSTM flood routing method based on adaptive weight distribution of claim 2, wherein, The model loss function The calculation formula is as follows: wherein L mse is a mean square error loss function, and is a Hadamard product; is based on obtained downstream flood first prediction value of the (t+k)th period, φ f is a fully connected layer prediction network.
4. The LSTM flood routing method based on adaptive weight distribution according to any one of claims 1-3, characterized in that, The construction method of the training set comprises: performing maximum minimum normalization on upstream and downstream historical flood data to obtain a plurality of upstream flood samples and corresponding downstream flood measured values as the training set.
5. The LSTM flood routing method based on adaptive weight distribution as claimed in claim 4, wherein, The upstream and downstream historical flood data comprises upstream flood flow sequences and downstream flood flow sequences, and the normalized upstream flood flow sequences and downstream flood flow sequences are sampled through sliding window sampling to extract flood subsequences, thereby obtaining upstream flood samples and corresponding downstream flood measured values.
6. An adaptive weight distribution based LSTM flood routing system characterized in that, The processor is configured to execute the LSTM flood evolution method based on adaptive weight distribution according to any one of claims 1-5.
7. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to realize the LSTM flood evolution method based on adaptive weight distribution according to any one of claims 1-5.
8. A computer program product, characterised in that, The computer program is executed by the processor to realize the LSTM flood evolution method based on adaptive weight distribution according to any one of claims 1-5.