Multi-basin medium and long term runoff forecasting method based on improved LSTM model
By adding gating units to the LSTM model and combining multi-scale data, the BA-LSTM model solves the shortcomings of existing medium- and long-term hydrological forecasting methods in generalization capabilities and multi-basin adaptability, achieving higher forecast accuracy and wider scope of application.
Patent Information
- Application Number
- CN202411672382.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-21
- Publication Date
- 2025-03-18
AI Technical Summary
The existing medium- and long-term hydrological forecasting methods have shortcomings in generalization capabilities and multi-basin adaptability, and it is difficult to effectively utilize data of different scales of global and basin factors, resulting in limited forecast accuracy and scope of application.
A multi-basin medium- and long-term runoff forecasting method based on improved LSTM model is proposed, called the BA-LSTM model. By adding gating units to the standard LSTM model, this model can distinguish the impact of different river basins on forecast factors, and combine the meteorological data, global scale data and basin attribute information of multiple river basins to learn the unique impact of global scale data on different river basins.
The accuracy of medium- and long-term forecasting has been improved, the automation and scale of medium- and long-term runoff forecasting in multiple basins has been achieved, the universality and generalization capabilities of the model have been enhanced, and the background of different basins and climate change can be better adapted to different basins and climate change.
Smart Images

Figure CN119647994A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of hydrological information digital twin technology, and in particular to a multi-basin medium- and long-term runoff forecasting method based on an improved LSTM model. Background Art
[0002] In recent years, extreme climate events have occurred frequently around the world, posing severe challenges to watershed management and water resource scheduling. As a key link in the field of hydrological forecasting, medium- and long-term runoff forecasts can provide important support for disaster prevention and mitigation, rational use of water resources and environmental protection. However, medium- and long-term hydrological forecasts are affected by a combination of multiple factors across time and space, such as global scale factors such as the climate system index, and basin-scale meteorological and hydrological factors such as previous precipitation and land surface water storage. At present, the traditional method starts with the selection of forecast factors, by regularly trying different factor combinations at a high rate, and then using machine learning algorithms to explore the correlation between factors and runoff, and then analyzing and comparing the simulation or forecast results of the verification period, so as to optimize the combination, and finally select the best combination for testing or actual forecasting. This type of method usually models a single river basin, but due to the large time scale of medium- and long-term forecasts, the amount of data available for training and factor combination optimization is often small. Therefore, the correlations mined by complex machine learning only perform well in the calibration stage, but poorly in the testing stage, or from the perspective of machine learning, the generalization ability is poor, and it is even more difficult to generalize the laws learned in one river basin to other river basins or to extended data conditions not included in historical observations under the background of climate change.
[0003] Traditional medium- and long-term hydrological forecasts often use forecast factors for a single basin. Data limitations lead to poor generalization of the model under existing data conditions. Deep learning uses multi-basin data to establish a unified regional model, which can identify and utilize similar information between different basins, give full play to the synergy of large sample data, and effectively capture the laws of complex hydrological processes, thus improving this problem. However, since there is only one set of global scale factors for each basin, existing multi-basin medium- and long-term modeling studies cannot distinguish the weights of the impact of different basins on these same input global factors, resulting in the inability to effectively and comprehensively utilize global and basin-scale factor data. Therefore, current studies either only use basin-scale factors for medium- and long-term runoff simulations, or use global scale factors but relatively macroscopic regional flood level predictions. Deep learning medium- and long-term hydrological models that can comprehensively utilize multi-scale factor data at the multi-basin scale level need to be studied. To this end, the present invention proposes a multi-basin medium- and long-term runoff forecasting method based on an improved LSTM model. It adopts mature open source technologies such as geopanda, regionmask, and pytorch. By adding the BA module to the standard LSTM model, the model is able to distinguish the impact of prediction factors on runoff in different basins. Summary of the invention
[0004] Based on the above problems, the present invention introduces the BA-LSTM (Basin-Aware LSTM) model, which can effectively distinguish the meteorological inputs of different basins and learn the unique impact of global scale data on different basins through the improved LSTM structure, combined with the meteorological data, global scale data and basin attribute information of multiple basins. At the same time, BA-LSTM also has strong universality and can adapt to the medium- and long-term runoff forecasting needs of multiple basins. By utilizing basin meteorological data, global scale data, runoff data and basin attribute data obtained from multiple authoritative data sources, the BA-LSTM model not only improves the medium- and long-term forecast accuracy, but also realizes the automation and scale of medium- and long-term runoff forecasts in multiple basins.
[0005] The technical solution of the present invention is as follows: a method for long-term runoff forecasting in multiple basins based on an improved LSTM model, comprising the following steps:
[0006] Step 1: Obtain the runoff dataset, watershed attribute dataset, watershed meteorological dataset, and global scale data of the hydrological station; based on the DEM data in the above watershed attribute dataset, establish a watershed boundary vector file and save it as a shapefile file for subsequent extraction of watershed meteorological data and watershed attribute data within the watershed boundary;
[0007] Step 2: Create a mask for each basin through the basin boundary vector file controlled by the hydrological station obtained in step 1, and extract the meteorological data in each basin from the basin meteorological data set obtained in step 1; then, calculate the basin area weighted average of the meteorological data in the basin based on the meteorological data after mask processing;
[0008] Step 3: Based on the watershed boundary vector file and watershed attribute dataset obtained in step 1, batch-crop the watershed attribute dataset to cover the boundaries of each watershed; select the required watershed attribute data to perform area weighting or statistical summation to extract the attribute data of each watershed;
[0009] Step 4: Organize the watershed meteorological data and global-scale data after mask processing in step 2 into a three-dimensional tensor, organize the runoff data in step 1 into a two-dimensional tensor, and organize the watershed attribute data after processing in step 3 into a two-dimensional tensor; concatenate all tensors as input data for the BA-LSTM model;
[0010] Step 5: Constructing a BA-LSTM model: The BA-LSTM model is based on the standard LSTM model and adds an additional gated unit input gate to process the input global scale data; the basin attribute data is input into the BA-LSTM model, and the weights are generated by the activation function sigmoid to adjust the impact of the basin meteorological data input by the first input gate on the runoff of different basins and the impact of the global scale data input by the second input gate on the runoff of different basins;
[0011] The input of the entire BA-LSTM model includes basin meteorological data, global scale data and basin attribute data, where basin meteorological data and global scale data are input in the form of three-dimensional tensors with the shape of batch, time step and feature dimension, describing the dynamic characteristics at different times; basin attribute data are input in the form of two-dimensional tensors with the shape of batch and feature dimension, describing the static characteristics of the basin; at the beginning of the BA-LSTM model, the initial hidden state h0 and the memory state c0 are initialized to the all-zero tensor zeros, so that the BA-LSTM model has no interference from prior information at the first time step and only relies on the current input data for calculation; at each time step, the basin meteorological data, global scale data and basin attribute data are spliced together and input into the BA-LSTM model, and the BA-LSTM processes the input data through its forget gate, two input gates and output gate, thereby capturing the dynamic characteristics in the time series, and combining the basin attribute data to improve the BA-LSTM model's ability to understand and distinguish different basin characteristics; finally, after all time steps are calculated, the BA-LSTM model outputs the final hidden state h at time T = t t , and generate the runoff prediction results of the BA-LSTM model through the fully connected layer;
[0012] Step 6: Train the BA-LSTM model to obtain the optimal weight model: During the training process, the performance of the BA-LSTM model is gradually optimized by continuously adjusting the hyperparameters. At the same time, the Nash efficiency coefficient and Kling-Gupta efficiency performance indicators are set to evaluate the training results until the BA-LSTM model reaches the optimal state and obtains the optimal weight; finally, the trained BA-LSTM model is used for monthly runoff forecasts in different river basins.
[0013] The training process of the entire BA-LSTM model: at T=0, the basin meteorological data, basin attribute data and global scale data processed in step 4 are simultaneously used as the input of the BA-LSTM model, wherein the basin meteorological data is input into the BA-LSTM model and first processed by the forget gate before entering the unit state of the BA-LSTM model; then processed by the tanh function of the first input gate, multiplied with the basin attribute data processed by the sigmod function of the first input gate to obtain the output of the first input gate; the global scale data is processed by the tanh function of the second input gate and multiplied with the basin attribute data processed by the sigmod function of the second input gate to obtain the output of the first input gate. The output information of the two input gates; the information processed by the forget gate is added to the information of the two input gates to obtain the unit state input at the next moment; the hidden layer state input at the next moment is obtained by multiplying the unit state output at the current moment by the basin meteorological data and the hidden layer state input at the current moment after being processed by the sigmoid function of the output gate; finally, after t moments of cyclic calculation, at time T=t, the output hidden layer information is passed through the fully connected layer to obtain the runoff prediction result output by the entire BA-LSTM model; compared with the measured runoff data in step 4, the model parameters are continuously adjusted by back-propagating the error until the BA-LSTM model reaches the optimal state.
[0014] The global scale data is transformed into a tensor input ranging from -1 to 1 through the activation function tanh; at the same time, the basin attribute data is used as the input of the new activation function sigmoid, and the output is a weight ratio ranging from 0 to 1; the global scale data and the basin attribute data are multiplied after the activation function, and the global scale factor information input to each basin is distributed to different basins according to the degree of influence, thereby integrating the global scale data and the basin attribute data into the core calculation process of the BA-LSTM model; for the basin meteorological data, the input meteorological data is processed through the input gate tanh function of the standard LSTM model and mapped to [-1,1]; the activation function sigmod determines the contribution or influence of the input meteorological data on the output runoff of the BA-LSTM model through the input basin attribute data; finally, under the framework of the standard LSTM model, the basin attribute data X is controlled through the forget gate, two input gates and the output gate. s , Basin meteorological data x t and global scale data x g The flow within each model unit determines which information to retain and which information to discard, thereby constructing a multi-scale data-driven multi-basin unified medium- and long-term regional hydrological model; the specific formula is as follows:
[0015] i1=σ(W s2 X s +b i1 ) (1)
[0016] g = tanh(W g [x g ,h t-1 ]+b g ) (2)
[0017] Where i1 is the static property X of the watershed of the input gate s Input, nonlinear transformation through sigmoid activation function σ, adjust the static attribute X of the watershed s The impact of input on the current state; W s2 is related to the static property X of the watershed s Input the associated weight matrix, b i1 is the bias term of the input gate; g is the global scale data x of the input gate g Input, calculated by tanh activation function, combined with the current input x g and the hidden state h of the previous time step t-1 To generate new candidate states; W g is the corresponding weight matrix, b g is the bias term;
[0018] t=tanh(W t [x t ,h t-1 ]+b t ) (3)
[0019] i2=σ(W s1 X s +b i2 ) (4)
[0020] f t =σ(W f [h t-1 ,x t ]+b f ) (5)
[0021] c t =c t-1 *f+i1*g+i2*t (6)
[0022] h t =o t *tanh(c t ) (7)
[0023] o t =σ(W o [x t ,h t-1 ]+b o ) (8)
[0024] Among them, W tis the current input basin weather x t and the previous hidden state h t-1 The weight matrix, b t is the bias term; i2 is the second input gate, controlling the static input X s Impact on t update, W s1 is the weight matrix of the second input gate, b i2 is the bias term of the second input gate; f t is the forget gate, which controls how much previous information is retained in the cell state, W f is the weight matrix of the forget gate, b f is the bias term of the forget gate; c t Indicates the update of the current unit state, the previous unit state c t-1 With the forget gate f t Multiplication retains some old information, input gate i1 controls the inflow of g, and input gate i2 controls the influence of t; h t is the hidden state, output gate o t is the output gate of the current time step, which determines the hidden state h t Which parts are used as output.
[0025] The beneficial effects of the present invention are as follows: Traditional medium- and long-term forecasts are modeled for a single river basin, and the trained model is difficult to apply to other river basins. The BA-LSTM model designed by the present invention can solve this problem well. At the same time, it adopts multi-basin data for modeling, which can solve the problem of deep learning models' demand for big data, give full play to the data-driven ability of the model, improve the accuracy of medium- and long-term forecasts, and provide algorithm support for the construction of digital twin river basins. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 The invention flow chart provided for the present invention;
[0027] Figure 2 The basic framework diagram of the BA-LSTM model provided by the present invention;
[0028] Figure 3 The change of loss value during the BA-LSTM model training process provided by the implementation example of the present invention;
[0029] Figure 4 A runoff simulation effect diagram of a Harbin hydrological station in a one-month forecast period is provided as an implementation example of the present invention.
[0030] Figure 5 A runoff simulation effect diagram of the Gongtan hydrological station in a one-month forecast period is provided as an implementation example of the present invention. DETAILED DESCRIPTION
[0031] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0032] A multi-basin medium- and long-term runoff forecasting method based on an improved LSTM model includes the following steps:
[0033] Step 1: Obtain runoff data of hydrological stations from reliable hydrological station data sources (such as GRDC, hydrological departments or databases of any authoritative data providers), obtain basin attribute data from reliable watershed attribute information data sources (such as HydroATLAS or databases of any authoritative data providers), obtain basin meteorological data from reliable meteorological data sources (such as remote sensing data ERA5, rainfall stations or databases of any authoritative data providers), obtain global scale data from reliable large-scale data sources such as atmospheric circulation and sea surface temperature (such as National Climate Center, NOAA or databases of any authoritative data providers), and obtain river network vector information from reliable river network information data sources (such as HydroRIVERS or databases of any authoritative data providers), and save shapefile files (including *.shp, *.shx, *.prj, *.dbf files) of the locations of hydrological stations.
[0034] Step 2: Through the built-in functions of Python geopandas and regionmask open source packages, use the shapefile files (including *.shp, *.shx, *.prj, and *.dbf files) of the hydrological station control basin to create masks for each basin, and extract the meteorological data in each basin from the basin meteorological dataset obtained in step 1; then, calculate the basin area weighted average of the meteorological data in the basin based on the masked meteorological data.
[0035] Step 3: Import the watershed vector file prepared in step 2, and load the global data source (such as Hydro ATLAS, etc.), and expand the data source to the watershed boundary range. Then select the required attribute data (such as terrain, slope or land cover, etc.) and process these data, such as calculating the average height or slope of the watershed. Select the required watershed attribute data for area weighting or statistical summation to extract the attribute data of each watershed. Finally, export the processing results to the format of a table file csv for further analysis and application.
[0036] Step 4: Use the PyTorch open source package to organize the basin meteorological data and global scale data into a three-dimensional tensor (batch_size, sequence, input_size), the runoff data into a two-dimensional tensor (batch_size, sequence), and the basin attribute data into a two-dimensional tensor (batch_size, input_size).
[0037] Step 5: Add a gating unit to the standard LSTM model, take the basin attribute data (such as topography, soil type, land cover, etc.) as input, and generate the weight-adjusted global scale data and basin meteorological data on the runoff of different basins through a specific activation function (such as sigmoid). The global scale factor is the same input for each basin because there is only one set of data in the world. Therefore, an additional gating unit is needed. For the basin meteorological data, it only needs to be input through the tanh function of the standard LSTM model input gate, and the activation function sigmod inputs the basin attribute data. This ensures that the model can dynamically adjust the runoff response to different basins based on static attribute features. This mechanism solves the limitation of the traditional LSTM model that it cannot effectively identify regional heterogeneity in multi-basin scenarios. This LSTM model that enables the model to "recognize" or "be aware" of the unique attributes of each basin is called the BA-LSTM model (Basin-Aware-LSTM). This weight mechanism based on static basin attributes can dynamically adjust the combination of static and dynamic information, solving the problem that traditional LSTM models have difficulty representing internal basin heterogeneity when processing multi-source data. In particular, in comparative experiments between different basins, this improved structure can clarify which static features have a more significant impact on global-scale dynamic data by comparing changes in weight ratios, thus providing new ideas for understanding complex hydrological phenomena.
[0038] Step 6: Train BA-LSTM to obtain the optimal weight model. Randomly divide the hydrological data set F into two parts: training set and test set. The training set is used as the data sample for model fitting; the test set is used to evaluate the generalization ability of the final model. The ratio of the two data sets is 4:1. Finally, the trained model is used for medium- and long-term runoff forecasts in different basins to evaluate its results.
[0039] Furthermore, the specific implementation of step 1 may be as follows:
[0040] Step 1.1: Obtain txt / xlsx / csv / nc files from the reliable data sources mentioned in step 1, and manually remove invalid data (such as data that exceeds the survey range, or has null coordinates, or has a high missing rate). For example, for global-scale data obtained from reliable data sources such as the National Climate Center, including atmospheric circulation, sea surface temperature and other indices, a total of 130 items are in the format of xlsx files. Mainly perform operations such as data removal and interpolation based on the missing rate to improve the quality of input data;
[0041] Step 1.2: Convert the DEM data downloaded in step 1.1 into shapefile files (including *.shp, *.shx, *.prj, *.dbf files) through ArcGIS / QGIS. If the data source already provides the shapefile files of the site control basin, step 1.2 can be omitted and the shapefile files can be used directly;
[0042] Furthermore, the specific implementation of step 2 may be as follows:
[0043] Step 2.1: Place the collected watershed vector files in the same folder, and then place the watershed meteorological data preprocessed in step 1 in a folder. By calling the python geopandas and regionmask open source packages, use the watershed vector files (in the shapefile format) to mask the meteorological data (in the nc file format) and calculate the average watershed area of the corresponding watershed.
[0044] Step 2.2: Use the python dask open source package to perform parallel calculations on step 2.1, batch calculate the average value of the basin meteorological data in the shapefile files under the basin vector folder, and finally obtain the meteorological data of each basin in the format of a csv file. This realizes batch processing and automation, and improves work efficiency.
[0045] Furthermore, the specific implementation of step 3 may be as follows:
[0046] Step 3.1: Upload the folder storing the watershed vector files in step 2.1 to the assets folder of Google Earth Engine to prepare for the subsequent API calls to process the attribute data of each watershed;
[0047] Step 3.2: Call the Google Earth Engine API, use the powerful computing resources of the Google Earth Engine cloud platform to call data sources such as HydroATLAS, and use the basin vector file (in the shapefile format) to extract the attribute data of each basin, a total of 195 types including topography, geology, hydrology and climate, human activity impact, etc., and save them in the format of csv file.
[0048] Furthermore, the specific implementation of step 4 may be as follows:
[0049] Step 4.1: Build a PyTorchDataset and Dataloader to read basin meteorology, attributes, runoff, and global-scale dataset data. Divide the basin samples into a series of mini-batches, and use a stochastic gradient descent algorithm to complete the gradient descent calculation of each mini-batch. When performing operations on a computer, the input data of each batch will be organized into a three-dimensional array of samples, time periods, and variables, namely tensors. Among them, the length of the first dimension represents the number of samples randomly selected from the total sample, namely the batch size; the length of the second dimension represents the time period length of the time series variable of BA-LSTM, which is fixed during training; the third dimension represents each type of input variable;
[0050] Step 4.2: According to step 4.1, organize the basin meteorological data and global scale data into a three-dimensional tensor (batch_size, sequence, input_size), the runoff data into a two-dimensional tensor (batch_size, sequence), and the basin attribute data into a two-dimensional tensor (batch_size, input_size), to prepare for the input of the subsequent model.
[0051] In order to better understand the multi-basin medium- and long-term runoff forecasting method based on the improved LSTM model, the workflow of the improved LSTM model for multi-basin medium- and long-term forecasting is first explained. Figure 1 As shown:
[0052] The first step is data collection and processing
[0053] To verify the effect of the invention, the inventor collected and processed the meteorological data, attribute data, runoff data and global scale data of 208 river basins and stored them in the following files respectively. The data storage format is as follows.
[0054] Meteorological data is stored in the data / forcing_data folder; global scale data is stored in the data / global_data / output folder; basin static attribute data is stored in the data / attribute_data folder; basin outlet section runoff data is stored in the data / runoff_data / txt folder.
[0055] Note: There are 130 global scale factors, which are divided into three categories: sea surface temperature index, atmospheric circulation index and other indices; there is only one set of global scale data, but each basin needs to enter the global factor once when inputting data, so the global scale data in each basin file are consistent.
[0056] The Dataset and Dataloader in pytorch are used to organize the basin meteorological data, basin attribute data, global scale data and runoff data, and the data set is divided into training period and testing period with a ratio of 4:1.
[0057] The second step is to build a BA-LSTM model for training
[0058] The BA-LSTM model proposed in this embodiment is modified on the basis of the standard LSTM model, retaining the basic architecture of the model, and improving the LSTM model input structure by adding BA-block and introducing a new set of gating units. Among them, the global scale data is transformed into a model input ranging from -1 to 1 through the activation function tanh, and the static attribute data of the watershed is used as the input of the new activation function sigmoid, and the output is a weight ratio ranging from 0 to 1, which can distinguish the influence weight of the general factor on the runoff of different watersheds through the watershed attribute data. Figure 2 It is the basic framework of the algorithm model of the present invention.
[0059] NMSE, or normalized mean square error loss, is used as the loss function for model training. It is a commonly used loss function in machine learning and deep learning models to measure the error between the model's predicted value and the true value. Compared with the common mean square error (MSE), NMSE normalizes the error, usually allowing data of different dimensions to be compared on the same scale.
[0060]
[0061] Where: y i is the true value; is the model prediction value; is the mean of the true value; n is the number of samples; MSE is the mean square error; Var(y) is the variance of the true value y.
[0062] During training, the model output is calculated by forward propagation, the loss is calculated based on the normalized mean square error (NMSE), and then the model parameters are optimized by back propagation. In this embodiment, the optimizer uses Adam during the model training process, the learning rate is set to lr = 0.001, and the early stopping method is used to pay attention to the loss of the validation set. When the loss of the validation set is no longer reduced after 10 consecutive iterations, the model training is interrupted.
[0063] The third step is to save the optimal weight model and use it for prediction
[0064] After the training is completed, the saved optimal model is used to evaluate the test set to further verify the generalization ability of the model. The test set data is data that has not participated in training and verification at all, and can truly reflect the performance of the model in practical applications. By bringing the test set into the optimal model, common hydrological evaluation indicators (such as KGE, NSE, etc.) are calculated to evaluate the prediction accuracy and stability of the model for new data.
[0065] During the model training process, draw the loss value and evaluation index curve of the training set and the test set, such as Figure 3 As shown. Figure 3 It can be seen that the training loss of the model (blue curve) drops rapidly in the early stage, indicating that the model gradually learns the patterns in the data. After a certain number of epochs, the rate of decline of the loss slows down and tends to stabilize, indicating that the model converges well. The loss of the test set (light blue curve) also has a rapid decline, but there are some fluctuations in the middle part, indicating that the model may have some overfitting or learning fluctuations during the training process. However, with the increase of epochs, the validation loss gradually stabilizes and eventually remains at a low level with the training loss, which means that the model has good generalization ability. At the same time, each indicator reaches the minimum value at the 98th generation, so this experiment finally believes that the model training is completed at the 98th generation and the model parameters at this time are saved. The data of the test set is brought into the above-mentioned optimal model to obtain the confusion matrix of the model, as shown in Table 1. It can be seen from the table that the NSE of the model is 0.9 and the KGE is 0.73. At the same time, the optimal weight model is used to predict the monthly runoff of the Harbin and Gongtan hydrological stations. The prediction results are shown in Figure 4 , 5 shown.
[0066] Table 1 BA-LSTM model performance index statistics
[0067]
[0068]
Claims
1. A multi-basin medium- and long-term runoff forecasting method based on an improved LSTM model, characterized in that: The steps include: Step 1: Obtain the runoff dataset, watershed attribute dataset, watershed meteorological dataset, and global scale data of the hydrological station; based on the DEM data in the above watershed attribute dataset, establish a watershed boundary vector file and save it as a shapefile file for subsequent extraction of watershed meteorological data and watershed attribute data within the watershed boundary; Step 2: Create a mask for each basin through the basin boundary vector file controlled by the hydrological station obtained in step 1, and extract the meteorological data in each basin from the basin meteorological data set obtained in step 1; then, calculate the basin area weighted average of the meteorological data in the basin based on the meteorological data after mask processing; Step 3: Based on the watershed boundary vector file and watershed attribute dataset obtained in step 1, batch-crop the watershed attribute dataset to cover the boundaries of each watershed; select the required watershed attribute data to perform area weighting or statistical summation to extract the attribute data of each watershed; Step 4: Organize the basin meteorological data and global scale data after mask processing in step 2 into a three-dimensional tensor, organize the runoff data in step 1 into a two-dimensional tensor, and organize the basin attribute data after processing in step 3 into a two-dimensional tensor; concatenate all tensors as input data for the BA-LSTM (Basin-Aware LSTM) model; Step 5: Constructing a BA-LSTM model: The BA-LSTM model is based on the standard LSTM model and adds an additional gated unit input gate to process the input global scale data; the basin attribute data is input into the BA-LSTM model, and the weights are generated by the activation function sigmoid to adjust the impact of the basin meteorological data input by the first input gate on the runoff of different basins and the impact of the global scale data input by the second input gate on the runoff of different basins; The input of the entire BA-LSTM model includes basin meteorological data, global scale data and basin attribute data, where basin meteorological data and global scale data are input in the form of three-dimensional tensors with the shape of batch, time step and feature dimension, describing the dynamic characteristics at different times; basin attribute data are input in the form of two-dimensional tensors with the shape of batch and feature dimension, describing the static characteristics of the basin; at the beginning of the BA-LSTM model, the initial hidden state h0 and the memory state c0 are initialized to the all-zero tensor zeros, so that the BA-LSTM model has no interference from prior information at the first time step and only relies on the current input data for calculation; at each time step, the basin meteorological data, global scale data and basin attribute data are spliced together and input into the BA-LSTM model, and the BA-LSTM processes the input data through its forget gate, two input gates and output gate, thereby capturing the dynamic characteristics in the time series, and combining the basin attribute data to improve the BA-LSTM model's ability to understand and distinguish different basin characteristics; finally, after all time steps are calculated, the BA-LSTM model outputs the final hidden state h at time T = t t , and generate the runoff prediction results of the BA-LSTM model through the fully connected layer; Step 6: Train the BA-LSTM model to obtain the optimal weight model: During the training process, the performance of the BA-LSTM model is gradually optimized by continuously adjusting the hyperparameters. At the same time, the Nash efficiency coefficient and Kling-Gupta efficiency performance indicators are set to evaluate the training results until the BA-LSTM model reaches the optimal state and obtains the optimal weight; finally, the trained BA-LSTM model is used for monthly runoff forecasts in different river basins.
2. The multi-basin medium- and long-term runoff forecasting method based on the improved LSTM model according to claim 1 is characterized in that: The training process of the entire BA-LSTM model: at T=0, the basin meteorological data, basin attribute data and global scale data processed in step 4 are simultaneously used as the input of the BA-LSTM model, wherein the basin meteorological data is input into the BA-LSTM model and first processed by the forget gate before entering the unit state of the BA-LSTM model; then processed by the tanh function of the first input gate, multiplied with the basin attribute data processed by the sigmod function of the first input gate to obtain the output of the first input gate; the global scale data is processed by the tanh function of the second input gate and multiplied with the basin attribute data processed by the sigmod function of the second input gate to obtain the output of the first input gate. The output information of the two input gates; the information processed by the forget gate is added to the information of the two input gates to obtain the unit state input at the next moment; the hidden layer state input at the next moment is obtained by multiplying the unit state output at the current moment by the basin meteorological data and the hidden layer state input at the current moment after being processed by the sigmoid function of the output gate; finally, after t moments of cyclic calculation, at time T=t, the output hidden layer information is passed through the fully connected layer to obtain the runoff prediction result output by the entire BA-LSTM model; compared with the measured runoff data in step 4, the model parameters are continuously adjusted by back-propagating the error until the BA-LSTM model reaches the optimal state.
3. The multi-basin medium- and long-term runoff forecasting method based on the improved LSTM model according to claim 2 is characterized in that: The global scale data is transformed into a tensor input ranging from -1 to 1 through the activation function tanh; meanwhile, the watershed attribute data is used as the input of the new activation function sigmoid, and the output is a weight ratio ranging from 0 to 1; The global scale data and the basin attribute data are multiplied after the activation function, and the same global scale factor information is input to each basin and distributed to different basins according to the degree of influence, so as to integrate the global scale data and the basin attribute data into the core calculation process of the BA-LSTM model; for the basin meteorological data, the input meteorological data is processed by the input gate tanh function of the standard LSTM model and mapped to [-1, 1]; the activation function sigmod determines the contribution or influence of the input meteorological data on the output runoff of the BA-LSTM model through the input basin attribute data; finally, under the framework of the standard LSTM model, the basin attribute data X is controlled by the forget gate, two input gates and the output gate. s , Basin meteorological data x t and global scale data x g The flow within each model unit determines which information to retain and which information to discard, thereby constructing a multi-scale data-driven multi-basin unified medium- and long-term regional hydrological model; the specific formula is as follows: i1=σ(W s2 X s +b i1 ) (1) g=tanh(W g [x g ,h t-1 ]+b g ) (2) Where i1 is the static property X of the watershed of the input gate s Input, nonlinear transformation through sigmoid activation function σ, adjust the static attribute X of the watershed s The impact of input on the current state; W s2 is related to the static property X of the watershed s Input the associated weight matrix, b i1 is the bias term of the input gate; g is the global scale data x of the input gate g Input, calculated by tanh activation function, combined with the current input x g and the hidden state h of the previous time step t-1 To generate new candidate states; W g is the corresponding weight matrix, b g is the bias term; t=tanh(W t [x t ,h t-1 ]+b t ) (3) i2=σ(W s1 X s +b i2 ) (4) f t =σ(W f [h t-1 ,x t ]+b f ) (5) c t =c t-1 *f+i1*g+i2*t (6) h t =o t *tanh(c t ) (7) the t =σ(W o [x] t ,h t-1 ]+b o ) (8) Among them, W t is the current input basin weather x t and the previous hidden state h t-1 The weight matrix, b t is the bias term; i2 is the second input gate, controlling the static input X s Impact on t update, W s1 is the weight matrix of the second input gate, b i2 is the bias term of the second input gate; f t is the forget gate, which controls how much previous information is retained in the cell state, W f is the weight matrix of the forget gate, b f is the bias term of the forget gate; c t Indicates the update of the current unit state, the previous unit state c t-1 With the forget gate f t Multiplication retains some old information, input gate i1 controls the inflow of g, and input gate i2 controls the influence of t; h t is the hidden state, output gate o t is the output gate of the current time step, which determines the hidden state h t Which parts are used as output.