Dissolved oxygen prediction method based on multi-dimensional graph space-time convolution and attention enhancement mechanism
By combining the graph convolution network, graph attention network and timing convolution network, multi-dimensional spatiotemporal characteristics in the basin environment are extracted, and the problem of dissolved oxygen prediction in complex basin environments is solved, and efficient and accurate dissolved oxygen prediction is achieved.
Patent Information
- Application Number
- CN202510005589.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-03
- Publication Date
- 2025-05-02
AI Technical Summary
In a complex watershed environment, the spatial and temporal changes of dissolved oxygen are affected by a combination of multiple factors, resulting in complex dynamic changes. It is difficult for the existing technology to achieve accurate prediction of dissolved oxygen content in a multi-dimensional dynamic environment.
The dissolved oxygen prediction method based on multi-dimensional graph spatiotemporal convolution and attention enhancement mechanism is adopted. Through the combination of graph convolution network, graph attention network and time-series convolution network, the topological relationship and time-series characteristics between monitoring nodes are extracted to predict the future value of dissolved oxygen.
It achieves efficient and accurate prediction of dissolved oxygen content in complex watershed environments, and improves the ability to manage water environments.
Smart Images

Figure CN119920362A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of environmental assessment, and in particular to a dissolved oxygen prediction method based on multi-dimensional graph spatiotemporal convolution and attention enhancement mechanism. Background Art
[0002] With the increasing development and utilization of water resources and the increasing demand for water environment protection, the efficient prediction of water quality indicators has become an important direction of ecological environmental research. Dissolved oxygen (DO) is a key indicator for measuring water quality, and its dynamic changes can directly reflect the ecological health of water bodies. In a complex watershed environment, the spatiotemporal changes of dissolved oxygen are affected by multiple factors such as hydrology, meteorology and human activities, and are highly nonlinear and complexly dependent. How to achieve accurate prediction of dissolved oxygen content in a multidimensional dynamic environment is an important challenge facing current water environment management. Summary of the invention
[0003] In a first aspect, an embodiment of the present invention provides a dissolved oxygen prediction method based on multi-dimensional graph spatiotemporal convolution and attention enhancement mechanism, the method comprising:
[0004] Obtain the location data of multiple monitoring nodes in the target area and the data of various water indicators including dissolved oxygen monitored by multiple monitoring nodes in multiple time steps;
[0005] The location data of multiple monitoring nodes and the data of water indicators other than dissolved oxygen monitored by multiple monitoring nodes in the first T time steps are used as samples, and the data of dissolved oxygen monitored by multiple monitoring nodes in the next time step are used as labels to construct a data set;
[0006] The dataset is used to train a dissolved oxygen prediction model that combines graph convolutional networks, graph attention networks, and temporal convolutional networks. In the spatial dimension, the dissolved oxygen prediction model uses a graph convolutional network to extract the topological relationship between monitoring nodes, and uses the attention mechanism of the graph attention network to enhance the focus on the features of important monitoring nodes, and then enhances the feature representation through a multi-head attention mechanism. In the temporal dimension, the dissolved oxygen prediction model uses a temporal convolutional network to capture short-term dynamic and long-term evolution characteristics through causal convolution and dilated convolution, and introduces residual connections to avoid gradient disappearance.
[0007] Use the trained dissolved oxygen prediction model to predict dissolved oxygen in the target area.
[0008] In some implementations of the first aspect, location data of multiple monitoring nodes and data of water indicators other than dissolved oxygen monitored by the multiple monitoring nodes in the first T time steps are used as samples, and data of dissolved oxygen monitored by the multiple monitoring nodes in the next time step are used as labels to construct a data set, including:
[0009] Performing sine-cosine encoding on the position data of multiple monitoring nodes to obtain three-dimensional position vectors of the multiple monitoring nodes;
[0010] Preprocessing the data of various water body indicators including dissolved oxygen monitored by multiple monitoring nodes in multiple time steps to obtain preprocessed data of various water body indicators including dissolved oxygen monitored by multiple monitoring nodes in multiple time steps; wherein the preprocessing includes missing value filling and missing value correction;
[0011] The three-dimensional position vectors of multiple monitoring nodes and the preprocessed data of water indicators except dissolved oxygen monitored by multiple monitoring nodes in the first T time steps are used as samples, and the preprocessed data of dissolved oxygen monitored by multiple monitoring nodes in the next time step are used as labels to construct a data set.
[0012] In some implementations of the first aspect, performing sine-cosine encoding on the position data of the plurality of monitoring nodes to obtain the three-dimensional position vectors of the plurality of monitoring nodes includes:
[0013] For any monitoring node, the longitude and latitude in its location data are respectively sine-cosine encoded to obtain the three-dimensional position vector of the longitude and latitude of the monitoring node;
[0014] The three-dimensional position vectors of the longitude and latitude of the monitoring node are averaged and merged to obtain the three-dimensional position vector of the monitoring node.
[0015] In some implementable embodiments of the first aspect, data of various water body indicators including dissolved oxygen monitored by multiple monitoring nodes within multiple time steps are preprocessed to obtain preprocessed data of various water body indicators including dissolved oxygen monitored by multiple monitoring nodes within multiple time steps, including:
[0016] The linear interpolation method is used to fill the missing values of the data of various water body indicators including dissolved oxygen monitored by multiple monitoring nodes in multiple time steps, and the time series correction method is used to correct the filled missing values to obtain the preprocessed data of various water body indicators including dissolved oxygen monitored by multiple monitoring nodes in multiple time steps.
[0017] In some implementations of the first aspect, three-dimensional position vectors of multiple monitoring nodes and preprocessed data of water indicators other than dissolved oxygen monitored by the multiple monitoring nodes in the first T time steps are used as samples, and preprocessed data of dissolved oxygen monitored by the multiple monitoring nodes in the next time step are used as labels to construct a data set, including:
[0018] A data set is constructed by using the sliding window method, with the three-dimensional position vectors of multiple monitoring nodes and the preprocessed data of water indicators other than dissolved oxygen monitored by multiple monitoring nodes in the first T time steps as samples, and the preprocessed data of dissolved oxygen monitored by multiple monitoring nodes in the next time step as labels.
[0019] In some implementations of the first aspect, a dissolved oxygen prediction model combining a graph convolutional network, a graph attention network, and a temporal convolutional network is trained using a data set, including:
[0020] Divide the data set into training set and test set according to the preset ratio;
[0021] The dissolved oxygen prediction model is trained using the training set, and after the training is completed, the dissolved oxygen prediction model is tested using the test set, and the dissolved oxygen prediction model that passes the test is used as the trained dissolved oxygen prediction model.
[0022] In some implementations of the first aspect, using the trained dissolved oxygen prediction model to predict dissolved oxygen in a target area includes:
[0023] The three-dimensional position vectors of multiple monitoring nodes in the target area and the preprocessed data of water indicators other than dissolved oxygen monitored by multiple monitoring nodes in the previous T time steps are input into the trained dissolved oxygen prediction model. The trained dissolved oxygen prediction model processes the input data to predict the dissolved oxygen in the next time step.
[0024] In a second aspect, an embodiment of the present invention provides a dissolved oxygen prediction device based on multi-dimensional graph spatiotemporal convolution and attention enhancement mechanism, the device comprising:
[0025] An acquisition module is used to acquire the location data of multiple monitoring nodes in the target area and the data of various water indicators including dissolved oxygen monitored by multiple monitoring nodes in multiple time steps;
[0026] A construction module is used to construct a data set using the location data of multiple monitoring nodes and the data of water body indicators other than dissolved oxygen monitored by the multiple monitoring nodes in the previous T time steps as samples, and the data of dissolved oxygen monitored by the multiple monitoring nodes in the next time step as labels;
[0027] The training module is used to use the data set to train the dissolved oxygen prediction model that combines the graph convolution network, the graph attention network and the temporal convolution network. In the spatial dimension, the dissolved oxygen prediction model uses the graph convolution network to extract the topological relationship between the monitoring nodes, and uses the attention mechanism of the graph attention network to enhance the attention to the features of important monitoring nodes, and then enhances the feature representation through the multi-head attention mechanism. In the temporal dimension, the dissolved oxygen prediction model uses the temporal convolution network to capture the short-term dynamic and long-term evolution characteristics through causal convolution and dilated convolution, and introduces residual connections to avoid gradient disappearance.
[0028] The prediction module is used to predict dissolved oxygen in the target area using the trained dissolved oxygen prediction model.
[0029] In a third aspect, an embodiment of the present invention provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; the memory stores instructions executable 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 the method described above.
[0030] In a fourth aspect, an embodiment of the present invention provides a non-transitory computer-readable storage medium storing computer instructions, where the computer instructions are used to enable a computer to execute the method described above.
[0031] In an embodiment of the present invention, first, the location data of multiple monitoring nodes in the target area and the data of various water indicators including dissolved oxygen monitored by the multiple monitoring nodes in multiple time steps are obtained, and then the location data of the multiple monitoring nodes and the data of water indicators other than dissolved oxygen monitored by the multiple monitoring nodes in the first T time steps are used as samples, and the dissolved oxygen data monitored by the multiple monitoring nodes in the next time step are used as labels to construct a data set, and then the data set is used to train a dissolved oxygen prediction model that combines a graph convolutional network, a graph attention network and a temporal convolutional network to obtain a dissolved oxygen prediction model with outstanding prediction ability, and based on the model, the dissolved oxygen is efficiently and accurately predicted.
[0032] It should be understood that the contents described in the summary of the invention are not intended to limit the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The above and other features, advantages and aspects of the embodiments of the present invention will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. The accompanying drawings are used to better understand the present invention and do not constitute a limitation of the present invention. In the accompanying drawings, the same or similar reference numerals represent the same or similar elements, wherein:
[0034] Figure 1 A flow chart of a dissolved oxygen prediction method based on multi-dimensional graph spatiotemporal convolution and attention enhancement mechanism provided in an embodiment of the present invention;
[0035] Figure 2 Dissolved oxygen data provided by the embodiment of the present invention;
[0036] Figure 3 The filled and corrected dissolved oxygen data provided by the embodiment of the present invention;
[0037] Figure 4 A schematic diagram of the model fitting effect provided by an embodiment of the present invention;
[0038] Figure 5 A schematic diagram of model evaluation indicators provided by an embodiment of the present invention;
[0039] Figure 6 A structural diagram of a dissolved oxygen prediction device based on multi-dimensional graph spatiotemporal convolution and attention enhancement mechanism provided by an embodiment of the present invention;
[0040] Figure 7 The figure is a structural diagram of an exemplary electronic device capable of implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0042] In addition, the term "and / or" in the present invention is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in the present invention generally indicates that the associated objects before and after are in an "or" relationship.
[0043] In order to solve the technical problems arising from the background technology, the embodiments of the present invention provide a dissolved oxygen prediction method, device, equipment and storage medium based on multi-dimensional graph spatiotemporal convolution and attention enhancement mechanism. Specifically, firstly, the location data of multiple monitoring nodes in the target area and the data of various water indicators including dissolved oxygen monitored by multiple monitoring nodes in multiple time steps are obtained, and then the location data of multiple monitoring nodes and the data of water indicators other than dissolved oxygen monitored by multiple monitoring nodes in the first T time steps are used as samples, and the data of dissolved oxygen monitored by multiple monitoring nodes in the next time step are used as labels to construct a data set, and then the data set is used to train a dissolved oxygen prediction model combining a graph convolutional network, a graph attention network and a temporal convolutional network, so as to obtain a dissolved oxygen prediction model with outstanding prediction ability, and based on the model, the dissolved oxygen is predicted efficiently and accurately.
[0044] In conjunction with the accompanying drawings, a method, device, equipment and storage medium for predicting dissolved oxygen based on multi-dimensional graph spatiotemporal convolution and attention enhancement mechanism provided by an embodiment of the present invention are described in detail through specific embodiments.
[0045] Figure 1 A flow chart of a dissolved oxygen prediction method based on multi-dimensional graph spatiotemporal convolution and attention enhancement mechanism provided by an embodiment of the present invention, such as Figure 1 As shown, the dissolved oxygen prediction method 100 may include:
[0046] S110, obtaining location data of multiple monitoring nodes in the target area and data of various water indicators including dissolved oxygen monitored by the multiple monitoring nodes in multiple time steps.
[0047] Among them, the target area is a river basin area designated by the researchers, in which multiple monitoring nodes for monitoring water body indicators are deployed; the location data of the monitoring node can be the latitude and longitude data of the monitoring node; the various water body indicators monitored by the monitoring node can be dissolved oxygen, water temperature, PH, permanganate index, ammonia nitrogen, total phosphorus, total nitrogen, conductivity, turbidity, etc.; the above time step can be one day.
[0048] S120, constructing a data set using the location data of multiple monitoring nodes and the data of water indicators other than dissolved oxygen monitored by the multiple monitoring nodes in the previous T time steps as samples, and the data of dissolved oxygen monitored by the multiple monitoring nodes in the next time step as labels.
[0049] In some embodiments, the position data of multiple monitoring nodes are sine-cosine encoded to obtain the three-dimensional position vectors of the multiple monitoring nodes. Specifically, for any monitoring node, the longitude and latitude in its position data can be sine-cosine encoded to obtain the three-dimensional position vector of the longitude and latitude of the monitoring node, and the three-dimensional position vectors of the longitude and latitude of the monitoring node are averaged and merged to obtain the three-dimensional position vector of the monitoring node.
[0050] The data of various water body indicators including dissolved oxygen monitored by multiple monitoring nodes in multiple time steps are preprocessed to obtain preprocessed data of various water body indicators including dissolved oxygen monitored by multiple monitoring nodes in multiple time steps. The preprocessing includes missing value filling and missing value correction. Specifically, the linear interpolation method can be used to fill the missing values of the data of various water body indicators including dissolved oxygen monitored by multiple monitoring nodes in multiple time steps, and the time series correction method can be used to correct the filled missing values to obtain preprocessed data of various water body indicators including dissolved oxygen monitored by multiple monitoring nodes in multiple time steps.
[0051] The three-dimensional position vectors of multiple monitoring nodes and the preprocessed data of water body indicators other than dissolved oxygen monitored by the multiple monitoring nodes in the first T time steps are used as samples, and the preprocessed data of dissolved oxygen monitored by the multiple monitoring nodes in the next time step are used as labels to construct a data set. Specifically, the three-dimensional position vectors of multiple monitoring nodes and the preprocessed data of water body indicators other than dissolved oxygen monitored by the multiple monitoring nodes in the first T time steps are used as samples, and the preprocessed data of dissolved oxygen monitored by the multiple monitoring nodes in the next time step are used as labels to construct a data set through a sliding window method.
[0052] As an example, in order to capture the spatial relationship of geographic information, the present invention performs sine and cosine encoding on the longitude and latitude of each monitoring node. Longitude and latitude have periodic and nonlinear characteristics. Directly using longitude and latitude values for modeling may make it difficult for the model to learn the relationship between geographic space. Therefore, the present invention uses sine and cosine to convert longitude and latitude into a three-dimensional position vector, retaining the periodic characteristics of geographic space.
[0053] Assuming that the latitude of the monitoring node is lat and the longitude is lon, it is converted into a three-dimensional position vector representation to retain its geographic spatial characteristics. The specific process can be as follows:
[0054] (1) General sine and cosine coding formula
[0055] For an input value x, the encoding dimension is d, and the sine-cosine encoding is expressed as:
[0056]
[0057] In the formula, x can be the value of latitude or longitude; d is the target encoding dimension, where d=3, indicating that it is mapped to a 3-dimensional vector space; i is the i-th dimension, which starts from 0.
[0058] (2) Specific sine and cosine encoding of latitude and longitude:
[0059] For latitude lat:
[0060] Dimension 1:
[0061] Dimension 2:
[0062] 3rd Dimension:
[0063] For longitude lon:
[0064] Dimension 1:
[0065] Dimension 2:
[0066] 3rd Dimension:
[0067] (3) Combined encoding of latitude and longitude
[0068] In order to combine the encoding results of latitude and longitude into a three-dimensional position vector, the present invention adopts averaging merging, and adds the encoding results of latitude and longitude dimension by dimension to obtain the average value, so as to obtain the final three-dimensional position vector, that is, the three-dimensional position vector of the monitoring node:
[0069]
[0070] Where, PE final is the three-dimensional position vector of the monitoring node; [PE 1 (lat),PE 2 (lat),PE 3 (lat)] is the three-dimensional position vector of the latitude of the monitoring node; [PE 1 (lon),PE 2 (lon),PE 3 (lon)] is the three-dimensional position vector of the longitude of the monitoring node.
[0071] The details are as follows:
[0072] Dimension 1:
[0073] Dimension 2:
[0074] 3rd Dimension:
[0075] (4) The significance of the above sine-cosine coding
[0076] (4.1) Local and global relations
[0077] a. Low-frequency components (sin(lat) and cos(lon) in the first dimension) are used to capture local geographic variations, such as the relative relationship between adjacent nodes in a region.
[0078] b. High-frequency components (second and third dimensions) are used to describe changes on a larger geographical scale, such as the relationship between nodes across different regions.
[0079] (4.2) Capturing periodic characteristics
[0080] The encoding is naturally periodic through sine and cosine functions, which allows the model to understand periodic features in geographic space.
[0081] (4.3) Advantages of three-dimensional representation:
[0082] Encoding longitude and latitude as three-dimensional rather than higher-dimensional representations can effectively reduce the computational complexity of the model while ensuring that the model retains sufficient geospatial information in lower dimensions.
[0083] This part mainly addresses how to convert geographic information such as longitude and latitude into feature representations that can be effectively used by the model to ensure that spatial relationships are well preserved and understood in the model.
[0084] In time series data processing, data integrity is crucial to the effectiveness of the model. However, in practical applications, the acquired water index data often contains many missing values, such as those caused by equipment failure, sensor failure, or network problems. If these missing values are not effectively processed, they will affect the performance and prediction accuracy of the model. Therefore, the present invention uses linear interpolation and time series correction methods to fill and correct these missing data. The specific process can be shown as follows:
[0085] (1) Raw data display
[0086] like Figure 2 As shown in the figure, taking the "dissolved oxygen" of a certain monitoring node as an example, there are different degrees of missing data, so missing values need to be filled to facilitate more accurate predictions for subsequent models.
[0087] (2) Linear interpolation filling
[0088] Linear interpolation is a simple and effective method for filling missing values. The idea is to construct a straight line between two known data points and use this line to estimate the value of the middle point. 1 ,y 1 ) and (x 2 ,y 2 ), where x 1 <x<x 2 , and want to estimate the y value at x, the interpolation formula is as follows:
[0089]
[0090] The formula is constructed by constructing a linear function f(x) at x 1 and x 2 The advantages of this method are that it has low computational complexity, simple implementation, and is suitable for situations where the data presents a linear trend.
[0091] (3) Time series correction based on the Prophet model
[0092] Since the data filled by the linear interpolation method does not have a time effect, and the problem being studied may have a time accumulation, it is necessary to further correct the missing values. Therefore, the Prophet time series forecast is used to correct the data filled in above so that the data has a time effect, that is, it is closer to the actual situation, thereby improving the practical application ability of the model obtained by subsequent training. The basic model is as follows:
[0093] y(t)=g(t)+s(t)+h(t)+ε t (4)
[0094] Where y(t) is the observed value at time t; g(t) is the trend function at time t; s(t) is the seasonal component at time t; h(t) is the holiday effect at time t; ε t is the error term; it represents unexplained noise.
[0095] a. The trend function g(t) uses a logistic trend in the present invention, which is expressed as follows:
[0096]
[0097] Where C is the saturation value; k is the growth rate; and m is the center of the logistic curve.
[0098] b. The seasonal component s(t) is represented by Fourier series expansion, which can capture the periodic pattern, as follows:
[0099]
[0100] Where N is the order of the Fourier series; P is the seasonal period; a n and b n are the Fourier coefficients.
[0101] c. The holiday effect h(t) is used to model the impact of special dates on time series, which is expressed as follows:
[0102]
[0103] Where H is the number of holidays, d i is the impact coefficient of holiday i, is an indicator function (1 when t is during holiday i, otherwise 0).
[0104] d. Error term ε t It represents the noise that cannot be explained by the model. The present invention assumes that it is independent and identically distributed Gaussian noise, which is expressed as follows:
[0105] ε t :N(0,σ 2 ) (8)
[0106] (4) Display of filled and corrected data
[0107] like Figure 3 As shown, taking the "dissolved oxygen" of a certain monitoring node as an example, the filled and corrected water index data, that is, the water index preprocessing data, maintains good time series and periodicity, and can be used for subsequent model training.
[0108] The sliding window method is a very common time series data processing technology, which is used to split the original time series into multiple subsequences of fixed length to facilitate model training and prediction. Its main purpose is to capture local patterns in the time series (such as short-term trends and cyclical changes) and provide these local patterns as input to the model, so that the model can effectively predict future states.
[0109] In the present invention, the sliding window method is used to construct the model input features, so that the model can predict the situation of the next time step (day) based on the data of the past T time steps (days). For time series data, the use of sliding windows helps to capture the dynamic change characteristics in the time series and provide valuable input for the model. The specific implementation process is as follows:
[0110] (1) Initial setting of window size and step size
[0111] Window size: Set the window size to T, for example, T = 25, which means that the input of the model consists of data from the past 25 days.
[0112] Step size: The step size defines the sliding speed of the window. In the present invention, the step size is set to 1, which means that the window slides forward 1 day each time, that is, the output of the model is the data of the next day.
[0113] (2) Constructing a dataset
[0114] Based on the above settings, the window is slid, and then the three-dimensional position vectors of multiple monitoring nodes and the pre-processed data of water indicators other than dissolved oxygen monitored by multiple monitoring nodes in the previous T time steps are used as samples, i.e., model inputs, and the pre-processed data of dissolved oxygen monitored by multiple monitoring nodes in the next time step are used as labels, i.e., the expected output of the model, to construct a data set. Obviously, the goal of using this data set to build a model here is to use the three-dimensional position vectors of multiple monitoring nodes and the pre-processed data of water indicators other than dissolved oxygen monitored by them in the past T time steps to predict the dissolved oxygen in the next time step.
[0115] S130, using the dataset to train a dissolved oxygen prediction model that combines a graph convolutional network, a graph attention network, and a temporal convolutional network.
[0116] In some embodiments, the data set is divided into a training set and a test set according to a preset ratio, and the training set is used to train a dissolved oxygen prediction model that combines a graph convolutional network, a graph attention network, and a temporal convolutional network. After the training, the test set is used to test the dissolved oxygen prediction model, and the dissolved oxygen prediction model that passes the test is used as the trained dissolved oxygen prediction model.
[0117] Among them, in the spatial dimension, the dissolved oxygen prediction model extracts the topological relationship between monitoring nodes through the graph convolutional network, and uses the attention mechanism of the graph attention network to enhance the attention to the features of important monitoring nodes, and then enhances the feature representation through the multi-head attention mechanism; in the temporal dimension, the dissolved oxygen prediction model uses the temporal convolutional network through causal convolution and dilated convolution to capture short-term dynamics and long-term evolution characteristics, and introduces residual connections to avoid gradient disappearance.
[0118] As an example, the construction of a dissolved oxygen prediction model combining a graph convolutional network (GCN), a graph attention network (GAT), and a temporal convolutional network (TCN) can be shown as follows:
[0119] (1) Construction of GCN and GAT
[0120] In the present invention, GCN is first used to perform preliminary feature aggregation to obtain the basic neighborhood feature representation of the node, i.e., the monitoring node, and then GAT is used to further weight these features, that is, combining the global feature aggregation capability of GCN and the dynamic weighted feature aggregation capability of GAT, and finally obtaining a more accurate node representation.
[0121] (1.1) Architecture details
[0122] Stage 1: Initial feature aggregation of GCN
[0123] First, the input is the node feature matrix H of the graph structure (0) And the adjacency matrix A, through GCN to perform preliminary feature aggregation. The calculation of the GCN layer is as follows:
[0124]
[0125] In the formula, To add the adjacency matrix after the self-loop, each node can contain its own information; for The degree matrix of (l) is the node feature matrix of the lth layer, H (0) =X, is the input feature; W (l) is the weight matrix of the lth layer, which is the parameter to be learned; σ(·) is the activation function, usually ReLU, which is used to introduce nonlinearity.
[0126] Through GCN, the basic neighborhood feature representation H of each node is obtained (l+1) ,These features contain information of the node itself and its neighborhood nodes, but the influence of all neighbors is treated the same.
[0127] Stage 2: Weighted Feature Aggregation of GAT
[0128] Use GAT to train the feature H obtained by GCN (l+1) Perform weighted aggregation to increase attention to important neighbor nodes:
[0129] Calculate the attention coefficient:
[0130] For each pair of nodes (i, j), the attention coefficient e of node i to node j is calculated through the attention mechanism ij :
[0131]
[0132] In the formula, is the learnable attention weight vector; W is the weight matrix; is the input feature matrix (vector form) of node i; is the input feature matrix (vector form) of node j; || is the feature connection operation, which is used to concatenate the features of nodes i and j; LeakyReLU is an activation function used to perform nonlinear processing on linear transformation results.
[0133] Softmax Normalization:
[0134] In order to obtain the final attention weight α ij , for e ij Perform normalization:
[0135]
[0136] In the formula, is the set of neighbor nodes of node i.
[0137] This ensures that the sum of all attention weights is 1, indicating the relative importance of the features of neighbor nodes to the central node.
[0138] Weighted sum of node features:
[0139] Finally, the updated feature of node i is It is expressed as a weighted sum of its neighbors’ features:
[0140]
[0141] Where σ(·) is the activation function, which is used to introduce nonlinearity.
[0142] (1.2) Use of multi-head attention mechanism
[0143] In order to enhance the learning ability of features, GAT usually uses a multi-head attention mechanism, that is, multiple independent attention calculations are performed on the neighbor relationship of each node. This allows the model to observe the relationship between nodes from multiple angles and improve the robustness of the model. The present invention uses an average operation to combine multiple attention heads, as follows:
[0144]
[0145] Where K is the number of attention heads; each attention head has its own independent weight matrix W k and attention coefficient The results of multiple attention heads are averaged to make the final feature representation more stable.
[0146] (1.3) Advantages of combining GCN and GAT
[0147] Combining the characteristics of GCN and GAT, we can make full use of the ability to distinguish global structural information and node importance. GCN aggregates nodes and their neighborhood information through global feature convolution, providing a comprehensive structural representation, but its limitation of lacking the ability to distinguish the importance of neighboring nodes can be compensated by the attention mechanism of GAT. GAT gives dynamic attention weights to different neighboring nodes, thereby highlighting the contribution of key nodes. In addition, the multi-head attention mechanism further enhances the feature expression ability of the model, enabling it to capture complex feature interactions from multiple perspectives and enhance robustness. More importantly, the weighted aggregation of GAT overcomes the problem of over-smoothing that may be caused by GCN as the number of layers deepens to a certain extent. By retaining the differences in key features, the node representation has higher discrimination and recognition.
[0148] (2) Construction of TCN
[0149] After the spatial features obtained by GCN and GAT, TCN is used to capture the temporal evolution of node features. Through causal convolution and dilated convolution, TCN can effectively capture the temporal dependency of node features.
[0150] (2.1) The role of causal convolution
[0151] Causal Convolution ensures that the model's prediction at a certain time step depends only on the features of that time step and before, thereby maintaining causality in time series prediction. Because in real prediction tasks, the model's prediction cannot use future data. Its calculation formula is as follows:
[0152]
[0153] In the formula, y t is the prediction result; k is the convolution kernel size; w i is the weight of the convolution kernel; x t―i is the value of the input sequence at the (t-i)th time step.
[0154] This design ensures that y t It only depends on data before the t-th time step, ensuring causality and temporal consistency.
[0155] (2.2) The role of dilated convolution
[0156] Extended Convolution significantly expands the receptive field of the convolution layer by inserting holes in the convolution kernel, so that it can capture dependencies with longer time spans. This is very useful when processing long time series data because it can increase the coverage of the receptive field without increasing the number of network layers. The calculation formula is as follows:
[0157]
[0158] In the formula, x t―d·i is the value of the input sequence at the (t-d·i)th time step; d is the expansion factor, which determines the interval between convolution kernels. When d=1, the dilated convolution degenerates into a normal causal convolution; when d>1, the receptive field of the convolution kernel will increase rapidly.
[0159] By setting different expansion factors d, the model can flexibly control the size of the convolution receptive field to capture short-term and long-term dependencies in the time series. For example, for expansion factor d = 2 and convolution kernel size k = 3, the convolution kernel will cover the time step [t, t-2, t-4], which can effectively increase the model's perception of long-distance dependencies in time.
[0160] (2.3) Multi-layer convolution and residual connection
[0161] TCN consists of multiple layers of dilated convolutional layers, and the output of each layer is used as the input of the next layer to increase the receptive field layer by layer, thereby capturing the complex dependencies in the time series.
[0162] Multi-layer convolution structure: Assume that TCN contains L layers of convolution, the convolution kernel size of each layer is k, and the expansion factor increases layer by layer to d l =2 l―1 , then the output H of the l-th convolution layer (l) for:
[0163]
[0164] Where σ(·) is the activation function; is the weight of the convolution kernel of the lth layer; is the input sequence at (t―d l i) time step values.
[0165] With this design, the receptive field grows exponentially with the number of layers.
[0166] Residual connection: In order to prevent the gradient vanishing problem and maintain the transmission of information, TCN introduces residual connection. Assuming the input is x and the output after convolution is f(x), the output y after residual connection is:
[0167] y=f(x)+x (17)
[0168] The introduction of residual connections not only accelerates the convergence of the model, but also ensures the stability of the model as the depth increases.
[0169] In view of this, the advantages of the dissolved oxygen prediction model combining GCN, GAT and TCN are:
[0170] By combining GCN, GAT, and TCN, the model achieves efficient joint modeling of spatiotemporal dependencies, giving full play to the complementarity and synergy of each module. GCN and GAT characterize the complex relationship between nodes from the spatial dimension. The attention mechanism of GAT gives the model the ability to dynamically model the importance of neighboring nodes, enhancing the flexibility and expressiveness of feature aggregation. TCN captures long-term dependencies in the time dimension through extended convolution, while avoiding the gradient vanishing problem in traditional neural network structures. Through this architectural design, the model performs excellently in the comprehensive representation of spatiotemporal data. The synergy of various modules effectively improves the prediction accuracy and robustness of complex graph time series data.
[0171] It is worth noting that the following experiment verifies the effectiveness of the above-mentioned dissolved oxygen prediction model.
[0172] During the experiment, a total of 1095 days × 53 monitoring nodes of water index data and 53 monitoring nodes of location data were used. After constructing the sequence sample through the above process, a total of 1070 days (T = 25) were used, of which 856 days (80%) were divided into training sets and 214 days (20%) were divided into test sets. Taking the prediction of the next day (53 monitoring points) as an example, the model fitting effect is as follows Figure 4 As shown in Figure 5 As shown, it can be seen that the model fitting effect and modeling accuracy are very good.
[0173] S140, using the trained dissolved oxygen prediction model to predict dissolved oxygen in the target area.
[0174] In some embodiments, the three-dimensional position vectors of multiple monitoring nodes in the target area and the preprocessed data of water indicators other than dissolved oxygen monitored by the multiple monitoring nodes currently acquired in the previous T time steps can be input into the trained dissolved oxygen prediction model, and the trained dissolved oxygen prediction model processes the input data to predict the dissolved oxygen in the next time step.
[0175] In summary, according to the embodiments of the present invention, at least the following technical effects are achieved:
[0176] (1) Accurate spatiotemporal feature modeling: GCN and GAT are used to capture the spatial topological relationship and key node characteristics of monitoring points, and TCN is used to capture the short-term dynamics and long-term dependencies of time series to achieve spatiotemporal joint modeling, thereby improving the prediction accuracy of complex scenarios.
[0177] (2) Powerful missing data processing capabilities: Multi-stage data preprocessing uses linear interpolation to quickly fill in missing data, and then uses the Prophet model to correct time trends to ensure data integrity and time series consistency, providing high-quality data support for model input.
[0178] (3) Efficient expression of geographic spatial features: Longitude and latitude sine and cosine coding technology converts geographic location characteristics into periodic, low-dimensional feature representations, enhancing the ability to capture geographic dependent information while reducing model complexity.
[0179] (4) Robustness of multi-dimensional data modeling: The multi-head attention mechanism strengthens the relationship between nodes from different perspectives, and the residual connection technology alleviates the gradient problem of deep networks, improving the robustness of the model and the training stability.
[0180] (5) Efficient computing and expansion capabilities: The extended convolution design is used to expand the receptive field and reduce the computational cost of time-dependent modeling. At the same time, the modular design facilitates model expansion and adaptation to multi-scenario applications.
[0181] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described order of actions, because according to the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present invention.
[0182] The above is an introduction to a method embodiment. The following is a further explanation of the solution of the present invention through an apparatus embodiment.
[0183] Figure 6 A structural diagram of a dissolved oxygen prediction device based on multi-dimensional graph spatiotemporal convolution and attention enhancement mechanism provided by an embodiment of the present invention, such as Figure 6 As shown, the dissolved oxygen prediction device 600 may include:
[0184] The acquisition module 610 is used to acquire the location data of multiple monitoring nodes in the target area and the data of various water indicators including dissolved oxygen monitored by the multiple monitoring nodes in multiple time steps.
[0185] Construction module 620 is used to construct a data set using the location data of multiple monitoring nodes and the data of water indicators other than dissolved oxygen monitored by the multiple monitoring nodes in the previous T time steps as samples, and the data of dissolved oxygen monitored by the multiple monitoring nodes in the next time step as labels.
[0186] The training module 630 is used to use the data set to train the dissolved oxygen prediction model that combines the graph convolution network, the graph attention network and the time series convolution network; wherein, in the spatial dimension, the dissolved oxygen prediction model extracts the topological relationship between the monitoring nodes through the graph convolution network, and uses the attention mechanism of the graph attention network to enhance the attention to the features of important monitoring nodes, and then enhances the feature representation through the multi-head attention mechanism; in the time dimension, the dissolved oxygen prediction model uses the time series convolution network to capture the short-term dynamic and long-term evolution characteristics through causal convolution and dilated convolution, and introduces residual connection to avoid gradient disappearance.
[0187] The prediction module 640 is used to predict the dissolved oxygen in the target area using the trained dissolved oxygen prediction model.
[0188] Understandably, Figure 6 Each module / unit in the dissolved oxygen prediction device 600 has the function of realizing Figure 1 The functions of the various steps in the dissolved oxygen prediction method 100 shown and the ability to achieve their corresponding technical effects are not described in detail here for the sake of brevity.
[0189] Figure 7 700 is a block diagram of an exemplary electronic device capable of implementing an embodiment of the present invention. Electronic device 700 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. Electronic device 700 may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown in the present invention, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required in the present invention.
[0190] like Figure 7 As shown, the electronic device 700 may include a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 may also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0191] Multiple components in the electronic device 700 are connected to the I / O interface 705, including: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a disk, an optical disk, etc.; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 709 allows the electronic device 700 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0192] The computing unit 701 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 701 performs the various methods and processes described above, such as method 100. For example, in some embodiments, the method 100 may be implemented as a computer program product, including a computer program, which is tangibly contained in a computer-readable medium, such as a storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 700 via ROM 702 and / or a communication unit 709. When the computer program is loaded into RAM 703 and executed by the computing unit 701, one or more steps of the method 100 described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to perform the method 100 in any other appropriate manner (e.g., by means of firmware).
[0193] The various embodiments described above in the present invention can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include: being implemented in one or more computer programs, which may be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general programmable processor, which may receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0194] The program code for implementing the method of the present invention can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code can be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.
[0195] In the context of the present invention, a computer-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. A computer-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. A more specific example of a computer-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0196] It should be noted that the present invention also provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute method 100 and achieve the corresponding technical effect achieved by executing the method in an embodiment of the present invention. For the sake of concise description, they will not be repeated here.
[0197] In addition, the present invention also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the method 100 is implemented.
[0198] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution disclosed in the present invention can be achieved, and the present invention is not limited here.
[0199] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A dissolved oxygen prediction method based on multi-dimensional graph spatiotemporal convolution and attention enhancement mechanism, characterized in that: The method comprises: Obtain the location data of multiple monitoring nodes in the target area and the data of various water indicators including dissolved oxygen monitored by multiple monitoring nodes in multiple time steps; The location data of multiple monitoring nodes and the data of water indicators other than dissolved oxygen monitored by multiple monitoring nodes in the first T time steps are used as samples, and the data of dissolved oxygen monitored by multiple monitoring nodes in the next time step are used as labels to construct a data set; The dataset is used to train a dissolved oxygen prediction model that combines graph convolutional networks, graph attention networks, and temporal convolutional networks. In the spatial dimension, the dissolved oxygen prediction model uses a graph convolutional network to extract the topological relationship between monitoring nodes, and uses the attention mechanism of the graph attention network to enhance the focus on the features of important monitoring nodes, and then enhances the feature representation through a multi-head attention mechanism. In the temporal dimension, the dissolved oxygen prediction model uses a temporal convolutional network to capture short-term dynamic and long-term evolution characteristics through causal convolution and dilated convolution, and introduces residual connections to avoid gradient disappearance. Use the trained dissolved oxygen prediction model to predict dissolved oxygen in the target area.
2. The method according to claim 1, characterized in that The data set is constructed by taking the location data of multiple monitoring nodes and the data of water body indicators other than dissolved oxygen monitored by the multiple monitoring nodes in the first T time steps as samples, and taking the data of dissolved oxygen monitored by the multiple monitoring nodes in the next time step as labels, including: Performing sine-cosine encoding on the position data of multiple monitoring nodes to obtain three-dimensional position vectors of the multiple monitoring nodes; Preprocessing the data of various water body indicators including dissolved oxygen monitored by multiple monitoring nodes in multiple time steps to obtain preprocessed data of various water body indicators including dissolved oxygen monitored by multiple monitoring nodes in multiple time steps; wherein the preprocessing includes missing value filling and missing value correction; The three-dimensional position vectors of multiple monitoring nodes and the preprocessed data of water indicators except dissolved oxygen monitored by multiple monitoring nodes in the first T time steps are used as samples, and the preprocessed data of dissolved oxygen monitored by multiple monitoring nodes in the next time step are used as labels to construct a data set.
3. The method according to claim 2, characterized in that The step of performing sine-cosine encoding on the position data of the multiple monitoring nodes to obtain the three-dimensional position vectors of the multiple monitoring nodes includes: For any monitoring node, the longitude and latitude in its location data are respectively sine-cosine encoded to obtain the three-dimensional position vector of the longitude and latitude of the monitoring node; The three-dimensional position vectors of the longitude and latitude of the monitoring node are averaged and merged to obtain the three-dimensional position vector of the monitoring node.
4. The method according to claim 2, characterized in that: The preprocessing of the data of various water body indicators including dissolved oxygen monitored by the multiple monitoring nodes in multiple time steps to obtain the preprocessed data of various water body indicators including dissolved oxygen monitored by the multiple monitoring nodes in multiple time steps includes: The linear interpolation method is used to fill the missing values of the data of various water body indicators including dissolved oxygen monitored by multiple monitoring nodes in multiple time steps, and the time series correction method is used to correct the filled missing values to obtain the preprocessed data of various water body indicators including dissolved oxygen monitored by multiple monitoring nodes in multiple time steps.
5. The method according to claim 2, characterized in that: The three-dimensional position vectors of multiple monitoring nodes and pre-processed data of water indicators other than dissolved oxygen monitored by multiple monitoring nodes in the first T time steps are used as samples, and the pre-processed data of dissolved oxygen monitored by multiple monitoring nodes in the next time step are used as labels to construct a data set, including: A data set is constructed by using the sliding window method, with the three-dimensional position vectors of multiple monitoring nodes and the preprocessed data of water indicators other than dissolved oxygen monitored by multiple monitoring nodes in the first T time steps as samples, and the preprocessed data of dissolved oxygen monitored by multiple monitoring nodes in the next time step as labels.
6. The method according to claim 2, characterized in that The dataset is used to train a dissolved oxygen prediction model that combines a graph convolutional network, a graph attention network, and a temporal convolutional network, including: Divide the data set into training set and test set according to the preset ratio; The dissolved oxygen prediction model is trained using the training set, and after the training is completed, the dissolved oxygen prediction model is tested using the test set, and the dissolved oxygen prediction model that passes the test is used as the trained dissolved oxygen prediction model.
7. The method according to claim 2, characterized in that The method of using the trained dissolved oxygen prediction model to predict dissolved oxygen in the target area includes: The three-dimensional position vectors of multiple monitoring nodes in the target area and the preprocessed data of water indicators other than dissolved oxygen monitored by multiple monitoring nodes in the previous T time steps are input into the trained dissolved oxygen prediction model. The trained dissolved oxygen prediction model processes the input data to predict the dissolved oxygen in the next time step.
8. A dissolved oxygen prediction device based on multi-dimensional graph spatiotemporal convolution and attention enhancement mechanism, characterized in that: The device comprises: An acquisition module is used to acquire the location data of multiple monitoring nodes in the target area and the data of various water indicators including dissolved oxygen monitored by multiple monitoring nodes in multiple time steps; A construction module is used to construct a data set using the location data of multiple monitoring nodes and the data of water body indicators other than dissolved oxygen monitored by the multiple monitoring nodes in the previous T time steps as samples, and the data of dissolved oxygen monitored by the multiple monitoring nodes in the next time step as labels; The training module is used to use the data set to train the dissolved oxygen prediction model that combines the graph convolution network, the graph attention network and the temporal convolution network. In the spatial dimension, the dissolved oxygen prediction model uses the graph convolution network to extract the topological relationship between the monitoring nodes, and uses the attention mechanism of the graph attention network to enhance the attention to the features of important monitoring nodes, and then enhances the feature representation through the multi-head attention mechanism. In the temporal dimension, the dissolved oxygen prediction model uses the temporal convolution network to capture the short-term dynamic and long-term evolution characteristics through causal convolution and dilated convolution, and introduces residual connections to avoid gradient disappearance. The prediction module is used to predict dissolved oxygen in the target area using the trained dissolved oxygen prediction model.
9. An electronic device, characterized in that: The electronic device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable 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 the method described in any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to enable a computer to execute the method according to any one of claims 1 to 7.