Monthly runoff prediction method and system of TCN-GRU integrated model
Through the TCN-GRU integrated model and random weight averaging technology, the problems of insufficient feature extraction capabilities and poor stability in the existing runoff prediction methods are solved, and higher prediction accuracy and computing efficiency are achieved, and more effective water resource management and flood prevention and disaster reduction are supported.
Patent Information
- Application Number
- CN202411444297.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2025-03-11
AI Technical Summary
The existing runoff prediction methods have problems such as insufficient feature extraction capabilities, poor stability, generalization and low computing efficiency, which are difficult to meet the needs of water resource management and scheduling and flood prevention and disaster reduction.
A month runoff prediction method for TCN-GRU integrated model is proposed. By obtaining historical monthly runoff sequence data, data processing and feature extraction are performed, combining time convolution network and gated cycle units, a hybrid model is constructed, and the model parameters are averaged through random weight averaging technology to improve prediction accuracy.
It improves the accuracy of monthly runoff prediction, enhances the stability and generalization capabilities of the model, improves the computing efficiency, and can more effectively support water resource management and scheduling and flood prevention and disaster reduction.
Smart Images

Figure CN119598179A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of runoff forecasting, and in particular to a monthly runoff forecasting method and system based on a TCN-GRU integrated model. Background Art
[0002] The monthly runoff series has strong nonlinear and non-stationary characteristics, and most areas cannot meet the modeling requirements of process-driven models. Therefore, data-driven models are currently mainly used to predict monthly runoff. With the deepening of research, the method of using multi-model integration technology to fuse a single model has become a hot spot in the development of runoff prediction in recent years due to its higher prediction accuracy. However, the runoff prediction model fused by this method faces problems such as insufficient model feature extraction ability, poor stability, generalization and low computational efficiency, which is not conducive to water resources management and scheduling and flood prevention and disaster reduction. At present, there are few deep learning models built for single model integration technology for the study of monthly runoff prediction. Summary of the invention
[0003] The purpose of this section is to summarize some aspects of embodiments of the present invention and briefly introduce some preferred embodiments. Some simplifications or omissions may be made in this section and the specification abstract and the invention title of this application to avoid blurring the purpose of this section, the specification abstract and the invention title, and such simplifications or omissions cannot be used to limit the scope of the present invention.
[0004] In view of the above existing problems, the present invention is proposed.
[0005] Therefore, the present invention provides a monthly runoff prediction method and system based on a TCN-GRU integrated model to solve the problems of insufficient feature extraction capability, poor stability, low generalization and computational efficiency of existing runoff prediction methods.
[0006] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0007] In a first aspect, the present invention provides a monthly runoff prediction method based on a TCN-GRU integrated model, comprising:
[0008] Obtain historical monthly runoff series data, process the historical monthly runoff series data, and obtain training samples and target values;
[0009] The temporal convolutional network and the gated recurrent unit are connected in series to construct the first hybrid model;
[0010] Training and optimizing the first hybrid model;
[0011] The first integration technology is used to average the parameters of the first hybrid model after training and optimization at different times, and the obtained average parameters are used as the parameters of the final integration model to obtain the final runoff prediction value.
[0012] As a preferred solution of the monthly runoff prediction method of the TCN-GRU integrated model described in the present invention, wherein:
[0013] The method of processing the historical monthly runoff series data to obtain training samples and target values includes the following steps:
[0014] Normalize the historical monthly runoff series data;
[0015] The normalized monthly runoff series data is divided into training set and test set in proportion;
[0016] The monthly runoff series data in the training set and test set are converted into training and test data samples and target values through the time window technology.
[0017] As a preferred solution of the monthly runoff prediction method of the TCN-GRU integrated model described in the present invention, wherein:
[0018] The temporal convolutional network and the gated recurrent unit are connected in series to construct a first hybrid model, wherein the first hybrid model comprises the following steps:
[0019] Input the divided training and test data samples into the temporal convolutional network layer;
[0020] The temporal convolutional network extracts the feature information of different time scales in the input runoff time series data through convolution operations and outputs it as the result to the gated recurrent unit layer;
[0021] The input runoff time series data and the feature information of different time scales output by the temporal convolutional network layer are concatenated and input into the gated recurrent unit layer;
[0022] Regularize the output of the gated recurrent unit layer;
[0023] The high-dimensional feature information output by the gated recurrent unit layer and regularization technique is input into the fully connected layer and mapped into runoff prediction values.
[0024] As a preferred solution of the monthly runoff prediction method of the TCN-GRU integrated model described in the present invention, wherein:
[0025] The training and optimization of the first hybrid model includes using mean square error as the loss function of the model and selecting an optimizer to optimize model parameters.
[0026] As a preferred solution of the monthly runoff prediction method of the TCN-GRU integrated model described in the present invention, wherein:
[0027] The selecting optimizer to optimize the model parameters includes defining a cosine annealing learning rate scheduler to dynamically adjust the learning rate;
[0028] The dynamic adjustment of the learning rate comprises the following steps:
[0029] Set the starting iteration period of the cosine annealing learning rate scheduler and the maximum and minimum values of the dynamic adjustment of the learning rate;
[0030] Select Adam optimizer to optimize model parameters;
[0031] Before the model reaches the set number of iterations, the model is trained according to the maximum learning rate.
[0032] When the set number of iterations is reached, the learning rate during model training decreases according to the trend of the cosine curve until it decreases to the specified minimum value, then the model parameters are recorded and the learning rate is restarted to decrease according to the trend of the cosine curve at the maximum value of the learning rate.
[0033] After looping the scheduler multiple times, the model parameters corresponding to each time the learning rate reaches the minimum value are averaged.
[0034] As a preferred solution of the monthly runoff prediction method of the TCN-GRU integrated model described in the present invention, wherein:
[0035] The cosine annealing learning rate adjustment formula is expressed as:
[0036]
[0037] Among them, η t is the learning rate of the tth generation, η max and η min They represent the maximum and minimum values of the set learning rate change, T is the change period of the cosine annealing learning rate, cos(·) represents the cosine function, and mod(t-1,T) represents the remainder of t-1 divided by T.
[0038] As a preferred solution of the monthly runoff prediction method of the TCN-GRU integrated model described in the present invention, wherein:
[0039] The first integration technology is used to average the parameters of the first hybrid model after training and optimization at different times, and the obtained average parameters are used as the parameters of the final integrated model to obtain the final runoff prediction value. After the model training optimization is completed, the model parameters recorded during the training process are averaged as the parameters of the random weight model, and also as the integrated model parameters for the final prediction. The test set is brought into the integrated model for prediction, and the predicted results are denormalized to obtain the actual runoff prediction value.
[0040] In a second aspect, the present invention provides a monthly runoff prediction system based on a TCN-GRU integrated model, comprising:
[0041] A data processing module is used to obtain historical monthly runoff sequence data, perform data processing on the historical monthly runoff sequence data, and obtain training samples and target values;
[0042] A series connection module, used for connecting the temporal convolutional network and the gated recurrent unit in series to construct a first hybrid model;
[0043] A training optimization module, used for training and optimizing the first hybrid model;
[0044] The parameter averaging module is used to average the parameters of the first hybrid model after training and optimization at different times through the first integration technology, and use the obtained average parameters as the parameters of the final integration model to obtain the final runoff prediction value.
[0045] In a third aspect, the present invention provides a computing device, comprising:
[0046] Memory, used to store programs;
[0047] A processor is used to execute the computer executable instructions, which, when executed by the processor, implement the steps of the monthly runoff prediction method based on the TCN-GRU integrated model.
[0048] In a fourth aspect, the present invention provides a computer-readable storage medium, comprising: when the program is executed by a processor, the steps of implementing the monthly runoff prediction method of the TCN-GRU integrated model are implemented.
[0049] Beneficial effects of the present invention: The present invention proposes a TCN-GRU monthly runoff prediction integration method based on random weight averaging (SWA) technology, which uses random weight averaging technology to periodically and dynamically adjust the learning rate of the TCN-GRU model trained to a set number of iterations according to a defined cosine annealing learning rate, and averages the TCN-GRU model parameters at fixed moments in each cycle. After the training is completed, the averaged TCN-GRU model parameters are used as parameters of the final integration model and are used to perform monthly runoff prediction. The present invention is applied to monthly runoff prediction to improve the accuracy of monthly runoff prediction. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. Among them:
[0051] Figure 1 A schematic diagram of the basic flow chart of a monthly runoff prediction method using a TCN-GRU integrated model provided by an embodiment of the present invention;
[0052] Figure 2 A flow chart of a TCN-GRU runoff prediction integration model based on random weight averaging of a monthly runoff prediction method of a TCN-GRU integration model provided by an embodiment of the present invention;
[0053] Figure 3 A cosine annealing learning rate scheduler diagram for defining a monthly runoff prediction method for a TCN-GRU integrated model provided by one embodiment of the present invention;
[0054] Figure 4 A comparison chart of the predicted monthly runoff value and the true value of the integrated model proposed in the present invention for a monthly runoff prediction method using a TCN-GRU integrated model provided in one embodiment of the present invention. DETAILED DESCRIPTION
[0055] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the drawings of the specification. Obviously, the described embodiments are part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary persons in the art without creative work should fall within the scope of protection of the present invention.
[0056] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0057] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The term "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive with other embodiments.
[0058] The present invention is described in detail with reference to schematic diagrams. When describing the embodiments of the present invention, for the sake of convenience, the cross-sectional diagrams showing the device structure will not be partially enlarged according to the general scale, and the schematic diagrams are only examples, which should not limit the scope of protection of the present invention. In addition, in actual production, the three-dimensional dimensions of length, width and depth should be included.
[0059] At the same time, in the description of the present invention, it should be noted that the directions or positional relationships indicated by the terms "upper, lower, inner and outer" are based on the directions or positional relationships shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific direction, be constructed and operated in a specific direction, and therefore cannot be understood as limiting the present invention. In addition, the terms "first, second or third" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance.
[0060] In the present invention, unless otherwise clearly specified and limited, the terms "install, connect, connect" should be understood in a broad sense, for example: it can be a fixed connection, a detachable connection or an integral connection; it can also be a mechanical connection, an electrical connection or a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0061] Example 1
[0062] Reference Figure 1-2 , is an embodiment of the present invention, and provides a monthly runoff prediction method based on a TCN-GRU integrated model, such as Figure 1 As shown, the following steps are included:
[0063] S1: Obtain historical monthly runoff series data, process the historical monthly runoff series data, and obtain training samples and target values;
[0064] In an embodiment of the present invention, data processing is performed on historical monthly runoff series data to obtain training samples and target values, including the following steps:
[0065] Normalize the historical monthly runoff series data;
[0066] The normalized monthly runoff series data is divided into training set and test set in proportion;
[0067] The monthly runoff series data in the training set and test set are converted into training and test data samples and target values through the time window technology.
[0068] In the embodiment of the present invention, the normalization processing of the historical monthly runoff series data is expressed as:
[0069]
[0070] Among them, X is the original runoff data, X norm is the normalized runoff data, X max and X min are the maximum and minimum values of the original runoff data respectively.
[0071] It should be noted that the original monthly runoff series data is normalized to avoid problems such as gradient explosion or gradient vanishing in deep learning caused by large differences between data, thereby improving the convergence speed and prediction accuracy of the model.
[0072] In the embodiment of the present invention, dividing the normalized monthly runoff sequence data into a training set and a test set in proportion includes dividing the first 75% of the normalized monthly runoff data into a training set and the last 25% into a test set. The training set is used to train the model and adjust the model parameters, and the test set is used to test the model prediction effect.
[0073] In an optional embodiment, the time window technology can be a "lookback" window method, a sliding window method, or a multi-step forecasting method, all of which can help better capture patterns and dependencies in time series data, thereby improving the predictive performance of the model.
[0074] In an optional embodiment, the sliding window method is similar to the "lookback" window method, but is more flexible. It allows the adjustment of the window size and step size, which can better adapt to different time series data characteristics. For example, different window sizes and step sizes can be selected to generate training samples.
[0075] In an optional embodiment, the multi-step prediction method not only predicts the next time step, but also predicts data for multiple time steps in the future. For example, the runoff value for the next three months can be predicted using the data from the previous 12 months. This method can capture dependencies over a longer time frame.
[0076] In the embodiment of the present invention, the time series data is converted into feature samples and targets through the "lookback" window method, that is, how many time steps of data in the past will be considered by the model when predicting the next value. Each training sample contains the historical data of the previous 12 months as input feature data, which is used to predict the target runoff value of the next time step (1 month).
[0077] It should be noted that the method through the "lookback" window has the advantages of being simple to implement, highly flexible, computationally efficient, and easy to understand and explain in time series data processing. These advantages make it the preferred method for many time series forecasting tasks, especially in the field of deep learning.
[0078] S2: Concatenate the temporal convolutional network and the gated recurrent unit to construct the first hybrid model;
[0079] In an optional embodiment, the first hybrid model can be a TCN-LSTM hybrid model, a CNN-LSTM hybrid model, or a TCN-GRU hybrid model. All of the above hybrid models can be used to process the monthly runoff prediction task.
[0080] In an optional embodiment, a temporal convolutional network (TCN) and a long short-term memory network (LSTM) are combined, TCN is used to extract local features, and LSTM captures long-term dependencies, which can handle more complex dependencies and is suitable for long sequence data.
[0081] In an optional embodiment, a convolutional neural network (CNN) and a long short-term memory network (LSTM) are combined, CNN is used to extract local features, and LSTM is used to capture long-term dependencies, which is suitable for processing the combination of local features and long-term dependencies.
[0082] In an embodiment of the present invention, a temporal convolutional network (TCN) and a gated recurrent unit (GRU) are connected in series to construct a hybrid model including the following three main parts:
[0083] 1. Temporal convolutional network layer: The divided training and test data samples are input to the temporal convolutional network layer, which can be used to capture the internal features of the time series data of runoff. The temporal convolutional network can extract the feature information of different time scales in the input runoff time series data through convolution operations, and output it as a result to the next layer to improve the learning efficiency of the next layer of the network, which helps to improve the prediction accuracy of the overall model.
[0084] 2. Gated recurrent unit layer: The input runoff time series data and the feature information of different time scales output by the time convolutional network layer are spliced together and input into the gated recurrent unit layer. The gated recurrent unit is used to further process the long-term and short-term dependencies of the time series.
[0085] 3. Fully connected layer: Before the output of the gated recurrent unit layer is input to the fully connected layer, it will first pass through Dropout, which is a regularization technology that randomly discards the neuron information input to it according to the set probability, thereby preventing the model from overfitting and improving the generalization ability of the model. Finally, the high-dimensional feature information output by the gated recurrent unit layer and Dropout is input to the fully connected layer and mapped to the runoff prediction value.
[0086] It should be noted that the TCN-GRU hybrid model combines the advantages of temporal convolutional networks and gated recurrent units, and can capture short-term and medium-term dependencies in time series data while maintaining high computational efficiency and generalization capabilities. Compared with other hybrid models, the TCN-GRU hybrid model has obvious advantages in comprehensive performance, model structure, generalization ability and data processing, and is suitable for a variety of runoff prediction tasks.
[0087] S3: training and optimizing the first hybrid model;
[0088] In an embodiment of the present invention, the first hybrid model is trained and optimized, including using mean square error as the loss function of the model and selecting an optimizer to optimize model parameters.
[0089] In the embodiment of the present invention, the calculation formula of the mean square error is expressed as:
[0090]
[0091] Among them, y i is the true value, For the prediction results.
[0092] In an embodiment of the present invention, an optimizer is selected to perform model parameter optimization, including defining a cosine annealing learning rate scheduler and dynamically adjusting the learning rate to achieve exploration of the optimal parameter boundary of the model.
[0093] In the embodiment of the present invention, the adjustment rule is as follows: first, the starting iteration cycle of the cosine annealing learning rate scheduler and the maximum and minimum values of the dynamic adjustment of the learning rate need to be set, and Adam is used as the model optimizer. The learning rate before the model reaches the set number of iterations is trained according to the maximum value of the learning rate. After reaching the set number of iterations, the learning rate during model training decreases according to the trend of the cosine curve until it decreases to the specified minimum value, and then the parameters of the model are recorded, and then the maximum value of the learning rate is restarted to decrease according to the trend of the cosine curve. After the scheduler is cycled multiple times, the model parameters corresponding to each time the learning rate reaches the minimum value are averaged.
[0094] In the embodiment of the present invention, the process of TCN-GRU model training and prediction is as follows: Figure 2 As shown, the following steps are included:
[0095] Input the processed training set to the TCN-GRU model, train the TCN-GRU model according to the set hyperparameters, and determine whether the training period t is less than or equal to the start period T of the defined cosine annealing learning rate scheduler. s ;
[0096] If the training period t is greater than the starting period T of the defined cosine annealing learning rate scheduler s , the cosine annealing learning rate scheduler is not used, and the TCN-GRU model is trained only according to the set maximum learning rate. After the training is completed, it is determined whether it is the last training (i.e., the training cycle t = T max ), if not, the training cycle is increased by one and training continues;
[0097] When the training period t is less than or equal to the start period T of the defined cosine annealing learning rate scheduler sWhen , the defined cosine annealing learning rate scheduler is used to adjust the learning rate of the TCN-GRU model during training, and the model parameters when the learning rate is the smallest are recorded; once again, it is determined whether the training cycle t is equal to T max , if t=T max , the training is completed, the model parameters recorded during the average model training process are used as the parameters of the integrated model, and finally the test set is input into the integrated model to obtain the predicted value.
[0098] In the embodiment of the present invention, the cosine annealing learning rate adjustment formula is expressed as:
[0099]
[0100] Among them, ηt is the learning rate of the tth generation, η max and η min They represent the maximum and minimum values of the set learning rate change, respectively. T is the change period of the cosine annealing learning rate. cos(·) represents the cosine function. mod(t-1, T) represents the remainder of t-1 divided by T.
[0101] S4: The parameters of the first hybrid model after training and optimization at different times are averaged through the first integration technology, and the obtained average parameters are used as parameters of the final integration model to obtain the final runoff prediction value.
[0102] In an optional embodiment, the first integration technology can be a random weighted average (SWA) technology, an exponential moving average (EMA) technology, or a snapshot integration technology. All of the above methods utilize different states or versions of a single model during the training process and combine them in some way to improve the stability and generalization ability of the model.
[0103] In an optional embodiment, an exponential moving average (EMA) technique can calculate the weighted average of model parameters in real time during the training process, where newer parameters have higher weights. This method can smooth the training process, reduce model fluctuations, and improve model stability and generalization ability.
[0104] In an optional embodiment, although snapshot integration usually involves averaging the prediction results of multiple models during testing, it is also possible to save multiple model snapshots during the training process and average the parameters of these snapshots as the parameters of the final integrated model. This method can improve the diversity and generalization ability of the model.
[0105] In an embodiment of the present invention, the parameters of the trained and optimized model at different times are averaged based on the random weight averaging (SWA) technology, and the obtained average parameters are used as the parameters of the final integrated model to obtain the final runoff prediction value. After the model training optimization is completed, the model parameters recorded during the training process are averaged as the parameters of the random weight model, and also as the integrated model parameters for the final prediction. The test set is brought into the integrated model for prediction, and the predicted results are denormalized to obtain the actual runoff prediction value.
[0106] It should be noted that the random weight averaging (SWA) technique records the model parameters at multiple time points during the training process, and then averages these parameters to obtain a more stable and generalizable model. This method is simple and effective, and is particularly suitable for deep learning models.
[0107] This embodiment also provides a monthly runoff prediction system based on a TCN-GRU integrated model, including:
[0108] A data processing module is used to obtain historical monthly runoff sequence data, perform data processing on the historical monthly runoff sequence data, and obtain training samples and target values;
[0109] A series connection module, used for connecting the temporal convolutional network and the gated recurrent unit in series to construct a first hybrid model;
[0110] A training optimization module, used for training and optimizing the first hybrid model;
[0111] The parameter averaging module is used to average the parameters of the first hybrid model after training and optimization at different times through the first integration technology, and use the obtained average parameters as the parameters of the final integration model to obtain the final runoff prediction value.
[0112] Furthermore, it also includes:
[0113] Memory, used to store programs;
[0114] A processor is used to load the program to execute the monthly runoff prediction method based on the TCN-GRU integrated model.
[0115] This embodiment also provides a computer-readable storage medium storing a program, which, when executed by a processor, implements the monthly runoff prediction method of the TCN-GRU integrated model.
[0116] The storage medium proposed in this embodiment and the monthly runoff prediction method of the TCN-GRU integrated model proposed in the above embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.
[0117] Through the above description of the implementation methods, the technicians in the relevant field can clearly understand that the present invention can be implemented by means of software and necessary general hardware, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ReadOnly, Memory, ROM), random access memory (RandomAccess Memory, RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform the methods of various embodiments of the present invention.
[0118] Example 2
[0119] Reference Figure 3-Figure 4 , which is an embodiment of the present invention, provides a monthly runoff prediction method based on a TCN-GRU integrated model. In order to verify its beneficial effects, scientific demonstration is carried out through specific implementation methods and implementation effects.
[0120] The present embodiment is as follows:
[0121] The present invention takes the historical monthly runoff of the Lidi Hydropower Station, the third-level hydropower station in the upper reaches of the Lancang River, as an example to verify the effect of the present invention. Based on the TCN-GRU runoff prediction integrated model flow chart of random weight average, monthly runoff prediction is performed to reflect the effect achieved by the present invention.
[0122] The data used are the historical runoff data of Lidi Hydropower Plant from 1953 to 2014 (744 data in total), and the first 75% of the data (January 1953-August 1995) is used as the training set for training the model, and the last 25% of the data (September 1995-December 2014) is used as the test set for testing the model results.
[0123] Step 1: Data processing
[0124] The divided model is normalized to convert all data into numbers between 0 and 1. Then, the “lookback” window method is used to obtain the feature samples and targets for model training. Because the monthly runoff data shows periodic fluctuations with a cycle of 12 months, 12 is set as the lookback window size. For example, if the 13th runoff value is predicted, the previous 12 values are used as the input of the model, and so on.
[0125] Step 2: Define the model architecture
[0126] The temporal convolutional network and the gated recurrent unit are connected in series to build a hybrid model of the two. The hybrid model consists of the following three parts:
[0127] 1. Temporal convolutional network layer: This layer has 4 hyperparameters, namely the feature size of the input model (set to 1), the number of convolution kernel layers (set to 1), the number of channels of the convolution kernel (set to 3), the size of the convolution kernel (set to 3), and the regularization technique Dropout (set to 0.1).
[0128] 2. Gated recurrent unit layer: This layer has three hyperparameters, namely the feature size of the input to this layer (set to 4, because its input features are a combination of 3 features from the channel output of the convolution kernel and 1 original feature), the number of hidden layers (set to 3), and the number of neurons in each hidden layer (set to 24).
[0129] 3. Fully connected layer: This layer has three hyperparameters, namely the feature size of the input layer (set to 24, consistent with the number of neurons in the previous layer), the regularization technology Dropout (set to 0.3), and the output feature size (set to 1).
[0130] Step 3: Define a learning rate scheduler
[0131] Define a cosine annealing learning rate scheduler to dynamically adjust the learning rate to explore the optimal parameter boundary of the model. The adjustment rule is:
[0132] 1. Setting parameters: The optimization algorithm is based on the Adam optimizer model, the total iteration cycle is set to 500 times, the starting iteration cycle of the cosine annealing learning rate scheduler is set to 473, the range of dynamic adjustment of the learning rate is [0.008, 0.001], and the dynamic adjustment cycle of each learning rate is 9. Therefore, this experiment conducted a total of 3 dynamic adjustments of the learning rate.
[0133] 2. Before reaching the set number of iterations (473), the model is trained at the maximum learning rate of 0.008.
[0134] 3. When the set number of iterations is reached (473), the learning rate during model training decreases according to the trend of the cosine curve, such as Figure 3 As shown, the parameters of the model are recorded until they decrease to the specified minimum value (0.001), and then they are restarted to decrease according to the trend of the cosine curve at the maximum value of the learning rate.
[0135] 4. After the set number of dynamic adjustments, the scheduler is cycled 3 times, and the model parameter W corresponding to the minimum value of each learning rate is averaged. 1 , W 2 , W 3The final ensemble model parameter W of random weight average (SWA) ensemble is obtained swa .
[0136] Step 4: Training the model
[0137] The training set features and targets split in step 1 are input into the model architecture defined in step 2, and according to the learner scheduler and iteration cycle defined in step 3, the entire SWA integrated TCN-GRU monthly runoff prediction model is trained by calculating the loss function (mean square error) between the model's output results and the target each time.
[0138] Step 5: Prediction
[0139] After the model training is completed, the test set features split in step 1 are input into the model, and the obtained results are denormalized to obtain the final prediction value. Figure 4 As shown in the figure, it is a comparison chart of the predicted value of monthly runoff and the true value of the integrated model proposed by the present invention. It can be seen from the figure that the fit between the true value and the predicted value is high. It proves that the TCN-GRU integrated model based on random weighted average can be used in monthly runoff prediction.
[0140] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.
Claims
1. A monthly runoff prediction method based on a TCN-GRU integrated model, characterized in that: include: Obtain historical monthly runoff series data, process the historical monthly runoff series data, and obtain training samples and target values; The temporal convolutional network and the gated recurrent unit are connected in series to construct the first hybrid model; Training and optimizing the first hybrid model; The first integration technology is used to average the parameters of the first hybrid model after training and optimization at different times, and the obtained average parameters are used as the parameters of the final integration model to obtain the final runoff prediction value.
2. The monthly runoff prediction method of the TCN-GRU integrated model according to claim 1, characterized in that: The method of processing the historical monthly runoff series data to obtain training samples and target values includes the following steps: Normalize the historical monthly runoff series data; The normalized monthly runoff series data is divided into training set and test set in proportion; The monthly runoff series data in the training set and test set are converted into training and test data samples and target values through the time window technology.
3. The monthly runoff prediction method of the TCN-GRU integrated model according to claim 1 or 2, characterized in that: The temporal convolutional network and the gated recurrent unit are connected in series to construct a first hybrid model, wherein the first hybrid model comprises the following steps: Input the divided training and test data samples into the temporal convolutional network layer; The temporal convolutional network extracts the feature information of different time scales in the input runoff time series data through convolution operations and outputs it as the result to the gated recurrent unit layer; The input runoff time series data and the feature information of different time scales output by the temporal convolutional network layer are concatenated and input into the gated recurrent unit layer; Regularize the output of the gated recurrent unit layer; The high-dimensional feature information output by the gated recurrent unit layer and regularization technique is input into the fully connected layer and mapped into runoff prediction values.
4. The monthly runoff prediction method of the TCN-GRU integrated model according to claim 3, characterized in that: The training and optimization of the first hybrid model includes using mean square error as the loss function of the model and selecting an optimizer to optimize model parameters.
5. The monthly runoff prediction method of the TCN-GRU integrated model according to claim 4, characterized in that: The selecting optimizer to optimize the model parameters includes defining a cosine annealing learning rate scheduler to dynamically adjust the learning rate; The dynamic adjustment of the learning rate comprises the following steps: Set the starting iteration period of the cosine annealing learning rate scheduler and the maximum and minimum values of the dynamic adjustment of the learning rate; Select Adam optimizer to optimize model parameters; Before the model reaches the set number of iterations, the model is trained according to the maximum learning rate. When the set number of iterations is reached, the learning rate during model training decreases according to the trend of the cosine curve until it decreases to the specified minimum value, then the model parameters are recorded and the learning rate is restarted to decrease according to the trend of the cosine curve at the maximum value of the learning rate. After looping the scheduler multiple times, the model parameters corresponding to each time the learning rate reaches the minimum value are averaged.
6. The monthly runoff prediction method of the TCN-GRU integrated model according to claim 5, characterized in that: The cosine annealing learning rate adjustment formula is expressed as: Among them, η t is the learning rate of the tth generation, η max and η min They represent the maximum and minimum values of the set learning rate change, T is the change period of the cosine annealing learning rate, cos(·) represents the cosine function, and mod(t-1,T) represents the remainder of t-1 divided by T.
7. The monthly runoff prediction method of the TCN-GRU integrated model according to claim 6, characterized in that: The first integration technology is used to average the parameters of the first hybrid model after training and optimization at different times, and the obtained average parameters are used as the parameters of the final integrated model to obtain the final runoff prediction value. After the model training optimization is completed, the model parameters recorded during the training process are averaged as the parameters of the random weight model, and also as the integrated model parameters for the final prediction. The test set is brought into the integrated model for prediction, and the predicted results are denormalized to obtain the actual runoff prediction value.
8. A system for monthly runoff prediction based on the TCN-GRU integrated model of claim 1, characterized in that: A data processing module is used to obtain historical monthly runoff sequence data, perform data processing on the historical monthly runoff sequence data, and obtain training samples and target values; A series connection module, used for connecting the temporal convolutional network and the gated recurrent unit in series to construct a first hybrid model; A training optimization module, used for training and optimizing the first hybrid model; The parameter averaging module is used to average the parameters of the first hybrid model after training and optimization at different times through the first integration technology, and use the obtained average parameters as the parameters of the final integration model to obtain the final runoff prediction value.
9. An electronic device, characterized in that: include: Memory, used to store programs; A processor, used to load the program to execute the steps of the monthly runoff prediction method based on the TCN-GRU integrated model as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a program, characterized in that: When the program is executed by a processor, the steps of the monthly runoff prediction method of the TCN-GRU integrated model as described in any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Chip testing method based on deep learning optimization
CN119846440A