Wastewater treatment plant effluent quality prediction method based on attention mechanism and long short-term memory network
Through deep learning methods based on attention mechanism and long-term memory network, nonlinear and hysteresis problems in the effluent quality prediction of sewage treatment plants are solved, and a higher precision effluent water quality prediction is achieved.
Patent Information
- Application Number
- CN202210765813.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-30
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2042-06-30
AI Technical Summary
The existing sewage treatment plant effluent water quality prediction method cannot consider the system's highly nonlinear, long-term lag and lag time uncertainty at the same time, resulting in insufficient prediction accuracy.
Deep learning methods based on attention mechanism and long and short-term memory network are adopted, and feature extraction and normalization of the actual operation and monitoring data of sewage treatment plants is used, and timing feature extraction is used using long and short-term memory networks. Combined with the attention mechanism module to obtain the time-influence weight distribution of input features, and a deep neural network is established to predict the effluent water quality.
The accuracy of the prediction of the effluent water quality of the sewage treatment plant is improved, the impact of the time-delay of the inlet flow can be automatically judged, and the characteristics of different time periods are effectively used to predict, improving the accuracy of the prediction.
Smart Images

Figure CN115345344B_ABST
Abstract
Description
Technical Field
[0001] The present invention is applied to the prediction of effluent quality of sewage treatment plants, and specifically relates to a deep learning method based on an attention mechanism and a long short-term memory network. Background Art
[0002] Water is essential to humanity and a valuable resource upon which we depend for survival and development. Human production activities inevitably generate wastewater. If discharged without treatment, it can severely harm the environment and lead to irreversible consequences. As a key component of water resource protection, sewage treatment plants bear the heavy responsibility of purifying wastewater. A sewage treatment plant is a system encompassing numerous processes that utilizes physical, chemical, and biological methods to remove pollutants such as organic matter, ammonia nitrogen, and phosphorus from wastewater, achieving the goal of wastewater purification and recycling. Once treated, wastewater flows into the natural water cycle without harming the ecological environment or aquatic life. Therefore, timely anticipating abnormal operating conditions and potential risks at sewage treatment plants, ensuring their safe and stable operation, and ensuring that their effluent quality meets discharge standards are crucial for water pollution prevention and control.
[0003] The anaerobic-anoxic-aerobic (A 2 The O) process is a wastewater treatment process based on the activated sludge method. The activated sludge method is a biological wastewater treatment technology that uses activated sludge as the main process to degrade pollutants through microbial activity. It is recognized as an economical and sustainable method. However, modeling this type of process is very challenging. First, the activated sludge process is a complex dynamic biochemical reaction process with highly nonlinear and strongly coupled characteristics. Second, the wastewater treatment system has long time lags. For larger wastewater treatment plants, it may take more than ten hours for a batch of wastewater to flow from the inlet to the outlet. In addition, the wastewater treatment system has uncertain time lags. In engineering practice, the influent flow rate of a wastewater treatment plant cannot be maintained constant. The irregular changes in the influent flow rate make it difficult to determine the time it takes for wastewater to flow through each process stage. It is also difficult to determine the extent to which the wastewater inflow at each time will affect the effluent water quality at a certain point in the future. Summary of the Invention
[0004] To overcome the problem that existing sewage treatment plant effluent quality prediction methods cannot simultaneously account for the system's inherent high nonlinearity, long time lag, and lag time uncertainty, this paper proposes a sewage treatment plant effluent quality prediction method based on an attention mechanism and a long short-term memory (LSTM) network. The LSTM network extracts features from time-series input data, and the attention mechanism module extracts the weighted distribution of the input features' impact on future effluent quality over time.
[0005] The technical solution adopted by the present invention to solve its technical problem is:
[0006] A method for predicting effluent quality from a sewage treatment plant based on an attention mechanism and a long short-term memory network, the method comprising the following steps:
[0007] 1) Collect and clean the actual operation and monitoring data of the sewage treatment plant, retain the features related to the effluent quality and normalize these features as input to the deep neural network. Establish data samples and datasets based on the time point to be predicted and the time scale of historical data to be used;
[0008] 2) Group the features by process stage. The same group of features are located in the same process stage, so they have the same or similar correlation with the effluent water quality in time. The inlet flow rate feature is placed in a separate group to distinguish it from other inlet water data.
[0009] 3) Build a deep neural network, including a time series feature extraction module composed of a long short-term memory network, an attention mechanism module composed of a convolutional network for acquiring time lag information, and a regression module composed of a fully connected network;
[0010] 4) Feed the inlet flow data into the input layer of the attention mechanism module, feed the remaining historical features into the input layer of the time series feature extraction module, and feed the outflow water quality data at the time to be predicted into the output layer of the regression module. Set the loss function and conduct training.
[0011] 5) Call the trained deep neural network to predict the effluent water quality.
[0012] Furthermore, in step 1), when establishing a data set for neural network training and testing, the present invention establishes samples based on the time point to be predicted and the time scale of the historical data to be used. The samples are established through the following steps to achieve the prediction of the effluent water quality in the next l hour using the data of the past r hours: the first step is to set a sliding window on the complete time axis corresponding to the data, which includes a total of r hours from the starting time, and all the features within this period are used as the input of the first sample, and the effluent water quality features at the moment of 1 hour after the end of the sliding window are used as the output corresponding to the first sample; the second step is to move the sliding window one unit in the positive direction along the time axis, and obtain the input and output of the second sample in the same way. And so on, all samples are obtained. After all samples are established, step 2) is executed to obtain a data set after feature grouping.
[0013] In step 3), the long short-term memory network for extracting a single set of features is formed by connecting a plurality of long short-term memory units;
[0014] There are three specific gating structures inside the long short-term memory unit: input gate, forget gate, and output gate. Gating is used to achieve selective information transmission. Its general form can be expressed as:
[0015] g(x)=σ(Wx+b) (1)
[0016] Where W and b are the learnable weight matrix and bias in the network, σ(x)=1 / (1+e -x ), is the Sigmoid function, which maps a real number to the interval (0, 1); the closer the output of the gate is to 0, the less information passes through, and the closer it is to 1, the more information passes through;
[0017] The LSTM unit contains two information flow pathways: the unit state and the hidden state. The unit state can store important historical information for a long time, even over a long period of time; the hidden state is responsible for transmitting information and making current decisions.
[0018] The LSTM unit completes the forward computation process at time step t through the following steps:
[0019] The forget gate selectively retains the important parts of the historical information and forgets those parts that are less useful for prediction. Through the information selection of the forget gate, the gradient vanishing problem when the gradient is back propagated along time will be alleviated. t The calculation formula is:
[0020] f t =σ(W f [h t-1 , x t ]+b f ) (2)
[0021] Among them, h t-1 is the hidden state of the long short-term memory unit output at the previous time step t-1, x t is the input data of the current time step t, W f and b f are the learnable weight matrices and biases in the forget gate;
[0022] The input gate controls the input data x at the current time step t How much information needs to be stored in the cell state, input gate i t and cell state update value x t and h t-1 Obtained through a neural network layer, the activation functions are Sigmoid and Tanh respectively:
[0023] i t =σ(W i[h t-1 , x t ]+b i ) (3)
[0024]
[0025] Among them, W i and b i represents the learnable weight matrix and bias in the input gate, W c and b c The learnable weight matrices and biases in the neural network layer that represent the calculation of the unit state update value;
[0026] The cell state c at the current time step t The cell state c at the previous time step t-1 Update value with the cell state at the current time step The forget gate f t and input gate i t As weighting coefficient we get:
[0027]
[0028] Among them, the symbol * represents dot product;
[0029] The hidden state h output by the long short-term memory unit t According to the cell state c t OK; output gate control unit state c t For the hidden state h t The influence of the output gate is the same as the forget gate and input gate. t Also by x t and h t-1 Calculation yields:
[0030] o t =σ(W o [h t-1 , x t ]+b o ) (6)
[0031] Finally, the cell state c t and output gate o t After dot multiplication, the hidden state h of the short-term memory unit output at the current time step is obtained t :
[0032] h t =o t *tanh(c t ) (7)
[0033] For the T time steps of data contained in the extracted single set of features, a total of T long short-term memory units are combined into a long short-term memory network to implement feature extraction. The output hidden state sequence H contains T hidden states:
[0034] H=[h1,h2,...,h t-1 , h t , h t+1 ,...,h T-1 , h T ] (8)
[0035] In step 3), the attention mechanism module for acquiring time-delay information for a single set of features is composed of a convolutional network;
[0036] The convolutional network consists of convolutional layers, pooling layers, linear layers, and activation layers;
[0037] The convolutional layer can be expressed mathematically as:
[0038]
[0039] Among them, x ⊙ Represents the output value of the convolution operation, n represents the number of channels of the input data, ⊙ represents the one-dimensional convolution operation, k j represents the convolution kernel parameters, Represents the area of convolution operation, i represents the starting point of convolution, h represents the length of convolution area, and b represents the deviation;
[0040] The pooling layer reduces the feature dimension by downsampling, removes redundant information, further compresses the features, and simplifies the network complexity. The pooling layer can be expressed as follows:
[0041]
[0042] Among them, x i Indicates the area, The activity value of the neuron is specified in , is the output value of the pooling layer;
[0043] The linear layer can be expressed as follows:
[0044] y=Wx+b (11)
[0045] Where x represents the input of the layer, W and b are the learnable weight matrix and bias, and y is the output value of the linear layer;
[0046] There are two usage scenarios for activation layers. One is to use it in each hidden layer and implement it through the ReLU function:
[0047]
[0048] Its function is to enable the neural network to have the ability to fit nonlinear functions; another scenario is to use the activation layer in the output layer of the attention mechanism module, which is implemented through the Softmax function:
[0049]
[0050] Among them, x i is the output value of the i-th node, and D is the number of output nodes. Its function is to convert the output value of the attention mechanism module into a probability distribution in the range [0, 1] with a sum of 1, so as to achieve the purpose of outputting the attention weight.
[0051] The dimension of the attention weight vector A is consistent with the number of hidden states T output by the LSTM network:
[0052] A=[a1,a2,...,a t-1 , a t , a t+1 ,...,a T-1 , a T ] (14)
[0053] Among them, a t Represents the hidden state h output by the long short-term memory network at time step t t The corresponding attention weight;
[0054] After obtaining the attention weight vector and the hidden state vector output by the long short-term memory network, the context vector is calculated for each feature group. For a single feature group, the context vector calculation formula is as follows:
[0055] C=a1h1+a2h2+…+a T h T (15)
[0056] Where C is the context vector.
[0057] In step 3), the regression module is composed of a fully connected neural network, which includes several linear layers and activation layers;
[0058] The input Z of the regression module is composed of the context vectors of each feature group:
[0059] Z=[C1,C2,...,C k-1 , C k , C k+1 ,...,C K-1 , C K ] (16)
[0060] Among them, C krepresents the context vector of the kth feature group, where K represents the number of feature groups;
[0061] The calculation formula of the linear layer in the regression module is consistent with that in the attention mechanism module. The activation layer only uses the ReLU function, which is applied to all linear layers except the output layer. The role of the regression module is to perform further operations on the extracted feature representations and map the extracted feature representations to the feature space where the prediction target, that is, the future effluent water quality, is located.
[0062] In step 4), the loss function is set to mean square error:
[0063]
[0064] Among them, n is the number of samples, y i represents the true value of the i-th sample target, Represents the predicted value of the i-th sample target.
[0065] Compared with the existing technology, the beneficial effect of the present invention is that: in order to address the problems of high system nonlinearity, long time lag and lag time uncertainty that are difficult to avoid when predicting the effluent water quality of sewage treatment plants, a sewage treatment plant effluent water quality prediction method based on an attention mechanism and a long short-term memory network is designed. Specifically, a long short-term memory network is designed to realize feature extraction of time series input data, and an attention mechanism module is designed to obtain the weight distribution of the impact of input features on future effluent water quality in time. Through the training of the neural network, the model can automatically judge the impact of time lag based on the influent flow rate, and effectively use the features of different time periods for prediction, thereby further improving the prediction accuracy of sewage treatment plant effluent water quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] Figure 1 This is a flow chart of the effluent water quality prediction method of the present invention.
[0067] Figure 2 This is a diagram of the structure of a long short-term memory unit.
[0068] Figure 3 This is the structure diagram of the long short-term memory network.
[0069] Figure 4 This is the structural diagram of the attention mechanism module.
[0070] Figure 5 This is the complete structural diagram of the designed neural network. DETAILED DESCRIPTION
[0071] In order to make the purpose, design ideas and technical solutions of the embodiments of the present invention clearer, the present invention is further described below with reference to the accompanying drawings.
[0072] Reference Figures 1 to 5 A method for predicting effluent quality from a sewage treatment plant based on an attention mechanism and a long short-term memory network is provided, the method comprising the following steps:
[0073] 1) Collect and clean the actual operation and monitoring data of the sewage treatment plant, retain the features that are correlated with the effluent water quality, and normalize these features as the input of the deep neural network. When establishing a data set for neural network training and testing, the present invention establishes samples based on the time point to be predicted and the time scale of the historical data to be used. The samples are established through the following steps to achieve the prediction of the effluent water quality in the next l hour using the data of the past r hours: the first step is to set a sliding window on the complete time axis corresponding to the data, which contains a total of r hours from the starting time, and all the features in the time period are used as the input of the first sample, and the effluent water quality features at 1 hour after the end of the sliding window are used as the output corresponding to the sample; the second step is to move the sliding window one unit in the positive direction along the time axis, and obtain the input and output of the second sample in the same way. And so on, all samples are obtained;
[0074] 2) Group the features according to the process stage. The same group of features are located in the same process stage, so they have the same or similar correlation with the effluent water quality in time. The inlet flow feature is placed in a separate group to distinguish it from other inlet data. is the inlet flow vector of the nth sample, N is the total number of samples, and T1 is the number of times the inlet flow value is sampled within the time span set for a single sample); define other historical characteristic data besides the inlet flow data is the historical feature data of the nth sample, is the matrix composed of the kth group of features of the nth sample, K is the number of feature groups, T2 is the number of times the historical features are sampled within the time span set for a single sample); define the effluent water quality data Y at the time to be predicted = {Y (n) |n=1…N}(Y (n) is the effluent water quality vector of the nth sample). Thus, the dataset after feature grouping is obtained;
[0075] 3) Build a deep neural network such as Figure 5 As shown in the figure, it includes a temporal feature extraction module composed of a long short-term memory network, an attention mechanism module composed of a convolutional network for obtaining time lag information, and a regression module composed of a fully connected network;
[0076] Furthermore, in step 3), the long short-term memory network for extracting a single set of features is composed of a plurality of long short-term memory units connected together, and the structure of a single long short-term memory unit is as follows: Figure 2As shown;
[0077] There are three specific gating structures inside the long short-term memory unit: input gate, forget gate, and output gate. Gating is used to achieve selective information transmission. Its general form can be expressed as:
[0078] g(x)=σ(Wx+b) (1)
[0079] Where W and b are the learnable weight matrix and bias in the network, σ(x)=1 / (1+e -x ), is the Sigmoid function, which maps a real number to the interval (0, 1); the closer the output of the gate is to 0, the less information passes through, and the closer it is to 1, the more information passes through;
[0080] The LSTM unit contains two information flow pathways: the unit state and the hidden state. The unit state can store important historical information for a long time, even over a long period of time; the hidden state is responsible for transmitting information and making current decisions.
[0081] The LSTM unit completes the forward computation process at time step t through the following steps:
[0082] The forget gate selectively retains the important parts of the historical information and forgets those parts that are less useful for prediction. Through the information selection of the forget gate, the gradient vanishing problem when the gradient is back propagated along time will be alleviated. t The calculation formula is:
[0083] f t =σ(W f [h t-1 , x t ]+b f ) (2)
[0084] Among them, h t-1 is the hidden state of the long short-term memory unit output at the previous time step t-1, x t is the input data of the current time step t, W f and b f are the learnable weight matrices and biases in the forget gate;
[0085] The input gate controls the input data x at the current time step t How much information needs to be stored in the cell state, input gate i t and cell state update value x t and h t-1 Obtained through a neural network layer, the activation functions are Sigmoid and Tanh respectively:
[0086] i t =σ(W i [h t-1 , x t ]+b i ) (3)
[0087]
[0088] Among them, W i and b i represents the learnable weight matrix and bias in the input gate, W c and b c The learnable weight matrices and biases in the neural network layer that represent the calculation of the unit state update value;
[0089] The cell state c at the current time step t The cell state c at the previous time step t-1 Update value with the cell state at the current time step The forget gate f t and input gate i t As weighting coefficient we get:
[0090]
[0091] Among them, the symbol * represents dot product;
[0092] The hidden state h output by the long short-term memory unit t According to the cell state c t OK; output gate control unit state c t For the hidden state h t The influence of the output gate is the same as the forget gate and input gate. t Also by x t and h t-1 Calculation yields:
[0093] o t =σ(W o [h t-1 , x t ]+b o ) (6)
[0094] Finally, the cell state c t and output gate o t After dot multiplication, the hidden state h of the short-term memory unit output at the current time step is obtained t :
[0095] h t =o t *tanh(c t ) (7)
[0096] For the T time steps of data contained in the extracted single set of features, a total of T long short-term memory units are combined into a long short-term memory network to implement feature extraction. The output hidden state sequence H contains T hidden states:
[0097] H=[h1,h2,...,h t-1 , h t , h t+1 ,...,h T-1 , h T ] (8)
[0098] The long short-term memory network structure diagram for extracting a single set of features is as follows Figure 3 shown.
[0099] In step 3), the attention mechanism module for acquiring time-delay information for a single set of features is composed of a convolutional network, and its structure is as follows: Figure 4 As shown;
[0100] The convolutional network consists of convolutional layers, pooling layers, linear layers, and activation layers;
[0101] The convolutional layer can be expressed mathematically as:
[0102]
[0103] Among them, x ⊙ Represents the output value of the convolution operation, n represents the number of channels of the input data, ⊙ represents the one-dimensional convolution operation, k j represents the convolution kernel parameters, Represents the area of convolution operation, i represents the starting point of convolution, h represents the length of convolution area, and b represents the deviation;
[0104] The pooling layer reduces the feature dimension by downsampling, removes redundant information, further compresses the features, and simplifies the network complexity. The pooling layer can be expressed as follows:
[0105]
[0106] Among them, x i Indicates the area, The activity value of the neuron is specified in , is the output value of the pooling layer;
[0107] The linear layer can be expressed as follows:
[0108] y=Wx+b (11)
[0109] Where x represents the input of the layer, W and b are the learnable weight matrix and bias, and y is the output value of the linear layer;
[0110] There are two usage scenarios for activation layers. One is to use it in each hidden layer and implement it through the ReLU function:
[0111]
[0112] Its function is to enable the neural network to have the ability to fit nonlinear functions; another scenario is to use the activation layer in the output layer of the attention mechanism module, which is implemented through the Softmax function:
[0113]
[0114] Among them, x i is the output value of the i-th node, and D is the number of output nodes. Its function is to convert the output value of the attention mechanism module into a probability distribution in the range [0, 1] with a sum of 1, so as to achieve the purpose of outputting the attention weight.
[0115] The dimension of the attention weight vector A is consistent with the number of hidden states T output by the LSTM network:
[0116] A=[a1,a2,...,a t-1 , a t , a t+1 ,...,a T-1 , a T ] (14)
[0117] Among them, a t Represents the hidden state h output by the long short-term memory network at time step t t The corresponding attention weight;
[0118] After obtaining the attention weight vector and the hidden state vector output by the long short-term memory network, the context vector is calculated for each feature group. For a single feature group, the context vector calculation formula is as follows:
[0119] C=a1h1+a2h2+…+a T h T (15)
[0120] Where C is the context vector.
[0121] In step 3), the regression module is composed of a fully connected neural network, which includes several linear layers and activation layers;
[0122] The input Z of the regression module is composed of the context vectors of each feature group:
[0123] Z=[C1,C2,...,C k-1 , C k , C k+1 ,...,CK-1 , C K ] (16)
[0124] Among them, C k represents the context vector of the kth feature group, where K represents the number of feature groups;
[0125] The calculation formula of the linear layer in the regression module is consistent with that in the attention mechanism module. The activation layer only uses the ReLU function, which is applied to all linear layers except the output layer. The role of the regression module is to perform further operations on the extracted feature representations and map the extracted feature representations to the feature space where the prediction target, that is, the future effluent water quality, is located.
[0126] The designed deep neural network is composed of various modules connected together, and its complete structure is as follows Figure 5 shown.
[0127] 4) Feed the inlet flow rate data Q into the input layer of the attention mechanism module, the remaining historical features X into the input layer of the time series feature extraction module, and the outflow water quality data Y at the time to be predicted into the output layer of the regression module. Set the loss function and conduct training;
[0128] In step 4), the loss function is set to mean square error:
[0129]
[0130] Among them, n is the number of samples, y i represents the true value of the i-th sample target, Represents the predicted value of the i-th sample target.
[0131] 5) Call the trained deep neural network to predict the effluent water quality.
[0132] The contents described in the embodiments of this specification are merely an enumeration of the implementation forms of the inventive concept. The scope of protection of the present invention should not be regarded as limited to the specific forms described in the embodiments. The scope of protection of the present invention also extends to equivalent technical means that can be conceived by those skilled in the art based on the inventive concept.
Claims
1. A method for predicting effluent quality from a sewage treatment plant based on an attention mechanism and a long short-term memory network, characterized in that: The following steps are involved: 1) Collect and clean the actual operation and monitoring data of the sewage treatment plant, retain the features related to the effluent quality and normalize these features as input to the deep neural network. Establish data samples and datasets based on the time point to be predicted and the time scale of historical data to be used; 2) Group the features by process stage. The same group of features are located in the same process stage, so they have the same or similar correlation with the effluent water quality in time. The inlet flow rate feature is placed in a separate group to distinguish it from other inlet water data. 3) Build a deep neural network, including a time series feature extraction module composed of a long short-term memory network, an attention mechanism module composed of a convolutional network for acquiring time lag information, and a regression module composed of a fully connected network; 4) Feed the water flow data into the input layer of the attention mechanism module to achieve the purpose of outputting attention weights; the attention weight vector The dimension of and the number of hidden states output by the long short-term memory network Consistent: (14) in, Represents the long short-term memory network at time step The hidden state of the output The corresponding attention weight; The remaining historical features are fed into the input layer of the temporal feature extraction module, and the output contains hidden state sequence of hidden states : (8) After obtaining the attention weight vector and the hidden state vector output by the long short-term memory network, the context vector is calculated for each feature group. For a single feature group, the context vector calculation formula is as follows: in, is the context vector; Input to the regression module It is composed of the concatenation of the context vectors of each feature group: in, Indicates the The context vector of feature groups, Indicates the number of feature groups. Feed the outflow water quality data at the time to be predicted into the output layer of the regression module, set the loss function, and perform training; 5) Call the trained deep neural network to predict the effluent water quality.
2. The method for predicting effluent quality from a sewage treatment plant based on an attention mechanism and a long short-term memory network according to claim 1, wherein: In step 1), when establishing the data set for neural network training and testing, samples are established according to the time point to be predicted and the time scale of the historical data to be used. The following steps are used to establish samples to achieve the use of past Hourly data prediction for the future Hourly water quality: The first step is to set a sliding window on the complete time axis corresponding to the data, which includes the total time from the starting moment to the hours, all features in this period are used as the input of the first sample, and after the end of the sliding window The outlet water quality characteristics at the hourly moment are used as the output corresponding to the first sample. In the second step, the sliding window moves one unit forward along the time axis, and the input and output of the second sample are obtained in the same way. This process is repeated for all samples. When all samples are established, step 2 is executed to obtain the feature-grouped dataset.
3. The method for predicting effluent quality from a sewage treatment plant based on an attention mechanism and a long short-term memory network according to claim 1, wherein: In step 3), the long short-term memory network for extracting a single set of features is composed of a plurality of long short-term memory units connected together; There are three specific gating structures inside the long short-term memory unit: input gate, forget gate, and output gate. Gating is used to achieve selective information transmission. Its general form can be expressed as: in, and are the learnable weight matrices and biases in the network, , is the Sigmoid function, which maps a real number to Interval; the closer the gate output is to 0, the less information passes through, and the closer it is to 1, the more information passes through; The LSTM unit contains two information flow pathways: the unit state and the hidden state. The unit state can store important historical information for a long time, even over a long period of time. The hidden state is responsible for transmitting information and making current decisions. The LSTM unit completes the forward computation process at time step t through the following steps: The forget gate selectively retains the important parts of the historical information and forgets those parts that are less useful for prediction. Through the information selection of the forget gate, the gradient vanishing problem when the gradient is back propagated along time will be alleviated. The calculation formula is: in, The previous time step The hidden state of the LSTM output, is the current time step The input data, and are the learnable weight matrices and biases in the forget gate; The input gate controls the input data of the current time step How much information needs to be stored in the cell state, input gate and cell state update value Respectively by and Obtained through a neural network layer, the activation functions are Sigmoid and Tanh respectively: in, and represents the learnable weight matrix and bias in the input gate, and The learnable weight matrices and biases in the neural network layer that represent the calculation of the unit state update value; The cell state at the current time step The cell state at the previous time step Update value with the cell state at the current time step Forget Gate and input gate As weighting coefficient we get: Among them, the symbol represents dot product; Hidden state output of the LSTM unit According to the unit status OK; output gate control unit status Hidden state The effect of the output gate is the same as the forget gate and input gate. Also by and Calculation yields: Finally, the cell state and output gate The hidden state of the short-term memory unit output at the current time step is obtained by point multiplication : For the extracted single set of features time steps of data, a total of The LSTM units are combined into a LSTM network to realize feature extraction.
4. The method for predicting effluent quality from a sewage treatment plant based on an attention mechanism and a long short-term memory network according to claim 1, wherein: In step 3), the attention mechanism module for acquiring time-delay information for a single set of features is composed of a convolutional network; The convolutional network consists of convolutional layers, pooling layers, linear layers, and activation layers; The convolutional layer can be expressed mathematically as: in, Represents the output value of the convolution operation, Indicates the number of channels of input data, represents a one-dimensional convolution operation, represents the convolution kernel parameters, represents the area of convolution operation, represents the starting point of the convolution, represents the length of the convolution region, express deviation; The pooling layer reduces the feature dimension by downsampling, removes redundant information, further compresses the features, and simplifies the network complexity. The pooling layer can be expressed as follows: in, Indicates the area, The activity value of the neuron is specified in , is the output value of the pooling layer; The linear layer can be expressed as follows: in, represents the input of this layer, and are the learnable weight matrices and biases, is the output value of the linear layer; There are two usage scenarios for activation layers. One is to use it in each hidden layer and implement it through the ReLU function: Its function is to enable the neural network to have the ability to fit nonlinear functions; another scenario is to use the activation layer in the output layer of the attention mechanism module, which is implemented through the Softmax function: in, For the The output value of each node, is the number of output nodes; its function is to convert the output value of the attention mechanism module into a range of , the probability distribution sums to 1, achieving the purpose of outputting attention weights.
5. The method for predicting effluent quality from a sewage treatment plant based on an attention mechanism and a long short-term memory network according to claim 1, wherein: In step 3), the regression module is composed of a fully connected neural network, which includes several linear layers and activation layers; The calculation formula of the linear layer in the regression module is consistent with that in the attention mechanism module. The activation layer only uses the ReLU function, which is applied to all linear layers except the output layer. The role of the regression module is to perform further operations on the extracted feature representations and map the extracted feature representations to the feature space where the prediction target, that is, the future effluent water quality, is located.
6. The method for predicting effluent quality from a sewage treatment plant based on an attention mechanism and a long short-term memory network according to claim 1, wherein: In step 4), the loss function is set to mean square error: in, is the number of samples, Indicates the The true value of the sample target, Indicates the The predicted value of the sample target.