Water Quality Monitoring Method Based on BP Neural Network
Through the water quality monitoring method based on BP neural network, the problem that traditional water quality monitoring relies on manual labor, low efficiency and inability to achieve real-time monitoring is solved, and intelligent real-time monitoring and high-precision identification of water quality are realized.
Patent Information
- Application Number
- CN202210801133.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-08
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2042-07-08
AI Technical Summary
In the prior art, water quality monitoring mainly relies on manual sampling and analysis, and there are problems such as high cost, low efficiency, prone to errors and inability to achieve real-time monitoring.
The water quality monitoring method based on BP neural network is adopted to collect water quality sample data, perform feature extraction and labeling, and train the BP neural network model, thereby achieving rapid and accurate evaluation of real-time water quality data.
It realizes intelligent real-time monitoring of water quality, reduces manual consumption, improves water quality recognition accuracy, and has strong anti-interference ability.
Smart Images

Figure CN115184352B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of water quality monitoring, and in particular to a water quality monitoring method based on BP neural network. Background Art
[0002] With the continuous development of the water economy, waters have been increasingly polluted, such as the water has become smelly, rivers have become turbid, and garbage is floating everywhere on the water surface. Both transportation and navigation and water supply have been faced with unprecedented challenges.
[0003] At present, water quality monitoring is mainly carried out by manual water sampling and water quality analysis. The traditional manual monitoring method is not only costly and prone to manual safety issues, but also has low operating efficiency and is more likely to cause water quality analysis errors. At the same time, it is also unable to respond to the needs of real-time water quality monitoring and analysis in a timely manner.
[0004] Therefore, in order to solve the above problems, a water quality monitoring method based on BP neural network is needed, which can realize unmanned measurement and meet the real-time monitoring of water quality. Summary of the invention
[0005] In view of this, the purpose of the present invention is to overcome the defects in the prior art and provide a water quality monitoring method based on BP neural network, which can realize intelligent real-time monitoring of water quality, has strong anti-interference ability and good monitoring effect.
[0006] The water quality monitoring method based on BP neural network of the present invention comprises the following steps:
[0007] S1. Collect water quality sample data;
[0008] S2. Feature-mark the water quality sample data to obtain marked sample data;
[0009] S3. Input the labeled sample data into the BP neural network model for network model training to obtain a trained neural network model;
[0010] S4. Collect real-time water quality data, input the real-time water quality data into the trained neural network model, and output the water quality assessment results.
[0011] Further, the step S2 specifically includes:
[0012] S21. Extracting features from the water quality sample data to obtain characteristic information of the water quality; wherein the characteristic information includes water color and floating object density;
[0013] S22. Use the characteristic information as a marking element to perform characteristic marking on the water quality sample data to obtain marked sample data.
[0014] Furthermore, feature extraction is performed on the water quality sample data, including:
[0015] S211. Perform preliminary feature extraction on the water quality sample data to obtain sample data after preliminary extraction;
[0016] S212. Perform feature extraction again on the sample data after preliminary extraction to obtain re-extracted sample data.
[0017] Furthermore, preliminary feature extraction is performed on the water quality sample data, including:
[0018] The image retrieval method based on multi-feature fusion performs preliminary feature extraction on water quality sample data; wherein, the image retrieval method based on multi-feature fusion includes an extraction method based on color features and a feature extraction method based on spatial relationships.
[0019] Furthermore, feature extraction is performed again on the sample data after preliminary extraction, specifically including:
[0020] S2121. Taking the feature points in the sample data after preliminary extraction as target points, and connecting the adjacent target points to form a target graph;
[0021] S2122. Determine the weights between target points;
[0022] S2123. Calculate the eigenvectors and eigenvalues of the Laplacian matrix of the target graph, and use the eigenvectors corresponding to the m non-zero eigenvalues as the result after dimensionality reduction; wherein the m non-zero eigenvalues are the first m values of the non-zero eigenvalues arranged in ascending order.
[0023] Furthermore, the labeled sample data is input into the BP neural network model for network model training, which specifically includes:
[0024] S31. Initialize BP neural network model;
[0025] S32. Divide the labeled sample data into a sample training set and a sample verification set according to a set ratio;
[0026] S33. Input the sample training set into the BP neural network model for network model training to obtain a trained neural network model;
[0027] S34. Input the sample verification set into the trained neural network model and output the sample prediction value;
[0028] S35. Determine whether the error between the sample prediction value and the sample true value is within the preset range. If so, stop the training of the neural network model; if not, use the error between the sample prediction value and the sample true value as the feedback result, and adjust the parameters of the trained neural network model according to the feedback result to obtain the adjusted neural network model, return to execute step S33, and perform network model training on the adjusted neural network model.
[0029] Furthermore, the step S35 also includes: first determining whether the number of training times of the network model exceeds a preset value, and if so, stopping the training of the neural network model; if not, determining whether the error between the sample prediction value and the sample true value is within a preset range.
[0030] Furthermore, the parameters include a weight matrix and a bias coefficient.
[0031] Furthermore, the step S31 specifically includes: determining initial parameters, and assigning values to the initial parameters to obtain initialization parameters; and constructing a BP neural network model according to the initialization parameters.
[0032] Furthermore, the initial parameters include the number of hidden layers, the number of neurons in each hidden layer, an activation function, a learning rate, and a loss function.
[0033] The beneficial effects of the present invention are as follows: the present invention discloses a water quality monitoring method based on a BP neural network, which trains a BP neural network model by collecting sample data, thereby obtaining a trained neural network model, and inputs real-time water quality data into the trained neural network model to quickly and accurately output water quality conditions, thereby achieving effective identification of the water quality status; the monitoring method of the present invention realizes intelligent water quality monitoring, greatly reduces labor consumption, and improves water quality identification accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] The present invention will be further described below in conjunction with the accompanying drawings and embodiments:
[0035] Figure 1 It is a schematic diagram of the method flow of the present invention;
[0036] Figure 2 It is a schematic diagram of the BP neural network model of the present invention. DETAILED DESCRIPTION
[0037] The present invention is further described below in conjunction with the accompanying drawings, as shown in the drawings:
[0038] The water quality monitoring method based on BP neural network of the present invention comprises the following steps:
[0039] S1. Collecting water quality sample data; wherein, a high-definition camera is used to collect video information of the target water area, and the video information is segmented frame by frame to obtain a number of images arranged in chronological order, and the several images constitute the water quality sample data.
[0040] S2. Feature-marking the water quality sample data to obtain the marked sample data; feature-marking the water quality sample data facilitates the training of the BP neural network model and improves the prediction accuracy of the BP neural network model;
[0041] S3. Input the labeled sample data into the BP neural network model for network model training to obtain a trained neural network model;
[0042] S4. Collect real-time water quality data, input the real-time water quality data into the trained neural network model, and output the water quality assessment results. According to the water quality assessment results, the water quality status can be warned in real time, thereby improving the quality management of the water quality environment.
[0043] The present invention introduces neural network technology into water quality monitoring, and identifies the complex nonlinear mapping relationship between influencing factors and water quality indicators through self-learning of samples, which can improve the accuracy and practicality of water quality prediction. Compared with conventional water quality monitoring, water quality monitoring with the introduction of neural networks can comprehensively consider various factors affecting water quality indicators, overcome the difficulties of basis function selection and coefficient solution in linear and nonlinear fitting through multiple compounding of simple nonlinear functions, and can perform advanced nonlinear precise mapping, with strong adaptive ability.
[0044] In this embodiment, the step S2 specifically includes:
[0045] S21. Extract features from water quality sample data to obtain characteristic information of water quality; wherein the characteristic information includes water color and floating object density; the floating object density is the number of floating objects per unit area;
[0046] S22. Using the characteristic information as a marking element to perform characteristic marking on the water quality sample data to obtain marked sample data. The characteristic marking adopts the existing image marking technology, which will not be described in detail here.
[0047] In this embodiment, feature extraction is performed on water quality sample data, specifically including:
[0048] S211. Perform preliminary feature extraction on the water quality sample data to obtain sample data after preliminary extraction; through preliminary feature extraction, preliminary screening of useful information in the water quality sample image is achieved to prepare data for subsequent feature extraction again.
[0049] S212. Perform feature extraction again on the sample data after preliminary extraction to obtain sample data after re-extraction. After preliminary feature extraction, the dimension of the image feature may still be relatively large, and it may also contain some irrelevant or redundant features; re-feature extraction can effectively reduce the dimension of the feature space and eliminate the possible correlation between features, thereby reducing useless information in the features.
[0050] In this embodiment, preliminary feature extraction is performed on the water quality sample data, specifically including:
[0051] The image retrieval method based on multi-feature fusion performs preliminary feature extraction on water quality sample data; wherein, the image retrieval method based on multi-feature fusion includes an extraction method based on color features and a feature extraction method based on spatial relationships. The color feature is a global feature that describes the surface properties of the scene corresponding to the image or image area; wherein, the extraction method based on color features can use existing color correlation graphs or color moments, etc., and the feature extraction method based on spatial relationships: the image can be automatically segmented first to divide the objects or color areas contained in the image, and then the image features can be extracted based on these areas and an index can be established.
[0052] In this embodiment, feature extraction is performed again on the sample data after preliminary extraction, specifically including:
[0053] S2121. The feature points in the sample data after preliminary extraction are taken as target points, and adjacent target points are connected to form a target graph; wherein the KNN algorithm can be used to connect the K target points closest to each target point; wherein K is a preset value;
[0054] S2122. Determine the weight between the target points; wherein, if there is an edge between the two target points, the weight may be 1, and if there is no edge between the two target points, the weight may be 0;
[0055] S2123. Calculate the eigenvectors and eigenvalues of the Laplacian matrix of the target graph, and use the eigenvectors corresponding to the m non-zero eigenvalues as the result after dimensionality reduction; wherein the m non-zero eigenvalues are the first m values of the non-zero eigenvalues arranged from small to large. The Laplacian matrix of the target graph can be determined using a graph-based dimensionality reduction algorithm, and the eigenvectors and eigenvalues of the matrix can be calculated;
[0056] Through the above method, target points that are related to each other are made as close as possible in the space after dimensionality reduction, so that the original data structure can still be maintained after dimensionality reduction.
[0057] In this embodiment, the labeled sample data is input into the BP neural network model for network model training, which specifically includes:
[0058] S31. Initialize BP neural network model;
[0059] S32. Divide the labeled sample data into a sample training set and a sample verification set according to a set ratio; wherein the set ratio can be set according to the actual working conditions; generally, the sample training set has more data than the sample verification set; the sample training set is used to train the BP neural network model, and the sample verification set is used to verify the trained neural network model;
[0060] S33. Input the sample training set into the BP neural network model for network model training to obtain a trained neural network model;
[0061] S34. Input the sample verification set into the trained neural network model and output the sample prediction value;
[0062] S35. Determine whether the error between the sample prediction value and the sample true value is within the preset range. If so, stop training the neural network model; if not, use the error between the sample prediction value and the sample true value as feedback, and adjust the parameters of the trained neural network model according to the feedback result to obtain the adjusted neural network model, return to step S33, and perform network model training on the adjusted neural network model. The preset range can be set according to the actual working conditions; the parameters include weight matrix and bias coefficient.
[0063] By returning to execute step S33, iterative training is performed on the neural network model whose output value does not achieve the expected effect, so that the trained neural network model can meet the expected requirements.
[0064] In this embodiment, the step S31 specifically includes: determining initial parameters and assigning values to the initial parameters to obtain initialization parameters; and constructing a BP neural network model according to the initialization parameters. The initial parameters include the number of hidden layers, the number of neurons in each hidden layer, the activation function, the learning rate, and the loss function.
[0065] In this embodiment, the step S35 further includes: first determining whether the number of training times of the network model exceeds a preset value, if so, stopping the training of the neural network model; if not, determining whether the error between the sample prediction value and the sample true value is within a preset range. The preset value may be any value from 1000 to 10000; after multiple iterations of training, the neural network model will gradually approach the expected effect; considering that after multiple iterations, the output effect of the neural network model may not change significantly, by setting the preset value of the number of training times, meaningless iterative training in the later stage is avoided, thereby reducing the computing consumption.
[0066] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the purpose and scope of the technical solution of the present invention, which should be included in the scope of the claims of the present invention.
Claims
1. A water quality monitoring method based on BP neural network, characterized in that: The steps include: S1. Collect water quality sample data; S2. Feature-mark the water quality sample data to obtain marked sample data; The step S2 specifically includes: S21. Extracting features from the water quality sample data to obtain characteristic information of the water quality; wherein the characteristic information includes water color and floating object density; S22. Using the characteristic information as a marking element to feature-mark the water quality sample data to obtain marked sample data; Feature extraction of water quality sample data, including: S211. Perform preliminary feature extraction on the water quality sample data to obtain sample data after preliminary extraction; S212. Perform feature extraction again on the sample data after preliminary extraction to obtain the sample data after re-extraction; Perform preliminary feature extraction on water quality sample data, including: The image retrieval method based on multi-feature fusion performs preliminary feature extraction on the water quality sample data; wherein the image retrieval method based on multi-feature fusion includes a feature extraction method based on color features and a feature extraction method based on spatial relationships; The sample data after preliminary extraction is subjected to feature extraction again, including: S2121. Taking the feature points in the sample data after preliminary extraction as target points, and connecting the adjacent target points to form a target graph; S2122. Determine the weights between target points; S2123. Calculate the eigenvectors and eigenvalues of the Laplacian matrix of the target graph, and use the eigenvectors corresponding to the m non-zero eigenvalues as the result after dimensionality reduction; wherein the m non-zero eigenvalues are the first m values of the non-zero eigenvalues arranged in ascending order; S3. Input the labeled sample data into the BP neural network model for network model training to obtain a trained neural network model; S4. Collect real-time water quality data, input the real-time water quality data into the trained neural network model, and output the water quality assessment results.
2. The water quality monitoring method based on BP neural network according to claim 1 is characterized in that: The labeled sample data is input into the BP neural network model for network model training, which specifically includes: S31. Initialize BP neural network model; S32. Divide the labeled sample data into a sample training set and a sample verification set according to a set ratio; S33. Input the sample training set into the BP neural network model for network model training to obtain a trained neural network model; S34. Input the sample verification set into the trained neural network model and output the sample prediction value; S35. Determine whether the error between the sample prediction value and the sample true value is within the preset range. If so, stop the training of the neural network model; if not, use the error between the sample prediction value and the sample true value as the feedback result, and adjust the parameters of the trained neural network model according to the feedback result to obtain the adjusted neural network model, return to execute step S33, and perform network model training on the adjusted neural network model.
3. The water quality monitoring method based on BP neural network according to claim 2 is characterized in that: The step S35 also includes: first determining whether the number of training times of the network model exceeds a preset value, and if so, stopping the training of the neural network model; if not, determining whether the error between the sample prediction value and the sample true value is within a preset range.
4. The water quality monitoring method based on BP neural network according to claim 2 is characterized in that: The parameters include a weight matrix and a bias coefficient.
5. The water quality monitoring method based on BP neural network according to claim 2 is characterized in that: The step S31 specifically includes: determining initial parameters, and assigning values to the initial parameters to obtain initialization parameters; and constructing a BP neural network model according to the initialization parameters.
6. The water quality monitoring method based on BP neural network according to claim 5 is characterized in that: The initial parameters include the number of hidden layers, the number of neurons in each hidden layer, the activation function, the learning rate and the loss function.
Citation Information
Patent Citations
Earth surface water quality prediction method based on deep learning
CN112529234A