River flow velocity prediction method based on time sequence detection and long and short term feature fusion

Through the combination of the dual-branch LSTM network and attention mechanism, the problem of insufficient separation of medium- and long-term features in river flow velocity prediction is solved, efficient prediction of complex hydrological environments is achieved, and prediction accuracy and model adaptability are improved.

CN120541765APending Publication Date: 2025-08-26TIANJIN POLYTECHNIC UNIV
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510625181.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-15
Publication Date
2025-08-26

AI Technical Summary

Technical Problem

Traditional river flow velocity prediction methods are difficult to take into account both short-term fluctuations and long-term trends, and cannot fully tap time information, resulting in limited prediction accuracy. In addition, existing deep learning models have problems such as gradient disappearance and fixed weight fusion methods that cannot adapt to different hydrological scenarios when dealing with multi-scale features.

Method used

The dual-branch LSTM network is used to process long and short-term features separately, and dynamic weighted fusion is carried out in combination with attention mechanisms, and the model training efficiency is improved through adaptive optimization strategies, including sliding window mechanisms, embedded layer feature extraction, attention enhancement and adaptive model update.

Benefits of technology

It improves the accuracy of river flow velocity prediction and the adaptability of the model, significantly improves the prediction accuracy and generalization ability of extreme hydrological events, and reduces the calculation cost.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120541765A_ABST
    Figure CN120541765A_ABST
Patent Text Reader

Abstract

Accurate prediction of the river flow velocity is crucial in water resource management and water conservancy projects, but a complex time sequence mode caused by seasonal changes and weather conditions faces huge challenges. The traditional method is difficult to consider short-term fluctuation and long-term trend and cannot fully mine time sequence information. The invention proposes a river flow velocity prediction method based on time sequence detection and long and short term feature fusion, and the method comprises the steps: mapping a time feature into a low-dimensional vector through an embedded layer to enhance time sequence representation, capturing a short-term dynamic rule and a long-term period rule through employing a dual-branch LSTM, and screening key features in combination with an attention mechanism; the synchronously proposed dynamic learning rate adjustment and early stop mechanism effectively relieves overfitting, and a robust solution is provided for a data scarce scene. According to the invention, through lightweight architecture design and time sequence characteristic collaborative modeling, theoretical support and practical examples are provided for real-time deployment and long-term evolution requirements of a hydrological prediction system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of hydrological time series prediction, and in particular relates to a river velocity prediction method based on time series detection and fusion of long-term and short-term features. Background Art

[0002] Deep learning, a key branch of machine learning, achieves adaptive learning of complex temporal patterns by constructing multi-layer neural networks. Its core lies in extracting abstract feature representations of data layer by layer through nonlinear transformations. In the field of hydrological time series forecasting, deep learning models can automatically discover the dynamic evolution of river flow rates from massive amounts of multi-source data, breaking through the reliance of traditional statistical methods on linear assumptions. Current mainstream models include long short-term memory networks (LSTMs), temporal convolutional networks (TCNs), and CNN-LSTM hybrid architectures that integrate spatiotemporal features. For example, LSTMs capture temporal dependencies through gating mechanisms, TCNs utilize dilated convolutions to expand the receptive field, and CNN-LSTMs combine spatial feature extraction with temporal modeling capabilities.

[0003] With the increasing diversity and complexity of hydrological monitoring data, river flow prediction faces core challenges such as the coupling of multi-time-scale features, difficulty in modeling long-range dependencies, and significant environmental noise interference. Traditional LSTM models are prone to the vanishing gradient problem when processing long sequences, resulting in limited ability to capture weekly and monthly periodic patterns. Although TCN has the advantage of parallel computing, its fixed convolution kernel makes it difficult to adaptively adjust the feature weights of different time granularities. While hybrid models such as CNN-LSTM integrate multimodal features, they do not explicitly distinguish between the differential contributions of short-term fluctuations (such as hourly water flow mutations) and long-term trends (such as seasonal water level changes), resulting in low efficiency in multi-scale feature coordination. In addition, the concept drift phenomenon caused by extreme meteorological events and human activities makes it difficult for static models to dynamically adapt to the non-stationary characteristics of river systems. Frequent retraining is required to maintain prediction accuracy, which incurs high computational costs.

[0004] As an improved variant of recurrent neural networks, LSTM effectively alleviates the vanishing gradient problem of traditional RNNs through its gating mechanisms of forget gates, input gates, and output gates. It is particularly adept at modeling long-term dependencies in time series data. The attention mechanism empowers the model to dynamically focus on key time nodes. Its core idea is to achieve differentiated feature importance extraction by calculating adaptive weights for hidden states.

[0005] Given that river flow velocity is influenced by the multi-temporal and spatial-scale coupling of multiple physical variables, including short-term meteorological fluctuations, long-term seasonal patterns, and water temperature, turbidity, and flow direction, river flow prediction faces key challenges, including strong multi-scale feature coupling, a lack of dynamic weight allocation mechanisms, and inadequate utilization of spatiotemporal features. Short-term, high-frequency fluctuations (such as hourly velocity fluctuations) are intertwined with long-term, low-frequency trends (such as weekly / monthly seasonal variations). Traditional statistical models, relying on linear assumptions and artificial feature engineering, struggle to capture nonlinear dynamic correlations. Shallow machine learning models lack the ability to model time series and cannot exploit serial correlation in time series. While existing deep learning models can handle long-range dependencies, their single network architecture leads to insufficient separation of long-term and short-term features. Furthermore, their fixed-weight fusion approach cannot adapt to the dynamic changes in feature importance under different hydrological scenarios, limiting prediction accuracy. Therefore, a prediction method is needed that can effectively decouple long-term and short-term timescale features, dynamically focus on key information, and efficiently integrate multi-source data to address the modeling challenges in complex hydrological environments. The method of combining time series detection with the fusion of long-term and short-term features solves this problem. By constructing a dual-branch LSTM network, it captures hourly short-term dynamic features and weekly long-term trend features respectively, realizing decoupled modeling of multi-scale dependencies. The introduction of the attention mechanism dynamically weights the importance of features at different time steps, providing an efficient and reliable solution for river flow prediction. Summary of the Invention

[0006] Accurate river velocity prediction is crucial for water resource management, hydraulic engineering, and ecological protection. However, because river velocity exhibits complex temporal patterns influenced by factors such as seasonal variations and weather conditions, traditional prediction methods struggle to balance short-term fluctuations with long-term trends, failing to fully exploit temporal information and limiting prediction accuracy.

[0007] Inspired by the advantages of deep learning in processing time series data, this paper proposes a river velocity prediction method based on time series detection and the fusion of long-term and short-term features. This method uses innovative technical means to effectively integrate long-term and short-term features, improving the prediction model's adaptability to complex river velocity variations and thereby enhancing prediction accuracy.

[0008] The specific steps are as follows:

[0009] S1 constructs multimodal temporal input features, slices the raw sensor data into time series through a sliding window mechanism, and extracts timestamp-related embedding features;

[0010] S2 designs a dual-path heterogeneous LSTM network architecture to process long-term and short-term features respectively, and uses a decomposed parameter matrix for feature space mapping;

[0011] S3 introduces an attention-enhanced feature fusion mechanism, which implements dynamic feature weighted fusion through learnable weight parameters;

[0012] S4 establishes an adaptive model update system that integrates early stopping mechanism, dynamic adjustment of learning rate and model state snapshot function to optimize the training process.

[0013] Furthermore, step S1 specifically includes:

[0014] S11 defines a fixed-length time window (len_session = 20) and uses a sliding window mechanism to extract continuous time series segments from the raw sensor data. Specifically, for each sample point, the sensor data (9-dimensional features) of the first 20 time steps are intercepted to form an input sequence with a shape of [N, 20, 9]. At the same time, the timestamp information of the corresponding moment is extracted to generate an hour / week scalar sequence. A 5-fold cross-validation (KFold(n_splits = 5, shuffle = True, random_state = 42)) is used to divide the training set and test set to ensure that the continuity of the time series data is not destroyed. In the timestamp processing stage, the pandas dt method is used to extract the hourly value (0-23) and store it in the hour column, and the day of the week (0-6) is stored in the week column.

[0015] S12 constructs multimodal input containing spatiotemporal features. The specific implementation includes:

[0016] ① Time feature embedding is implemented through the nn.Embedding layer, where the hour embedding layer maps the integer hour scalar to a 20-dimensional vector, and the week embedding layer maps the week scalar to a 7-dimensional vector;

[0017] ② In the feature concatenation stage, the short-term feature path concatenates the sensor data ([batch, 20, 9]) with the hourly embedding ([batch, 20, 20]) in the second dimension to form a 29-dimensional feature tensor. The long-term feature path concatenates the sensor data with the weekly embedding ([batch, 20, 7]) to form a 16-dimensional feature tensor.

[0018] ③ The resulting three-dimensional tensor is passed through DataLoader, and the training set shape is [number of samples, 20, 29] (short-term path) and [number of samples, 20, 16] (long-term path);

[0019] S13 implements differentiated data standardization strategies, including:

[0020] ① Use StandardScaler to perform Z-score normalization on the input sensor features (9 dimensions), calculate the mean μ and standard deviation σ of each feature, perform the (x-μ) / σ transformation, and store the normalizer object scaler_x persistently;

[0021] ② Use MinMaxScaler to perform linear normalization on the target variable "Average Water Speed". Compress the value range to the interval [0,1] according to the formula (y - y_min) / (y_max - y_min). Save scaler_y for subsequent denormalization.

[0022] ③ The standardization process acts independently on the training set and test set after data division to avoid data leakage.

[0023] Furthermore, step S2 specifically includes:

[0024] The S21 dual-branch LSTM design concatenates sensor data with hourly embedding vectors and inputs them into the first LSTM network as a short-term feature path. It also concatenates sensor data with weekly embedding vectors and inputs them into the second LSTM network as a long-term feature path.

[0025] S22 establishes the latent space projection matrix, and the spliced ​​data is passed through the long-term LSTM and short-term LSTM to obtain the long-term LSTM hidden state H long and the short-term LSTM hidden state H short ,Right now:

[0026]

[0027] H long =LSTM(concat(X,E week )) (2)

[0028] H short =LSTM(concat(X,E hour )) (3)

[0029] where d hour is the dimension of the hour embedding vector, d week is the dimension of the week embedding vector, d hidden is the dimension E of the LSTM hidden layer week is the week embedding vector, E hour is the hour embedding vector, X is the original data;

[0030] S23 attention enhancement uses a dual-path attention weight matrix to calculate the temporal attention score:

[0031] α long =softmax(H long W long ) (4)

[0032] α short =softmax(H short Wshort ) (5)

[0033] where α long and α short They are long-term and short-term attention scores, W long and W short They are the long-term and short-term attention weight matrices, and the softmax function normalizes the features.

[0034] Furthermore, step S3 specifically includes:

[0035] S31 constrains its evolution space through the L2 regularization term of the Adam optimizer, and the weight update formula is:

[0036]

[0037] in, Indicates the value of the i-th parameter at the t-th iteration η is the learning rate, w i is the i-th parameter, l is the loss function, and λ is the weight attenuation coefficient;

[0038] S32 performs multi-level feature fusion. First, the primary fusion is performed to perform attention-weighted summation on the temporal hidden state output by LSTM:

[0039]

[0040] in, and is the long-term and short-term information of the t-th iteration, and are respectively the long-term and short-term eigenvectors of the t-th iteration;

[0041] Then, secondary fusion is performed to concatenate the two-way features and obtain the final feature vector H after the attention mechanism processing. attn :

[0042] H attn =FC attn (concat(H short ,H long )) (9)

[0043] Among them, FC attn It is a fully connected layer with attention-related parameters, and concat is a connection operation;

[0044] The final output is the dynamic weighted fusion three-way result out:

[0045] out=W short FC short (H short )+W long FClong (H long )+W time FC attn (H attn ) (10)

[0046] Where W time is the temporal weight matrix, FC long It is based on the long-term fully connected layer, FC short It is based on a short-term fully connected layer.

[0047] Furthermore, step S4 specifically includes:

[0048] S41 implements a dynamic optimization training control mechanism. The specific process is as follows:

[0049] S401 dynamic learning rate adjustment, based on the ReduceLROnPlateau strategy of verification loss plateau detection. When the verification loss does not improve for 5 consecutive epochs, the learning rate is decayed by a proportional factor of 0.5;

[0050] S402 early stopping mechanism monitors the validation loss and terminates the training if there is no decrease for 10 consecutive epochs to prevent overfitting;

[0051] S403 model snapshot, save the best model parameters and optimizer state to .pt file, the storage content includes: epoch, model_state_dict, optimizer_state_dict, loss;

[0052] The above S401 to S403 is a training and updating process of the model, and only the model with the best effect is retained;

[0053] S42 calculates MSE, RMSE, MAE, R by comparing the predicted value with the predicted value 2 Four-dimensional indicators are used, and P@k and MAP@k ranking indicators are defined to evaluate the model effect.

[0054] Compared with the prior art, the technical solution of the present invention has the following beneficial effects:

[0055] 1. To address the challenges of traditional river velocity prediction methods in balancing short-term fluctuations with long-term trends and inadequately exploiting temporal information, a feature fusion solution based on a dual-scale LSTM and attention mechanism was proposed. This model transforms temporal features through an embedding layer, utilizes dual LSTM layers to capture long- and short-term dependencies, leverages an attention mechanism to highlight key features, and employs a weighted fusion strategy to improve prediction accuracy.

[0056] 2. To address the insufficient integration of physical environmental variables and temporal features, we proposed an input modeling scheme that combines an embedding layer with feature splicing. By mapping temporal features such as hours and weeks into low-dimensional vectors and then splicing them with standardized physical variables such as flow direction and temperature, we achieved efficient integration of spatiotemporal features and enhanced the model's adaptability to complex environmental factors.

[0057] 3. To address the problem of poor robustness in extreme hydrological event prediction, a multi-resolution feature extraction and uncertainty perception fusion solution was proposed. By balancing high-frequency and low-frequency abnormal features through an attention mechanism and dynamically adjusting model weights in combination with an ensemble learning strategy, the prediction accuracy and model generalization ability of extreme flow events were significantly improved.

[0058] 4. To address the difficulty in balancing convergence speed and generalization ability during traditional model training, which can easily lead to overfitting, we proposed an adaptive optimization strategy for the SeekRiver model. This strategy combines gradient descent with L2 regularization using the Adam optimizer, dynamically adjusts the learning rate using ReduceLROnPlateau, and implements an early stopping mechanism to optimize the model training process. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] Figure 1 This is the data distribution of each indicator in the Water quality measurements for Brisbane River, Australia dataset.

[0060] Figure 2 is the trend of average water velocity over time.

[0061] Figure 3 The following is a performance comparison chart of different models.

[0062] Figure 4 This is a graph showing the performance change with the number of modules. As the number of modules increases, the mean square error has been on a downward trend. DETAILED DESCRIPTION

[0063] To verify the proposed model's advantages in performance and balancing multi-timescale characteristics, the effectiveness of model optimization in river velocity prediction, its adaptability to complex environmental factors, and its high robustness in extreme hydrological events, and to achieve effective model prediction in sample data, the specific steps are as follows:

[0064] (1) Dataset and preprocessing:

[0065] (101) Dataset: The Brisbane River water quality dataset in Australia is used. Figure 1The data in is the original data, including parameters such as water flow velocity, temperature, dissolved oxygen, pH value, turbidity, etc., and the sampling interval is 30 minutes. During the processing, the present invention removes redundant fields (such as "salinity [quality]"), retains key physical variables (water flow direction, temperature, dissolved oxygen, etc.) and the target variable "water flow velocity", Figure 2 The changes in average water speed from August 2023 to March 2024 are analyzed.

[0066] (102) Data preprocessing: Before training the model, the present invention will perform a series of preprocessing steps, delete irrelevant columns, and use MinMaxScaler to normalize all numerical features to the [0, 1] interval. The formula is:

[0067]

[0068] Where X represents the original data, X min and X max Represent the minimum and maximum values ​​of the features, X norm It is standardized data.

[0069] Sliding window processing divides the time series into continuous windows of length 20. The flow rate at the last time step of each window is used as the predicted label. Features and labels are assigned according to the requirements of different models. The data is divided into training and test sets in an 8:2 ratio to ensure that the time series continuity is not disrupted.

[0070] (103) Parameter settings: batch size 32, hidden size 64, one layer, 25 epochs, learning rate 0.001, weight decay 0.0001, embedding dimension hours 20, weeks 7. The learning rate is adjusted dynamically. Parameter tuning experiments show that modifying the batch size, hidden size, number of layers, or epochs leads to performance degradation. Therefore, the parameters are kept at the specified values.

[0071] (2) Comparative experiment:

[0072] (201) This paper proposes a SeekRiver model for river velocity prediction. The data set used is the Brisbane River water quality measurement data set in Australia. 80% of the data is used as a training set and 20% as a test set. Four machine learning models are selected as baseline models for comparative analysis. The model is then compared with four common deep learning models: LR, DTR, RNN, and LSTM. Since these four models have a high influence in the field of classification, they are used to verify the effectiveness of the method of the present invention.

[0073] LR: Assuming a linear relationship between the input features and the target variable, the parameters are determined by minimizing the mean squared error between the predicted value and the actual value.

[0074] DTR: Decision Tree Regressor recursively partitions the feature space, forms prediction decision rules, sets random seeds and simulates multiple training cycles to analyze training dynamics.

[0075] RNN: Used to process sequence data, it learns temporal dependencies by combining the output of the previous time step as the input of the current time step, fixes the random seed and performs multiple trainings to observe the loss changes and performance improvements.

[0076] LSTM: It solves the vanishing gradient problem through forget gates, input gates, and output gates, effectively handles long-term dependencies, and is widely used in fields such as speech recognition and machine translation. It analyzes its training process by tracking the loss function and optimizing progress through multiple training sessions.

[0077] (3) Comparative experimental results and analysis:

[0078] (301) During the experiment, each model was tested ten times, and the one with the best performance was taken as the experimental result. The specific results of each model are shown in Table 1.

[0079] Table 1 Overall performance comparison

[0080]

[0081] As can be seen from Table 1, the proposed method outperforms the baseline model in terms of MSE, RMSE, and MAE. Compared with DTR, the proposed model has a MSE reduction of 45.7986, a RMSE reduction of 2.3564, and a MAE reduction of 1.5021; compared with LR, the MSE is reduced by 23.0859, the RMSE is reduced by 1.2589, and the MAE is reduced by 1.1134; compared with RNN, the MSE is reduced by 48.88, the RMSE is reduced by 2.4969, and the MAE is reduced by 3.5463; compared with LSTM, the MSE is reduced by 4.1305, the RMSE is reduced by 0.2385, and the MAE is reduced by 0.2214. 2 In terms of scores, although the model proposed in this paper does not exceed LSTM, it is significantly higher than the other three baseline models, with the gap with LSTM being only 0.0261. This is because its attention mechanism focuses on local features, resulting in a slight weakness in grasping the overall data features.

[0082] from Figure 3 It can be proved again that the present invention is superior to the traditional model in terms of error in real scenarios and can better fit long-term and short-term dynamic changes.

[0083] In terms of P@k and MAP@k metrics, our model performs best on P@2, MAP@2, and MAP@5. Compared with the MAP metric of LSTM, SeekRiver shows significant improvements, with an increase of 0.2487 at MAP@2, 0.0987 at MAP@5, and 0.0598 at MAP@10.

[0084] In summary, SeekRiver performs well in the time series water velocity forecasting task. It can effectively manage the prediction error, although its R 2 The score is slightly lower than LSTM, but still significantly higher than other models, showing its strong data fitting ability. SeekRiver also excels in multiple key P@k and MAP@k. Although SeekRiver is slightly weaker than the decision tree in the MAP@10 metric due to the combination of long-term and short-term models, it shows substantial improvement compared to LSTM.

[0085] (4) Ablation experiment:

[0086] (401) To evaluate the contribution of each component in the model proposed by the present invention to the river flow velocity prediction task. The focus of this experiment is the output fusion of the model. The output of the original model is the weighted fusion result of short-term feature output, long-term feature output and attention output. The present invention performs three configurations: (A) removing the short-term feature output and only fusing the long-term feature output and attention output; (B) removing the long-term feature output and only fusing the short-term feature and attention output; (C) removing the attention output and only fusing the short-term and long-term feature outputs. In each setting, the model was trained and tested using the same water flow velocity time series dataset, and key performance indicators were recorded. The specific experimental results are shown in Table 2.

[0087] Table 2 Ablation studies

[0088]

[0089] The results show that all three components contribute positively to the model's performance. The attention mechanism has the greatest impact, while the long-term feature module's influence is less pronounced. Model B, which combines short-term features with attention, performs best across all metrics, approaching the performance of the full model. Model C, which excludes the attention output, has relatively high error metrics, confirming the important role of short-term features and the attention mechanism module in improving model performance. Water velocity data often has strong short-term correlations. The short-term feature module captures recent trends in water velocity changes, while the attention mechanism, through weighted fusion, highlights key feature information and enhances the model's focus on important features, thereby improving prediction accuracy and reliability.

[0090] from Figure 4It can be proved again that each module has an optimization effect on the model, among which the attention mechanism has the greatest effect on model optimization.

[0091] In summary, the short-term feature module and the attention mechanism are the key components to improve the performance of the model in water velocity prediction, while the long-term feature module serves as auxiliary information to help other modules achieve more accurate predictions.

Claims

1. A river velocity prediction method based on time series detection and fusion of long-term and short-term features, characterized by: The following steps are involved: S1 constructs multimodal temporal input features, slices the raw sensor data into time series through a sliding window mechanism, and extracts timestamp-related embedding features; S2 designs a dual-path heterogeneous LSTM network architecture to process long-term and short-term features respectively, and uses a decomposed parameter matrix for feature space mapping; S3 introduces an attention-enhanced feature fusion mechanism, which implements dynamic feature weighted fusion through learnable weight parameters; S4 establishes an adaptive model update system that integrates early stopping mechanism, dynamic adjustment of learning rate and model state snapshot function to optimize the training process.

2. The river velocity prediction method based on time series detection and fusion of long-term and short-term features according to claim 1 is characterized in that: Step S1 specifically includes: S11 defines a fixed-length time window (len_session = 20) and uses a sliding window mechanism to extract continuous time series segments from the raw sensor data. Specifically, for each sample point, the sensor data (9-dimensional features) of the first 20 time steps are intercepted to form an input sequence with a shape of [N, 20, 9]. At the same time, the timestamp information of the corresponding moment is extracted to generate an hour / week scalar sequence. A 5-fold cross-validation (KFold(n_splits = 5, shuffle = True, random_state = 42)) is used to divide the training set and test set to ensure that the continuity of the time series data is not destroyed. In the timestamp processing stage, the pandas dt method is used to extract the hourly value (0-23) and store it in the hour column, and the day of the week (0-6) is stored in the week column. S12 constructs multimodal input containing spatiotemporal features. The specific implementation includes: ① Time feature embedding is implemented through the nn.Embedding layer, where the hour embedding layer maps the integer hour scalar to a 20-dimensional vector, and the week embedding layer maps the week scalar to a 7-dimensional vector; ② In the feature concatenation stage, the short-term feature path concatenates the sensor data ([batch, 20, 9]) with the hourly embedding ([batch, 20, 20]) in the second dimension to form a 29-dimensional feature tensor. The long-term feature path concatenates the sensor data with the weekly embedding ([batch, 20, 7]) to form a 16-dimensional feature tensor. ③ The resulting three-dimensional tensor is passed through DataLoader, and the training set shape is [number of samples, 20, 29] (short-term path) and [number of samples, 20, 16] (long-term path); S13 implements differentiated data standardization strategies, including: ① Use StandardScaler to perform Z-score normalization on the input sensor features (9 dimensions), calculate the mean μ and standard deviation σ of each feature, perform the (x-μ) / σ transformation, and store the normalizer object scaler_x persistently; ② Use MinMaxScaler to perform linear normalization on the target variable "Average Water Speed". Compress the value range to the interval [0,1] according to the formula (y - y_min) / (y_max - y_min). Save scaler_y for subsequent denormalization. ③ The standardization process acts independently on the training set and test set after data division to avoid data leakage.

3. The river velocity prediction method based on time series detection and fusion of long-term and short-term features according to claim 1 is characterized in that: Step S2 specifically includes: The S21 dual-branch LSTM design concatenates sensor data with hourly embedding vectors and inputs them into the first LSTM network as a short-term feature path. It also concatenates sensor data with weekly embedding vectors and inputs them into the second LSTM network as a long-term feature path. S22 builds the latent space projection matrix, and the spliced ​​data is passed through the long-term LSTM and short-term LSTM to obtain the long-term LSTM hidden state H long and the short-term LSTM hidden state H short ,Right now: H long =LSTM(concat(X,E week )) (2) H short =LSTM(concat(X,E hour )) (3) where d hour is the dimension of the hour embedding vector, d week is the dimension of the week embedding vector, d hidden is the dimension E of the LSTM hidden layer week is the week embedding vector, E hour is the hour embedding vector, X is the original data; S23 attention enhancement uses a two-way attention weight matrix to calculate the temporal attention score: a long =softmax(H long ·W long ) (4) a short =softmax(H short ·W short ) (5) where α long and α short They are long-term and short-term attention scores, W long and W short They are the long-term and short-term attention weight matrices, and the softmax function normalizes the features.

4. The river velocity prediction method based on time series detection and fusion of long-term and short-term features according to claim 1 is characterized in that: Step S3 specifically includes: S31 constrains its evolution space through the L2 regularization term of the Adam optimizer, and the weight update formula is: in, Indicates the value of the i-th parameter at the t-th iteration η is the learning rate, w i is the i-th parameter, l is the loss function, and λ is the weight attenuation coefficient; S32 performs multi-level feature fusion. First, the primary fusion is performed to perform attention-weighted summation on the temporal hidden state output by LSTM: in, and is the long-term and short-term information of the t-th iteration, and are respectively the long-term and short-term eigenvectors of the t-th iteration; Then, secondary fusion is performed to concatenate the two-way features and obtain the final feature vector H after the attention mechanism processing. attn : H attn =FC attn (concat(H short ,H long )) (9) Among them, FC attn It is a fully connected layer with attention-related parameters, and concat is a connection operation; The final output is the dynamic weighted fusion three-way result out: out=W short ·FC short (H short )+W long ·FC long (H long )+W time ·FC attn (H attn ) (10) Where W time is the temporal weight matrix, FC long It is based on the long-term fully connected layer, FC short It is based on a short-term fully connected layer.

5. The river velocity prediction method based on time series detection and fusion of long-term and short-term features according to claim 1 is characterized in that: Step S4 specifically includes: S41 implements a dynamic optimization training control mechanism. The specific process is as follows: S401 dynamic learning rate adjustment, based on the ReduceLROnPlateau strategy of verification loss plateau detection. When the verification loss does not improve for 5 consecutive epochs, the learning rate is decayed by a proportional factor of 0.5; S402 early stopping mechanism monitors the validation loss and terminates the training if there is no decrease for 10 consecutive epochs to prevent overfitting; S403 model snapshot, save the best model parameters and optimizer state to .pt file, the storage content includes: epoch, model_state_dict, optimizer_state_dict, loss; The above S401 to S403 is a training and updating process of the model, and only the model with the best effect is retained; S42 calculates MSE, RMSE, MAE, R by comparing the predicted value with the predicted value 2 Four-dimensional indicators are used, and P@k and MAP@k ranking indicators are defined to evaluate the model effect.

Citation Information

Cited By

  • Illegal behavior prediction method based on dynamic slicing and double-branch confrontation

    CN120952960A

  • Embedded landslide real-time early warning method based on spatial-temporal feature decoupling

    CN121034058A