Water conservancy data analysis method and device based on self-attention mechanism and medium
By building a water conservancy time series data warehouse and using a self-attention mechanism to process water conservancy time series data, the problem of integrating multi-source heterogeneous data is solved, high-precision water conservancy data trend prediction and flood control scheduling decision support are achieved, and the intelligence level and decision-making efficiency of water conservancy project management are improved.
Patent Information
- Application Number
- CN202510895292.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-30
- Publication Date
- 2025-09-26
AI Technical Summary
Existing technologies make it difficult to effectively integrate multi-source heterogeneous water conservancy time series data, resulting in deficiencies in water conservancy time series data analysis in terms of temporal and spatial consistency, data quality and prediction accuracy, making it difficult to meet the high timeliness and high precision requirements of flood control scheduling.
Build a water conservancy time series data warehouse, process water conservancy time series data through self-attention mechanism and gated recurrent unit, realize data standardization, spatiotemporal feature representation and trend prediction, and generate high-precision flood control scheduling decision support data.
It significantly improves the quality and consistency of water conservancy data, accurately captures cross-temporal and spatial dependencies, generates high-precision water conservancy data trend forecast results, and supports intelligent decision-making in flood control and scheduling and the timeliness of responding to sudden water situations.
Smart Images

Figure CN120705513A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of water conservancy technology, and in particular to a water conservancy data analysis method, device and medium based on a self-attention mechanism. Background Art
[0002] The digital transformation of the water conservancy industry has led to the widespread application of technologies such as the Internet of Things and big data, generating massive amounts of time-series data covering a wide range of variables, including water levels, flow, rainfall, and water quality, as well as spatial distribution information. This data is crucial for critical decision-making, including flood control and scheduling, water resource management, and disaster warning. However, existing technologies face significant challenges in processing this complex water conservancy time-series data.
[0003] First, water conservancy time series data exhibits typical spatiotemporal coupling. Its value lies not only in the temporal trends of a single variable but also in the complex nonlinear dependencies between variables at different time points, spatial locations, and across time. Traditional time series analysis methods (such as classic statistical models or simple machine learning models) struggle to effectively capture these deep spatiotemporal connections across time steps and variables, leading to biased understanding of the system's overall state and evolutionary trends, making it difficult to meet the demands of precise analysis.
[0004] Secondly, water conservancy data comes from a variety of sources (such as sensors, remote sensing, and business systems), often with varying formats, time bases, spatial coordinate systems, and resolutions, making data fusion difficult. Existing data processing processes are inefficient in ensuring spatiotemporal consistency (such as timestamp alignment, coordinate system integrity, and topological correctness) and data quality (such as addressing missing values, noise, and redundancy). Furthermore, the lack of a unified, standardized data asset management mechanism makes it difficult to ensure the reusability, credibility, and security of data assets (such as desensitizing sensitive data and ensuring tiered accessibility), limiting the reliability and application value of analytical results.
[0005] Finally, for scenarios requiring high real-time performance, such as flood control and dispatch, existing forecasting models often fail to fully exploit key spatiotemporal patterns in the data, resulting in limited forecast accuracy and delayed response. The generation and delivery of decision-support information often relies primarily on structured data reports, lacking deep integration with geographic information systems and intuitive visualization. This makes it difficult to provide commanders with timely, high-value auxiliary information including risk locations, evolving trends, and specific dispatch recommendations.
[0006] Therefore, how to effectively integrate multi-source heterogeneous water conservancy time series data and generate intelligent analysis results with high precision, high timeliness and intuitive application in flood control scheduling decisions has become a technical problem that technicians in this field urgently need to solve. Summary of the Invention
[0007] The embodiments of the present application provide a water conservancy data analysis method, device and medium based on the self-attention mechanism to solve the following technical problem: how to effectively integrate multi-source heterogeneous water conservancy time series data to generate high-precision, high-timeliness and intelligent analysis results that can be intuitively applied to flood control scheduling decisions.
[0008] In the first aspect, an embodiment of the present application provides a water conservancy data analysis method based on a self-attention mechanism, the method including: constructing a water conservancy time series data warehouse, and establishing a water conservancy source data access mechanism to access the water conservancy time series data to be processed; performing standardized preprocessing on the water conservancy time series data to be processed to obtain standard time series data; inputting the standard time series data into a pre-trained water conservancy data analysis model to calculate the attention weight distribution between different time steps and different variables through the self-attention mechanism unit in the water conservancy data analysis model; according to the attention weight distribution, performing weighted summation on the standard time series data to generate a spatiotemporal feature representation vector, and inputting the spatiotemporal feature representation vector into the gated recurrent unit in the water conservancy data analysis model, performing spatiotemporal information fusion through the update gate and the reset gate; performing water conservancy data trend prediction based on the fused features, and outputting flood control scheduling decision support data.
[0009] In one embodiment of the present application, standardized preprocessing is performed on the water conservancy time series data to be processed, specifically including: defining a spatiotemporal data metamodel, and based on the spatiotemporal data metamodel, uniformly converting the timestamp format, coordinate system standard, and spatial resolution of the water conservancy time series data to be processed; performing spatiotemporal continuity verification on the water conservancy time series data to be processed, and performing spatiotemporal interpolation and completion when it is determined that there is missing data; wherein, the spatiotemporal continuity verification includes time series breakpoint detection and administrative division boundary topological relationship verification.
[0010] In one embodiment of the present application, after the water conservancy time series data to be processed is subjected to standardized preprocessing to obtain standard time series data, the method further includes: classifying and grading the standard time series data based on a preset data security level, and generating a data asset directory containing open attributes; establishing a multidimensional retrieval index based on the data asset directory, and recording metadata information; wherein the metadata information includes acquisition time, spatial range, and sensor model.
[0011] In one embodiment of the present application, the method also includes: constructing a water conservancy data analysis model, specifically including: loading historical standard time series data based on a data asset catalog and a multidimensional retrieval index; dividing the historical standard time series data into a training data set and a test data set, and constructing an initial Attention-GRU model structure, configuring the input feature dimension, the number of GRU units and the output feature dimension; iteratively training the initial Attention-GRU model based on the training data set, and evaluating the prediction accuracy of the trained model based on the test data set until a converged water conservancy data analysis model is obtained.
[0012] In one embodiment of the present application, the attention weight distribution between different time steps and different variables is calculated by the self-attention mechanism unit in the water conservancy data analysis model, specifically including: generating a query vector, a key vector and a value vector through a fully connected layer for the standard time series data; calculating the similarity score between the query vector and the key vector to generate an original attention score matrix; normalizing the original attention score matrix to obtain the joint attention weight distribution of the time step dimension and the variable dimension.
[0013] In one embodiment of the present application, a weighted summation is performed on the standard time series data according to the attention weight distribution to generate a spatiotemporal feature representation vector, specifically including: based on the joint attention weight distribution, weighted aggregation is performed on the value vector in the time step dimension to generate time-aware features; matrix multiplication of the time-aware features and the variable dimension attention weights is performed to generate cross-variable correlation features; the cross-variable correlation features are spliced along the channel dimension and compressed through a convolutional layer to generate a spatiotemporal feature representation vector.
[0014] In one embodiment of the present application, the spatiotemporal feature representation vector is input into the gated recurrent unit in the water conservancy data analysis model, and spatiotemporal information fusion is performed through the update gate and the reset gate, specifically including: inputting the spatiotemporal feature representation vector into the reset gate, calculating the reset coefficient to control the forgetting ratio of historical state information; inputting the spatiotemporal feature representation vector into the update gate, calculating the update coefficient to fuse the current feature with the historical state; based on the reset coefficient and the update coefficient, performing a nonlinear transformation on the unit state to generate a fused spatiotemporal feature.
[0015] In one embodiment of the present application, water conservancy data trend prediction is performed based on the fused features, and flood control scheduling decision support data is output, specifically including: inputting the fused spatiotemporal features into the fully connected layer, and outputting the predicted values of hydrological indicators in the future time window; calculating the water level change rate and flow mutation threshold of the key nodes based on the predicted values; when it is detected that the water level change rate exceeds the preset safety threshold or the flow mutation occurs, generating a decision support data package containing the risk location, risk level and scheduling recommendations; and converting the decision support data package into a visual layer data format that can be superimposed on a GIS map.
[0016] In the second aspect, an embodiment of the present application also provides a water conservancy data analysis device based on a self-attention mechanism, the device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute a water conservancy data analysis method based on a self-attention mechanism such as any one of the above.
[0017] In a third aspect, an embodiment of the present application further provides a non-volatile computer storage medium storing computer executable instructions. When the computer executable instructions are executed, a water conservancy data analysis method based on a self-attention mechanism as described above is implemented.
[0018] The embodiments of the present application provide a water conservancy data analysis method, device and medium based on the self-attention mechanism, which have the following beneficial effects: by constructing a unified water conservancy time series data warehouse and establishing a standardized data access and preprocessing process, the inconsistency problem of multi-source heterogeneous data in time and space benchmarks and formats is effectively solved, and the quality and consistency of the data are significantly improved; on this basis, the self-attention mechanism unit in the pre-trained water conservancy data analysis model can dynamically calculate the complex correlation weights between different time steps and different variables, and accurately capture the cross-time and space dependencies contained in the water conservancy time series data; and then explicitly fuse the time and space feature representation vectors generated by the attention mechanism through the gated recurrent unit, fully mining and integrating the deep time and space patterns of the data; finally, the model can generate high-precision water conservancy data trend prediction results, and convert them into visual decision support information containing specific risk locations, levels and scheduling recommendations, directly serving key application scenarios such as flood control scheduling, thereby significantly improving the intelligence level of water conservancy project management, decision-making efficiency and the accuracy and timeliness of responding to sudden water situations. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings: Figure 1 A flow chart of a water conservancy data analysis method based on a self-attention mechanism provided in an embodiment of the present application; Figure 2 A schematic diagram of the internal structure of a water conservancy data analysis device based on a self-attention mechanism provided in an embodiment of the present application. DETAILED DESCRIPTION
[0020] To make the purpose, technical solutions, and advantages of this application more clear, the technical solutions of this application will be clearly and completely described below in conjunction with the specific embodiments of this application and the corresponding drawings. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0021] The embodiments of the present application provide a water conservancy data analysis method, device and medium based on the self-attention mechanism to solve the following technical problem: how to effectively integrate multi-source heterogeneous water conservancy time series data to generate high-precision, high-timeliness and intelligent analysis results that can be intuitively applied to flood control scheduling decisions.
[0022] The technical solutions proposed in the embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0023] Figure 1 This is a flow chart of a water conservancy data analysis method based on the self-attention mechanism provided in the embodiment of the present application. Figure 1 As shown, the embodiment of the present application provides a water conservancy data analysis method based on the self-attention mechanism, which specifically includes the following steps: Step 101: Build a water conservancy time series data warehouse and establish a water conservancy source data access mechanism to access the water conservancy time series data to be processed.
[0024] In this embodiment, this step is the key starting point for establishing a unified, reliable, and real-time data foundation for the entire water conservancy data analysis method. Building a water conservancy time-series data warehouse means establishing a centralized storage system specifically for storing, organizing, and managing water conservancy data with strict time series properties. It should be noted that the core design goal of this warehouse is to efficiently handle the unique writing, querying, and compression requirements of time series data. Specifically, the warehouse's data schema typically includes key fields such as a unique measurement point identifier (used to distinguish different sensors or observation points), a precise timestamp (recording the time when data was generated or collected), specific observation values (such as water level, flow, rainfall, water quality parameters, etc.), optional data quality tags (indicating whether the data is valid or has anomalies), and associated spatial location information (such as latitude and longitude coordinates, administrative division code, or project facility number). It is understandable that choosing an appropriate time series database technology (such as InfluxDB, TimescaleDB, or OpenTSDB) is the foundation for achieving efficient storage and querying. These technologies are optimized for the characteristics of time series data (such as chronological writing and time range-based queries).
[0025] Establishing a water conservancy source data access mechanism aims to address the real-time or near-real-time aggregation of multi-source, heterogeneous water conservancy time-series data. In this embodiment, this mechanism needs to be highly compatible and flexible to support data access from a variety of common source systems in the water conservancy industry. Specifically, the "water conservancy source data access mechanism" includes multiple access methods, including source library access, ETL synchronization, and MQ.
[0026] Exemplary: Source database access: refers to directly accessing and reading relevant data tables or views in the source database of an existing business system (such as a hydrological automatic monitoring and reporting system, a water resources management system, and a reservoir scheduling system) through a database connection interface (such as JDBC, ODBC). This method is suitable for scenarios where the source data is structured and can provide direct access rights. ETL synchronization: refers to the use of dedicated extraction (Extract), transformation (Transform), and loading (Load) tools (such as Apache NiFi, Kettle) to periodically extract the required water conservancy time series data from the source system (which may be a relational database, file server, API interface, etc.) according to a pre-configured task plan (such as daily, hourly). Before loading into the target time series data warehouse, necessary preliminary cleaning, format conversion, or simple calculations can be performed. This method is suitable for scenarios where regular batch integration of data is required. MQ access refers to receiving streaming data pushed in real time by IoT devices (such as RTU telemetry terminals, smart water level gauges, and rain sensors) or edge computing nodes via message protocols (such as MQTT and AMQP) through a message queue (e.g., Kafka, RabbitMQ, or Pulsar) middleware. This data is pushed in real time by IoT devices (e.g., RTU telemetry terminals, smart water level gauges, and rain sensors) or edge computing nodes via message protocols (e.g., MQTT and AMQP). It should be noted that this approach is particularly suitable for scenarios with extremely high real-time requirements (e.g., second-level water level monitoring during flood prevention), as it enables millisecond-level data transmission and storage, ensuring real-time updates of time-series data. For example, hundreds of water level sensors deployed at key river sections can publish their second-level data to a designated Kafka topic in real time via the MQTT protocol. The system's data access service, acting as a consumer, subscribes to this topic and continuously writes streaming data to the water conservancy time-series data warehouse.
[0027] It's understandable that by combining the various access methods described above, this step effectively aggregates "unprocessed water conservancy time-series data" scattered across diverse sources, such as the "source repository" (business database), sensor networks (via MQ), and historical files (via ETL), into a unified water conservancy time-series data warehouse, providing raw data input for subsequent data standardization, asset management, and intelligent analysis. This step addresses the initial issues of dispersed, diversely formatted data from multiple sources, and the difficulty in ensuring real-time performance.
[0028] Step 102: perform standardization preprocessing on the water conservancy time series data to be processed to obtain standard time series data.
[0029] In one embodiment of the present application, standardized preprocessing is performed on the water conservancy time series data to be processed, specifically including: defining a spatiotemporal data metamodel, and based on the spatiotemporal data metamodel, uniformly converting the timestamp format, coordinate system standard, and spatial resolution of the water conservancy time series data to be processed; performing spatiotemporal continuity verification on the water conservancy time series data to be processed, and performing spatiotemporal interpolation and completion when it is determined that there is missing data; wherein, the spatiotemporal continuity verification includes time series breakpoint detection and administrative division boundary topological relationship verification.
[0030] In one embodiment of the present application, after the water conservancy time series data to be processed is subjected to standardized preprocessing to obtain standard time series data, the method further includes: classifying and grading the standard time series data based on a preset data security level, and generating a data asset directory containing open attributes; establishing a multidimensional retrieval index based on the data asset directory, and recording metadata information; wherein the metadata information includes acquisition time, spatial range, and sensor model.
[0031] In this embodiment, necessary cleaning, conversion, and normalization are performed on the received "water conservancy time series data to be processed". Its core goal is to solve the heterogeneity problem of multi-source data and ensure the accuracy and consistency of subsequent analysis.
[0032] Specifically, the first task of the standardization preprocessing is to define the spatiotemporal data metamodel. This is an abstract framework or specification that describes the core elements, relationships and constraints of water conservancy time series data. It can be understood that the metamodel provides a unified data description benchmark for all subsequent processing. Based on the spatiotemporal data metamodel, the following key unification operations are performed: unify the timestamp format, convert all possible time representations (such as local time, time with time zone, Unix timestamp) of data from different sources into a standard format (for example, the ISO8601 standard coordinated universal time UTC format YYYY-MM-DDThh:mm:ssZ) to eliminate the confusion caused by time base differences; unify the coordinate system standard, and convert the location information of various spatial coordinate systems (such as WGS84, Beijing 54, and local independent coordinate systems) that may exist in the original data. To a single coordinate system mandated by the state or industry or agreed upon by the project (such as the CGCS2000 National Geodetic Coordinate System) to ensure the comparability of spatial positions and the accuracy of analysis results; unify the spatial resolution. For data with inconsistent spatial coverage and resolution (such as gridded rainfall data and surface temperature data from different satellites or models), resample them to the unified spatial resolution grid specified by the project (for example, a finer meter-level grid or kilometer-level grid) through spatial interpolation algorithms (such as the nearest neighbor method, bilinear interpolation method, and kriging method) to ensure scale consistency of spatial analysis.
[0033] Furthermore, the spatiotemporal continuity of the water conservancy time series data to be processed is verified, which is a key link in data quality assurance. Specifically, time series breakpoint detection, that is, analyzing whether the timestamp interval of each data point sequence meets the expected collection frequency (such as one point per minute), identifies data missing in continuous time periods due to sensor failure, communication interruption, etc. (i.e., "breakpoints"); administrative division boundary topological relationship verification, mainly for spatial vector data (such as provincial, municipal, county, and township boundary data), using the spatial analysis function of the geographic information system (GIS), to check the logical correctness of its topological relationship, such as detecting whether there is unnecessary overlap between adjacent administrative district boundaries (the boundary lines of two regions intersect and encroach on each other), gaps (there is a gap between the boundaries of two regions that should be seamless), or overhangs (the boundary line is not correctly closed). When the above verification determines that there is missing data, a spatiotemporal interpolation and completion operation is performed. For example, missing points (breakpoints) in the temporal dimension can be supplemented based on valid observations at the same measurement point before and after using linear interpolation, time series prediction models (such as ARIMA), or synchronous interpolation of data from adjacent similar stations. For missing points in the spatial dimension (such as missing observations at a certain spatial location), interpolation estimation can be performed based on valid observations at adjacent spatial locations using spatial correlation models (such as inverse distance weighting (IDW) and kriging interpolation). The data obtained thus, which has been standardized in format, coordinates, and resolution, and has undergone continuity verification and necessary interpolation, is called "standard time series data," which lays a high-quality and consistent foundation for subsequent model analysis.
[0034] It is understandable that after obtaining the "standard time series data", in order to further improve the manageability, security and availability of the data, data asset management content is performed. Specifically, the standard time series data is classified and graded based on the preset data security level.
[0035] In this embodiment, the preset data security level rules can be formulated in accordance with national data security laws and regulations and internal management regulations of the water conservancy industry. For example, they can be divided into five levels: Level 1 (external sharing and openness, such as public disclosure of basic water level data from hydrological stations); Level 2 (internal sharing and openness, such as detailed flow data shared within river basin organizations); Level 3 (external application and openness, such as water level data for sensitive areas requiring approval before external disclosure); Level 4 (internal application and openness, such as key operational data of core water conservancy hubs requiring internal approval after departmental approval); and Level 5 (not externally accessible, such as detailed engineering drawings and real-time dispatch instructions involving national security or extremely sensitive information). Based on this classification and grading, a data asset catalog with open attributes is generated. This catalog is a structured, manageable resource list that clearly lists all available spatiotemporal data assets (such as "Real-time water level monitoring data for the middle and lower reaches of the Yangtze River (Level 1)" and "Internal operation log data of XX large reservoir (Level 4)") and clearly annotates core metadata such as their security level (openness attribute), spatiotemporal scope of data coverage (such as start and end times, geographic boundaries), data type, and update frequency.
[0036] At the same time, a multi-dimensional search index is established based on the data asset catalog. This means that the system constructs efficient index structures (such as inverted indexes and spatial indexes) based on key attributes in the catalog (such as spatial location (watershed, administrative district), time range, data type, and security level). This allows users to quickly locate the required data assets by combining search criteria. Furthermore, recording metadata is key to ensuring data traceability, understandability, and trustworthiness. It should be noted that this metadata information includes at least: acquisition time (recording the specific moment when the data was actually generated or acquired), spatial range (precisely describing the geographic area covered by the data, such as boundary coordinates, center point coordinates, and grid coverage), and sensor model (recording the specific model and specifications of the equipment used to collect the data, which is crucial for understanding the data's accuracy, range, and potential errors). For example, an entry for "standard time series data" regarding a reservoir's water level would have metadata detailing that the data was collected by a "model XX radar water level gauge" at "YYYY-MM-DDHH:MM:SS," covering the "XX reservoir dam area," and with a security level of "Level 2." These asset management tasks provide convenience and guarantee for subsequent model construction (such as screening data with specific security levels for training) and data service calls (such as retrieval by permissions).
[0037] Step 103: Input the standard time series data into the pre-trained water conservancy data analysis model to calculate the attention weight distribution between different time steps and different variables through the self-attention mechanism unit in the water conservancy data analysis model.
[0038] In one embodiment of the present application, the method also includes: constructing a water conservancy data analysis model, specifically including: loading historical standard time series data based on a data asset catalog and a multidimensional retrieval index; dividing the historical standard time series data into a training data set and a test data set, and constructing an initial Attention-GRU model structure, configuring the input feature dimension, the number of GRU units and the output feature dimension; iteratively training the initial Attention-GRU model based on the training data set, and evaluating the prediction accuracy of the trained model based on the test data set until a converged water conservancy data analysis model is obtained.
[0039] In one embodiment of the present application, the attention weight distribution between different time steps and different variables is calculated by the self-attention mechanism unit in the water conservancy data analysis model, specifically including: generating a query vector, a key vector and a value vector through a fully connected layer for the standard time series data; calculating the similarity score between the query vector and the key vector to generate an original attention score matrix; normalizing the original attention score matrix to obtain the joint attention weight distribution of the time step dimension and the variable dimension.
[0040] It should be noted that the pre-trained water conservancy data analysis model is a neural network model that integrates a self-attention mechanism and a gated recurrent unit (GRU). The model is fed with processed, uniformly formatted, and high-quality "standard time series data" (typically organized as a three-dimensional tensor, such as [sample index, time step, number of variables]).
[0041] Specifically, the model first processes the input data through its built-in self-attention mechanism unit (Self-Attention Mechanism Unit), whose core function is to calculate the attention weight distribution between different time steps and different variables.
[0042] In this embodiment, the calculation process is carried out according to the following logic: Generating query, key, and value vectors: First, the input standard time series data is transformed through a fully connected layer (also known as a linear transformation layer or projection layer). Specifically, this layer learns different weight matrices to independently map each position in the input data (i.e., the specific variable features of each sample at a specific time step) to generate three different vectors: the query vector (Q), the key vector (K), and the value vector (V). The Q vector represents the "subject" of current computational focus (e.g., the state of a key variable at the current moment), the K vector represents the "candidate information" in the data for comparison (e.g., the states of all variables at all time steps), and the V vector represents the actual "content" of the information. These three vectors provide low-dimensional representations of the original data in different semantic spaces, laying the foundation for calculating relevance.
[0043] Calculate the original attention score matrix: Next, calculate the similarity score between the query vector and the key vector. In this embodiment, this is usually achieved by a dot product operation (i.e., calculating the matrix multiplication QK^T between the Q vector and the transpose K^T of the K vector). For example, for a specific query (such as the water level variable A representing the current moment t), it is dot-producted with the key vectors corresponding to all variables (such as water level A, flow B, rainfall C, etc.) at all time steps (including historical moments and the current moment) to obtain a series of similarity scores. It can be understood that the higher the score, the stronger the correlation or importance of the corresponding key (i.e., the state of a variable at a certain time step) with the current query. All these dot product results constitute a raw attention score matrix (or similarity matrix). The rows of this matrix usually correspond to the positions of the queries (which can be a combination of time step indices or variable indices), the columns correspond to the positions of the keys, and each element score[i,j] quantifies the "raw attention" of the i-th position (such as variable m at time step t_i) to the j-th position (such as variable n at time step t_j).
[0044] Generate a joint attention weight distribution: Then, the original attention score matrix is normalized. Specifically, this is usually done using the Softmax function along a specific dimension (usually the row dimension, i.e. for each Query position). The Softmax function converts the original score into a probability distribution so that the sum of the weights of all Key positions corresponding to each Query position is 1, and each weight value is between 0 and 1. It should be noted that the result of this normalization is the final attention weight distribution (AttentionWeights). Crucially, since the Query and Key dimensions cover the time step and variable, the final attention weight distribution is a joint attention weight distribution of the time step dimension and the variable dimension. For example, when analyzing flood risk for a particular river section, the model might calculate that, for the water level at the current time t (as the query subject), it places significant emphasis on the rainfall at a key upstream rain gauge three hours prior (time step t-3) (variable B) and the change in the opening of a sluice gate upstream of the river section one hour prior (time step t-1) (variable C), assigning these higher weights (e.g., close to 0.5 and 0.3), while paying less attention to other time points and other variables (weights close to 0). This distribution dynamically and quantitatively reveals the key spatial and temporal correlation strengths between the current analysis target (water level) and historical conditions and various influencing factors (rainfall, sluice gate opening).
[0045] It's understandable that the joint attention weight distribution output from this step accurately quantifies the complex dependencies within the input data, using the self-attention mechanism. This provides precise guidance for extracting the most critical information from the raw data and performing spatiotemporal information fusion. The model thus intelligently identifies and quantitatively assesses the most important information (key variables) at the "when" (key historical / future time points) of the input data.
[0046] Step 104: Based on the attention weight distribution, perform weighted summation on the standard time series data to generate a spatiotemporal feature representation vector, and input the spatiotemporal feature representation vector into the gated recurrent unit in the water conservancy data analysis model, and perform spatiotemporal information fusion through the update gate and reset gate.
[0047] In one embodiment of the present application, a weighted summation is performed on the standard time series data according to the attention weight distribution to generate a spatiotemporal feature representation vector, specifically including: based on the joint attention weight distribution, weighted aggregation is performed on the value vector in the time step dimension to generate time-aware features; matrix multiplication of the time-aware features and the variable dimension attention weights is performed to generate cross-variable correlation features; the cross-variable correlation features are spliced along the channel dimension and compressed through a convolutional layer to generate a spatiotemporal feature representation vector.
[0048] In one embodiment of the present application, the spatiotemporal feature representation vector is input into the gated recurrent unit in the water conservancy data analysis model, and spatiotemporal information fusion is performed through the update gate and the reset gate, specifically including: inputting the spatiotemporal feature representation vector into the reset gate, calculating the reset coefficient to control the forgetting ratio of historical state information; inputting the spatiotemporal feature representation vector into the update gate, calculating the update coefficient to fuse the current feature with the historical state; based on the reset coefficient and the update coefficient, performing a nonlinear transformation on the unit state to generate a fused spatiotemporal feature.
[0049] In this embodiment, this step aims to extract the most critical spatiotemporal information from the original data and deeply integrate it with the historical state to form a more powerful fusion feature representation.
[0050] In this example, this involves the following steps: Time-aware features are generated by weighted aggregation in the time dimension: Based on the joint attention weight distribution, the distribution has quantified the importance of different time steps and variable positions. Specifically, we first focus on the information fusion in the time dimension. The value vector (ValueVector, V) is weightedly aggregated in the time step dimension. This is achieved by applying the attention weight matrix normalized in step 103 (whose rows correspond to Query positions and columns correspond to Key positions) to the value vector V. For example, for a specific Query position (which can be understood as the state of the target variable we are paying attention to at the current moment), its corresponding attention weight row vector will be weighted and summed with the corresponding vectors of all time steps in the value vector V. The weighted result generated by this operation is called time-aware features, which integrates the information of all moments in the entire time window, but dynamically assigns different importance (weights) to different historical moments by the attention weight, thereby highlighting the key historical fragments that have the greatest impact on the current analysis target.
[0051] Variable dimension fusion generates cross-variable correlation features: The time-aware features obtained in the previous step already incorporate key temporal information, but the correlation of variable dimensions must also be considered. Specifically, matrix multiplication (or other weighted fusion methods) is performed on the time-aware features with the variable-dimensional attention weights. It should be noted that the "variable-dimensional attention weights" here can refer to the portion of the joint attention weight distribution associated with the variables, or an inter-variable attention matrix further extracted or derived from the joint distribution. For example, the time-aware features can be multiplied with a matrix reflecting inter-variable correlations (this matrix can be aggregated or derived from the joint attention weights by variable dimension) to strengthen or suppress the contribution of different variable features to the current key temporal information. This operation generates cross-variable correlation features, which reflect the interactions and correlation strength between different variables (such as water level, rainfall, and gate opening) at the key time points identified by the attention mechanism.
[0052] Concatenation and compression generate a spatiotemporal feature representation vector: After the two steps above are combined, time perception and variable association information are obtained, respectively. These cross-variable association features are concatenated along the channel dimension (if multidimensional features exist) to form a higher-dimensional feature combination that combines critical temporal information and variable interaction information. This is then compressed using a convolutional layer (typically a 1x1 convolution). 1x1 convolutions effectively reduce feature dimensions while preserving spatial (here, feature dimension) structure, further fusing and refining feature channels. Ultimately, the output is a low-dimensional, high-information-density vector, the spatiotemporal representation vector (SpatiotemporalRepresentationVector). This vector is a highly refined and abstract representation of the core spatiotemporal patterns of the original standard time series data, as determined by the self-attention mechanism. It captures the historical dynamics and inter-variable associations most relevant to the current analysis objective.
[0053] Next, the generated spatiotemporal feature representation vector is input into the gated recurrent unit (GRU) in the water conservancy data analysis model. This step aims to perform spatiotemporal information fusion through update and reset gates, dynamically integrating the currently extracted key spatiotemporal features with the long-term historical state of the model memory. In this embodiment, the core of the GRU unit lies in its two gating mechanisms: The reset gate calculates a reset coefficient to control the proportion of historical forgetting: the spatiotemporal feature representation vector is input into the reset gate (ResetGate). Specifically, the reset gate is usually implemented by a Sigmoid activation function layer, which connects the current input (i.e., the spatiotemporal feature representation vector) with the hidden state of the GRU unit at the previous moment (representing historical state information). After a weight matrix transformation, a reset coefficient (usually a vector with a value between 0 and 1) is calculated. It can be understood that this reset coefficient determines the proportion of the hidden state information at the previous moment that should be "forgotten" or "retained" for current calculations. For example, if the reset coefficient is close to 0, it means that the model tends to "forget" most of the historical information and focus more on the latest key spatiotemporal patterns represented by the current input (the spatiotemporal feature representation vector); if it is close to 1, it tends to retain more historical states.
[0054] The update gate calculates the update coefficient to fuse the current features with the historical state: Simultaneously, the spatiotemporal feature representation vector is input into the update gate (UpdateGate). The update gate is also implemented by a Sigmoid activation function layer, whose output is called the update coefficient (also a vector between 0 and 1). The update coefficient determines the proportion of the new candidate hidden state (CandidateHiddenState) generated at the current moment that will be incorporated into the final current hidden state, while the remaining proportion of the historical hidden state will be retained. For example, an update coefficient close to 1 means that the new state is primarily driven by the current input information, while a coefficient close to 0 means that the old state is primarily retained.
[0055] Nonlinear transformation generates fused spatiotemporal features: After obtaining the reset coefficient and update coefficient, the GRU unit performs a nonlinear transformation on the unit state. Specifically, the reset coefficient is first used to selectively "reset" (i.e., element-wise multiplication) the previous hidden state to obtain a temporary state. This temporary state is then concatenated with the current input (the spatiotemporal feature representation vector) and passed through a Tanh activation layer to generate a candidate hidden state (representing a possible new state based on the current input and the reset historical state). Finally, the update coefficient is used to fuse the candidate hidden state with the previous hidden state via a weighted average: the resulting fused spatiotemporal feature (i.e., the current hidden state) = update coefficient candidate hidden state + (1-update coefficient) previous hidden state. It is important to note that this gating mechanism enables the GRU to adaptively and selectively fuse the key spatiotemporal features extracted by the attention mechanism with long-term accumulated historical state information, thereby generating a powerful feature representation that both captures the latest key insights and preserves long-term evolution patterns, providing a solid foundation for final prediction.
[0056] Step 105: Perform water conservancy data trend forecasting based on the fused features and output flood control scheduling decision support data.
[0057] In one embodiment of the present application, water conservancy data trend prediction is performed based on the fused features, and flood control scheduling decision support data is output, specifically including: inputting the fused spatiotemporal features into the fully connected layer, and outputting the predicted values of hydrological indicators in the future time window; calculating the water level change rate and flow mutation threshold of the key nodes based on the predicted values; when it is detected that the water level change rate exceeds the preset safety threshold or the flow mutation occurs, generating a decision support data package containing the risk location, risk level and scheduling recommendations; and converting the decision support data package into a visual layer data format that can be superimposed on a GIS map.
[0058] In this embodiment, the fully connected layer is responsible for mapping the high-dimensional fused feature space to the specific prediction target dimension. Its output is the predicted value of the hydrological indicator for the future time window. For example, the prediction target may include water level values or flow rates at key monitoring stations or sections, or inflow / outflow of specific reservoirs within the next several hours (e.g., the next 6, 12, or 24 hours). These predicted values are the model's quantitative estimates of the future dynamic evolution of water conditions based on historical and current fused features, forming the foundational data for decision-making.
[0059] In this embodiment, the water level change rate refers to the speed at which the water level rises or falls within the forecast period (for example, the magnitude of the water level rise per unit time), and its calculation is usually based on the difference or slope calculation of the predicted water level value. The flow mutation threshold is a reference standard for determining whether the flow has undergone an abnormal and drastic change. It is understandable that the threshold can be determined based on historical statistical data (such as the standard deviation of the flow at a specific site, historical extreme values), a critical value calculated by a hydrological physics model, or a safety threshold set by the scheduling procedures. For example, the system can calculate the difference in flow between the start and end times of the forecast period, or calculate the instantaneous flow change rate, and compare it with a preset mutation threshold.
[0060] When a water level change rate exceeds a preset safety threshold or a sudden change in flow is detected (i.e., a potential risk is identified), the system generates a decision-support data package containing the risk location, risk level, and dispatch recommendations. It should be noted that the risk location precisely identifies the location predicted to exceed the warning level or anomaly (e.g., specific river section stake number, reservoir name, or urban flood control zone). The risk level is categorized into different levels (e.g., blue, yellow, orange, and red) based on factors such as the predicted magnitude of the exceeding warning level (e.g., the degree to which the warning level will be exceeded or the guaranteed level will be guaranteed), the impact area (e.g., estimated inundation range), and the rate of change / sudden change magnitude. Dispatching recommendations generate specific engineering and non-engineering measures based on a pre-set contingency plan library, rule engine, or expert knowledge base. For example, recommendations might include "Open XX gate to release flow to XX cubic meters per second," "Pre-discharge XX million cubic meters of XX reservoir capacity," or "Notify personnel in low-lying areas along the river in YY district to evacuate according to the plan." This data package is a structured information summary for decision makers.
[0061] Finally, to facilitate flood control commanders to intuitively and efficiently grasp the global risk situation and formulate dispatch plans on a geographic information platform (such as a WebGIS flood control command system), the decision support data package is converted into a visual layer data format that can be overlaid on a GIS map. Specifically, this involves converting the aforementioned structured decision information (risk location, level, and recommendations) into a standard geospatial data format. In this embodiment, commonly used formats include, but are not limited to, GeoJSON (a lightweight geographic data exchange format based on JSON), KML (Keyhole Markup Language, commonly used in platforms such as Google Earth), or directly generating OGC-compliant WMS (Web Map Service) or WFS (Web Feature Service). Exemplary results after conversion may include: risky river sections highlighted on the map with different colors (corresponding to risk levels); risk points (such as reservoirs and gates) displayed with color-coded icons; and clicking on a risk location pops up an information window detailing the predicted value, rate of change, risk level, and specific dispatch recommendations. This visual decision-support data can be seamlessly integrated into the GIS platform for flood control command, enabling decision-makers to grasp water risks and response strategies in a "one-picture" manner, significantly improving the accuracy and timeliness of flood control scheduling decisions.
[0062] The above is an embodiment of the method proposed in this application. Based on the same inventive concept, this application embodiment also provides a water conservancy data analysis device based on the self-attention mechanism, whose structure is as follows: Figure 2 shown.
[0063] Figure 2This is a schematic diagram of the internal structure of a water conservancy data analysis device based on the self-attention mechanism provided in an embodiment of the present application. Figure 2 As shown, the equipment includes: at least one processor 201; and, a memory 202 communicatively coupled to the at least one processor; The memory 202 stores instructions that can be executed by at least one processor, and the instructions are executed by the at least one processor 201 to enable the at least one processor 201 to: Build a water conservancy time series data warehouse and establish a water conservancy source data access mechanism to access the water conservancy time series data to be processed; Perform standard preprocessing on the water conservancy time series data to be processed to obtain standard time series data; Input the standard time series data into the pre-trained water conservancy data analysis model to calculate the attention weight distribution between different time steps and different variables through the self-attention mechanism unit in the water conservancy data analysis model; According to the attention weight distribution, the standard time series data is weighted and summed to generate a spatiotemporal feature representation vector, which is then input into the gated recurrent unit in the water conservancy data analysis model to perform spatiotemporal information fusion through the update gate and reset gate. Based on the fused features, water conservancy data trends are predicted and flood control scheduling decision support data is output.
[0064] Some embodiments of the present application provide corresponding Figure 1 A non-volatile computer storage medium stores computer executable instructions, wherein the computer executable instructions are configured as follows: Build a water conservancy time series data warehouse and establish a water conservancy source data access mechanism to access the water conservancy time series data to be processed; Perform standard preprocessing on the water conservancy time series data to be processed to obtain standard time series data; Input the standard time series data into the pre-trained water conservancy data analysis model to calculate the attention weight distribution between different time steps and different variables through the self-attention mechanism unit in the water conservancy data analysis model; According to the attention weight distribution, the standard time series data is weighted and summed to generate a spatiotemporal feature representation vector, which is then input into the gated recurrent unit in the water conservancy data analysis model to perform spatiotemporal information fusion through the update gate and reset gate. Based on the fused features, water conservancy data trends are predicted and flood control scheduling decision support data is output.
[0065] The various embodiments in this application are described in a progressive manner. Similar portions between the various embodiments can be referenced to each other. Each embodiment focuses on the differences from the other embodiments. In particular, the IoT device and media embodiments are generally similar to the method embodiments, so their description is relatively simple. For relevant portions, refer to the description of the method embodiments.
[0066] The system and medium provided in the embodiments of the present application correspond one-to-one to the method. Therefore, the system and medium also have similar beneficial technical effects to their corresponding methods. Since the beneficial technical effects of the method have been described in detail above, the beneficial technical effects of the system and medium will not be repeated here.
[0067] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0068] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0069] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0070] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0071] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
[0072] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0073] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0074] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0075] The foregoing is merely an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.
Claims
1. A water conservancy data analysis method based on self-attention mechanism, characterized in that: The method comprises: Build a water conservancy time series data warehouse and establish a water conservancy source data access mechanism to access the water conservancy time series data to be processed; Performing standardization preprocessing on the water conservancy time series data to be processed to obtain standard time series data; Inputting the standard time series data into a pre-trained water conservancy data analysis model to calculate the attention weight distribution between different time steps and different variables through the self-attention mechanism unit in the water conservancy data analysis model; Performing weighted summation on the standard time series data according to the attention weight distribution to generate a spatiotemporal feature representation vector, and inputting the spatiotemporal feature representation vector into the gated recurrent unit in the water conservancy data analysis model to perform spatiotemporal information fusion through an update gate and a reset gate; Based on the fused features, water conservancy data trends are predicted and flood control scheduling decision support data is output.
2. The water conservancy data analysis method based on the self-attention mechanism according to claim 1 is characterized in that: The water conservancy time series data to be processed is subjected to standardized preprocessing, specifically including: Defining a spatiotemporal data metamodel, and based on the spatiotemporal data metamodel, uniformly converting the timestamp format, coordinate system standard, and spatial resolution of the water conservancy time series data to be processed; The spatiotemporal continuity of the water conservancy time series data to be processed is checked, and when it is determined that there is missing data, spatiotemporal interpolation is performed to complete the data; wherein the spatiotemporal continuity check includes time series breakpoint detection and administrative division boundary topological relationship verification.
3. The water conservancy data analysis method based on the self-attention mechanism according to claim 1 is characterized in that: After performing standardization preprocessing on the water conservancy time series data to be processed to obtain standard time series data, the method further includes: Classify and grade the standard time series data based on preset data security levels to generate a data asset catalog containing open attributes; A multi-dimensional search index is established based on the data asset catalog, and metadata information is recorded; wherein the metadata information includes acquisition time, spatial range, and sensor model.
4. The water conservancy data analysis method based on the self-attention mechanism according to claim 1 is characterized in that: The method further comprises: Constructing the water conservancy data analysis model specifically includes: Loading historical standard time series data based on the data asset catalog and the multidimensional search index; Divide the historical standard time series data into a training dataset and a test dataset, build an initial Attention-GRU model structure, and configure the input feature dimension, the number of GRU units, and the output feature dimension; The initial Attention-GRU model is iteratively trained based on the training data set, and the prediction accuracy of the trained model is evaluated based on the test data set until a converged water conservancy data analysis model is obtained.
5. The water conservancy data analysis method based on the self-attention mechanism according to claim 1 is characterized in that: The self-attention mechanism unit in the water conservancy data analysis model calculates the attention weight distribution between different time steps and different variables, specifically including: Passing the standard time series data through a fully connected layer to generate a query vector, a key vector, and a value vector; Calculating a similarity score between the query vector and the key vector to generate an original attention score matrix; The original attention score matrix is normalized to obtain the joint attention weight distribution of the time step dimension and the variable dimension.
6. The water conservancy data analysis method based on the self-attention mechanism according to claim 5 is characterized in that: According to the attention weight distribution, weighted summation is performed on the standard time series data to generate a spatiotemporal feature representation vector, specifically including: Based on the joint attention weight distribution, performing weighted aggregation on the value vector in the time step dimension to generate a time-aware feature; Performing matrix multiplication on the time perception feature and the variable dimension attention weight to generate a cross-variable correlation feature; The cross-variable correlation features are spliced along the channel dimension and compressed through a convolutional layer to generate the spatiotemporal feature representation vector.
7. The water conservancy data analysis method based on the self-attention mechanism according to claim 6 is characterized in that: The spatiotemporal feature representation vector is input into the gated recurrent unit in the water conservancy data analysis model, and spatiotemporal information fusion is performed through an update gate and a reset gate, specifically including: Inputting the spatiotemporal feature representation vector into a reset gate, and calculating a reset coefficient to control the forgetting ratio of historical state information; Input the spatiotemporal feature representation vector into the update gate and calculate the update coefficient to fuse the current feature with the historical state; Based on the reset coefficient and the update coefficient, a nonlinear transformation is performed on the unit state to generate a fused spatiotemporal feature.
8. The water conservancy data analysis method based on the self-attention mechanism according to claim 1 is characterized in that: Based on the fused features, water conservancy data trends are predicted and flood control scheduling decision support data is output, including: Input the fused spatiotemporal features into a fully connected layer and output the predicted value of the hydrological index in the future time window; Calculate the water level change rate and flow mutation threshold of key nodes based on the predicted value; When the water level change rate exceeds the preset safety threshold or the flow rate changes suddenly, a decision support data package containing the risk location, risk level and dispatch recommendations is generated; The decision support data package is converted into a visual layer data format that can be overlaid on a GIS map.
9. A water conservancy data analysis device based on self-attention mechanism, characterized in that: The device comprises: at least one processor; and, a memory communicatively coupled to the at least one processor; In which, the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute a water conservancy data analysis method based on a self-attention mechanism as described in any one of claims 1-8.
10. A non-volatile computer storage medium storing computer executable instructions, characterized in that: When the computer-executable instructions are executed, a water conservancy data analysis method based on a self-attention mechanism as described in any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Satellite telemetry data prediction method and device based on space-time attention mechanism
CN116451848A
Mixed deep learning water quality prediction method based on time-frequency feature extraction
CN117194954A
Sewage quality abnormal fluctuation detection method and system
CN117726215A
Fault early warning method for current transformer
CN119310516A
Data processing method and apparatus, device, and storage medium
WO2024000852A1
Cited By
Rice blast incubation period diagnosis and prediction method and model based on double-flow data fusion
CN121582748A
Rice blast latent period diagnosis and prediction method and model based on double-flow data fusion
CN121582748B