A data recovery and water quality detection method and device based on variational autoencoder

The variational autoencoder network model is used to restore sewage treatment sensor data, which solves the problem of sensor data loss affecting water quality detection and improves the accuracy of detection results and monitoring efficiency.

CN116522086BActive Publication Date: 2024-09-24CHINA THREE GORGES CORPORATION
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202310493139.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-25
Publication Date
2024-09-24
Estimated Expiration
2043-04-25

AI Technical Summary

Technical Problem

The loss of sensor data in existing sewage treatment plants affects the accuracy of water quality detection results, resulting in inefficient monitoring, evaluation and compensation measures.

Method used

A data recovery method based on variational autoencoders is used to obtain sensor data from each link of sewage treatment, build a training data set, establish a variational autoencoder network model, train the data recovery model, and recover lost sensor data, and Combined with water quality classification model for water quality detection.

Benefits of technology

Effectively recover lost sensor data, improve the accuracy of water quality detection and monitoring and evaluation, and reduce manual intervention and operation and maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116522086B
    Figure CN116522086B
Patent Text Reader

Abstract

The present invention discloses a data recovery and water quality detection method and device based on a variational autoencoder. The method comprises: obtaining sensor data of each link of sewage treatment to construct a training data set; establishing a variational autoencoder network model; inputting the training data set into the variational autoencoder network model for training to obtain a data recovery model, and in the process of inputting the training data set into the variational autoencoder network model for training, inactivating each data node of an input layer and a first hidden layer; inputting a first target data set with part of the sensor data lost into the data recovery model to obtain the recovery data corresponding to the first target data set, so that the lost sensor data can be effectively recovered, and based on the recovered data, the production activities of each link can be guided to improve the accuracy of water quality detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of sewage treatment, and in particular to a data recovery and water quality detection method and device based on a variational autoencoder. Background Art

[0002] With the rapid development of social economy, water resources are seriously polluted. The discharge of industrial and agricultural sewage increases year by year. Sewage treatment is related to people's livelihood and is closely related to everyone. The water quality detection technology currently used in sewage treatment plants only relies on the installation of relevant sensors in each link. After the data collector obtains the sensor data, it is directly sent to the monitoring personnel. The monitoring personnel have two main tasks: one is to judge whether the treatment of each link meets the standards based on the sensors in each link. If it does not meet the standards, compensation measures must be taken in time; the second is to evaluate the current water quality output based on the sensor data installed in the final water outlet link.

[0003] However, reduced or damaged sensor sensitivity and partial sensor signal loss are common problems in sewage treatment plants. The loss of sensor data will greatly affect the monitoring and evaluation of the working status of the step and affect the accuracy of the final water quality results. Summary of the invention

[0004] Therefore, the technical problem to be solved by the present invention is to overcome the defect that the loss of existing sensor data affects the accuracy of water quality detection results, thereby providing a data recovery and water quality detection method and device based on variational autoencoder.

[0005] According to a first aspect, an embodiment of the present invention discloses a data recovery method based on a variational autoencoder, the method comprising: obtaining sensor data of each link of sewage treatment to construct a training data set; establishing a variational autoencoder network model; inputting the training data set into the variational autoencoder network model for training to obtain a data recovery model, the variational autoencoder network model comprising an input layer, a first hidden layer, a second hidden layer, a third hidden layer, a fourth hidden layer and an output layer connected in sequence, in the process of inputting the training data set into the variational autoencoder network model for training, in the process of training any batch of data in the data set, each data node of the input layer and the first hidden layer is inactivated; a first target data set with a portion of sensor data lost is input into the data recovery model to obtain recovery data corresponding to the first target data set, and the recovery data contains the lost portion of sensor data.

[0006] Optionally, before inputting the training data set into the variational autoencoder network model for training, the method further includes: normalizing all sensor data in the training data set.

[0007] Optionally, the inputting the training data set into the variational autoencoder network model for training includes: inputting the training data set into the variational autoencoder network model to obtain corresponding predicted recovery data; calculating the loss function corresponding to the variational autoencoder network model based on the predicted recovery data and the actual data corresponding to the inactivation processing in the training data set; judging whether the loss function is less than a preset threshold, if it is greater than the preset threshold, adjusting the parameters of the variational autoencoder network model, and reusing the training data set to train the variational autoencoder network model until the loss function is less than the preset threshold.

[0008] According to the second aspect, an embodiment of the present invention further discloses a method for water quality detection, the method comprising: obtaining a data set corresponding to the water quality of each link of sewage treatment, the data set comprising a grade label corresponding to the water quality after sewage treatment and various parameters of the water quality; inputting the data set into a preset classification model for training to obtain a water quality classification model; inputting a second target data set after recovering the lost sensor data into the water quality classification model to obtain a water quality grade corresponding to the second target data set, the second target data set after recovering the lost sensor data is obtained by the data recovery method based on the variational autoencoder as described in the first aspect or any optional embodiment of the first aspect.

[0009] Optionally, the grade label corresponding to the water quality after sewage treatment is determined by the following steps: obtaining the scores corresponding to various parameters of water quality, adding the weights corresponding to the various parameters of water quality to obtain the total score of the water quality; and determining the grade label of the water quality based on the total score of the water quality.

[0010] Optionally, the method also includes: when the water quality level corresponding to the second target data set is lower than a preset level threshold, calculating the mean and variance of the sensor data corresponding to each sewage treatment link output by the data recovery model at different times; comparing the calculated mean and variance corresponding to each sewage treatment link with a preset reasonable range to determine whether each sewage treatment link is normal.

[0011] According to the third aspect, an embodiment of the present invention also discloses a data recovery device based on a variational autoencoder, the device comprising: a data acquisition module, used to acquire sensor data of each link of sewage treatment and construct a training data set; a model building module, used to establish a variational autoencoder network model; a model training module, used to input the training data set into the variational autoencoder network model for training to obtain a data recovery model, the variational autoencoder network model comprises an input layer, a first hidden layer, a second hidden layer, a third hidden layer, a fourth hidden layer and an output layer connected in sequence, in the process of inputting the training data set into the variational autoencoder network model for training, in the process of training any batch of data in the data set, each data node of the input layer and the first hidden layer is inactivated; a data recovery module, used to input a first target data set with a portion of sensor data lost into the data recovery model, to obtain recovery data corresponding to the first target data set, the recovery data containing the lost portion of sensor data.

[0012] According to the fourth aspect, an embodiment of the present invention further discloses a water quality detection device, which includes: a water quality data acquisition module, which is used to obtain a data set corresponding to the water quality of each link of sewage treatment, and the data set includes a grade label corresponding to the water quality after sewage treatment and various parameters of water quality; a model training module, which is used to input the data set into a preset classification model for training to obtain a water quality classification model; a water quality detection module, which is used to input a second target data set after recovering the lost sensor data into the water quality classification model to obtain the water quality grade corresponding to the second target data set, and the second target data set after recovering the lost sensor data is obtained by the data recovery method based on the variational autoencoder as described in the first aspect or any optional embodiment of the first aspect.

[0013] According to the fifth aspect, an embodiment of the present invention also discloses an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the data recovery method based on the variational autoencoder as described in the first aspect or any optional embodiment of the first aspect, or the steps of the water quality detection method as described in the second aspect or any optional embodiment of the second aspect.

[0014] According to the sixth aspect, an embodiment of the present invention further discloses a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it implements the data recovery method based on the variational autoencoder as described in the first aspect or any optional embodiment of the first aspect, or the steps of the water quality detection method as described in the second aspect or any optional embodiment of the second aspect.

[0015] The technical solution of the present invention has the following advantages:

[0016] The data recovery method based on variational autoencoder provided by the present invention constructs a training data set by acquiring sensor data of each link of sewage treatment; establishes a variational autoencoder network model; inputs the training data set into the variational autoencoder network model for training to obtain a data recovery model, and in the process of inputting the training data set into the variational autoencoder network model for training, inactivates each data node of the input layer and the first hidden layer; inputs a first target data set with part of the sensor data lost into the data recovery model to obtain the recovery data corresponding to the first target data set, so that the lost sensor data can be effectively recovered, and based on the recovered data, the production activities of each link can be guided to improve the accuracy of water quality detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0018] Figure 1 is a flowchart of a specific example of a data recovery method based on a variational autoencoder in an embodiment of the present invention;

[0019] Figure 2 is a specific example diagram of a variational autoencoder network model in an embodiment of the present invention;

[0020] Figure 3 A flowchart of a specific example of a water quality detection method in an embodiment of the present invention;

[0021] Figure 4 is a principle block diagram of a specific example of a data recovery device based on a variational autoencoder in an embodiment of the present invention;

[0022] Figure 5 This is a specific example principle block diagram of a water quality detection device in an embodiment of the present invention;

[0023] Figure 6 FIG. 4 is a specific example diagram of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION

[0024] The technical solution of the present invention will be described clearly and completely below in conjunction with the accompanying drawings. 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.

[0025] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.

[0026] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, it can also be the internal connection of two components, it can be a wireless connection, or it can be a wired connection. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0027] In addition, the technical features involved in the different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.

[0028] The embodiment of the present invention discloses a data recovery method based on a variational autoencoder, such as Figure 1 As shown, the method comprises the following steps:

[0029] Step 101, obtain sensor data of each link of sewage treatment and construct a training data set.

[0030] Exemplarily, the sewage treatment process from sewage to dischargeable water and even to tap water available to residents usually includes a series of start-up, operation, adjustment, stop, and maintenance links such as a regulating tank, a hair collector, a biological contact oxidation tank, a sedimentation tank, an intermediate water tank, a secondary lift pump, a mechanical filter, an activated carbon filter, a backwash pump, and a clean water tank. The corresponding sensors include water flow sensors, pH sensors, water level altimeters, thermometers, oxygen content detectors, residual chlorine analyzers, Bod / Cod meters, nitrogen and ammonia detectors, phosphide detectors, etc. Just as an example, the data collected by the above sensors can be obtained in real time, or the historical data in the sensor database can be directly obtained, and the obtained sensor data can be formed into a one-dimensional vector. For example, the number of sensors involved in the sewage treatment process is 137, that is, 137 corresponding data are obtained, and the dimension of the one-dimensional vector is 137. Just as an example.

[0031] Step 102, establishing a variational autoencoder network model.

[0032] Exemplarily, the variational autoencoder network model VAE can actively generate data that is very similar to the input by extracting and observing the features of the input data and adding a normal distribution. The variational autoencoder network model in the embodiment of the present application consists of an encoder and a decoder. Figure 2 As shown, the encoder part is composed of an input layer, a first hidden layer and a second hidden layer, the decoder part is composed of a third hidden layer, a fourth hidden layer and an output layer, and the decoder part and the encoder part are of a symmetrical structure. In a specific embodiment, the one-dimensional vector 137 obtained above is input into the input layer, and the dimension of the input layer is [137, 1], the dimension of the first hidden layer is [1024, 1], the dimension of the second hidden layer is [256, 1], the dimension of the intermediate encoding result is [10, 1], the dimension of the third hidden layer is [256, 1], the dimension of the fourth hidden layer is [1024, 1], and the dimension of the output layer is [137, 1]. For example only, the embodiment of the present application can use PYTHON and PyTorch to establish a model, for example only.

[0033] Step 103: input the training data set into the variational autoencoder network model for training to obtain a data recovery model.

[0034] Among them, the variational autoencoder network model includes an input layer, a first hidden layer, a second hidden layer, a third hidden layer, a fourth hidden layer and an output layer which are connected in sequence.

[0035] In the process of inputting the training data set into the variational autoencoder network model for training, in the training process of any batch of data in the data set, each data node of the input layer and the first hidden layer is inactivated.

[0036] Exemplarily, there is no limitation on the method of inactivating data nodes. For example, the SpatialDropout method can be used to inactivate random areas of the convolution layer, or the DropBlock method can be used to inactivate blocks one by one. This can be used for inactivation of images. This is just an example and can be determined based on actual conditions. The embodiment itself can use Dropout to discard each data node of the neural network with a probability of P, and retain a probability of 1-P. The discard is implemented by treating the output of the node as zero. Dropout can correct the erroneous information of some neurons, which can effectively alleviate the overfitting problem of the model, play a regularization role, and prevent the co-adaptation between nodes.

[0037] In the embodiment of the present application, when a training data set is input into a variational autoencoder network model for training, for example, the number of samples in the training data set is 300. During each batch of data training, Dropout can be used to randomly discard data nodes at a lower probability in the input layer. At the same time, a probability can be set in the first hidden layer to randomly discard data nodes. The specific probability setting can be determined according to the actual situation. The output data set corresponding to the training data set can be obtained. Multiple batches of training, such as 200 rounds of training, are performed until the model converges, and a data recovery model can be obtained.

[0038] Step 104: input the first target data set with part of the sensor data missing into the data recovery model to obtain the recovery data corresponding to the first target data set.

[0039] The restored data includes the lost sensor data.

[0040] Exemplarily, there is some missing sensor data in the first target data set obtained by the embodiment of the present application. When the first target data set is input into the data recovery model, the data nodes corresponding to the lost sensor data can be set to 0. Since Dropout has conducted a lot of training on the situation where data nodes are missing information during the training process, the information of the current data nodes has little effect on the results of encoding and decoding of the data recovery model. Finally, the result output by the data recovery model decoder, that is, the missing part of the sensor data is effectively recovered, can obtain the recovered data corresponding to the first target data set.

[0041] The data recovery method based on variational autoencoder provided by the present invention constructs a training data set by acquiring sensor data of each link of sewage treatment; establishes a variational autoencoder network model; inputs the training data set into the variational autoencoder network model for training to obtain a data recovery model, and in the process of inputting the training data set into the variational autoencoder network model for training, inactivates each data node of the input layer and the first hidden layer; inputs a first target data set with part of the sensor data lost into the data recovery model to obtain the recovery data corresponding to the first target data set, so that the lost sensor data can be effectively recovered, and based on the recovered data, the production activities of each link can be guided to improve the accuracy of water quality detection.

[0042] As an optional implementation manner of the present invention, before inputting the training data set into the variational autoencoder network model for training, the method further includes: normalizing all sensor data in the training data set.

[0043] For example, the data in the training data set are collected by different sensors. Due to the different ranges of different sensors, the data ranges involved may vary greatly. In the embodiment of the present application, all sensor data in the training data set may be normalized by the following formula to ensure that all sensor data are between [0, 1]:

[0044]

[0045] Among them, x represents a data value of any sensor; x_min represents the minimum value of all data in any sensor; x_max represents the maximum value of all data in any sensor; x_norm represents the normalized data value corresponding to a data value.

[0046] In the embodiment of the present application, professionals can also directly define a sensor value range that conforms to the actual situation for the relevant sensors in each link based on the actual production experience of the water plant, and directly obtain data within the preset range when the sensor collects data. Just as an example, by normalizing the data input to the variational autoencoder network model, the difficulty of model training can be reduced, making the model easier to converge and improving the efficiency of obtaining the data recovery model.

[0047] As an optional implementation of the present invention, the inputting of the training data set into the variational autoencoder network model for training includes: inputting the training data set into the variational autoencoder network model to obtain corresponding predicted recovery data; calculating the loss function corresponding to the variational autoencoder network model based on the predicted recovery data and the actual data corresponding to the inactivation processing in the training data set; judging whether the loss function is less than a preset threshold, if it is greater than the preset threshold, adjusting the parameters of the variational autoencoder network model, and reusing the training data set to train the variational autoencoder network model until the loss function is less than the preset threshold.

[0048] Exemplarily, the loss function is used to measure the inconsistency between the predicted recovery value of the model and the true value, and may include two parts: one is the direct distance measurement between the input and output, which may use the mean square loss; the other is the loss obtained by evaluating that the intermediate encoding result should conform to the normal distribution, which uses the KL divergence between the distribution of the encoding result and the standard Gaussian (zero mean and unit variance). The two parts are added together to obtain the overall loss function.

[0049] In the embodiment of the present application, a training data set is input into a variational autoencoder network model for training, and predicted recovery data corresponding to the training data set can be obtained. The predicted recovery data and the actual data before discarding are calculated to obtain a loss function corresponding to the batch training process, and it is determined whether the loss function obtained in the batch training process is less than a preset threshold, wherein the preset threshold can be determined based on human experience. If the loss function is less than the preset threshold, it means that the training result meets the requirements. If the loss function is greater than the preset threshold, it is necessary to adjust the parameters of the variational autoencoder network model, and reuse the training set to train the variational autoencoder network model until the loss function is less than the preset threshold. As an example only, by calculating the loss function to determine whether the variational autoencoder network model is trained, the accuracy of data recovery by the data recovery model can be improved.

[0050] The present invention also discloses a water quality detection method. Figure 3 As shown, the method includes:

[0051] Step 201, obtaining a data set corresponding to the water quality of each stage of sewage treatment.

[0052] Among them, the data set includes the grade labels corresponding to the water quality after sewage treatment and various water quality parameters.

[0053] Exemplarily, the water quality design parameters of a sewage treatment plant may include total bacteria count, total chlorine in water, chromaticity, turbidity, metal content such as aluminum and copper, reflectivity index and limit values, etc. As an example only, a data set corresponding to the water quality of each link in sewage treatment can be obtained in real time through sensors, where the data set includes various parameters of water quality in each link. The grade label corresponding to the treated water quality can be set to seven grades from 1 to 7, and the water quality grade can be determined by human experience through water quality testing, as an example only.

[0054] As an optional embodiment of the present invention, the grade label corresponding to the water quality after sewage treatment is determined by the following steps: obtaining the scores corresponding to various parameters of water quality, adding the weights corresponding to the various parameters of water quality to obtain the total score of the water quality; based on the total score of the water quality, determining the grade label of the water quality.

[0055] Exemplarily, the grade label corresponding to the water quality determined in the embodiment of the present application can be that the monitoring personnel with rich experience in the water plant assign different weights to each parameter based on the actual situation, and each water quality parameter can be scored accordingly, and the weights corresponding to each water quality parameter can be added together to obtain a total score for the water quality. The total score can be divided into corresponding grades of 1-7, such as determining the corresponding grade based on the score within a certain range, as an example only.

[0056] Step 202: input the data set into a preset classification model for training to obtain a water quality classification model.

[0057] Exemplarily, the preset classification model of the embodiment of the present application can be a multi-layer perceptron network classification model, and ReLU (activation function) can be used as a nonlinear unit to improve the network expression ability, wherein the network structure can be 4 layers, and the dimensions are 137, 1024, 128, and 7, respectively, wherein 7 represents the 7 levels of the final output, wherein the 7 levels are the probabilities of each level corresponding to the input water quality parameters calculated using the Softmax function, wherein the level corresponding to the node with the highest probability is the input water quality level, and the above-obtained data set is input into the preset classification model for training, and it is determined whether the level obtained after the training of the data set is consistent with the pre-determined water quality level. If they are consistent, the training of the preset classification model is terminated to obtain the water quality classification model, and if they are inconsistent, the parameters of the preset classification model can be adjusted, and the training is retrained until the level obtained after the training of the data set is consistent with the pre-determined water quality level. This is just an example.

[0058] Step 203, inputting the second target data set after recovering the lost sensor data into the water quality classification model to obtain the water quality grade corresponding to the second target data set, wherein the second target data set after recovering the lost sensor data is obtained by the data recovery method based on variational autoencoder described in the above embodiment.

[0059] Exemplarily, the embodiment of the present application inputs the second target data set after the lost sensor data is recovered into a trained water quality classification model to obtain the water quality grade corresponding to the second target data set.

[0060] The water quality detection method provided by the present invention obtains a data set corresponding to the water quality of each link of sewage treatment, inputs the data set into a preset classification model for training, obtains a water quality classification model, inputs a second target data set after the lost sensor data is restored into the water quality classification model, obtains the water quality grade corresponding to the second target data set, and can realize automatic 24-hour real-time monitoring of the water quality grade, does not require manual frequent attention to whether various indicators are normal, has low labor costs, and can improve the accuracy of water quality detection.

[0061] As an optional embodiment of the present invention, the method also includes: when the water quality level corresponding to the second target data set is lower than a preset level threshold, the mean and variance of the sensor data corresponding to each sewage treatment link output by the data recovery model at different times are calculated respectively; the calculated mean and variance corresponding to each sewage treatment link are compared with the preset reasonable range respectively to determine whether each sewage treatment link is normal.

[0062] Exemplarily, the embodiment of the present application can pre-set a normal level threshold for water quality treatment based on human experience. After obtaining the water quality level corresponding to the second target data set, it is compared with the preset level threshold. If the output water quality level is lower than the preset level threshold, it indicates that there is a problem in a certain link of the sewage treatment. An alarm can be automatically issued, and the sensor data corresponding to each sewage treatment link output by the data recovery model at different times, such as the sensor data of each link output by the data recovery model 30 times, are calculated for mean and variance. According to the 3σ criterion, it can be assumed that a set of detection data contains random errors, and the standard deviation is calculated and processed to obtain the standard deviation. The reasonable interval of the mean and the reasonable interval of the variance are determined according to a certain probability. If the calculated variance exceeds the reasonable interval or the calculated mean exceeds the reasonable interval, it indicates that the sewage treatment link is abnormal. Each treatment link can be independently controlled, and the problem in which the sewage treatment link has occurred can be quickly found out, so that the operation and maintenance personnel can quickly make adjustments based on the data.

[0063] The embodiment of the present invention also discloses a data recovery device based on a variational autoencoder, such as Figure 4 As shown, the device comprises:

[0064] The data acquisition module 301 is used to acquire sensor data of each link of sewage treatment and construct a training data set;

[0065] A model building module 302 is used to build a variational autoencoder network model;

[0066] A model training module 303 is used to input the training data set into the variational autoencoder network model for training to obtain a data recovery model, wherein the variational autoencoder network model includes an input layer, a first hidden layer, a second hidden layer, a third hidden layer, a fourth hidden layer and an output layer connected in sequence, and in the process of inputting the training data set into the variational autoencoder network model for training, in the process of training any batch of data in the data set, each data node of the input layer and the first hidden layer is inactivated;

[0067] The data recovery module 304 is used to input the first target data set with a portion of sensor data missing into the data recovery model to obtain recovery data corresponding to the first target data set, wherein the recovery data includes the portion of sensor data missing.

[0068] The data recovery device based on variational autoencoder provided by the present invention constructs a training data set by acquiring sensor data of each link of sewage treatment; establishes a variational autoencoder network model; inputs the training data set into the variational autoencoder network model for training to obtain a data recovery model, and in the process of inputting the training data set into the variational autoencoder network model for training, inactivates each data node of the input layer and the first hidden layer; inputs a first target data set with part of the sensor data lost into the data recovery model to obtain the recovery data corresponding to the first target data set, so that the lost sensor data can be effectively recovered, and based on the recovered data, the production activities of each link can be guided to improve the accuracy of water quality detection.

[0069] As an optional implementation of the present invention, the device further includes: a data processing module, configured to normalize all sensor data in the training data set.

[0070] As an optional embodiment of the present invention, the model training module includes: a data recovery submodule, used to input the training data set into the variational autoencoder network model to obtain corresponding predicted recovery data; a loss function calculation submodule, used to calculate the loss function corresponding to the variational autoencoder network model based on the predicted recovery data and the actual data corresponding to the inactivation processing in the training data set; a model adjustment submodule, used to determine whether the loss function is less than a preset threshold. If it is greater than the preset threshold, the parameters of the variational autoencoder network model are adjusted, and the training data set is reused to train the variational autoencoder network model until the loss function is less than the preset threshold.

[0071] The present invention also discloses a water quality detection device, which is characterized in that: Figure 5 As shown, the device comprises:

[0072] The water quality data acquisition module 501 is used to acquire a data set corresponding to the water quality of each stage of sewage treatment, wherein the data set includes a grade label corresponding to the water quality after sewage treatment and various water quality parameters;

[0073] A model training module 502 is used to input the data set into a preset classification model for training to obtain a water quality classification model;

[0074] The water quality detection module 503 is used to input the second target data set after the lost sensor data is restored into the water quality classification model to obtain the water quality grade corresponding to the second target data set, and the second target data set after the lost sensor data is restored is obtained by the data recovery method based on the variational autoencoder described in the above embodiment.

[0075] The water quality detection device provided by the present invention obtains a data set corresponding to the water quality of each link of sewage treatment, inputs the data set into a preset classification model for training, obtains a water quality classification model, inputs a second target data set after recovering the lost sensor data into the water quality classification model, obtains the water quality grade corresponding to the second target data set, and can realize automatic 24-hour real-time monitoring of the water quality grade, does not need manual frequent attention to whether various indicators are normal, has low labor costs, and can improve the accuracy of water quality detection.

[0076] As an optional embodiment of the present invention, the water quality data acquisition module includes: a total score determination submodule, which is used to obtain the scores corresponding to various parameters of water quality, and add the weights corresponding to the various parameters of water quality to obtain the total score of the water quality; a grade determination submodule, which is used to determine the grade label of the water quality based on the total score of the water quality.

[0077] As an optional embodiment of the present invention, the device also includes: a data calculation module, which is used to calculate the mean and variance of the sensor data corresponding to each sewage treatment link output by the data recovery model at different times when the water quality level corresponding to the second target data set is lower than the preset level threshold; a processing link judgment module, which is used to compare the calculated mean and variance corresponding to each sewage treatment link with the preset reasonable range, to determine whether each sewage treatment link is normal.

[0078] The embodiment of the present invention further provides an electronic device, such as Figure 6 As shown, the electronic device may include a processor 401 and a memory 402, wherein the processor 401 and the memory 402 may be connected via a bus or other means. Figure 6 The example of connecting through bus is taken in the following.

[0079] The processor 401 may be a central processing unit (CPU). The processor 401 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination of the above chips.

[0080] The memory 402, as a non-transient computer-readable storage medium, can be used to store non-transient software programs, non-transient computer executable programs and modules, such as program instructions / modules corresponding to the data recovery method based on the variational autoencoder or the water quality detection method in the embodiment of the present invention. The processor 401 executes various functional applications and data processing of the processor by running the non-transient software programs, instructions and modules stored in the memory 402, that is, realizing the data recovery method based on the variational autoencoder or the water quality detection method in the above method embodiment.

[0081] The memory 402 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required by at least one function; the data storage area may store data created by the processor 401, etc. In addition, the memory 402 may include a high-speed random access memory, and may also include a non-transitory memory, such as at least one disk storage device, a flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory 402 may optionally include a memory remotely arranged relative to the processor 401, and these remote memories may be connected to the processor 401 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0082] The one or more modules are stored in the memory 402, and when executed by the processor 401, the following is performed: Figure 1 The data recovery method based on the variational self-encoder in the embodiment shown, or Figure 3 The water quality detection method in the illustrated embodiment.

[0083] For details of the above electronic equipment, please refer to Figure 1 or Figure 3 The corresponding related descriptions and effects in the illustrated embodiments can be understood and will not be repeated here.

[0084] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD), etc.; the storage medium can also include a combination of the above-mentioned types of memory.

[0085] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the defined scope.

Claims

1. A water quality detection method, It is characterized in that The method comprises: Obtain a data set corresponding to the water quality of each link of sewage treatment, the data set including a grade label corresponding to the water quality after sewage treatment and various parameters of water quality, the grade label corresponding to the water quality after sewage treatment is obtained by the following steps: obtaining scores corresponding to various parameters of water quality, adding weights corresponding to various parameters of water quality to obtain a total score of the water quality; determining the grade label of the water quality based on the total score of the water quality; Inputting the data set into a preset classification model for training to obtain a water quality classification model; Inputting the second target data set after the lost sensor data is restored into the water quality classification model to obtain the water quality grade corresponding to the second target data set, wherein the second target data set after the lost sensor data is restored is obtained by inputting the second target data set into the data recovery model, wherein the water quality classification model is a multi-layer perceptron network classification model, and includes a ReLU activation function as a nonlinear unit, and uses a Softmax function to calculate the probability of each grade corresponding to the input water quality parameter, and selects the grade with the highest probability as the water quality grade; The data recovery model is obtained by the following steps: obtaining sensor data of each link of sewage treatment to construct a training data set; establishing a variational autoencoder network model; inputting the training data set into the variational autoencoder network model for training to obtain a data recovery model, wherein the variational autoencoder network model comprises an input layer, a first hidden layer, a second hidden layer, a third hidden layer, a fourth hidden layer and an output layer connected in sequence, and in the process of inputting the training data set into the variational autoencoder network model for training, in the process of training any batch of data in the data set, each data node of the input layer and the first hidden layer is inactivated; When the water quality level corresponding to the second target data set is lower than the preset level threshold, the sensor data corresponding to each sewage treatment link output by the data recovery model at different times are respectively calculated for mean and variance; The calculated mean and variance corresponding to each sewage treatment link are compared with the preset reasonable range to determine whether each sewage treatment link is normal.

2. The method according to claim 1, It is characterized in that Before inputting the training data set into the variational autoencoder network model for training, the method further includes: All sensor data in the training data set are normalized.

3. The method according to claim 1, It is characterized in that The step of inputting the training data set into the variational autoencoder network model for training comprises: Inputting the training data set into the variational autoencoder network model to obtain corresponding predicted recovery data; Calculating a loss function corresponding to the variational autoencoder network model based on the predicted restored data and the actual data corresponding to the inactivation process in the training data set; Determine whether the loss function is less than a preset threshold. If it is greater than the preset threshold, adjust the parameters of the variational autoencoder network model, and re-train the variational autoencoder network model using the training data set until the loss function is less than the preset threshold.

4. A water quality detection device, It is characterized in that The device comprises: The water quality data acquisition module is used to obtain a data set corresponding to the water quality of each link of sewage treatment, wherein the data set includes a grade label corresponding to the water quality after sewage treatment and various parameters of water quality. The grade label corresponding to the water quality after sewage treatment is obtained by the following steps: obtaining scores corresponding to various parameters of water quality, adding weights corresponding to various parameters of water quality to obtain a total score of the water quality; and determining the grade label of the water quality based on the total score of the water quality; A model training module is used to input the data set into a preset classification model for training to obtain a water quality classification model; A water quality detection module, used for inputting a second target data set after recovering the lost sensor data into the water quality classification model to obtain a water quality grade corresponding to the second target data set, wherein the second target data set after recovering the lost sensor data is obtained by inputting the second target data set into the data recovery model, and the water quality classification model is a multi-layer perceptron network classification model, and includes a ReLU activation function as a nonlinear unit, and uses a Softmax function to calculate the probability of each grade corresponding to the input water quality parameter, and selects the grade with the highest probability as the water quality grade; The data recovery model is obtained by the following steps: obtaining sensor data of each link of sewage treatment to construct a training data set; establishing a variational autoencoder network model; inputting the training data set into the variational autoencoder network model for training to obtain a data recovery model, wherein the variational autoencoder network model comprises an input layer, a first hidden layer, a second hidden layer, a third hidden layer, a fourth hidden layer and an output layer connected in sequence, and in the process of inputting the training data set into the variational autoencoder network model for training, in the process of training any batch of data in the data set, each data node of the input layer and the first hidden layer is inactivated; A data calculation module, used for calculating the mean and variance of the sensor data corresponding to each sewage treatment link output by the data recovery model at different times when the water quality level corresponding to the second target data set is lower than a preset level threshold; The processing link judgment module is used to compare the calculated mean and variance corresponding to each sewage treatment link with the preset reasonable range to determine whether each sewage treatment link is normal.

5. An electronic device, It is characterized in that include: at least one processor; And a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor performs the steps of the water quality detection method as described in any one of claims 1-3.

6. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the water quality detection method according to any one of claims 1 to 3 are implemented.

Citation Information

Patent Citations

  • Method for diagnosing abnormal quality of sewage discharged by steam generator in nuclear power plant

    CN111157694A

  • Water pollution alarm grade identification method based on artificial intelligence

    CN112101789A

  • Ship abnormal track data detection method and device based on variational auto-encoder

    CN112395382A

  • Sewage treatment water quality prediction method based on simple circulation unit neural network

    CN112735541A

  • Sewage quality prediction method based on optimized LSTM neural network

    CN112884056A