Sewage treatment effluent ammonia nitrogen prediction method and system based on neural network
A double-layer sparse Bayesian echo state network is used to predict ammonia nitrogen in sewage treatment effluent, addressing measurement challenges with real-time accuracy and reducing overfitting, enhancing digital sewage treatment processes.
Patent Information
- Application Number
- CN202411146007.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-20
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2044-08-20
AI Technical Summary
Current methods for measuring ammonia nitrogen in sewage treatment effluent are affected by environmental and human factors, leading to inaccurate and costly offline measurements, and existing models struggle with complex structures and high maintenance costs, making real-time online monitoring difficult.
A method and system using a double-layer sparse Bayesian echo state network to predict ammonia nitrogen in sewage treatment effluent, employing sparse Bayesian reasoning to learn model parameters, reducing data dimensionality and preventing overfitting, thereby enabling accurate online prediction.
The system achieves real-time, accurate prediction of ammonia nitrogen concentration in sewage treatment effluent, improving the self-organizing and generalization ability of the neural network, ensuring digital operation and safe water quality management.
Smart Images

Figure CN119089139A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of sewage treatment, and in particular to a method and system for predicting ammonia nitrogen in sewage treatment effluent based on a neural network. Background Art
[0002] At present, freshwater resources are in short supply and seriously polluted. The deterioration of water ecology in cities and major economic zones is very prominent, and has become a bottleneck problem restricting the sustainable development of the economy and society. The eutrophication of water bodies caused by pollutants such as ammonia nitrogen and total nitrogen is showing an increasingly serious trend. Eutrophication of water bodies will cause dense algal blooms or red tides to form on the water surface, and a large number of fish will die. The "2023 Ecological Environment Bulletin" published in May 2024 shows that ammonia nitrogen is one of the important factors causing pollution. Therefore, the establishment of urban sewage treatment plants and the online measurement of the ammonia nitrogen concentration in sewage treatment effluent are the key to achieving closed-loop control of ammonia nitrogen emissions and improving effluent water quality, which is of great significance to protecting the water environment.
[0003] The traditional off-line measurement method of ammonia nitrogen based on the principle of chemical reaction and carried out in the laboratory is affected by external factors such as environmental and human factors, and the measurement results fluctuate. The test measurement cycle is long, making it difficult to achieve real-time online monitoring. With the rapid development of sensor technology and automation technology, some scholars have combined the chemical reaction principle of ammonia nitrogen detection with measuring instruments to design sewage ammonia nitrogen online measurement instruments. These instruments can realize online measurement of ammonia nitrogen concentration, but the accuracy is low and the equipment maintenance cost is high; the measurement method based on the mechanism model has a complex model structure. The International Water Quality Association has established multiple activated sludge models (Activated Sludge Model, ASM), which require many parameters to be adjusted during use and are mostly used in sewage treatment plant design. In the sewage treatment process, people do not fully understand the survival laws and dependent conditions of microorganisms in sewage. The field test cycle is long and the cost is high. This is a huge challenge to the establishment of traditional ammonia nitrogen prediction models based on microbial reaction mechanisms or mathematical statistics. With the development of brain-like model research and intelligent theory, the application of artificial intelligence technology to study data-driven soft measurement methods for sewage treatment has become a hot topic. The development trend of intelligent sewage treatment plants is to build intelligent soft-sensing models based on historical data and use easy-to-measure variables to monitor difficult-to-measure variables in sewage treatment in real time. Due to the powerful nonlinear approximation ability of artificial neural networks, many scholars have applied them to soft-sensing of sewage treatment processes in recent years. By designing a neural network structure and weight training algorithm that matches specific tasks and optimizing network parameters, intelligent online detection of effluent ammonia nitrogen concentration in urban sewage treatment processes can be achieved, providing a guarantee for the digital operation of urban sewage treatment processes. Summary of the invention
[0004] Based on this, the embodiment of the present application provides a method and system for predicting ammonia nitrogen in sewage treatment effluent based on a neural network, which realizes online rapid detection of ammonia nitrogen in effluent from urban sewage treatment process, and can construct a soft measurement model of ammonia nitrogen in effluent from urban sewage treatment process based on a double-layer sparse Bayesian echo state network, so as to realize online prediction of effluent ammonia nitrogen concentration. The model uses sparse Bayesian reasoning method to learn model parameters, and the sparsity of the input layer can remove irrelevant input features to achieve the purpose of data dimensionality reduction; the sparsity of the hidden layer can enable the hidden layer to have appropriate neurons, obtain a network scale that matches the historical data, effectively prevent the occurrence of overfitting, and improve the self-organizing ability and generalization ability of the neural network.
[0005] In a first aspect, a method for predicting ammonia nitrogen in sewage treatment effluent based on a neural network is provided, the method comprising:
[0006] Obtain water sample data, perform noise reduction, abnormal data removal, missing data supplementation, and normalization on the water sample data in turn to obtain P groups of training samples, and take the first P1 group of data as training samples and the latter P2 group of data as test samples;
[0007] Determine the input variables of the neural network model; wherein the input variables specifically include influent total phosphorus, redox potential, dissolved oxygen concentration, total suspended solids, and pH value;
[0008] Design a neural network model, and use training samples to train the output layer weights of the network; the neural network is a double-layer sparse Bayesian echo state network, which consists of an input layer, a hidden layer, and an output layer. The network topology is 5-m-1, the number of neurons in the network input layer is 5, the number of neurons in the network hidden layer is m, and the number of neurons in the output layer is 1; the network hidden node activation function uses the sigmoid function, and the output node activation function uses the linear function;
[0009] The trained neural network is tested using the test samples, and the output of the neural network after the test is used as the prediction result of effluent ammonia nitrogen.
[0010] Optionally, in the normalization process of the water sample data, the specific formula is
[0011]
[0012] Normalized, where v i is the measured data set of sewage treatment influent before normalization, max(v i ) is the maximum value in the array, min(v i ) is the minimum value in the array, v i ′ is the corresponding normalized water inlet data value.
[0013] Optionally, design a neural network model, specifically including:
[0014] Determine the input layer neurons, update the hidden layer neuron states, and calculate the output layer output.
[0015] Optionally, determine the input layer neurons according to the formula
[0016] u i (n) = v i (n)
[0017] Determine the output of the input layer neuron, where u i (n) is the output of the i-th input layer node at the n-th sample, i = 1, 2, …, 5, and the input vector is u(n) = [u1(n), u2(n), u3(n), u4(n), u5(n)].
[0018] Optionally, updating the hidden layer neuron state specifically includes:
[0019] Randomly generate a sub-reservoir, randomly generate the reserve weight W0 of each sub-reservoir module in the hidden layer according to the given reserve pool size and sparsity with uniform distribution, and adjust W0 by the scaling factor α(W) (0<α(W)<1) and the spectral radius ρ(W0);
[0020] Generate the input weight matrix W according to uniform distribution in , initialize the reservoir state x of the i-th sub-reservoir module i (0);
[0021] The input signal u(n) is used to drive the reserve pool, and its update formula is:
[0022] x i (n) = f(W in u i (n)+Wx i (n-1))
[0023] Among them, x i (n) is the i-th reservoir vector of the hidden layer, denoted by H i (n)=(u i (n),x i (n)) T (i=1,...,5), in order to overcome the influence of initial transient, from n min Start collecting the internal state matrix H = (H (n min +1),H(2),...,H(P)) T , where H(n)=(H1(1),H2(2),...,H5(P)) T,P is the number of training samples.
[0024] Optionally, the output of the output layer is calculated, including:
[0025] Initializing Hyperparameters α β and σ 2 ;
[0026] Calculate the output value of the output layer, the formula is:
[0027]
[0028] Among them, ε(n) is an independent noise that satisfies the Gaussian distribution, with a mean of 0 and a variance of σ 2 , W out Output weight vector for the reserve pool; output of each submodule of the hidden layer and unknown weight parameter β = (β1, β2, ..., β5) T Related, and record the expected output as T = (t(1), t(2), ..., t(P)) T ;
[0029] The output formula is written in the form of a matrix, and the likelihood function of the training samples and the prior distribution of the output weights are given, as well as the posterior distribution of the unknown parameters of the double-layer sparse Bayesian echo state network. After calculating the covariance and the mean, the second-class maximum likelihood method is used to calculate the optimal value of the hyperparameters, and the expected output is obtained after calculating the optimal value of the output weights and weight parameters.
[0030] Optionally, the output formula is written in the form of a matrix, including:
[0031]
[0032] in, H β =(H(1) T β,H(2) T β,...,H(P) T β) T .
[0033] Optionally, the likelihood function of the training sample and the prior distribution of the output weights are given, and the posterior distribution of the unknown parameters of the two-layer sparse Bayesian echo state network is given, specifically including:
[0034] Give the likelihood function of the training sample and the prior distribution of the output weights
[0035]
[0036] in, and They are independent priors;
[0037] The posterior distribution of the unknown parameters of the two-layer sparse Bayesian echo state network is given as:
[0038]
[0039] According to Bayes' rule, the first term on the right side of the equation,
[0040]
[0041] Optionally, after calculating the covariance and the mean, the optimal value of the hyperparameter is calculated using the second-kind maximum likelihood method, and after calculating the optimal value of the output weight and the weight parameter, the expected output is obtained, specifically including:
[0042] Calculating covariance Σ β , mean μ β ,in:
[0043]
[0044]
[0045] Calculate hyperparameters using the second-type maximum likelihood method α β and σ 2 The optimal value of the hyperparameter satisfies The maximum likelihood function is given by:
[0046]
[0047] By differentiating the marginal log-likelihood function, we can obtain the optimal value of the hyperparameter:
[0048]
[0049] Calculate the output weight W out and the optimal value of the weight parameter β, we can obtain Σ β ,μ β , until convergence, and finally get W out The optimal value of The optimal value of β
[0050] Prediction output based on
[0051]
[0052] Calculated, where y new For the prediction results.
[0053] In a second aspect, a system for predicting ammonia nitrogen in sewage treatment effluent based on a neural network is provided, the system comprising:
[0054] The data processing module is used to obtain water sample data, perform noise reduction, abnormal data elimination, missing data supplementation, and normalization on the water sample data in turn to obtain P groups of training samples, and take the first P1 group of data as training samples and the latter P2 group of data as test samples;
[0055] A variable determination module is used to determine the input variables of the neural network model; wherein the input variables specifically include influent total phosphorus, redox potential, dissolved oxygen concentration, total suspended solids, and pH value;
[0056] The model training module is used to design a neural network model and train the output layer weights of the network using training samples; the neural network is a double-layer sparse Bayesian echo state network, which consists of an input layer, a hidden layer, and an output layer. The topological structure of the network is 5-m-1, the number of neurons in the network input layer is 5, the number of neurons in the network hidden layer is m, and the number of neurons in the output layer is 1; the sigmoid function is used as the activation function of the network hidden node, and the linear function is used as the activation function of the output node;
[0057] The result output module is used to test the trained neural network using the test samples, and the output of the neural network after the test is the prediction result of effluent ammonia nitrogen.
[0058] The beneficial effects brought by the technical solution provided by the embodiment of the present application include at least:
[0059] (1) In order to solve the problem that ammonia nitrogen in the effluent of urban sewage treatment process is difficult to measure online, the present invention obtains an intelligent prediction method for ammonia nitrogen in the effluent of urban sewage treatment process based on a double-layer sparse Bayesian echo state network, thereby realizing accurate online prediction of ammonia nitrogen in the effluent of urban sewage treatment process.
[0060] (2) The present invention learns model parameters through the sparse Bayesian reasoning method. The sparsity of the input layer can remove irrelevant input features to achieve the purpose of data dimensionality reduction; the sparsity of the hidden layer can enable the hidden layer to have appropriate neurons, obtain a network scale that matches the historical data, effectively prevent the occurrence of overfitting, and improve the self-organizing ability and generalization ability of the neural network. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] In order to more clearly illustrate the implementation methods of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for the implementation methods or the description of the prior art. Obviously, the drawings in the following description are only exemplary, and for ordinary technicians in this field, other implementation drawings can be derived from the provided drawings without creative work.
[0062] Figure 1 A flowchart of the steps of a method for predicting ammonia nitrogen in sewage treatment effluent based on a neural network provided in this application;
[0063] Figure 2 It is a double-layer sparse Bayesian echo state network topology diagram of the present invention;
[0064] Figure 3 This is a diagram showing the prediction effect of the present invention on the effluent ammonia nitrogen in the process of urban sewage treatment;
[0065] Figure 4 This is a prediction error diagram of ammonia nitrogen in effluent from a municipal sewage treatment process according to the present invention. DETAILED DESCRIPTION
[0066] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0067] In the description of the present invention, the terms "comprises", "has" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may also include other steps or units that are not explicitly listed but are inherent to these processes, methods, products or apparatuses, or steps or units added based on further optimization schemes conceived by the present invention.
[0068] The effluent ammonia nitrogen content is an important monitoring indicator of urban sewage treatment plants and an important indicator for water quality evaluation. In view of the problem that the effluent ammonia nitrogen in the current urban sewage treatment process is difficult to measure in real time online, the present invention designs an effluent ammonia nitrogen prediction method for the urban sewage treatment process based on a double-layer sparse Bayesian echo state network, and realizes the online real-time prediction of effluent ammonia nitrogen. The method designs a double-layer sparse Bayesian echo state network structure, and learns the model parameters through the sparse Bayesian reasoning method. The sparsity of the input layer can remove irrelevant input features to achieve the purpose of data dimensionality reduction; the sparsity of the hidden layer can enable the hidden layer to have appropriate neurons, obtain a network scale that matches the historical data, effectively prevent the occurrence of overfitting, and improve the self-organizing ability and generalization ability of the neural network. The experimental results show that the intelligent prediction method can accurately measure the effluent ammonia nitrogen concentration in the urban sewage treatment process. It creates conditions for the digital operation of the urban sewage treatment process, provides guarantees for the effluent water quality to meet the standards, practices smart environmental protection construction, and provides theoretical support and technical guarantees for the safe and stable operation of the sewage treatment process. The present invention belongs to both the field of control science and engineering and the field of environmental science and engineering.
[0069] The present invention is only for the convenience of description, and adopts the prediction of ammonia nitrogen in the effluent of the sewage treatment process. Similarly, the invention can also be applied to the prediction of other key water quality parameters of the sewage treatment process. As long as the principle of the present invention is used for prediction, it should fall within the scope of the present invention.
[0070] The present invention obtains an intelligent prediction method for ammonia nitrogen in the effluent of urban sewage treatment process. Based on the double-layer sparse Bayesian echo state network, a soft measurement model for ammonia nitrogen in the effluent of urban sewage treatment process is constructed to realize online prediction of effluent ammonia nitrogen concentration. The model uses sparse Bayesian reasoning method to learn model parameters. The sparsity of the input layer can remove irrelevant input features to achieve the purpose of data dimensionality reduction; the sparsity of the hidden layer can enable the hidden layer to have appropriate neurons, obtain a network scale that matches the historical data, effectively prevent the occurrence of overfitting, and improve the self-organization ability and generalization ability of the neural network. Please refer to Figure 1 , which shows a flowchart of a method for predicting ammonia nitrogen in sewage treatment effluent based on a neural network provided in an embodiment of the present application, which may include the following steps:
[0071] S1, obtain water sample data, and perform noise reduction, abnormal data elimination, missing data supplementation, and normalization on the water sample data in sequence.
[0072] Get P groups of training samples, and take the first P1 group data as training samples, and the second P2 group data as test samples. In this step, the data is subjected to noise reduction, abnormal data removal, missing data supplementation, and normalization processing in turn. The calculation formula for normalization processing is:
[0073]
[0074] where v i is the measured data set of sewage treatment influent before normalization, max(v i ) is the maximum value in the array, min(v i ) is the minimum value in the array, v i ′ is the corresponding normalized water inlet data value.
[0075] S2, determine the input variables of the neural network model.
[0076] Among them, the neural network model input is selected as the input variables of the ammonia nitrogen soft sensor model, namely, total phosphorus (TP), oxidation-reduction potential (ORP), dissolved oxygen concentration (DO), total suspended solids (TSS), and pH value. v1, v2, v3, v4, and v5 are the measured data sets of influent total phosphorus (TP), oxidation-reduction potential (ORP), dissolved oxygen concentration (DO), total suspended solids (TSS), and pH value before normalization; v1′, v′2, v3′, v′4, and v5′ are the data sets of influent total phosphorus (TP), oxidation-reduction potential (ORP), dissolved oxygen concentration (DO), total suspended solids (TSS), and pH value after normalization according to formula (1).
[0077] S3, design a neural network model and use training samples to train the output layer weights of the network.
[0078] The two-layer sparse Bayesian echo state network consists of an input layer, a hidden layer, and an output layer (such as Figure 2 The topological structure of the double-layer sparse Bayesian echo state network is shown in the figure). The topological structure of the network is 5-m-1, the number of neurons in the network input layer is 5, the number of neurons in the network hidden layer is m, and the number of neurons in the output layer is 1; the input weights and hidden layer weights of the network are fixed once generated, and only the output layer weights of the network need to be trained. The sigmoid function is used as the activation function of the network hidden nodes, and the linear function is used as the activation function of the output nodes. The calculation formulas for each layer of the double-layer sparse Bayesian echo state network are:
[0079] 3.1) Determine the input layer neurons: This layer contains 5 neurons, and the output of the input layer neurons is:
[0080] u i (n) = v i (n) (2)
[0081] Among them, u i (n) is the output of the i-th input layer node at the n-th sample, i = 1, 2, …, 5, and the input vector is u(n) = [u1(n), u2(n), u3(n), u4(n), u5(n)].
[0082] 3.2) Update the hidden layer neuron state:
[0083] 3.2.1) Randomly generate a sub-reservoir. According to the given reserve pool size and sparsity, the reserve pool weight W0 of each sub-reservoir module in the hidden layer is randomly generated with uniform distribution, and W0 is adjusted by the scale factor α(W) (0<α(W)<1) and the spectrum radius ρ(W0), that is, W=(α W / ρ(W0))W0,ρ(W)<1;
[0084] 3.2.2) Generate the input weight matrix W according to a continuous probability distribution such as uniform distribution in , initialize the reservoir state x of the i-th sub-reservoir module i (0);
[0085] 3.2.3) Using the input signal u(n) to drive the storage pool, the update formula is:
[0086] x i (n) = f(W in u i (n)+Wx i (n-1)) (3)
[0087] Among them, x i (n) is the i-th reservoir vector of the hidden layer, denoted by H i (n)=(u i (n),x i (n)) T (i=1,...,5), in order to overcome the influence of initial transient, from n min Start collecting the internal state matrix H = (H (n min +1),H(2),...,H(P)) T , where H(n)=(H1(1),H2(2),...,H5(P)) T ,P is the number of training samples.
[0088] 3.3) Calculate the output layer output:
[0089] 3.3.1) Initialize hyperparameters α β and σ 2 ;
[0090] 3.3.1) Calculate the output value of the output layer, the formula is:
[0091]
[0092] Among them, ε(n) is an independent noise that satisfies the Gaussian distribution, with a mean of 0 and a variance of σ 2 , Wout Output weight vector for the reserve pool; output of each submodule of the hidden layer and unknown weight parameter β = (β1, β2, ..., β5) T Related, and record the expected output as T = (t(1), t(2), ..., t(P)) T .
[0093] 3.3.2) Write the output formula (4) in matrix form:
[0094]
[0095] in, H β =(H(1) T β,H(2) T β,...,H(P) T β) T .
[0096] 3.3.3) Give the likelihood function of the training sample and the prior distribution of the output weights
[0097]
[0098] in, and are independent priors respectively.
[0099] 3.3.4) Give the posterior distribution of the unknown parameters of the two-layer sparse Bayesian echo state network
[0100]
[0101] According to Bayes' rule, the first term on the right side of equation (9) is
[0102]
[0103] 3.3.5) Calculate covariance Σ β , mean μ β , specifically:
[0104]
[0105] 3.3.6) Calculate hyperparameters using the second-class maximum likelihood method α β and σ 2 The optimal value of the hyperparameter satisfies The maximum likelihood function is given by:
[0106]
[0107] By differentiating the marginal log-likelihood function, we can obtain the optimal value of the hyperparameters.
[0108]
[0109]
[0110] 3.3.7) Calculate the output weight W out and the optimal value of the weight parameter β
[0111] According to (11)-(14) and (16)-(17), we can obtain Σ β ,μ β , until convergence. Finally, we get W out The optimal value of The optimal value of β
[0112] 3.3.8) The predicted output is calculated according to formula (19):
[0113]
[0114] S4, using the test sample to test the trained neural network, and the output of the neural network after the test is the prediction result of effluent ammonia nitrogen.
[0115] In this step, the trained network is used to test the test data set, and the auxiliary variables in the test sample are used as the input of the trained two-layer sparse Bayesian echo state network. The output of the neural network is the prediction result of effluent ammonia nitrogen.
[0116] The creativity of the present invention is mainly reflected in:
[0117] (1) In order to solve the problem that ammonia nitrogen in the effluent of urban sewage treatment process is difficult to measure online, the present invention obtains an intelligent prediction method for ammonia nitrogen in the effluent of urban sewage treatment process based on a double-layer sparse Bayesian echo state network, thereby realizing accurate online prediction of ammonia nitrogen in the effluent of urban sewage treatment process.
[0118] (2) The present invention learns model parameters through the sparse Bayesian reasoning method. The sparsity of the input layer can remove irrelevant input features to achieve the purpose of data dimensionality reduction; the sparsity of the hidden layer can enable the hidden layer to have appropriate neurons, obtain a network scale that matches the historical data, effectively prevent the occurrence of overfitting, and improve the self-organizing ability and generalization ability of the neural network.
[0119] It should be noted that the present invention is only for the convenience of description and adopts the prediction of ammonia nitrogen in the effluent of the sewage treatment process. Similarly, the present invention can also be applied to the prediction of other key water quality parameters of the sewage treatment process. As long as the principle of the present invention is used for prediction, it should fall within the scope of the present invention.
[0120] A specific embodiment using the above method is given below:
[0121] S1, data preprocessing:
[0122] The experimental data were processed by noise reduction, abnormal data removal, missing data filling, and normalization, leaving 2029 sets of data and 11 variables. The 2029 sets of data samples were divided into two parts: 1200 sets of data were used as training samples, and the remaining 829 sets of data were used as test samples.
[0123] S2, auxiliary variable selection:
[0124] The experimental data for this experiment comes from the daily report of water quality analysis of a sewage treatment plant. Based on partial least squares regression, auxiliary variable selection is performed, and five variables, namely, influent total phosphorus (TP), oxidation-reduction potential (ORP), dissolved oxygen concentration (DO), total suspended solids (TSS), and pH value, are used as input variables of the ammonia nitrogen soft sensor model. The specific implementation steps are as follows:
[0125] 2.1) The input matrix is recorded as X, and the output matrix is recorded as Y. After standardization, we get X0 and Y0. The first principal component score vector extracted from X0 is recorded as t1, and the first principal component score vector extracted from Y0 is recorded as u1. Then there is a weight vector w1, c1 that makes t1=X0w1, u1=Y0c1, maximizing the feature information of t1, u1 in advance to meet the variance maximization, that is, Var(t1)→max, Var(u1)→max; t1, u1 meet the correlation maximization, Corr(t1, u1)→max. Satisfy the target covariance maximization:
[0126]
[0127] When the number of principal component scores is 0, the fitting error matrix corresponding to X0 is recorded as E0, and the fitting error matrix corresponding to Y0 is recorded as F0, that is, E0=X0, F0=Y0.
[0128] 2.2) Based on formula (20) and the premise that the weight vector is a unit vector, w1 is obtained as the matrix The eigenvector corresponding to the maximum eigenvalue of The eigenvector corresponding to the largest eigenvalue of .
[0129] 2.3) According to t1=X0w1,u1=Y0c1, we get t1,u1. According to the idea of principal component regression, we model Y0 for t1 and X0 for t1, and get formulas (21) and (22).
[0130]
[0131] in, F1 is the fitting error matrix of Y0 corresponding to t1; E1 is the fitting error matrix of X0 corresponding to t1.
[0132] 2.4) Treat E1, F1 as new X0, Y0, and use formulas (21) and (22) to get the second pair of principal component scores t2, u2. Repeat this cycle to get all m pairs of principal component scores.
[0133] 2.5) Using 10-fold cross validation and Q 2 Indicators are used to optimize the score logarithm of the selected principal components.
[0134] Two-layer sparse Bayesian echo state network design:
[0135] The two-layer sparse Bayesian echo state network consists of an input layer, a hidden layer, and an output layer (such as Figure 2 ), the topological structure of the network is 5-m-1, the number of neurons in the network input layer is 5, the number of neurons in the network hidden layer is m, and the number of neurons in the output layer is 1; the input weights and hidden layer weights of the network are fixed once generated, and only the output layer weights of the network need to be trained. The sigmoid function is used as the activation function of the network hidden nodes, and the linear function is used as the activation function of the output nodes. The calculation formulas for each layer of the double-layer sparse Bayesian echo state network are:
[0136] 3.1) Determine the input layer neurons: This layer contains 5 neurons, and the output of the input layer neurons is:
[0137] u i (n) = v i (n) (23)
[0138] Among them, u i (n) is the output of the i-th input layer node at the n-th sample, i = 1, 2, …, 5, and the input vector is u(n) = [u1(n), u2(n), u3(n), u4(n), u5(n)].
[0139] 3.2) Update the hidden layer neuron state:
[0140] 3.2.1) Randomly generate a sub-reservoir. According to the given reserve pool size and sparsity, the reserve pool weight W0 of each sub-reservoir module in the hidden layer is randomly generated with uniform distribution, and W0 is adjusted by the scale factor α(W) (0<α(W)<1) and the spectrum radius ρ(W0), that is, W=(α W / ρ(W0))W0,ρ(W)<1;
[0141] 3.2.2) Generate the input weight matrix W according to a continuous probability distribution such as uniform distribution in , initialize the reservoir state x of the i-th sub-reservoir module i (0);
[0142] 3.2.3) Using the input signal u(n) to drive the reserve pool, the update formula is:
[0143] x i (n) = f(W in u i (n)+Wx i (n-1)) (24)
[0144] Among them, x i (n) is the i-th reservoir vector of the hidden layer, denoted by H i (n)=(u i (n),x i (n)) T (i=1,...,5), in order to overcome the influence of initial transient, from n min Start collecting the internal state matrix H = (H (n min +1),H(2),...,H(P)) T , where H(n)=(H1(1),H2(2),...,H5(P)) T ,P is the number of training samples.
[0145] 3.3) Calculate the output layer output:
[0146] 3.3.1) Initialize hyperparameters α β and σ 2 ;
[0147] 3.3.1) Calculate the output value of the output layer, the formula is:
[0148]
[0149] Among them, ε(n) is an independent noise that satisfies the Gaussian distribution, with a mean of 0 and a variance of σ 2 , W outOutput weight vector for the reserve pool; output of each submodule of the hidden layer and unknown weight parameter β = (β1, β2, ..., β5) T Related, and record the expected output as T = (t(1), t(2), ..., t(P)) T .
[0150] 3.3.2) The output formula (4) is written in matrix form as follows:
[0151]
[0152] in, H β =(H(1) T β,H(2) T β,...,H(P) T β) T .
[0153] 3.3.3) Give the likelihood function of the training sample and the prior distribution of the output weights:
[0154]
[0155] in, and are independent priors respectively.
[0156] 3.3.4) Give the posterior distribution of the unknown parameters of the two-layer sparse Bayesian echo state network:
[0157]
[0158] According to Bayes' rule, the first term on the right side of equation (9) is
[0159]
[0160] 3.3.5) Calculate covariance Σ β , mean μ β ,
[0161]
[0162] 3.3.6) Calculate hyperparameters using the second-class maximum likelihood method α β and σ 2 The optimal value of the hyperparameter satisfies The maximum likelihood function is given as follows,
[0163]
[0164] By differentiating the marginal log-likelihood function, we can obtain the optimal value of the hyperparameter:
[0165]
[0166] 3.3.7) Calculate the output weight W out And the optimal value of the weight parameter β:
[0167] According to (11)-(14) and (16)-(17), we can obtain Σ β ,μ β , until convergence. Finally, we get W out The optimal value of The optimal value of β
[0168] 3.3.8) The predicted output is calculated according to formula (19):
[0169]
[0170] 4. Test the trained two-layer sparse Bayesian echo state network
[0171] The test sample data is used as the input of the trained two-layer sparse Bayesian echo state network, and the output of the neural network is the prediction result of effluent ammonia nitrogen. Figure 3 , X-axis: time, unit is sample / day, Y-axis: effluent ammonia nitrogen, unit is mg / L. The two days' broken lines in the figure correspond to the expected effluent ammonia nitrogen concentration and the broken line results of the actual network output effluent ammonia nitrogen predicted concentration (DLSBESN). The most different part of the figure (sample days are 1365-1380) is enlarged and displayed through a small picture.
[0172] The error between the actual output water ammonia nitrogen concentration and the expected output water ammonia nitrogen concentration is as follows: Figure 4 ,X-axis: time, the unit is sample / day, Y-axis: the difference between the network output ammonia nitrogen concentration and the expected effluent ammonia nitrogen concentration, the unit is mg / L, the results prove the effectiveness of this method.
[0173] The present application also provides a system for predicting ammonia nitrogen in sewage treatment effluent based on a neural network, comprising:
[0174] The data processing module is used to obtain water sample data, perform noise reduction, abnormal data elimination, missing data supplementation, and normalization on the water sample data in turn to obtain P groups of training samples, and take the first P1 group of data as training samples and the latter P2 group of data as test samples;
[0175] A variable determination module is used to determine the input variables of the neural network model; wherein the input variables specifically include influent total phosphorus, redox potential, dissolved oxygen concentration, total suspended solids, and pH value;
[0176] The model training module is used to design a neural network model and train the output layer weights of the network using training samples; the neural network is a double-layer sparse Bayesian echo state network, which consists of an input layer, a hidden layer, and an output layer. The topological structure of the network is 5-m-1, the number of neurons in the network input layer is 5, the number of neurons in the network hidden layer is m, and the number of neurons in the output layer is 1; the sigmoid function is used as the activation function of the network hidden node, and the linear function is used as the activation function of the output node;
[0177] The result output module is used to test the trained neural network using the test samples, and the output of the neural network after the test is the prediction result of effluent ammonia nitrogen.
[0178] For the specific limitations of the sewage treatment effluent ammonia nitrogen prediction system, please refer to the limitations of the sewage treatment effluent ammonia nitrogen prediction based on neural network in the above text, which will not be repeated here. Each module in the above sewage treatment effluent ammonia nitrogen prediction system can be implemented in whole or in part by software, hardware and a combination thereof. The above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0179] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0180] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be construed as limiting the scope of the patent application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent application shall be subject to the attached claims.
Claims
1. A method for predicting ammonia nitrogen in sewage treatment effluent based on neural network, characterized in that: The method comprises: Obtain water sample data, perform noise reduction, abnormal data removal, missing data supplementation, and normalization on the water sample data in turn to obtain P groups of training samples, and take the first P1 group of data as training samples and the latter P2 group of data as test samples; Determine the input variables of the neural network model; wherein the input variables specifically include influent total phosphorus, redox potential, dissolved oxygen concentration, total suspended solids, and pH value; Design a neural network model, and use training samples to train the output layer weights of the network; the neural network is a double-layer sparse Bayesian echo state network, which consists of an input layer, a hidden layer, and an output layer. The network topology is 5-m-1, the number of neurons in the network input layer is 5, the number of neurons in the network hidden layer is m, and the number of neurons in the output layer is 1; the network hidden node activation function uses the sigmoid function, and the output node activation function uses the linear function; The trained neural network is tested using the test samples, and the output of the neural network after the test is used as the prediction result of effluent ammonia nitrogen.
2. The method for predicting ammonia nitrogen in sewage treatment effluent according to claim 1, characterized in that: In the normalization of water sample data, according to the formula Normalized, where v i is the measured data set of sewage treatment influent before normalization, max(v i ) is the maximum value in the array, min(v i ) is the minimum value in the array, v i ′ is the corresponding normalized water inlet data value.
3. The method for predicting ammonia nitrogen in sewage treatment effluent according to claim 1, characterized in that: Design a neural network model, including: Determine the input layer neurons, update the hidden layer neuron states, and calculate the output layer output.
4. The method for predicting ammonia nitrogen in sewage treatment effluent according to claim 1, characterized in that: Determine the input layer neurons, according to the formula u i (n)=v i (n) Determine the output of the input layer neuron, where u i (n) is the output of the i-th input layer node at the n-th sample, i = 1, 2, …, 5, and the input vector is u(n) = [u1(n), u2(n), u3(n), u4(n), u5(n)].
5. The method for predicting ammonia nitrogen in sewage treatment effluent according to claim 3, characterized in that: Updating the hidden layer neuron state includes: Randomly generate a sub-reservoir, randomly generate the reserve weight W0 of each sub-reservoir module in the hidden layer according to the given reserve pool size and sparsity with uniform distribution, and adjust W0 by the scaling factor α(W) (0<α(W)<1) and the spectral radius ρ(W0); Generate the input weight matrix W according to uniform distribution in , initialize the reservoir state x of the i-th sub-reservoir module i (0); The input signal u(n) is used to drive the storage pool, and its update formula is: x i (n)=f(W in u i (n)+Wx i (n-1)) Among them, x i (n) is the i-th reservoir vector of the hidden layer, denoted by H i (n)=(u i (n),x i (n)) T (i=1,...,5), in order to overcome the influence of initial transient, from n min Start collecting the internal state matrix H = (H (n min +1),H(2),...,H(P)) T , where H(n)=(H1(1),H2(2),...,H5(P)) T ,P is the number of training samples.
6. The method for predicting ammonia nitrogen in sewage treatment effluent according to claim 3, characterized in that: The calculation output layer output includes: Initializing Hyperparameters and σ 2 ; Calculate the output value of the output layer, the formula is Among them, ε(n) is an independent noise that satisfies the Gaussian distribution, with a mean of 0 and a variance of σ 2 , W out Output weight vector for the reserve pool; output of each submodule of the hidden layer and unknown weight parameter β = (β1, β2, ..., β5) T Related, and record the expected output as T = (t(1), t(2), ..., t(P)) T ; The output formula is written in the form of a matrix, and the likelihood function of the training samples and the prior distribution of the output weights are given, as well as the posterior distribution of the unknown parameters of the double-layer sparse Bayesian echo state network. After calculating the covariance and the mean, the second-class maximum likelihood method is used to calculate the optimal value of the hyperparameters, and the expected output is obtained after calculating the optimal value of the output weights and weight parameters.
7. The method for predicting ammonia nitrogen in sewage treatment effluent according to claim 6, characterized in that: Write the output formula in the form of a matrix, including: Among them, H β =(H(1) T β,H(2) T β,...,H(P) T b) T 。 8. The method for predicting ammonia nitrogen in sewage treatment effluent according to claim 7, characterized in that: The likelihood function of the training samples and the prior distribution of the output weights are given, as well as the posterior distribution of the unknown parameters of the two-layer sparse Bayesian echo state network, including: Give the likelihood function of the training sample and the prior distribution of the output weights in, and They are independent priors; The posterior distribution of the unknown parameters of the two-layer sparse Bayesian echo state network is given as: According to Bayes' rule, the first term on the right side of the equation, 9. The method for predicting ammonia nitrogen in sewage treatment effluent according to claim 8, characterized in that: After calculating the covariance and mean, the optimal value of the hyperparameter is calculated using the second-class maximum likelihood method. After calculating the optimal value of the output weight and weight parameter, the expected output is obtained, including: Calculating covariance Mean in: Calculate hyperparameters using the second-type maximum likelihood method and σ 2 The optimal value of the hyperparameter satisfies The maximum likelihood function is given by: By differentiating the marginal log-likelihood function, we can obtain the optimal value of the hyperparameter: Calculate the output weight W out and the optimal value of the weight parameter β, we can obtain Until convergence, finally get W out The optimal value of The optimal value of β Prediction output based on Calculated, where y new For the prediction results.
10. A system for predicting ammonia nitrogen in sewage treatment effluent based on neural network, characterized in that: The system comprises: The data processing module is used to obtain water sample data, perform noise reduction, abnormal data elimination, missing data supplementation, and normalization on the water sample data in turn to obtain P groups of training samples, and take the first P1 group of data as training samples and the latter P2 group of data as test samples; A variable determination module is used to determine the input variables of the neural network model; wherein the input variables specifically include influent total phosphorus, redox potential, dissolved oxygen concentration, total suspended solids, and pH value; The model training module is used to design a neural network model and train the output layer weights of the network using training samples; the neural network is a double-layer sparse Bayesian echo state network, which consists of an input layer, a hidden layer, and an output layer. The topological structure of the network is 5-m-1, the number of neurons in the network input layer is 5, the number of neurons in the network hidden layer is m, and the number of neurons in the output layer is 1; the sigmoid function is used as the activation function of the network hidden node, and the linear function is used as the activation function of the output node; The result output module is used to test the trained neural network using the test samples, and the output of the neural network after the test is the prediction result of effluent ammonia nitrogen.
Citation Information
Cited By
Pruning double-Q learning echo state network-based effluent ammonia nitrogen concentration prediction method
CN121051680A
