A multi-dimensional Yangtze River water quality prediction method and device based on deep learning

By adopting a neural network model with an encoder-decoder architecture in water quality prediction, combining convolutional layers and long and short-term memory networks to capture time and space characteristics, the existing methods are solved. The prediction performance of poor prediction performance when large data volume and complex water quality is solved. The problem has achieved more accurate water quality prediction.

CN118332341BActive Publication Date: 2024-11-22CHONGQING UNIV OF POSTS & TELECOMM
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410511152.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-26
Publication Date
2024-11-22
Estimated Expiration
2044-04-26

AI Technical Summary

Technical Problem

The existing water quality prediction methods are difficult to accurately capture the spatial characteristics and global information of the sample when the data volume is large and the water quality is complex, resulting in poor prediction performance.

Method used

The neural network model adopts the encoder-decoder architecture, combining convolutional layer, long and short-term memory network and spatiotemporal attention processing module, captures the characteristic information of the time and space dimensions, and performs data processing through jump connections and sub-pixel convolution layers. Optimize network parameters using the Adam algorithm.

Benefits of technology

In the case of complex water quality conditions and large data volume, more accurate water quality prediction is achieved, improving the accuracy and stability of the prediction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118332341B_ABST
    Figure CN118332341B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of artificial intelligence, and in particular to a multi-dimensional Yangtze River water quality prediction method based on deep learning, comprising collecting water quality feature data input to construct a water environment quality prediction model for water quality prediction, wherein the water environment quality prediction model is constructed by using an encoder-decoder neural network, that is, the water environment quality prediction model is composed of a cascaded encoder, a bottleneck layer, and a decoder, and each layer of the encoder output is processed by a convolution layer and then jump-connected with each layer of the decoder input of the corresponding dimension; the encoder is composed of a cascaded first to fifth encoding modules, and the first encoding module and the second encoding module are composed of a cascaded two-dimensional convolution layer, a batch normalization operation layer, and an ELU activation function layer. The third encoding module to the fifth encoding module are composed of a cascaded two-dimensional convolution layer, a batch normalization operation layer, an ELU activation function layer, and a spatiotemporal attention processing module; the bottleneck layer includes a Flatten layer, a long short-term memory network layer, a linear layer, and a reshape layer; the decoder is composed of a cascaded first to fifth decoding modules, the first to fourth decoding modules are composed of a cascaded spatiotemporal attention processing module, a sub-pixel convolution layer, a batch normalization operation layer, and an ELU activation function layer, and the fifth decoding module is composed of a cascaded spatiotemporal attention processing module and a sub-pixel convolution layer; the present invention can accurately predict water quality when the water quality situation is complex and the amount of data is large.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence, and in particular to a multi-dimensional Yangtze River water quality prediction method and device based on deep learning. Background Art

[0002] Water quality prediction is one of the important issues related to water affairs. Through water quality prediction, we can find the signs of water quality deterioration, so that decision makers can take measures in advance. Therefore, it is very important to accurately predict the trend of pollutant concentration in water bodies over time.

[0003] The current water quality prediction methods can be roughly divided into two categories. One is the prediction method based on statistical learning. However, due to the high complexity of the water environment system, the uncertainty of indicators, nonlinearity and other characteristics, this type of method cannot accurately and timely predict water quality. The second type is the water quality detection method based on artificial intelligence. Many neural network models have been used in water quality prediction, but traditional neural network models, such as CNN, LSTM, CNN-LSTM, etc., although they can extract data features and more accurately predict water quality changes, often only consider the temporal characteristics of the sample, and it is difficult to capture the spatial characteristics of the sample, let alone the global information and the internal connection of the long distance within the feature. When the amount of data increases and the water quality situation is complicated, the performance of this type of method is often poor. Summary of the invention

[0004] In order to improve the accuracy of water quality prediction when the amount of data is large and the water quality situation is complex, the present invention proposes a multi-dimensional Yangtze River water quality prediction method based on deep learning, including collecting water quality feature data input to construct a water environment quality prediction model for water quality prediction, the water environment quality prediction model is constructed using an encoder-decoder neural network, that is, the water environment quality prediction model consists of a cascaded encoder, a bottleneck layer and a decoder, and each layer of the encoder output is processed by a convolution layer and then jump-connected with each layer of the decoder input of the corresponding dimension; the encoder consists of a cascade of first to fifth encoding modules, and the first encoding module and the second encoding module are composed of a cascade of The decoder is composed of the first to the fifth decoding modules in cascade, and the first to the fourth decoding modules are composed of the cascaded spatiotemporal attention processing modules, sub-pixel convolution layers, batch normalization operation layers, and ELU activation function layers. The third encoding module to the fifth encoding module are composed of cascaded two-dimensional convolution layers, batch normalization operation layers, ELU activation function layers, and spatiotemporal attention processing modules. The bottleneck layer includes a Flatten layer, a long short-term memory network layer, a linear layer, and a reshape layer. The decoder is composed of the first to the fifth decoding modules in cascade, and the first to the fourth decoding modules are composed of the cascaded spatiotemporal attention processing modules, sub-pixel convolution layers, batch normalization operation layers, and ELU activation function layers. The fifth decoding module is composed of a cascaded spatiotemporal attention processing module and a sub-pixel convolution layer.

[0005] Furthermore, water quality characteristic data are acquired by setting sensors at different locations in the watershed to be tested. The water quality characteristic data include conventional water quality indicators, metal content, inorganic content, organic content, harmful substance content, microbial content, radiation, water level, liquid level, flow rate, and flow velocity.

[0006] Furthermore, before the water quality characteristic data is input into the constructed water environment quality prediction model, the missing value filling operation is performed on the data. If the data at time t is missing, it is filled based on the data at time t-1 and time t+1. The filling process includes:

[0007]

[0008] Among them, x t Represents the data at time t.

[0009] Furthermore, the water quality characteristic data are normalized to the maximum-minimum value before being input into the constructed water environment quality prediction model.

[0010] Furthermore, the data processing flow of the spatiotemporal attention processing module includes:

[0011] If the input data is B×Ci×T×S dimensional data, the input data is adjusted to B×S×T×Ci dimensional data through the reshape layer;

[0012] The B×S×T×C dimensional data is processed through a cascade of two-dimensional point-by-point convolutional layers, batch normalization operation layers, and Prelu activation function layers, and then the query value of the time attention with the current dimension of B×S×T×C and the key value of the time attention with the dimension of B×S×C×T are obtained through the reshape layer respectively;

[0013] The query value of the temporal attention is multiplied by the key value of the temporal attention and then a mask operation is performed. After the mask operation, the temporal attention score matrix is ​​calculated by the Softmax function.

[0014] The B×C×T×S dimensional input data is processed once through a cascade of two-dimensional point-by-point convolutional layers, batch normalization operation layers, and Prelu activation function layers, and then passed through a reshape layer to obtain the key value of the spatial attention of the current moment with dimensions of B×T×S×C, the key value of the spatial attention of B×T×C×S, and the value of the spatial attention of B×T×S×C;

[0015] The spatial attention score matrix is ​​obtained by multiplying the query value of the spatial attention with the key value of the spatial attention through the Softmax function.

[0016] The spatial attention score matrix is ​​multiplied by the spatial attention value of B×T×S×C and then passed through the reshape layer to obtain the spatial attention output of B×S×T×C dimensions;

[0017] The spatial attention output of dimension B×S×T×C is multiplied by the temporal attention score matrix and then passed through the reshape layer to obtain the temporal attention output of dimension B×C×T×S;

[0018] The B×C×T×S-dimensional temporal attention output is processed by the cascaded two-dimensional point-by-point convolution layer, batch normalization operation layer, and Prelu activation function layer to obtain B×Ci×T×S data, which is added to the B×Ci×T×S-dimensional input data as the output of the spatiotemporal attention processing module;

[0019] Among them, B represents the batch size, Ci represents the number of channels of input data, T represents the number of time dimensions, S represents the number of spatial dimensions, and C represents the number of attention channels.

[0020] Furthermore, the processing of input data by the long short-term memory network layer includes:

[0021]

[0022]

[0023]

[0024]

[0025]

[0026] h t =o t *tanh(C t )

[0027] Among them, f t represents the output of the forget gate at time t, σ() represents the sigmoid function, W f represents the weight matrix of the forget gate, b f represents the bias vector of the forget gate, [,] represents the concatenation operation, represents the input of the long short-term memory network layer at the current time t; i t represents the output of the input gate at time t, W i represents the weight matrix of the input gate, b i Represents the bias vector of the input gate; o t represents the output of the output gate at time t, W o represents the weight matrix of the output gate, b o Represents the bias vector of the output gate; C trepresents the output of the cell state at time t, represents the updated value of the cell state at time t, W C The weight matrix representing the cell state, b C represents the cell state bias vector; tanh represents the hyperbolic tangent function.

[0028] Furthermore, the water environment quality prediction model uses the Adam algorithm to update network parameters during the training phase, which specifically includes the following steps:

[0029]

[0030] a t =β1a t-1 +(1-β1)g t

[0031]

[0032]

[0033]

[0034]

[0035] Among them, g t represents the time step gradient at time t, Indicates the gradient; J(θ t-1 ) indicates that the network parameters are θ t-1 The loss function when t is the exponential moving average, β1 is the first-order decay rate of the moment estimate; r t is the corrected gradient mean at time t, v t-1 represents the second-order moment at time step t-1, β2 is the second-order decay rate of the moment estimate; represents the corrected squared gradient; represents the bias-corrected second-order moment gradient estimate; ε = 10 -8 is a constant; α is the learning rate.

[0036] Furthermore, the loss function used by the water environment quality prediction model in the training stage is expressed as:

[0037] loss = RMSE + MAE

[0038]

[0039]

[0040] Among them, loss is the loss function of the water environment quality prediction model; RMSE is the root mean square error of the water environment quality prediction model; MAE is the mean absolute error of the water environment quality prediction model; y i is the true label of the i-th sample in the training data, is the predicted label of the i-th sample in the training data, and n is the number of samples in the training data.

[0041] The present invention also proposes a multi-dimensional Yangtze River water quality prediction device based on deep learning, which is used to implement a multi-dimensional Yangtze River water quality prediction method based on deep learning, including a data acquisition system and a water environment quality prediction model, the data acquisition system is used to collect water quality characteristic data; the water environment quality prediction model is used to predict the current water quality of the basin based on the water quality characteristic data, and the water environment quality prediction model is constructed using a neural network with an encoder-decoder architecture, that is, the water environment quality prediction model consists of a cascaded encoder, a bottleneck layer and a decoder, and each layer of the encoder output is processed by a convolution layer and then jump-connected with each layer of the decoder input of the corresponding dimension; the encoder is composed of a cascade of first to fifth encoding modules, the first to fifth encoding modules are connected to the decoder, and the decoder is connected to the decoder by a bottleneck layer. The first encoding module and the second encoding module are composed of cascaded two-dimensional convolutional layers, batch normalization operation layers, and ELU activation function layers. The third encoding module to the fifth encoding module are composed of cascaded two-dimensional convolutional layers, batch normalization operation layers, ELU activation function layers, and spatiotemporal attention processing modules; the bottleneck layer includes a Flatten layer, a long short-term memory network layer, a linear layer, and a reshape layer; the decoder is composed of the first to fifth decoding modules in cascade, the first to fourth decoding modules are composed of cascaded spatiotemporal attention processing modules, sub-pixel convolutional layers, batch normalization operation layers, and ELU activation function layers, and the fifth decoding module is composed of a cascaded spatiotemporal attention processing module and a sub-pixel convolutional layer.

[0042] The method proposed in the present invention adopts an encoder-decoder structure and adds a self-attention module to the encoder and decoder parts, which can simultaneously capture the global information of features and the long-distance intrinsic connections within features from the time and space dimensions for better modeling. It can accurately predict water quality when the water quality situation is complex and the amount of data is large. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1 It is a schematic diagram of the structure of the water environment quality prediction model in the present invention;

[0044] Figure 2 It is a schematic diagram of the structure of the spatiotemporal attention processing module in the water environment quality prediction model of the present invention;

[0045] Figure 3 This is a comparison between the predicted results of ammonia nitrogen in the water environment quality prediction model of the present invention and the actual value. DETAILED DESCRIPTION

[0046] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only 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.

[0047] The present invention proposes a multi-dimensional Yangtze River water quality prediction method based on deep learning, including collecting water quality feature data input to construct a water environment quality prediction model for water quality prediction, the water environment quality prediction model is constructed by using an encoder-decoder neural network, that is, the water environment quality prediction model is composed of a cascaded encoder, a bottleneck layer and a decoder, and each layer of the encoder output is processed by a convolution layer and then jump-connected with each layer of the decoder input of the corresponding dimension; the encoder is composed of a cascade of first to fifth encoding modules, and the first encoding module and the second encoding module are composed of a cascade of two-dimensional convolutional layers, batch normalization operations The third encoding module to the fifth encoding module are composed of a cascaded two-dimensional convolution layer, a batch normalization operation layer, an ELU activation function layer, and a spatiotemporal attention processing module; the bottleneck layer includes a Flatten layer, a long short-term memory network layer, a linear layer and a reshape layer; the decoder is composed of the cascaded first to fifth decoding modules, the first to fourth decoding modules are composed of a cascaded spatiotemporal attention processing module, a sub-pixel convolution layer, a batch normalization operation layer, and an ELU activation function layer, and the fifth decoding module is composed of a cascaded spatiotemporal attention processing module and a sub-pixel convolution layer.

[0048] In this embodiment, the input data includes conventional water quality indicators, metal content, inorganic content, organic content, harmful substance content, microbial content, radiation, water level, liquid level, flow rate, and flow velocity at different locations. This embodiment collects water quality characteristic data by setting sensors at different locations in the watershed to be detected.

[0049] Technical personnel in this field generally perform preprocessing on the collected data. The general preprocessing includes data missing processing, data integration, data standardization, and data normalization.

[0050] As an optional implementation, if the original data contains missing values, considering that the number of missing values ​​is small, this embodiment chooses to use linear interpolation to fill the missing values ​​in the time series. The mathematical expression of linear interpolation is as follows:

[0051]

[0052] In the formula, x t is missing data, the sampling time is t, x t-1is the normal sampling data of the previous moment, x t+1 It is the normal sampling data at the next moment.

[0053] As an optional implementation, before the data set is input into the model, in order to speed up the convergence speed of the model and eliminate the influence of dimension, the training and test data sets need to be normalized. Normalization refers to the use of a specific algorithm to keep the data within a specific range. The method used in this study is the normalization of the linear function. The expression is as follows:

[0054]

[0055] Among them, x represents the original data, x′ represents the normalized data, and x max and x min Represents the maximum and minimum values ​​in the original data.

[0056] The water environment quality prediction model structure constructed in this embodiment is as follows: Figure 1 As shown in the figure, the model is an encoder-decoder structure, which can efficiently handle situations where the lengths of the input and output sequences are different, and can also reduce dimensionality: if the input is high-dimensional data (such as pictures), the encoder-decoder can compress it into a vector of fixed length, thereby achieving the purpose of dimensionality reduction. In addition, the structure is an end-to-end structure, and the model can directly perform end-to-end learning from the original input to the final output without manually designing features or rules.

[0057] The encoder is composed of a cascade of first to fifth encoding modules, the first encoding module and the second encoding module are composed of a cascade of two-dimensional convolutional layers, batch normalization operation layers, and ELU activation function layers, the third encoding module to the fifth encoding module are composed of a cascade of two-dimensional convolutional layers, batch normalization operation layers, ELU activation function layers, and spatiotemporal attention processing modules. In this embodiment, the cascaded two-dimensional convolutional layers, batch normalization operation layers, and ELU activation function layers are regarded as a convolution block.

[0058] The water quality prediction model inputs water quality characteristic data, and the input water quality characteristic data is recorded as s∈R c×t×s , this feature is processed by two convolution blocks, one convolution block contains a two-dimensional convolution, a batch normalization operation, and an ELU activation function. Through a convolution block, the feature s∈R c×t×s will become s∈R c×t×s / 2 ,The formula for convolution block processing is expressed as:

[0059] y=ELU(Batchnorm(Conv 2D(s)))

[0060] The ELU function formula is:

[0061]

[0062] Then the input data is processed by the third encoding module to the fifth encoding module. Each encoding module of the third encoding module to the fifth encoding module includes a convolution block and a time-space attention module. That is, the input data is first processed by the convolution block and then by the TSA module. The TSA module is as follows: Figure 2 As shown in the figure, the TSA module uses the self-attention mechanism to capture the global information and long-distance dependencies between features from the time and space dimensions, and further extracts and models features. The specific processing flow includes:

[0063] If the input data is B×Ci×T×S dimensional data, the input data is adjusted to B×S×T×Ci dimensional data through the reshape layer;

[0064] The B×S×T×C dimensional data is processed through a cascade of two-dimensional point-by-point convolutional layers, batch normalization operation layers, and Prelu activation function layers, and then the query value of the time attention with the current dimension of B×S×T×C and the key value of the time attention with the dimension of B×S×C×T are obtained through the reshape layer respectively;

[0065] The query value of the temporal attention is multiplied by the key value of the temporal attention and then a mask operation is performed. After the mask operation, the temporal attention score matrix is ​​calculated by the Softmax function, which is expressed as:

[0066]

[0067] Among them, M S (t) represents the spatial attention score matrix of the input feature s at time t; Q S (t) represents the query value of the spatial attention of the input feature s at time t, K S (t) represents the key value of the spatial attention of the input feature s at time t; Softmax(·) represents the Softmax function; A T It means to find the transpose of matrix A;

[0068] The B×C×T×S dimensional input data is processed once through a cascade of two-dimensional point-by-point convolutional layers, batch normalization operation layers, and Prelu activation function layers, and then passed through a reshape layer to obtain the key value of the spatial attention of the current moment with dimensions of B×T×S×C, the key value of the spatial attention of B×T×C×S, and the value of the spatial attention of B×T×S×C;

[0069] The spatial attention score matrix is ​​obtained by multiplying the query value of the spatial attention with the key value of the spatial attention through the Softmax function, which is expressed as:

[0070]

[0071] Among them, M t (s) represents the temporal attention score matrix of the input feature s at time t; Q t (s) represents the query value of the temporal attention of the input feature s at time t; K t (s) represents the key value of the temporal attention of the input feature s at time t; Mask (·) represents the mask operation. In this embodiment, the mask operation is used to adjust the length in the temporal attention so that the entire module does not see future information;

[0072] The spatial attention score matrix is ​​multiplied by the spatial attention value of B×T×S×C and then passed through the reshape layer to obtain the spatial attention output of B×S×T×C dimensions;

[0073] The spatial attention output of dimension B×S×T×C is multiplied by the temporal attention score matrix and then passed through the reshape layer to obtain the temporal attention output of dimension B×C×T×S;

[0074] The B×C×T×S-dimensional temporal attention output is processed by the cascaded two-dimensional point-by-point convolution layer, batch normalization operation layer, and Prelu activation function layer to obtain B×Ci×T×S data, which is added to the B×Ci×T×S-dimensional input data as the output of the spatiotemporal attention processing module;

[0075] Among them, B represents the batch size, Ci represents the number of channels of input data, T represents the number of time dimensions, S represents the number of spatial dimensions, and C represents the number of attention channels.

[0076] After passing through the encoder, the feature enters the bottleneck layer, first in the Flatten layer to convert the feature dimension s∈R c×t×s Transformed into s∈R t×(c×s) , and then reaches the long short-term memory network layer, which includes the forget gate, input gate, output gate, second hidden state and cell state in sequence; the forget gate determines to forget certain feature information in the time series and target sequence, and the input gate determines to store certain feature information in the cell state. The formulas for the forget gate, input gate, output gate and cell state are as follows:

[0077]

[0078]

[0079]

[0080]

[0081]

[0082] h t =o t *tanh(C t )

[0083] Among them, f t represents the output of the forget gate at time t, σ() represents the sigmoid function, W f represents the weight matrix of the forget gate, b f represents the bias vector of the forget gate, [,] represents the concatenation operation, represents the input of the long short-term memory network layer at the current time t; i t represents the output of the input gate at time t, W i represents the weight matrix of the input gate, b i Represents the bias vector of the input gate; o t represents the output of the output gate at time t, W o represents the weight matrix of the output gate, b o Represents the bias vector of the output gate; C t represents the output of the cell state at time t, represents the updated value of the cell state at time t, W C The weight matrix representing the cell state, b C represents the cell state bias vector; tanh represents the hyperbolic tangent function.

[0084] The convolutional block of the encoder is used to extract the local dependency features of the target sequence and time series; the spatiotemporal attention mechanism module captures the global information and long-distance dependencies between features from the temporal and spatial dimensions; the long short-term memory network layer is used to extract the long-term dependency features of the target sequence and time series.

[0085] After the long short-term memory layer, the feature is linearly projected through the linear layer and transformed back to s∈R through the reshape layer. c×t×s .

[0086] The decoder consists of the first to fifth decoding modules in cascade. The first to fourth decoding modules are composed of cascaded spatiotemporal attention processing modules, sub-pixel convolution layers, batch normalization operation layers, and ELU activation function layers. The fifth decoding module is composed of a cascaded spatiotemporal attention processing module and a sub-pixel convolution layer.

[0087] After the encoder partially reduces the input on the spatial axis, it needs to be enlarged back to the original resolution in the decoder. This embodiment replaces the conventional enlargement method based on transposed convolution with sub-pixel convolution, which learns a series of filters to enlarge the low-resolution feature map to a high-resolution output. Each enlargement is performed with a factor of twice on the spatial axis. Formally, the feature vector s∈R ci×t×s, is transformed to s∈R by a regular convolution with 2c filters 2c×t×s , then transposed and reshaped into the actual output s∈R c×t×2s

[0088] In addition, this embodiment replaces the classic skip connection based on concatenation or summation with a convolutional layer with a kernel size of 1×1 and a stride of 1. The encoder features are projected point by point and then summed with the corresponding decoder output. In addition to decoupling the encoder and decoder feature spaces, point-by-point convolution allows the number of channels in the encoder to be selected independently of the number of channels in the decoder, and obtains better results in the performance-speed trade-off.

[0089] After completing the construction of the water environment quality prediction model, water quality characteristic data containing real labels are collected to train the water environment quality prediction model. In the training process of this embodiment, the root mean square error (RMSE) and the mean absolute error (MAE) are used as the loss function of the model. The formulas of the two are as follows:

[0090]

[0091]

[0092] The final loss function is:

[0093] loss = RMSE + MAE

[0094] Among them, loss is the loss function of the water environment quality prediction model; RMSE is the root mean square error of the water environment quality prediction model; MAE is the mean absolute error of the water environment quality prediction model; y i is the true label of the i-th sample in the training data, is the predicted label of the i-th sample in the training data, and n is the number of samples in the training data.

[0095] The initial learning rate is set to 0.001, and the model learning rate calculation formula is:

[0096] Learn (epoch) =lrate (epoch-1) ×0.96 epoch

[0097] In the formula, learn is the current learning rate, lrate is the learning rate of the previous round, and epoch is the number of iterations.

[0098] The water environment quality prediction model uses the optimizer Adam to optimize parameters. The Adam algorithm is an adaptive matrix estimation algorithm. The Adam algorithm can dynamically update network parameters such as model weights and learning rates when training the model, so the algorithm converges faster than the traditional gradient descent method. The calculation process of the Adam algorithm is as follows:

[0099]

[0100] a t =β1a t-1 +(1-β1)g t

[0101]

[0102]

[0103]

[0104]

[0105] Among them, g t represents the time step gradient at time t, Indicates the gradient; J(θ t-1 ) indicates that the network parameters are θ t-1 The loss function when t is the exponential moving average, β1 is the first-order decay rate of the moment estimate; r t is the corrected gradient mean at time t, v t-1 represents the second-order moment vector at time step t-1, β2 is the second-order decay rate of the moment estimate; represents the corrected squared gradient; represents the bias-corrected second-order moment (without central variance) gradient estimate; ε = 10 -8 is a constant; α is the learning rate.

[0106] Table 1 Evaluation indicators of the proposed method

[0107]

[0108] Table 2 CNN evaluation indicators

[0109]

[0110] Table 3 CNN-LSTM evaluation indicators

[0111]

[0112] In this embodiment, the water quality data collected by the sensor is used as the input of the model to predict the dissolved oxygen (DO), pH value (pH), ammonia nitrogen (NH3-N) and total phosphorus (P) content in the water area. Figure 3 A schematic diagram comparing the predicted values ​​and true values ​​of the present invention and the prior art is given. Tables 1 to 3 are the root mean square error (RMSE) and mean square error (MSE) between the predicted values ​​and true values ​​of the present invention and the prior art CNN and CNN-LSTM prediction schemes, respectively. Mean Absolute Percentage Error (MAPE), these three errors are used to measure the difference between the predicted value and the true value. The smaller the error value, the more accurate the model prediction. It can be seen that compared with the CNN and CNN-LSTM methods, the error between the predicted value and the true value of the present invention is very small, and the future water quality changes can be predicted more accurately.

[0113] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A multi-dimensional Yangtze River water quality prediction method based on deep learning, characterized in that: The water quality prediction model constructed by collecting water quality characteristic data as input is used to predict water quality. The water environment quality prediction model is constructed using a neural network with an encoder-decoder architecture, that is, the water environment quality prediction model consists of a cascaded encoder, a bottleneck layer, and a decoder, and each layer of the encoder output is processed by a convolution layer and then jump-connected with each layer of the input of the corresponding dimension of the decoder; the encoder consists of a cascade of the first to fifth encoding modules, the first encoding module and the second encoding module consist of a cascade of two-dimensional convolutional layers, a batch normalization operation layer, and an ELU activation function layer, and the third encoding module to the fifth encoding module consist of a cascade of two-dimensional convolutional layers, a batch normalization operation layer, an ELU activation function layer, and a spatiotemporal layer. The decoder is composed of the first to fifth decoding modules in cascade, the first to fourth decoding modules are composed of cascaded spatiotemporal attention processing modules, sub-pixel convolution layers, batch normalization operation layers, and ELU activation function layers, and the fifth decoding module is composed of cascaded spatiotemporal attention processing modules and sub-pixel convolution layers; water quality characteristic data are obtained by setting sensors at different locations in the watershed to be tested, and the water quality characteristic data include metal content, inorganic content, organic content, harmful substance content, microbial content, radiation, water level, liquid level, flow rate, and flow rate.

2. The multi-dimensional Yangtze River water quality prediction method based on deep learning according to claim 1 is characterized in that: Before the water quality characteristic data is input into the constructed water environment quality prediction model, the missing value filling operation is performed on the data. If the data at time t is missing, it is filled based on the data at time t-1 and time t+1. The filling process includes: Among them, x t Represents the data at time t.

3. A multi-dimensional Yangtze River water quality prediction method based on deep learning according to claim 1 or 2, characterized in that: The water quality characteristic data were normalized to the maximum and minimum values ​​before being input into the constructed water environment quality prediction model.

4. The multi-dimensional Yangtze River water quality prediction method based on deep learning according to claim 1 is characterized in that: The data processing flow of the spatiotemporal attention processing module includes: If the input data is B×Ci×T×S dimensional data, the input data is adjusted to B×S×T×Ci dimensional data through the reshape layer; The B×S×T×C dimensional data is processed through a cascade of two-dimensional point-by-point convolutional layers, batch normalization operation layers, and Prelu activation function layers, and then the query value of the time attention with the current dimension of B×S×T×C and the key value of the time attention with the dimension of B×S×C×T are obtained through the reshape layer respectively; The query value of the temporal attention is multiplied by the key value of the temporal attention and then a mask operation is performed. After the mask operation, the temporal attention score matrix is ​​calculated by the Softmax function. The B×C×T×S dimensional input data is processed once through the cascaded two-dimensional point-by-point convolution layer, batch normalization operation layer, and Prelu activation function layer, and then passed through the reshape layer to obtain the key value of the spatial attention of the current moment with the dimensions of B×T×S×C, the key value of the spatial attention of B×T×C×S, and the value of the spatial attention of B×T×S×C; The spatial attention score matrix is ​​obtained by multiplying the query value of the spatial attention with the key value of the spatial attention through the Softmax function. The spatial attention score matrix is ​​multiplied by the spatial attention value of B×T×S×C and then passed through the reshape layer to obtain the spatial attention output of B×S×T×C dimensions; The spatial attention output of dimension B×S×T×C is multiplied by the temporal attention score matrix and then passed through the reshape layer to obtain the temporal attention output of dimension B×C×T×S; The B×C×T×S-dimensional temporal attention output is processed by the cascaded two-dimensional point-by-point convolution layer, batch normalization operation layer, and Prelu activation function layer to obtain B×Ci×T×S data, which is added to the B×Ci×T×S-dimensional input data as the output of the spatiotemporal attention processing module; Among them, B represents the batch size, Ci represents the number of channels of input data, T represents the number of time dimensions, S represents the number of spatial dimensions, and C represents the number of attention channels.

5. The multi-dimensional Yangtze River water quality prediction method based on deep learning according to claim 1 is characterized in that: The processing of input data by the long short-term memory network layer includes: h t =o t *tanh(C t ) Among them, f t represents the output of the forget gate at time t, σ( ) represents the sigmoid function, W f represents the weight matrix of the forget gate, b f represents the bias vector of the forget gate, [,] represents the concatenation operation, represents the input of the long short-term memory network layer at the current time t; i t represents the output of the input gate at time t, W i represents the weight matrix of the input gate, b i Represents the bias vector of the input gate; o t represents the output of the output gate at time t, W o represents the weight matrix of the output gate, b o Represents the bias vector of the output gate; C t represents the output of the cell state at time t, represents the updated value of the cell state at time t, W C The weight matrix representing the cell state, b C represents the cell state bias vector; tanh represents the hyperbolic tangent function.

6. The multi-dimensional Yangtze River water quality prediction method based on deep learning according to claim 1 is characterized in that: The water environment quality prediction model uses the Adam algorithm to update network parameters during the training phase, which specifically includes the following steps: a t =β1a t-1 +(1-β1)g t Among them, g t represents the time step gradient at time t, Indicates the gradient; J(θ t-1 ) indicates that the network parameters are θ t-1 The loss function when t is the exponential moving average, β1 is the first-order decay rate of the moment estimate; r t is the corrected gradient mean at time t, v t-1 represents the second-order moment at time step t-1, β2 is the second-order decay rate of the moment estimate; represents the corrected squared gradient; represents the bias-corrected second-order moment gradient estimate; ε = 10 -8 is a constant; α is the learning rate.

7. A multi-dimensional Yangtze River water quality prediction method based on deep learning according to claim 1 or 6, characterized in that: The loss function used by the water environment quality prediction model in the training stage is expressed as: loss=RMSE+MAE Among them, loss is the loss function of the water environment quality prediction model; RMSE is the root mean square error of the water environment quality prediction model; MAE is the mean absolute error of the water environment quality prediction model; y i is the true label of the i-th sample in the training data, is the predicted label of the i-th sample in the training data, and n is the number of samples in the training data.

8. A multi-dimensional Yangtze River water quality prediction device based on deep learning, characterized in that: The method is used to implement a multi-dimensional Yangtze River water quality prediction method based on deep learning as described in claim 1, including a data acquisition system and a water environment quality prediction model, wherein the data acquisition system is used to collect water quality characteristic data; the water environment quality prediction model is used to predict the current water quality of the basin based on the water quality characteristic data, and the water environment quality prediction model is constructed using a neural network with an encoder-decoder architecture, that is, the water environment quality prediction model is composed of a cascaded encoder, a bottleneck layer and a decoder, and each layer of the encoder output is processed by a convolution layer and then jump-connected with each layer of the decoder input of the corresponding dimension; the encoder is composed of a cascade of first to fifth encoding modules, and the first encoding module and the second encoding module are connected. The code module is composed of a cascaded two-dimensional convolution layer, a batch normalization operation layer, and an ELU activation function layer. The third encoding module to the fifth encoding module are composed of a cascaded two-dimensional convolution layer, a batch normalization operation layer, an ELU activation function layer, and a spatiotemporal attention processing module; the bottleneck layer includes a Flatten layer, a long short-term memory network layer, a linear layer, and a reshape layer; the decoder is composed of the cascaded first to fifth decoding modules, the first to fourth decoding modules are composed of a cascaded spatiotemporal attention processing module, a sub-pixel convolution layer, a batch normalization operation layer, and an ELU activation function layer, and the fifth decoding module is composed of a cascaded spatiotemporal attention processing module and a sub-pixel convolution layer.