Warehouse-in flow prediction method and device based on multi-scale time sequence attention mechanism

CN122596362APending Publication Date: 2026-08-18HUAZHONG UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611075577.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-20
Publication Date
2026-08-18

AI Technical Summary

Technical Problem

[0003]针对现有技术的缺陷,本申请的目的在于提供一种基于多尺度时序注意力机制的入库流量预测方法及装置,旨在解决现有技术因物理水文模型在构建过程中存在模型输入的误差累积、参数调试依赖工程师的经验、可移植性差等缺陷、数据驱动模型在应用过程中存在处理长序列数据能力不足、在应对复杂的时序数据时精度较差等缺陷导致预测入库流量的精度较低的问题

Benefits of technology

(1)本申请在基于目标输入窗口,根据当前多源水文气象数据生成时间序列流量预测矩阵后,引入将自注意力子层被替换为多尺度时序注意力机制的目标入库流量预测模型,显著增强模型对入库流量变化规律的表征能力,通过局部时序注意力分支和全局时序注意力分支分别学习短期和长期关联,充分表征时间序列中局部与全局依赖关系,采用的是端到端学习的方式,整个操作无需进行时间序列分解,然后结合自适应门控融合策略,实现对时间序列流量预测矩阵中的短期波动特征和整体变化趋势的协同提取,挖掘复杂水文时间序列中的多尺度动态信息,从而能够有效提高预测入库流量的精度,进而为水库调度运行、防洪控制及水资源优化配置提供技术支持。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122596362A_ABST
    Figure CN122596362A_ABST
Patent Text Reader

Abstract

This application belongs to the field of hydrological forecasting technology, specifically disclosing a method and apparatus for predicting reservoir inflow based on a multi-scale temporal attention mechanism. This application generates a time-series flow prediction matrix based on current multi-source hydrological and meteorological data; it employs a multi-scale temporal attention mechanism to extract short-term fluctuation features and overall trends through local and global temporal attention branches; it then fuses these short-term fluctuation features and overall trends using a learnable gating mechanism; and finally, it determines the predicted inflow to the target reservoir within the future forecast period based on the encoded feature representation. By introducing a target inflow prediction model that replaces the self-attention sublayer with a multi-scale temporal attention mechanism, and by learning short-term and long-term correlations through local and global temporal attention branches respectively, it fully characterizes the local and global dependencies in the time series, thereby effectively improving the accuracy of inflow prediction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of hydrological forecasting technology, and more specifically, relates to a method and apparatus for predicting reservoir flow based on a multi-scale temporal attention mechanism. Background Technology

[0002] Accurate prediction of reservoir inflow plays a crucial role in reservoir safety management, ecological environmental protection, and hydropower peak and frequency regulation. In recent years, scholars and experts at home and abroad have conducted extensive research on inflow prediction technology, proposing to construct hydrological models or data-driven models for inflow prediction. Among them, physical hydrological models are usually established based on runoff generation and confluence processes, such as the Xin'anjiang model and the SWAT model. However, physical hydrological models involve a large number of hydrological elements during construction, resulting in defects such as accumulated errors in model input, reliance on engineers' experience for parameter tuning, and poor portability. Data-driven models are usually constructed based on historical inflow data of reservoirs and time-series data of relevant meteorological factors. The mainstream method is machine learning or deep learning models. For Transformer, by introducing a self-attention mechanism, a connection is established between any two positions of the given data. At the same time, an encoder-decoder architecture is adopted, where the data input passes through multiple encoders and the output is sent to each decoder to calculate the attention. On the other hand, Transformer uses positional encoding to manually add data and input data in parallel, further improving the model's training efficiency. However, in practical applications, it still has shortcomings such as insufficient ability to handle long sequence data and poor accuracy when dealing with complex time-series data. Therefore, the above methods have low accuracy in predicting inbound traffic. Summary of the Invention

[0003] To address the shortcomings of existing technologies, this application aims to provide a method and apparatus for predicting inflow based on a multi-scale time-series attention mechanism. This aims to solve the problems of low accuracy in predicting inflow caused by the accumulation of errors in the model input during the construction of physical hydrological models, reliance on engineers' experience for parameter debugging, poor portability, insufficient ability of data-driven models to process long-series data, and poor accuracy when dealing with complex time-series data.

[0004] To achieve the above objectives, in a first aspect, this application provides an inflow flow prediction method based on a multi-scale temporal attention mechanism, comprising: Acquire the current multi-source hydrological and meteorological data of the target reservoir, and generate a time series flow prediction matrix based on the target input window and the current multi-source hydrological and meteorological data; The time series flow prediction matrix is ​​input into the target inflow flow prediction model, and the multi-scale time series attention mechanism in the target inflow flow prediction model is used to extract the short-term fluctuation features and overall change trends within the target input window through local time series attention branches and global time series attention branches, respectively. The short-term fluctuation characteristics and the overall trend of change are fused through the learnable gating mechanism in the target inbound flow prediction model to generate a coded feature representation; The predicted inflow of the target reservoir in the foreseeable future period is determined based on the encoded feature representation.

[0005] In one embodiment, the step of inputting the time series flow prediction matrix into the target inflow flow prediction model, and using the multi-scale temporal attention mechanism in the target inflow flow prediction model to extract the short-term fluctuation characteristics and overall trend within the target input window through local temporal attention branches and global temporal attention branches respectively, includes: The time series traffic prediction matrix is ​​input into the target inbound traffic prediction model, and the time series traffic prediction matrix is ​​linearly mapped through the input embedding layer in the target inbound traffic prediction model to obtain high-dimensional hidden features of a unified dimension. The high-dimensional hidden features of the unified dimension are superimposed with the positional encoding; Based on an encoder composed of multiple identical coding layers stacked together, the multi-scale temporal attention mechanism in the target inbound traffic prediction model is used to extract short-term fluctuation features within the target input window through local temporal attention branches and superimposed high-dimensional hidden features. Based on the encoder composed of multiple identical coding layers stacked together, the multi-scale temporal attention mechanism in the target inbound traffic prediction model is used to extract the overall change trend within the target input window through global temporal attention branches and superimposed high-dimensional hidden features.

[0006] In one embodiment, the step of fusing the short-term fluctuation characteristics and the overall trend of change through the learnable gating mechanism in the target inbound flow prediction model to generate an encoded feature representation includes: The short-term fluctuation characteristics and the overall trend of change are spliced ​​together; The gating weight matrix is ​​determined by the learnable gating mechanism in the target inbound flow prediction model based on the spliced ​​features, target activation function, learnable weights, and bias terms. The short-term fluctuation characteristics and the overall trend are fused based on the gating weight matrix to generate a coded feature representation.

[0007] In one embodiment, the step of determining the predicted inflow of the target reservoir within a future forecast period based on the encoded feature representation includes: The encoded feature representation is transformed by the output embedding layer in the target inbound flow prediction model to obtain the temporal decoding input information; The timing decoding input information is superimposed with the position encoding; Based on a decoder composed of multiple identical decoding layers stacked together, the temporal dependencies within the decoded sequence are modeled using the multi-scale temporal attention mechanism in the target inbound traffic prediction model to generate decoded features. A high-dimensional decoding feature representation is generated based on the decoding end features and historical hydrological and meteorological features; The high-dimensional decoded feature representation is linearly mapped, and the linear mapping result is normalized to obtain the inflow prediction result of the target reservoir in the future forecast period.

[0008] In one embodiment, before the step of inputting the time series flow prediction matrix into the target inflow flow prediction model and using the multi-scale temporal attention mechanism in the target inflow flow prediction model to extract the short-term fluctuation characteristics and overall trend within the target input window through local temporal attention branches and global temporal attention branches respectively, the method further includes: Historical inflow data of the target reservoir, historical flow data of the upstream hydrological station, and meteorological data of the study basin are obtained, and a model training sample set is generated based on the historical inflow data, the historical flow data, and the meteorological data. The training sample set of the model is divided into data according to a preset ratio; A multi-dimensional correlation coefficient analysis strategy was used to perform correlation analysis on the training data in the divided sample training set; The data in the divided sample training set is filtered based on the correlation coefficients analyzed, and the target inbound traffic prediction model is trained based on the filtered sample training set.

[0009] In one embodiment, after the step of training the target inbound traffic prediction model based on the target model training sample test set, the method further includes: Obtain the segmented sample test set and input the segmented sample test set into the target inbound flow prediction model; Obtain the predicted inbound flow value output by the target inbound flow prediction model after single-step and multi-step prediction; Determine a multidimensional accuracy evaluation index applicable to the target inbound flow prediction model, and evaluate the performance of the target inbound flow prediction model based on the multidimensional accuracy evaluation index; When the performance evaluation results meet the preset conditions, the step of inputting the time series flow prediction matrix into the target inbound flow prediction model is executed.

[0010] Secondly, this application provides an inflow prediction device based on a multi-scale temporal attention mechanism, comprising: The generation module is used to acquire the current multi-source hydrological and meteorological data of the target reservoir, and generate a time series flow prediction matrix based on the target input window and the current multi-source hydrological and meteorological data. The feature extraction module is used to input the time series flow prediction matrix into the target inflow flow prediction model, and to use the multi-scale temporal attention mechanism in the target inflow flow prediction model to extract the short-term fluctuation features and overall change trends within the target input window through local temporal attention branches and global temporal attention branches respectively. The fusion module is used to fuse the short-term fluctuation characteristics and the overall change trend through the learnable gating mechanism in the target inbound flow prediction model to generate a coded feature representation; The prediction module is used to determine the predicted inflow of the target reservoir in the foreseeable future period based on the coded feature representation.

[0011] Thirdly, this application provides an electronic device, comprising: at least one memory for storing a program; and at least one processor for executing the program stored in the memory, wherein when the program stored in the memory is executed, the processor is configured to execute the method described in the first aspect or any possible implementation thereof.

[0012] Fourthly, this application provides a computer-readable storage medium storing a computer program that, when run on a processor, causes the processor to perform the method described in the first aspect or any possible implementation thereof.

[0013] Fifthly, this application provides a computer program product that, when run on a processor, causes the processor to perform the method described in the first aspect or any possible implementation thereof.

[0014] It is understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here.

[0015] Overall, the technical solutions conceived in this application have the following beneficial effects compared with the prior art: (1) Based on the target input window, this application generates a time series flow prediction matrix based on the current multi-source hydrological and meteorological data. Then, it introduces a target inflow flow prediction model that replaces the self-attention sublayer with a multi-scale time series attention mechanism. This significantly enhances the model's ability to represent the change pattern of inflow flow. By learning short-term and long-term correlations through local time series attention branches and global time series attention branches, the local and global dependencies in the time series are fully represented. An end-to-end learning approach is adopted, and the entire operation does not require time series decomposition. Then, combined with an adaptive gating fusion strategy, the short-term fluctuation characteristics and overall change trends in the time series flow prediction matrix are extracted collaboratively. Multi-scale dynamic information in complex hydrological time series is mined, which can effectively improve the accuracy of inflow flow prediction and provide technical support for reservoir scheduling and operation, flood control and water resource optimization.

[0016] (2) This application introduces the sequential information of each time step in the input window. After converting the time series traffic prediction matrix into a high-dimensional hidden feature of a unified dimension using a linear mapping method, it superimposes it with the location encoding. In addition, in order to evaluate the prediction performance of the model from multiple perspectives, a multi-dimensional accuracy evaluation index is introduced, such as the coefficient of determination R. 2 The Nash efficiency coefficient (NSE) and root mean square error (RMSE) were evaluated, and the results showed that the prediction accuracy of the target inflow prediction model was superior to other deep learning models. It not only performed well in single-step prediction, but also had the same superior accuracy in multi-step prediction, effectively improving the robustness and generalization ability of the model prediction.

[0017] In summary, this application acquires current multi-source hydrological and meteorological data of the target reservoir, and generates a time-series flow prediction matrix based on the target input window and the current multi-source hydrological and meteorological data. The time-series flow prediction matrix is ​​input into the target inflow prediction model, and the multi-scale temporal attention mechanism in the target inflow prediction model is used to extract short-term fluctuation features and overall trends within the target input window through local and global temporal attention branches, respectively. The short-term fluctuation features and overall trends are fused using a learnable gating mechanism in the target inflow prediction model to generate an encoded feature representation. The inflow prediction result for the target reservoir in the future forecast period is determined based on the encoded feature representation. By using the above method, after generating the time series flow prediction matrix, a target inflow prediction model is introduced that replaces the self-attention sublayer with a multi-scale time series attention mechanism. By learning short-term and long-term correlations through local and global time series attention branches respectively, the local and global dependencies in the time series can be fully represented, thereby effectively improving the accuracy of inflow prediction and providing technical support for reservoir scheduling and operation, flood control and water resource optimization. Attached Figure Description

[0018] Figure 1 This is one of the flowcharts illustrating the inbound flow prediction method based on a multi-scale temporal attention mechanism provided in this application embodiment; Figure 2 This is a schematic diagram of the daily forecast results provided in the embodiments of this application; Figure 3 This is a bar chart showing the performance evaluation results of the multiple models provided in the embodiments of this application; Figure 4 This is a schematic diagram of the overall framework of the target inbound flow prediction model provided in the embodiments of this application; Figure 5 This is the second flowchart of the inbound flow prediction method based on a multi-scale temporal attention mechanism provided in the embodiments of this application; Figure 6 This is a schematic diagram of the module structure of the inbound flow prediction device based on a multi-scale temporal attention mechanism provided in this application embodiment; Figure 7 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0019] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0020] In this article, the term "and / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. The symbol " / " in this article indicates that the related objects are in an "or" relationship; for example, A / B means A or B.

[0021] The terms "first" and "second," etc., used in the specification and claims herein are used to distinguish different objects, not to describe a specific order of objects. For example, "first response message" and "second response message," etc., are used to distinguish different response messages, not to describe a specific order of response messages.

[0022] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0023] Based on this, embodiments of this application provide an inbound flow prediction method based on a multi-scale temporal attention mechanism, referring to... Figure 1 , Figure 1 This is one of the flowcharts illustrating the inbound flow prediction method based on a multi-scale temporal attention mechanism provided in this application. In this embodiment, the inbound flow prediction method based on a multi-scale temporal attention mechanism includes steps S10 to S40: Step S10: Obtain the current multi-source hydrological and meteorological data of the target reservoir, and generate a time series flow prediction matrix based on the target input window and the current multi-source hydrological and meteorological data.

[0024] It should be noted that for target reservoirs that require inflow forecasting, current multi-source hydrological and meteorological data should be collected. In order to effectively improve the accuracy of inflow forecasting, the current multi-source hydrological and meteorological data needs to be constructed into a time series flow forecasting matrix. For any given time, the current multi-source hydrological and meteorological data of several consecutive days prior to that time are used as the target input window to form an input matrix with the dimension of "time step × number of features", which is the time series flow forecasting matrix.

[0025] Step S20: Input the time series flow prediction matrix into the target inflow flow prediction model, and use the multi-scale time series attention mechanism in the target inflow flow prediction model to extract the short-term fluctuation features and overall change trends within the target input window through local time series attention branches and global time series attention branches respectively.

[0026] It is understandable that the target inflow prediction model refers to a model used to accurately predict the inflow of a target reservoir in the future forecast period. This target inflow prediction model can be an MSTA-Transformer model, which is built on the Transformer architecture. It uses a multi-scale temporal attention mechanism (MSTA) to replace the self-attention sublayer, and then further encapsulates it into an MSTAEncoderLayer. It also adopts an encoder-decoder architecture. The encoder is used to encode the features of the time series flow prediction matrix and extract the hydrological and meteorological driving information in the target input window. The decoder is used to receive the transformed output sequence and combine it with the temporal feature representation output by the encoder to gradually generate the inflow prediction result in the future forecast period.

[0027] It should be noted that in the standard Transformer, similarity can be calculated using scaled dot product attention to obtain a matrix. , , Specifically: .

[0028] in, , , These represent the query, key, and value, respectively. This indicates the number of columns in the query matrix, i.e., the vector dimension.

[0029] It should be understood that for the target inflow prediction model, after inputting the time series flow prediction matrix, the multi-scale temporal attention mechanism in the target inflow prediction model is used to collaboratively extract local fluctuation features and global dependency features from the time series flow prediction matrix through local and global temporal attention branches. This yields short-term fluctuation features and overall trends within the target input window, thereby fully mining the multi-scale dynamic information in the complex time series flow prediction matrix. This effectively overcomes the problems of existing technologies, such as the inability to fully represent local and global dependencies in time series and the accumulation of errors during multi-step prediction. It significantly enhances the model's ability to represent the changing patterns of inflow, effectively improving the accuracy and stability of predicted inflow, and has important guiding significance for the forecasting, scheduling, and flood control of target reservoirs. Specifically, for the local temporal attention branch, a local window mask can be introduced. M This establishes a connection between the current position and the time steps within the neighboring window, specifically: .

[0030] in, M Indicates a local window mask. , , These represent the query, key, and value, respectively. Indicates the number of columns in the query matrix.

[0031] Furthermore, prior to step S20, the method further includes: acquiring historical inflow data of the target reservoir, historical flow data of upstream hydrological stations, and meteorological data of the study basin; generating a model training sample set based on the historical inflow data, the historical flow data, and the meteorological data; dividing the model training sample set into data segments according to a preset ratio; performing correlation analysis on the training data in the segmented sample training set using a multi-dimensional correlation coefficient analysis strategy; filtering the segmented sample training set based on the analyzed correlation coefficients; and training the target inflow prediction model based on the filtered sample training set.

[0032] It should be understood that when training a model, it is necessary to obtain historical inflow data of the target reservoir, historical flow data of upstream hydrological stations, and meteorological data of the study basin. The model training sample set should be divided according to a preset ratio, which can be 8:2. For example, taking the Three Gorges Reservoir as an example, from the perspective of geographical location and topographic features, the Three Gorges Reservoir is located in a key area of ​​the transition from the upper to the middle reaches of the Yangtze River. The topography of the upstream section of the Yichang River is undulating, and flood control scheduling is difficult. It is not only an important node for the allocation of water resources in the Yangtze River Basin, but also a control project that connects the upstream water inflow with the flood control and water supply needs of the middle and lower reaches. The selected data consist of historical inflow data of the Three Gorges Reservoir at daily scale from 2012 to 2021, historical flow data of the four main hydrological stations upstream (Shigu Station, Panzhihua Station, Zhutuo Station, and Cuntan Station), and meteorological data of the study area, including precipitation, temperature, relative humidity, longwave radiation, and shortwave radiation. The flow data can be obtained from the corresponding reservoir management stations and hydrological stations, and the meteorological data comes from open official scientific data centers. The sample training set can consist of data from January 1, 2012 to December 31, 2019, and the sample test set can consist of data from January 1, 2020 to December 31, 2021.

[0033] Understandably, to prevent overfitting, 20% of the training set is extracted as a validation set. To effectively improve the accuracy and efficiency of training the model, a multi-dimensional correlation coefficient analysis strategy is needed to perform correlation analysis on the training data in the divided training set. This strategy can include both Pearson and Spearman correlation coefficients. The divided training set is then filtered based on the correlation coefficients. For example, features with correlation coefficients greater than 0.3 are selected as the selected training set for training the target inbound traffic prediction model.

[0034] Furthermore, after the step of training the target inbound flow prediction model based on the target model training sample test set, the method further includes: obtaining a partitioned sample test set and inputting the partitioned sample test set into the target inbound flow prediction model; obtaining the inbound flow prediction values ​​output by the target inbound flow prediction model after single-step and multi-step prediction; determining a multi-dimensional accuracy evaluation index applicable to the target inbound flow prediction model and performing a performance evaluation on the target inbound flow prediction model based on the multi-dimensional accuracy evaluation index; and when the performance evaluation result meets preset conditions, performing the step of inputting the time series flow prediction matrix into the target inbound flow prediction model.

[0035] It should be noted that for the target inbound traffic prediction model, the input step size is uniformly 7 days, and the output step size is 1 or 3 days. After training the target inbound traffic prediction model, it is also necessary to test its prediction performance through a divided sample test set. During the testing process, the target inbound traffic prediction model will perform single-step and multi-step predictions, for example, predicting the inbound traffic for the next 1 day and 3 days. In addition, it will be compared with Convolutional Neural Network (CNN), Gated Recurrent Unit (GRU), Long Short-Term Memory Network (LSTM), and Transformer to highlight the target inbound traffic prediction model in this embodiment.

[0036] It is understandable that multidimensional accuracy evaluation metrics refer to evaluation metrics used to assess the predictive performance of a model, and these multidimensional accuracy evaluation metrics include, but are not limited to, the coefficient of determination (R²). 2 The predictive performance of the model is evaluated from multiple perspectives, including the Nash efficiency coefficient (NSE) and root mean square error (RMSE). Daily prediction results during the testing period can be referenced. Figure 2 Analysis shows that the predicted values ​​of the five models generally match the trends of the measured values. Among them, the MTA-Transformer model in this embodiment has the closest predicted value to the measured value, reflecting the changes in the measured value well even in the peak and trough areas of the flow. GRU shows an overestimation tendency, which is evident in the line graph predicting the inflow of the next 3 days. In addition, as the prediction period lengthens, the prediction accuracy of each model decreases to some extent, and the deviation between their line graphs and the measured values ​​increases accordingly. However, the MTA-Transformer model still has the best prediction performance.

[0037] It should be understood that the performance evaluation results of the multi-model approach can be found in Table 1, and its bar chart can be referenced from... Figure 3 Specifically: Table 1:

[0038] It should be noted that the analysis of the above prediction results shows that Transformer-type models have an absolute advantage in prediction accuracy, especially the MSTA-Transformer model in this embodiment, with a coefficient of determination R0. 2 The Nash efficiency coefficients (NSE) are as high as 0.960 and 0.923, respectively, while the RMSE is as low as 2147.368m. 3 / s, 3070.626m 3The MTA-Transformer model demonstrates excellent short-term inflow prediction performance not only for single-step predictions but also for multi-step prediction tasks. In summary, the MTA-Transformer model in this embodiment can effectively improve the accuracy and stability of short-term inflow prediction for large reservoirs, providing important reference value for improving the prediction accuracy of short-term inflow and enhancing the robustness and generalization ability of the prediction results.

[0039] Step S30: The short-term fluctuation characteristics and the overall change trend are fused through the learnable gating mechanism in the target inbound flow prediction model to generate a coded feature representation.

[0040] It should be understood that, for the task of predicting inbound traffic, the multi-scale temporal attention mechanism in the encoder extracts the short-term fluctuation features and overall change trends within the target input window through local and global temporal attention branches. Then, it fuses the short-term fluctuation features and overall change trends through a learnable gating mechanism to generate an encoded feature representation, which can be used as the output of the encoder.

[0041] Further, step S30 includes: splicing the short-term fluctuation features and the overall change trend; determining the gating weight matrix based on the spliced ​​features, target activation function, learnable weights, and bias terms through the learnable gating mechanism in the target inbound flow prediction model; and fusing the short-term fluctuation features and the overall change trend based on the gating weight matrix to generate an encoded feature representation.

[0042] It should be noted that after concatenating the short-term fluctuation characteristics and the overall trend, the gating weight matrix can be determined through a learnable gating mechanism in the target inflow prediction model. This learnable gating mechanism can be an adaptive gating mechanism based on the Sigmoid function, used to adaptively adjust the contribution ratio of local and global information, specifically as follows: .

[0043] in, Represents the gate weight matrix. This represents the Sigmoid activation function. Indicates the characteristics of splicing. Indicates learnable weights; This indicates the bias term.

[0044] Step S40: Determine the predicted inflow rate of the target reservoir in the foreseeable future period based on the encoded feature representation.

[0045] It is understandable that after generating the coded feature representation, the coded feature representation is input into the decoder in the target inflow prediction model to output the inflow prediction result of the target reservoir in the future forecast period. That is, the target inflow prediction model realizes the end-to-end mapping from the multi-source hydrological and meteorological input sequence to the future inflow prediction sequence, thereby effectively improving the accuracy of the predicted inflow.

[0046] Further, step S40 includes: transforming the encoded feature representation through the output embedding layer in the target inflow prediction model to obtain temporal decoding input information; superimposing the temporal decoding input information with positional encoding; modeling the temporal dependency within the decoded sequence through the multi-scale temporal attention mechanism in the target inflow prediction model based on a decoder composed of multiple stacked decoding layers with the same structure to generate decoded features; generating a high-dimensional decoded feature representation based on the decoded features and historical hydrological and meteorological features; performing a linear mapping on the high-dimensional decoded feature representation and normalizing the linear mapping result to obtain the inflow prediction result of the target reservoir in the future forecast period.

[0047] It should be understood that after the encoded feature representation is converted into temporal decoded input information through the output embedding layer in the target inflow prediction model, the decoding stage takes the temporal decoded input information as input, superimposes it with the positional encoding, and inputs it to the decoder. The decoder consists of multiple decoding layers with the same structure stacked together. For each decoding layer, the temporal dependency relationship within the decoded sequence is first modeled through a multi-scale temporal attention mechanism. Then, the historical hydrological and meteorological features of the encoder output are introduced through the encoder-decoder attention structure, so that the prediction end can generate a high-dimensional decoded feature representation based on the key time steps and key driving factors in the target input window.

[0048] It should be noted that the reference Figure 4 For the high-dimensional decoded feature representation output by the decoder, it will pass through residual connection, layer normalization and location-aware fully connected network in sequence to convert the high-dimensional decoded feature representation into the inflow prediction value within the future forecast period. For this purpose, the decoded feature representation needs to be input to the linear mapping and normalization output layer for linear mapping and normalization processing to realize the end-to-end mapping from the multi-source hydrological and meteorological input sequence to the future inflow prediction sequence. In order to effectively improve the accuracy of the predicted inflow, addition and norm layers are set between the multi-scale temporal attention mechanism, between the multi-scale temporal attention mechanism and the location-aware fully connected network, and between the location-aware fully connected network and the linear mapping and normalization output layer.

[0049] This embodiment acquires current multi-source hydrological and meteorological data of the target reservoir and generates a time-series flow prediction matrix based on the target input window. The time-series flow prediction matrix is ​​then input into the target inflow prediction model. The multi-scale temporal attention mechanism in the target inflow prediction model extracts short-term fluctuation features and overall trends within the target input window through local and global temporal attention branches. A learnable gating mechanism in the target inflow prediction model fuses the short-term fluctuation features and overall trends to generate an coded feature representation. The inflow prediction result for the target reservoir in the future forecast period is determined based on the coded feature representation. By introducing a target inflow prediction model after generating the time-series flow prediction matrix, replacing the self-attention sublayer with a multi-scale temporal attention mechanism, and learning short-term and long-term correlations through local and global temporal attention branches respectively, the local and global dependencies in the time series are fully characterized. This effectively improves the accuracy of inflow prediction and provides technical support for reservoir scheduling, flood control, and optimal water resource allocation.

[0050] In one specific implementation, this application provides steps for extracting short-term fluctuation characteristics and overall trends within a target input window. Please refer to... Figure 5 , Figure 5 This is the second flowchart illustrating the inbound flow prediction method based on a multi-scale temporal attention mechanism provided in this application. Step S20 includes steps S201 to S204: Step S201: Input the time series traffic prediction matrix into the target inbound traffic prediction model, and perform linear mapping on the time series traffic prediction matrix through the input embedding layer in the target inbound traffic prediction model to obtain high-dimensional hidden features of a unified dimension.

[0051] It should be noted that the time series traffic prediction matrix will enter the input embedding layer of the target inbound traffic prediction model, and the time series traffic prediction matrix will be converted into a high-dimensional hidden feature of a unified dimension using a linear mapping method.

[0052] Step S202: Superimpose the high-dimensional hidden features of the unified dimension with the positional encoding.

[0053] Understandably, in order to incorporate the sequential information of each time step in the input window, after obtaining the high-dimensional hidden features of a unified dimension, these features are superimposed with the positional encoding, and the superimposed high-dimensional hidden features are input into the encoder to enter the encoding stage.

[0054] Step S203: Based on the encoder composed of multiple stacked coding layers with the same structure, the multi-scale temporal attention mechanism in the target inbound traffic prediction model is used to extract short-term fluctuation features within the target input window through local temporal attention branches and superimposed high-dimensional hidden features.

[0055] It should be understood that the encoder, too, is composed of multiple stacked coding layers with the same structure. (Continue to refer to...) Figure 4 For each coding layer, it sequentially includes a multi-scale temporal attention mechanism, residual connections and layer normalization, a location-aware fully connected network, and another residual connection and layer normalization. In order to achieve the collaborative extraction of short-term fluctuation features and overall change trends in the time series traffic prediction matrix, it is also necessary to construct local temporal attention branches and global temporal attention branches respectively. The local temporal attention branch is used to extract short-term fluctuation features within the target input window and capture local correlations. The local temporal attention branch is equipped with local QKV projection and sliding window mask attention. The output projection at this time is the short-term fluctuation feature. The global temporal attention branch is equipped with global multi-head attention and scaling dot product attention. The output at this time is the multi-scale dynamic information.

[0056] Step S204: Based on the encoder composed of multiple stacked encoding layers with the same structure, the multi-scale temporal attention mechanism in the target inbound traffic prediction model is adopted to extract the overall change trend within the target input window through global temporal attention branches and stacked high-dimensional hidden features.

[0057] It should be noted that the global time series attention branch can extract the overall trend of change within the target input window, capture global dependencies, and further complete the collaborative extraction of local fluctuation features and global dependency features in the time series traffic prediction matrix, which can fully explore the multi-scale dynamic information in the complex time series traffic prediction matrix.

[0058] In this embodiment, the time-series traffic prediction matrix is ​​input into the target inbound traffic prediction model, and the time-series traffic prediction matrix is ​​linearly mapped through the input embedding layer in the target inbound traffic prediction model to obtain a high-dimensional hidden feature of uniform dimension. The high-dimensional hidden feature of uniform dimension is superimposed with the positional encoding. Based on the encoder composed of multiple stacked encoding layers with the same structure, the multi-scale temporal attention mechanism in the target inbound traffic prediction model is used to extract the short-term fluctuation features within the target input window through local temporal attention branches and superimposed high-dimensional hidden features. Based on the encoder composed of multiple stacked encoding layers with the same structure, the multi-scale temporal attention mechanism in the target inbound traffic prediction model is used to extract the overall change trend within the target input window through global temporal attention branches and superimposed high-dimensional hidden features. By using the above method, the time series traffic prediction matrix is ​​converted into a high-dimensional hidden feature with a unified dimension through linear mapping. This hidden feature is then superimposed with the positional encoding to introduce the sequential information of each time step in the input window. At this point, the local temporal attention branch is used to extract short-term fluctuation features within the target input window to capture local correlations. Simultaneously, the global temporal attention branch is used to extract the overall trend of change within the target input window to capture global dependencies. This enables the coordinated extraction of short-term fluctuation features and overall trend of change in the time series traffic prediction matrix.

[0059] The following describes the inflow prediction device based on a multi-scale temporal attention mechanism provided in this application. The inflow prediction device described below corresponds to the inflow prediction method based on a multi-scale temporal attention mechanism described above. Please refer to... Figure 6 , Figure 6 This is a schematic diagram of the module structure of the inbound flow prediction device based on a multi-scale temporal attention mechanism provided in this application embodiment, including: The generation module T10 is used to acquire the current multi-source hydrological and meteorological data of the target reservoir, and generate a time series flow prediction matrix based on the target input window and the current multi-source hydrological and meteorological data.

[0060] The feature extraction module T20 is used to input the time series flow prediction matrix into the target inflow flow prediction model, and to use the multi-scale temporal attention mechanism in the target inflow flow prediction model to extract the short-term fluctuation features and overall change trends within the target input window through local temporal attention branches and global temporal attention branches respectively.

[0061] The fusion module T30 is used to fuse the short-term fluctuation characteristics and the overall change trend through the learnable gating mechanism in the target inbound flow prediction model to generate a coded feature representation.

[0062] The prediction module T40 is used to determine the predicted inflow of the target reservoir in the future forecast period based on the coded feature representation.

[0063] This embodiment acquires current multi-source hydrological and meteorological data of the target reservoir and generates a time-series flow prediction matrix based on the target input window. The time-series flow prediction matrix is ​​then input into the target inflow prediction model. The multi-scale temporal attention mechanism in the target inflow prediction model extracts short-term fluctuation features and overall trends within the target input window through local and global temporal attention branches. A learnable gating mechanism in the target inflow prediction model fuses the short-term fluctuation features and overall trends to generate an coded feature representation. The inflow prediction result for the target reservoir in the future forecast period is determined based on the coded feature representation. By introducing a target inflow prediction model after generating the time-series flow prediction matrix, replacing the self-attention sublayer with a multi-scale temporal attention mechanism, and learning short-term and long-term correlations through local and global temporal attention branches respectively, the local and global dependencies in the time series are fully characterized. This effectively improves the accuracy of inflow prediction and provides technical support for reservoir scheduling, flood control, and optimal water resource allocation.

[0064] It is understood that the detailed functional implementation of each of the above modules can be found in the description of the aforementioned method embodiments, and will not be repeated here.

[0065] It should be understood that the above-described device is used to execute the methods in the above embodiments. The implementation principle and technical effect of the corresponding program modules in the device are similar to those described in the above methods. The working process of the device can be referred to the corresponding process in the above methods, and will not be repeated here.

[0066] Based on the methods in the above embodiments, this application provides an electronic device, please refer to... Figure 7 , Figure 7 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application.

[0067] It should be noted that the system may include: a processor 10, a communications interface 20, a memory 30, and a communication bus 40. The processor 10, communications interface 20, and memory 30 communicate with each other via the communication bus 40. The processor 10 can invoke logical instructions stored in the memory 30 to execute the methods described in the above embodiments.

[0068] Furthermore, the logical instructions in the aforementioned memory 30 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.

[0069] Based on the methods in the above embodiments, this application provides a computer-readable storage medium storing a computer program that, when run on a processor, causes the processor to execute the methods in the above embodiments.

[0070] Based on the methods in the above embodiments, this application provides a computer program product that, when run on a processor, causes the processor to execute the methods in the above embodiments.

[0071] It is understood that the processor in the embodiments of this application can be a central processing unit, or it can be other general-purpose processors, digital signal processors, application-specific integrated circuits, field-programmable gate arrays, or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. The general-purpose processor can be a microprocessor or any conventional processor.

[0072] The method steps in this application embodiment can be implemented in hardware or by a processor executing software instructions. The software instructions can consist of corresponding software modules, which can be stored in random access memory, flash memory, read-only memory, programmable read-only memory, erasable programmable read-only memory, electrically erasable programmable read-only memory, registers, hard disks, portable hard disks, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor, enabling the processor to read information from and write information to the storage medium. Of course, the storage medium can also be a component of the processor.

[0073] It is understood that the various numerical designations used in the embodiments of this application are merely for descriptive convenience and are not intended to limit the scope of the embodiments of this application. Those skilled in the art will readily understand that the above descriptions are merely preferred embodiments of this application and are not intended to limit this application. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A method for predicting inbound flow based on a multi-scale temporal attention mechanism, characterized in that, include: Acquire the current multi-source hydrological and meteorological data of the target reservoir, and generate a time series flow prediction matrix based on the target input window and the current multi-source hydrological and meteorological data; The time series flow prediction matrix is ​​input into the target inflow flow prediction model, and the multi-scale time series attention mechanism in the target inflow flow prediction model is used to extract the short-term fluctuation features and overall change trends within the target input window through local time series attention branches and global time series attention branches, respectively. The short-term fluctuation characteristics and the overall trend of change are fused through the learnable gating mechanism in the target inbound flow prediction model to generate a coded feature representation; The predicted inflow of the target reservoir in the foreseeable future period is determined based on the encoded feature representation.

2. The inbound flow prediction method as described in claim 1, characterized in that, The step of inputting the time series flow prediction matrix into the target inflow flow prediction model, and using the multi-scale time series attention mechanism in the target inflow flow prediction model to extract the short-term fluctuation characteristics and overall trend within the target input window through local time series attention branches and global time series attention branches respectively, includes: The time series traffic prediction matrix is ​​input into the target inbound traffic prediction model, and the time series traffic prediction matrix is ​​linearly mapped through the input embedding layer in the target inbound traffic prediction model to obtain high-dimensional hidden features of a unified dimension. The high-dimensional hidden features of the unified dimension are superimposed with the positional encoding; Based on an encoder composed of multiple identical coding layers stacked together, the multi-scale temporal attention mechanism in the target inbound traffic prediction model is used to extract short-term fluctuation features within the target input window through local temporal attention branches and superimposed high-dimensional hidden features. Based on the encoder composed of multiple identical coding layers stacked together, the multi-scale temporal attention mechanism in the target inbound traffic prediction model is used to extract the overall change trend within the target input window through global temporal attention branches and superimposed high-dimensional hidden features.

3. The inbound flow prediction method as described in claim 1, characterized in that, The step of fusing the short-term fluctuation characteristics and the overall trend of change through the learnable gating mechanism in the target inbound flow prediction model to generate an encoded feature representation includes: The short-term fluctuation characteristics and the overall trend of change are spliced ​​together; The gating weight matrix is ​​determined by the learnable gating mechanism in the target inbound flow prediction model based on the spliced ​​features, target activation function, learnable weights, and bias terms. The short-term fluctuation characteristics and the overall trend are fused based on the gating weight matrix to generate a coded feature representation.

4. The inbound flow prediction method as described in any one of claims 1 to 3, characterized in that, The step of determining the predicted inflow of the target reservoir within a future forecast period based on the encoded feature representation includes: The encoded feature representation is transformed by the output embedding layer in the target inbound flow prediction model to obtain the temporal decoding input information; The timing decoding input information is superimposed with the position encoding; Based on a decoder composed of multiple identical decoding layers stacked together, the temporal dependencies within the decoded sequence are modeled using the multi-scale temporal attention mechanism in the target inbound traffic prediction model to generate decoded features. A high-dimensional decoding feature representation is generated based on the decoding end features and historical hydrological and meteorological features; The high-dimensional decoded feature representation is linearly mapped, and the linear mapping result is normalized to obtain the inflow prediction result of the target reservoir in the future forecast period.

5. The inbound flow prediction method as described in claim 1, characterized in that, Before the step of inputting the time series flow prediction matrix into the target inflow flow prediction model and using the multi-scale time series attention mechanism in the target inflow flow prediction model to extract the short-term fluctuation characteristics and overall trend within the target input window through local time series attention branches and global time series attention branches respectively, the method further includes: Historical inflow data of the target reservoir, historical flow data of the upstream hydrological station, and meteorological data of the study basin are obtained, and a model training sample set is generated based on the historical inflow data, the historical flow data, and the meteorological data. The training sample set of the model is divided into data according to a preset ratio; A multi-dimensional correlation coefficient analysis strategy was used to perform correlation analysis on the training data in the divided sample training set; The data in the divided sample training set is filtered based on the correlation coefficients analyzed, and the target inbound traffic prediction model is trained based on the filtered sample training set.

6. The inbound flow prediction method as described in claim 5, characterized in that, After the step of training the target inbound traffic prediction model based on the target model training sample test set, the method further includes: Obtain the segmented sample test set and input the segmented sample test set into the target inbound flow prediction model; Obtain the predicted inbound flow value output by the target inbound flow prediction model after single-step and multi-step prediction; Determine a multidimensional accuracy evaluation index applicable to the target inbound flow prediction model, and evaluate the performance of the target inbound flow prediction model based on the multidimensional accuracy evaluation index; When the performance evaluation results meet the preset conditions, the step of inputting the time series flow prediction matrix into the target inbound flow prediction model is executed.

7. An inflow prediction device based on a multi-scale temporal attention mechanism, characterized in that, include: The generation module is used to acquire the current multi-source hydrological and meteorological data of the target reservoir, and generate a time series flow prediction matrix based on the target input window and the current multi-source hydrological and meteorological data. The feature extraction module is used to input the time series flow prediction matrix into the target inflow flow prediction model, and to use the multi-scale temporal attention mechanism in the target inflow flow prediction model to extract the short-term fluctuation features and overall change trends within the target input window through local temporal attention branches and global temporal attention branches respectively. The fusion module is used to fuse the short-term fluctuation characteristics and the overall change trend through the learnable gating mechanism in the target inbound flow prediction model to generate a coded feature representation; The prediction module is used to determine the predicted inflow of the target reservoir in the foreseeable future period based on the coded feature representation.

8. An electronic device, characterized in that, include: At least one memory for storing computer programs; At least one processor is configured to execute a program stored in the memory, wherein when the program stored in the memory is executed, the processor is configured to perform the method as described in any one of claims 1-6.

9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is run on the processor, it causes the processor to perform the method as described in any one of claims 1-6.

10. A computer program product, characterized in that, When the computer program product is run on a processor, the processor causes the processor to perform the method as described in any one of claims 1-6.