A chemical oxygen demand prediction model training method and a chemical oxygen demand determination method
By dividing the water body into grids according to water depth and using submersibles to collect data to construct a chemical oxygen demand (COD) prediction model, the problems of insufficient data representativeness and mismatch between spectral and physicochemical data in traditional monitoring methods are solved, and high-precision COD prediction and real-time monitoring are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-09
- Publication Date
- 2026-06-23
AI Technical Summary
Traditional monitoring of chemical oxygen demand (COD) in water bodies suffers from problems such as unreasonable site layout, insufficient data representativeness, and spatiotemporal mismatch between spectral and physicochemical data, leading to low prediction accuracy.
By defining a vertical monitoring profile within the area to be measured and dividing it into grids according to relative water depth, and using a submersible to collect spectral and physicochemical data, a spatial attention dual-branch deep ensemble network is constructed to train a chemical oxygen demand (COD) prediction model, thereby achieving deep coupling and feature extraction of spectral and physicochemical characteristics.
It achieves high-precision, real-time prediction of chemical oxygen demand, solves the problem of inaccurate prediction caused by poor data representativeness and non-standard model training samples, and improves the efficiency of water quality monitoring and the reliability of prediction results.
Smart Images

Figure CN122266539A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of water quality monitoring technology, specifically to a method for training a chemical oxygen demand (COD) prediction model and a method for measuring COD. Background Technology
[0002] With the acceleration of urbanization and industrialization, the problem of organic pollution in water bodies is becoming increasingly prominent. Chemical oxygen demand (COD) is a key indicator for measuring the degree of organic pollution in water bodies. Traditional COD detection mainly relies on laboratory chemical analysis methods. Although this method has high accuracy, it has many problems. First, the sampling cycle is long, requiring manual collection of water samples and their return to the laboratory for analysis, making it impossible to obtain water quality information in real time. Second, the cost is high, involving expenses for sampling equipment, reagents, and labor. Third, the spatial coverage is limited, making it difficult to comprehensively monitor large areas of water.
[0003] In recent years, remote sensing technology has been used for large-scale water quality parameter inversion. COD inversion research based on satellites (such as Sentinel-2 and Landsat 8) or UAV platforms has made some progress. However, existing remote sensing methods have the following significant limitations: 1) Lack of vertical information; satellites / UAVs can only acquire information about the water surface or near-surface layer (usually <1). 1) Optical signals are difficult to reflect the vertical heterogeneity inside deep lakes, reservoirs and other water bodies, resulting in severely limited inversion accuracy in complex three-dimensional water environments; 2) Data processing is cumbersome. Traditional methods require converting the original digital values (DN values) into water reflectance and then selecting characteristic bands through correlation analysis, band ratios and other means. The process is lengthy and prone to introducing errors; 3) Insufficient model capabilities. Existing inversion models mostly use single spectral inputs (such as PLSR, SVM or simple CNN), which do not fully integrate the physicochemical background information of the water body. It is difficult to effectively model high-dimensional nonlinear spectrum-water quality relationships and has poor spatial adaptability; 4) Lack of systematic sampling support. There is a lack of three-dimensional and spatiotemporal collaborative sampling strategies for the three-dimensional structure of water bodies, making it difficult to construct a representative training dataset. Summary of the Invention
[0004] This invention provides a method for training a chemical oxygen demand (COD) prediction model and a method for measuring COD, in order to solve the problems of low prediction accuracy caused by unreasonable site layout, insufficient data representativeness, and spatiotemporal mismatch between spectral and physicochemical data in traditional water COD monitoring.
[0005] In a first aspect, the present invention provides a method for training a chemical oxygen demand (COD) prediction model, the method comprising: Based on the hydrological data of the area to be measured, multiple vertical monitoring profiles are determined within the area, and these profiles are divided into multiple grids. Multiple monitoring locations are then determined based on these grids, with the vertical length of each grid determined according to the relative water depth of the vertical monitoring profile. A submersible is used to sample at each monitoring location, obtaining raw datasets for each location. These raw datasets include spectral data, physicochemical data, and the true value of chemical oxygen demand (COD). Training samples are constructed based on these raw datasets, and a spatial attention-based bi-branch deep ensemble network is trained using these samples to obtain a COD prediction model. This model is used to predict COD based on the spectral and physicochemical data within the area to be measured.
[0006] The chemical oxygen demand (COD) prediction model training method provided by this invention determines the vertical monitoring profile based on the hydrological data of the area to be measured, divides the grid according to the relative water depth, and determines the monitoring location. This ensures that the monitoring points uniformly cover different vertical levels of the water body, avoiding data deviation caused by one-sided deployment of monitoring points, and ensuring that the sampled data can comprehensively reflect the overall water quality characteristics of the area to be measured. Furthermore, by using a submersible to simultaneously sample at each monitoring location, it ensures that the spectral data, physicochemical data, and true COD values are strictly correlated in time and space, solving the problems of misalignment and low matching degree of different data sources in traditional sampling, and providing real and reliable basic data for the construction of training samples. Furthermore, based on the original dataset, matching training samples are constructed and a spatial attention dual-branch deep ensemble network is trained, enabling the network to accurately learn the intrinsic correlation between the spectral characteristics, physicochemical characteristics, and COD of the water body. This results in a high-precision COD prediction model that can adapt to the water quality characteristics of the area to be measured, effectively solving the problems of poor data representativeness and inaccurate prediction caused by non-standard model training samples in traditional COD prediction methods.
[0007] In one optional implementation, the spatial attention dual-branch deep integrated network includes a spectral branch layer, a physicochemical branch layer, a channel-space dual attention fusion layer, and a chemical oxygen demand prediction output layer. The spectral branch layer uses a one-dimensional convolutional neural network to extract local texture and fine spectral features from the preprocessed spectral data, outputting a fixed-dimensional spectral feature vector. The physicochemical branch layer uses a fully connected neural network to extract water quality correlation features from the preprocessed physicochemical data, outputting a fixed-dimensional physicochemical embedding vector. The channel-spatial dual attention fusion layer performs physicochemical-guided cross-modal gating fusion and channel-spatial dual attention weighting on the spectral feature vector and physicochemical embedding vector, outputting a deeply coupled fused feature vector. The chemical oxygen demand (COD) prediction output layer performs global feature aggregation and nonlinear mapping on the fused feature vector, outputting the predicted COD value.
[0008] The chemical oxygen demand (COD) prediction model training method provided by this invention adopts a dual-branch network structure consisting of a spectral branch layer, a physicochemical branch layer, a channel-space dual attention fusion layer, and a COD prediction output layer. This structure can perform dedicated feature extraction using adapted networks for one-dimensional spectral data and multi-dimensional physicochemical data, avoiding mutual interference between features of different modalities. Furthermore, it achieves deep coupling of the two types of features through physicochemical-guided cross-modal gating fusion and channel-space dual attention weighting, strengthening effective features related to COD and suppressing redundant information. Finally, it completes the prediction output through global feature aggregation and nonlinear mapping. This method not only improves the targeting and completeness of feature extraction but also enhances the effectiveness of feature fusion, thereby significantly improving the accuracy and robustness of COD prediction.
[0009] In one optional implementation, the channel-space dual attention fusion layer includes a physicochemically guided cross-modal gating fusion unit, a feature splicing unit, and a channel-space dual attention weighting unit; The physicochemical-guided cross-modal gating fusion unit is used to transform the physicochemical embedding vector into a dynamic gating signal using a fully connected neural network. The dynamic gating signal is then multiplied element-wise with the spectral feature vector to obtain the physicochemical-perceived spectral features. The feature splicing unit is used to splice the physicochemical-perceived spectral features and the physicochemical embedding vector in the channel dimension and reshape them to obtain a two-dimensional tensor. The channel-space dual attention weighting unit is used to perform dual feature weighting on the two-dimensional tensor in both the channel dimension and the spatial dimension, and output a deeply coupled fusion feature vector.
[0010] The chemical oxygen demand (COD) prediction model training method provided by this invention, by setting up a physicochemical-guided cross-modal gating fusion unit, a feature splicing unit, and a channel-space dual attention weighting unit, can use physicochemical embedding vectors to generate dynamic gating signals to adaptively calibrate spectral features, making the spectral information more consistent with the actual physicochemical environment of the water body. Then, the two types of features are spliced in the channel dimension and normalized into a two-dimensional tensor, providing a unified and regular input for dual attention weighting. Finally, key features are strengthened and interference information is suppressed in both the channel and spatial dimensions, respectively, to achieve deep coupling of spectral and physicochemical features, further improving the characterization ability of the fused features and providing a more reliable feature basis for subsequent accurate prediction of COD.
[0011] In one optional implementation, training samples are constructed based on the original datasets from each monitoring location, including: Preprocessed spectral and physicochemical data from the same monitoring location and time in the original dataset are used as input feature values for the samples, and the true value of chemical oxygen demand is used as the label value for the samples. The input feature values and label values are matched to obtain multiple sets of samples. The multiple sets of samples are divided into training set and validation set according to a preset ratio to form the sample set for model training.
[0012] The chemical oxygen demand (COD) prediction model training method provided by this invention constructs samples by matching spectral data, physicochemical data, and COD true values from the same monitoring location and time. This ensures that the input features and labels strictly correspond in time and space, avoiding model learning bias caused by sample distortion. Dividing the training set and validation set according to a preset ratio can effectively supervise the training process, prevent overfitting, and improve the model's generalization ability. Finally, a standardized sample set is formed, providing data support for the stable training and accurate prediction of the COD prediction model.
[0013] In one optional implementation, the physicochemical data includes water depth, temperature, turbidity, chlorophyll a concentration, and colored soluble organic matter concentration in the area to be measured. Preprocessing of the physicochemical data includes: Logarithmic transformations were performed on turbidity, chlorophyll a concentration, and colored soluble organic matter concentration to obtain the logarithmically transformed physicochemical characteristics of each parameter. The water depth, temperature, and the logarithmically transformed characteristics of each parameter were standardized to obtain pre-processed physicochemical data.
[0014] The chemical oxygen demand (COD) prediction model training method provided by this invention can compress the influence of high-value outliers by performing logarithmic transformation on turbidity, chlorophyll a concentration, and colored soluble organic matter concentration, making the distribution of parameters of different magnitudes more uniform. Furthermore, by standardizing the water depth, temperature, and logarithmically transformed features, the dimensional differences and numerical range differences between various physicochemical parameters can be eliminated, avoiding the problems of unstable model training and unbalanced feature weights caused by large differences in parameter numerical ranges, thereby improving the efficiency of subsequent network feature extraction and model convergence.
[0015] Secondly, the present invention provides a method for determining chemical oxygen demand, the method comprising: Based on the hydrological data of the area to be measured, multiple vertical monitoring profiles are determined within the area, and these profiles are divided into multiple grids. Multiple monitoring locations are determined based on these grids, with the vertical length of each grid determined according to the relative water depth of the vertical monitoring profile. A submersible is used to sample at each monitoring location to obtain spectral and physicochemical data. The spectral and physicochemical data are then input into a chemical oxygen demand (COD) prediction model to obtain predicted COD values. The COD prediction model is trained using the COD prediction model training method of the first aspect or any corresponding implementation thereof.
[0016] The chemical oxygen demand (COD) measurement method provided by this invention, by dividing the water body into vertical grids according to relative water depth and setting up monitoring positions, can comprehensively and uniformly acquire water quality information at different depths, avoiding the bias of monitoring; by using a submersible to collect spectral and physicochemical data in situ and simultaneously, it ensures the spatiotemporal consistency of the data and reduces the errors and lags caused by manual sampling; and then inputting the data into a trained COD prediction model for rapid inference, it can achieve efficient, real-time, and accurate measurement of COD in the area to be measured, greatly improving the efficiency of water quality monitoring, while ensuring the reliability and stability of the prediction results.
[0017] Thirdly, the present invention provides a chemical oxygen demand (COD) measuring device, the device comprising: The monitoring location determination module is used to determine multiple vertical monitoring profiles within the area to be monitored based on the hydrological data of the area to be monitored, and to divide the vertical monitoring profiles into multiple grids. Multiple monitoring locations are determined based on the grids, and the vertical length of the grid is determined based on the relative water depth of the vertical monitoring profile. The sampling module is used to take samples at the monitoring location using the submersible to obtain spectral and physicochemical data for each monitoring location; The chemical oxygen demand (COD) measurement module is used to input spectral and physicochemical data into the COD prediction model to obtain the predicted COD value.
[0018] Fourthly, the present invention provides an electronic device, comprising: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the computer instructions to perform the chemical oxygen demand prediction model training method of the first aspect or any corresponding embodiment thereof, or to perform the chemical oxygen demand measurement method of the second aspect.
[0019] Fifthly, the present invention provides a computer-readable storage medium storing computer instructions, which are used to cause a computer to execute the chemical oxygen demand prediction model training method of the first aspect or any corresponding embodiment thereof, or to execute the chemical oxygen demand measurement method of the second aspect.
[0020] In a sixth aspect, the present invention provides a computer program product, including computer instructions, which are used to cause a computer to execute the chemical oxygen demand prediction model training method of the first aspect or any corresponding embodiment thereof, or to execute the chemical oxygen demand measurement method of the second aspect. Attached Figure Description
[0021] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0022] Figure 1 This is a schematic diagram of an application scenario according to an embodiment of the present invention; Figure 2 This is a flowchart illustrating the chemical oxygen demand prediction model training method according to an embodiment of the present invention. Figure 3 This is a schematic diagram showing the specific monitoring locations; Figure 4 This is a schematic flowchart of a method for determining chemical oxygen demand according to an embodiment of the present invention; Figure 5 This is a structural block diagram of a chemical oxygen demand (COD) measuring device according to an embodiment of the present invention; Figure 6 This is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the present invention. Detailed Implementation
[0023] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0024] It is understood that before using the technical solutions disclosed in the various embodiments of the present invention, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in the present invention and their authorization should be obtained in accordance with relevant laws and regulations through appropriate means.
[0025] As an optional application scenario of this invention, the specific application environment architecture or specific hardware architecture on which the execution of the chemical oxygen demand prediction model training method depends is described herein. For example... Figure 1 As shown, the architecture system may include at least one terminal device and at least one server. Figure 1 The system is illustrated in the example, which includes a computer 101, a mobile terminal 102, and a server 103, and the terminal devices such as the computer 101 and the mobile terminal 102 are connected to the server 103 through a network 110.
[0026] Specifically, the terminal device can be a smartphone, tablet, laptop, PDA, desktop computer, game console, smart TV, smart wearable device, in-vehicle terminal, VR (Virtual Reality) device, AR (Augmented Reality) device, etc. Server 103 can be a standalone physical server, a server cluster, a distributed system, or a cloud server providing cloud services. Network 110 can be a wired or wireless network, examples of which include, but are not limited to, the Internet, corporate intranet, local area network, wide area network, mobile communication network, and combinations thereof.
[0027] According to an embodiment of the present invention, a method for training a chemical oxygen demand (COD) prediction model is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0028] This embodiment provides a method for training a chemical oxygen demand (COD) prediction model, which can be used on the aforementioned mobile terminals, such as mobile phones and tablets. Figure 2 This is a flowchart of a chemical oxygen demand (COD) prediction model training method according to an embodiment of the present invention, such as... Figure 2 As shown, the process includes the following steps: Step S201: Based on the hydrological data of the area to be measured, determine multiple vertical monitoring profiles within the area to be measured, divide the vertical monitoring profiles into multiple grids, and determine multiple monitoring locations based on the grids. The vertical length of the grid is determined based on the relative water depth of the vertical monitoring profile.
[0029] In one optional embodiment, based on the fact that geographical elements (such as water quality) are not uniformly distributed in space but exhibit differences and gradient changes, and considering the biochemical differences along the water flow direction from the head to the tail of the reservoir, the monitoring area is divided into a core area, a central transition area, and an upstream edge area. Each monitoring area is further divided into multiple vertical monitoring profiles. Furthermore, since stratified sampling theory better ensures sample representativeness, the vertical monitoring profiles are divided into multiple grids based on the relative water depth of the vertical monitoring profiles, ultimately resulting in multiple monitoring locations.
[0030] Specifically, such as Figure 3The diagram shows the specific deployment scheme for a 6 km² area (water depth 0-180 m) of a reservoir. Specifically, one monitoring section with five vertical lines is deployed at the head of the reservoir; three monitoring sections with three to five vertical lines are deployed in the middle of the reservoir; and one monitoring section with three vertical lines is deployed at the tail of the reservoir. Each vertical line has five sampling layers based on relative water depths (i.e., 0, 0.3H, 0.5H, 0.7H, 1.0H, where H is the total water depth of the vertical line).
[0031] Step S202: Use the submersible to sample at the monitoring locations to obtain the original datasets for each monitoring location.
[0032] In one optional embodiment, an underwater intelligent vehicle (AUV / ROV) equipped with a hyperspectral water quality sensor is used to collect data at various monitoring locations to obtain a raw dataset. The raw dataset includes spectral data, physicochemical data, and the true value of chemical oxygen demand (COD). The true COD value is obtained by chemically measuring the water samples collected by the underwater intelligent vehicle.
[0033] Step S203: Construct training samples based on the original datasets of each monitoring location, and use the training samples to train the spatial attention dual-branch deep ensemble network to obtain the chemical oxygen demand prediction model.
[0034] In one optional embodiment, training samples are constructed using the collected raw dataset, enabling a spatial attention-based dual-branch deep ensemble network to learn the intrinsic correlation between the spectral and physicochemical characteristics of water bodies and chemical oxygen demand (COD). After training convergence, a COD prediction model is formed. This COD prediction model is used to predict COD based on the spectral and physicochemical data within the area to be measured.
[0035] The chemical oxygen demand (COD) prediction model training method provided in this embodiment determines the vertical monitoring profile based on the hydrological data of the area to be measured, divides the grid according to the relative water depth, and determines the monitoring location. This ensures that the monitoring points uniformly cover different vertical levels of the water body, avoiding data deviation caused by one-sided deployment of monitoring points, and ensuring that the sampled data can comprehensively reflect the overall water quality characteristics of the area to be measured. Furthermore, by using a submersible to simultaneously sample at each monitoring location, it ensures that the spectral data, physicochemical data, and true COD values are strictly correlated in time and space, solving the problems of misalignment and low matching degree of different data sources in traditional sampling, and providing real and reliable basic data for the construction of training samples. Furthermore, based on the original dataset, matching training samples are constructed and a spatial attention dual-branch deep ensemble network is trained, enabling the network to accurately learn the intrinsic correlation between the spectral characteristics, physicochemical characteristics, and COD of the water body. This results in a COD prediction model with high prediction accuracy that can adapt to the water quality characteristics of the area to be measured, effectively solving the problems of poor data representativeness and inaccurate prediction caused by non-standard model training samples in traditional COD prediction methods.
[0036] In one optional implementation, the spatial attention dual-branch deep integration network includes a spectral branch layer, a physicochemical branch layer, a channel-space dual attention fusion layer, and a chemical oxygen demand prediction output layer; The spectral branch layer is used to extract local texture and fine spectral features from the preprocessed spectral data using a one-dimensional convolutional neural network, and output a fixed-dimensional spectral feature vector.
[0037] In one optional embodiment, the spectral data is one-dimensional sequence data. The spectral branch layer uses a one-dimensional convolutional neural network to capture local texture features and fine spectral features in the spectral data, and at the same time transforms the extracted features into a fixed-dimensional spectral feature vector.
[0038] Specifically, the preprocessed DN value sequence is input into a one-dimensional convolutional neural network (1D-CNN). The 1D-CNN contains at least two levels of convolution-activation-pooling units, with the following structure: First layer: 32 convolutional kernels, kernel size 5, stride 1, padding "same", followed by ReLU activation function; Second layer: 64 convolutional kernels, kernel size 3, stride 1, padding "same", followed by ReLU activation function; Then, a global average pooling layer is applied to compress the variable-length feature map into a fixed-dimensional vector, and finally, a 128-dimensional spectral feature vector is output through a fully connected layer.
[0039] The physicochemical branch layer is used to extract water quality correlation features from the preprocessed physicochemical data using a fully connected neural network, and outputs a fixed-dimensional physicochemical embedding vector.
[0040] In one optional embodiment, the physicochemical data is multi-dimensional numerical data. The physicochemical branch layer uses a fully connected neural network to fully explore the intrinsic relationship between each physicochemical parameter and water quality, and transforms it into a physicochemical embedding vector with representational significance. The fixed dimension design can maintain the same dimension as the spectral feature vector, which meets the input requirements of cross-modal fusion.
[0041] Specifically, depth affects optical path attenuation, temperature regulates biochemical reaction rates, turbidity dominates scattering interference, Chl-a and CDOM characterize biological and abiotic organic matter, respectively, and the five-dimensional parameters together constitute a complete context of the optical and biochemical environment of the water body, providing physical constraints for spectral interpretation. The preprocessed vector P is input into two fully connected layers (with 64 and 128 hidden units, respectively), and each layer is followed by a ReLU activation function, finally outputting a 128-dimensional physicochemical embedding vector.
[0042] The channel-space dual attention fusion layer is used to perform physicochemical-guided cross-modal gating fusion of spectral feature vectors and physicochemical embedding vectors and channel-space dual attention weighting, outputting a deeply coupled fused feature vector.
[0043] In one optional embodiment, cross-modal gating fusion can achieve directional fusion of spectral features and physicochemical features. Channel-spatial dual attention weighting can accurately enhance effective features related to chemical oxygen demand and suppress redundant interference features to obtain a fused feature vector, which contains key information from both the spectrum and the physicochemical properties.
[0044] The chemical oxygen demand (COD) prediction output layer is used to perform global feature aggregation and nonlinear mapping on the fused feature vectors and output the predicted COD value.
[0045] In one optional embodiment, the fused feature vector contains deep coupling information of spectral and physicochemical properties. The chemical oxygen demand (COD) prediction output layer integrates the global effective information in the features through global feature aggregation, and then converts the fused features into a COD numerical output through nonlinear mapping.
[0046] The chemical oxygen demand (COD) prediction model training method provided in this embodiment adopts a dual-branch network structure consisting of a spectral branch layer, a physicochemical branch layer, a channel-space dual attention fusion layer, and a COD prediction output layer. This structure can perform dedicated feature extraction using adapted networks for one-dimensional spectral data and multi-dimensional physicochemical data, avoiding mutual interference between features of different modalities. Furthermore, deep coupling of the two types of features is achieved through physicochemical-guided cross-modal gating fusion and channel-space dual attention weighting, which strengthens effective features related to COD and suppresses redundant information. Finally, the prediction output is completed through global feature aggregation and nonlinear mapping. This method not only improves the targeting and completeness of feature extraction but also enhances the effectiveness of feature fusion, thereby significantly improving the accuracy and robustness of COD prediction.
[0047] In one optional implementation, the channel-space dual attention fusion layer includes a physicochemically guided cross-modal gating fusion unit, a feature splicing unit, and a channel-space dual attention weighting unit; The physicochemical-guided cross-modal gating fusion unit is used to transform the physicochemical embedding vector into a dynamic gating signal using a fully connected neural network. The dynamic gating signal is then multiplied element-wise with the spectral feature vector to obtain the physicochemical-sensing spectral features.
[0048] In one optional embodiment, a fully connected neural network is used to generate a dynamic gating signal from the physicochemical embedding vector through a lightweight MLP with Sigmoid activation. The dynamic gating signal is then multiplied element-wise with the spectral feature F to obtain the physicochemical sensing spectral feature.
[0049] The feature splicing unit is used to splice and reshape the spectral features and physicochemical embedding vectors of physicochemical perception in the channel dimension to obtain a two-dimensional tensor.
[0050] In one optional embodiment, the spectral features of physicochemical perception and the physicochemical embedding vector are merged in the channel dimension, and then a two-dimensional tensor that conforms to the input format of the subsequent attention layer is formed by reshaping the unified feature size, so as to ensure that the channel and spatial dimensions can be processed separately.
[0051] The channel-space dual attention weighting unit is used to perform dual feature weighting of the two-dimensional tensor in both channel and spatial dimensions, and output a deeply coupled fused feature vector.
[0052] In one optional embodiment, for the spliced features, multi-scale depth-separable convolution is introduced to construct channel-space dual attention: in the channel dimension, channel weights are generated through global average pooling and MLP with bottleneck structure to strengthen feature channels that are strongly correlated with target components such as chlorophyll a and soluble organic matter concentration; in the spatial dimension, 1×3, 1×5, and 1×7 convolution kernels are deployed in parallel to capture local absorption peaks and global baseline trends in the spectrum, generating a highly discriminative spatial weight map, and finally outputting a deep fusion feature F. This feature deeply embeds the physical constraints of physicochemical parameters, which significantly improves the model's ability to characterize complex water quality components.
[0053] The chemical oxygen demand (COD) prediction model training method provided in this embodiment, by setting up a physicochemical-guided cross-modal gating fusion unit, a feature splicing unit, and a channel-space dual attention weighting unit, can use physicochemical embedding vectors to generate dynamic gating signals to adaptively calibrate spectral features, making the spectral information more consistent with the actual physicochemical environment of the water body. Then, the two types of features are spliced and normalized into a two-dimensional tensor in the channel dimension, providing a unified and regular input for dual attention weighting. Finally, key features are strengthened and interference information is suppressed in both the channel and spatial dimensions, respectively, to achieve deep coupling of spectral and physicochemical features, further improving the characterization ability of the fused features and providing a more reliable feature basis for subsequent accurate prediction of COD.
[0054] In one alternative implementation, training samples are constructed based on the original datasets from each monitoring location, including: Step a1: Use the preprocessed spectral data and physicochemical data from the same monitoring location and time in the original dataset as the input feature values of the samples, and the true value of chemical oxygen demand as the label value of the samples. Match the input feature values with the label values to obtain multiple sets of samples.
[0055] In one optional embodiment, to ensure that the characteristics of each sample group highly match the actual water quality indicators, the input features and label values need to strictly correspond in time and space. The input features are spectral data and physicochemical data, and the label value is the true value of chemical oxygen demand (COD) measured from water samples at the monitoring location.
[0056] Step a2: Divide multiple sets of samples into training set and validation set according to a preset ratio to form a sample set for model training.
[0057] In one optional embodiment, multiple sets of samples are allocated to the training set, validation set, and test set in a 7:2:1 ratio to form a sample set for model training.
[0058] The chemical oxygen demand (COD) prediction model training method provided in this embodiment constructs samples by matching spectral data, physicochemical data, and COD true values from the same monitoring location and time. This ensures that the input features and labels strictly correspond in time and space, avoiding model learning bias caused by sample distortion. Dividing the training set and validation set according to a preset ratio can effectively supervise the training process, prevent overfitting, and improve the model's generalization ability. Finally, a standardized sample set is formed, providing data support for the stable training and accurate prediction of the COD prediction model.
[0059] In one optional embodiment, the physicochemical data includes water depth, temperature, turbidity, chlorophyll a concentration, and colored soluble organic matter concentration in the area to be measured. Preprocessing of the physicochemical data includes: Step b1: Perform logarithmic transformations on turbidity, chlorophyll a concentration, and colored soluble organic matter concentration to obtain the physicochemical characteristics of each parameter after logarithmic transformation.
[0060] In an alternative embodiment, for turbidity ( ), chlorophyll a concentration ( ) and the concentration of colored soluble organic matter ( To mitigate the long-tailed distribution, logarithmic transformations were performed on each parameter to obtain their logarithmically transformed physicochemical characteristics. The calculation formulas are as follows:
[0061] Step b2 involves standardizing the characteristics of water depth, temperature, and each parameter after logarithmic transformation to obtain preprocessed physicochemical data.
[0062] In an optional embodiment, the logarithmic transformation features corresponding to water depth, temperature, and each parameter are standardized using the following formula: , ,
[0063] in, , Let be the mean and standard deviation of the i-th dimension in the training set, respectively.
[0064] The chemical oxygen demand (COD) prediction model training method provided in this embodiment compresses the influence of high-value outliers by performing logarithmic transformations on turbidity, chlorophyll a concentration, and colored soluble organic matter concentration, making the distribution of parameters of different magnitudes more uniform. Furthermore, standardizing the water depth, temperature, and logarithmically transformed features eliminates dimensional differences and numerical range discrepancies among various physicochemical parameters, avoiding problems such as unstable model training and unbalanced feature weights caused by significant differences in parameter numerical ranges, thereby improving the efficiency of subsequent network feature extraction and model convergence.
[0065] This embodiment provides a method for determining chemical oxygen demand, such as... Figure 4 As shown, the method includes: Step S401: Based on the hydrological data of the area to be measured, determine multiple vertical monitoring profiles within the area, divide the vertical monitoring profiles into multiple grids, and determine multiple monitoring locations based on the grids. The vertical length of the grid is determined based on the relative water depth of the vertical monitoring profile. For details, please refer to [link to details]. Figure 2 Step S201 of the illustrated embodiment will not be described again here.
[0066] Step S402: Use the submersible to sample at the monitoring location to obtain spectral and physicochemical data for each monitoring location.
[0067] Step S403: Input the spectral data and physicochemical data into the chemical oxygen demand (COD) prediction model to obtain the predicted COD value. The COD prediction model is trained according to the COD prediction model training method.
[0068] The chemical oxygen demand (COD) measurement method provided in this embodiment, by dividing the monitoring positions into vertical grids according to relative water depth, can comprehensively and uniformly acquire water quality information at different depths of the water body, avoiding the partiality of monitoring; by using a submersible to synchronously collect spectral and physicochemical data in situ, it ensures the spatiotemporal consistency of the data and reduces the errors and lags caused by manual sampling; and then inputting the data into a trained COD prediction model for rapid inference, it can achieve efficient, real-time, and accurate measurement of COD in the area to be measured, greatly improving the efficiency of water quality monitoring, while ensuring the reliability and stability of the prediction results.
[0069] This embodiment also provides a chemical oxygen demand (COD) measuring device, which is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated. Figure 5 As shown, the device includes: The monitoring location determination module 501 is used to determine multiple vertical monitoring profiles in the area to be measured based on the hydrological data of the area to be measured, divide the vertical monitoring profiles into multiple grids, and determine multiple monitoring locations based on the grids. The vertical length of the grid is determined based on the relative water depth of the vertical monitoring profile. The sampling module 502 is used to take samples at the monitoring location using the submersible to obtain spectral and physicochemical data for each monitoring location; The chemical oxygen demand (COD) measurement module 503 is used to input spectral data and physicochemical data into the COD prediction model to obtain the predicted COD value.
[0070] The chemical oxygen demand (COD) measuring device provided in this embodiment of the invention can execute the COD measuring method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects for executing the method. Further functional descriptions of the various modules and units described above are the same as in the corresponding embodiments described above, and will not be repeated here.
[0071] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention.
[0072] The following is a detailed reference. Figure 6 This diagram illustrates a suitable structural design for implementing an electronic device according to embodiments of the present invention. The electronic device may include a processor (e.g., a central processing unit, graphics processor, etc.) 601, which can perform various appropriate actions and processes based on a program stored in read-only memory (ROM) 602 or a program loaded from memory 608 into random access memory (RAM) 603. RAM 603 also stores various programs and data required for the operation of the electronic device. The processor 601, ROM 602, and RAM 603 are interconnected via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0073] Typically, the following devices can be connected to I / O interface 605: input devices 606 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 607 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; memory devices 608 including, for example, magnetic tapes, hard disks, etc.; and communication devices 609. Communication device 609 allows electronic devices to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 6 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown, and more or fewer devices may be implemented or have instead.
[0074] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 609, or installed from a memory 608, or installed from a ROM 602. When the computer program is executed by the processor 601, it performs the functions defined in the chemical oxygen demand prediction model training method or chemical oxygen demand measurement method of the embodiments of the present invention.
[0075] Figure 6 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments of the present invention.
[0076] This invention also provides a computer-readable storage medium. The methods described above according to embodiments of the invention can be implemented in hardware or firmware, or implemented as recordable on a storage medium, or implemented as computer code downloaded via a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that the computer, processor, microprocessor controller, or programmable hardware includes storage components capable of storing or receiving software or computer code. When the software or computer code is accessed and executed by the computer, processor, or hardware, the chemical oxygen demand (COD) prediction model training method or COD measurement method shown in the above embodiments is implemented.
[0077] A portion of this invention can be applied as a computer program product, such as computer program instructions, which, when executed by a computer, can invoke or provide the methods and / or technical solutions according to the invention through the operation of the computer. Those skilled in the art will understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, installation package files, etc. Correspondingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executing the instructions, or the computer compiling the instructions and then executing the corresponding compiled program, or the computer reading and executing the instructions, or the computer reading and installing the instructions and then executing the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to a computer.
[0078] Although embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. A method for training a chemical oxygen demand (COD) prediction model, characterized in that, The method includes: Based on the hydrological data of the area to be measured, multiple vertical monitoring profiles are determined within the area to be measured, and the vertical monitoring profiles are divided into multiple grids. Multiple monitoring locations are determined based on the grids. The vertical length of the grid is determined based on the relative water depth of the vertical monitoring profile. The underwater vehicle is used to collect samples at the monitoring locations to obtain raw datasets for each monitoring location. The raw datasets include spectral data, physicochemical data, and the true value of chemical oxygen demand. Training samples are constructed based on the original datasets of each monitoring location. The spatial attention dual-branch deep ensemble network is trained using the training samples to obtain a chemical oxygen demand (COD) prediction model. The COD prediction model is used to predict COD based on the spectral and physicochemical data of the area to be measured.
2. The method according to claim 1, characterized in that, The spatial attention dual-branch deep integration network includes a spectral branch layer, a physicochemical branch layer, a channel-space dual attention fusion layer, and a chemical oxygen demand prediction output layer. The spectral branch layer is used to extract local texture and fine spectral features from the preprocessed spectral data using a one-dimensional convolutional neural network, and output a fixed-dimensional spectral feature vector. The physicochemical branch layer is used to extract water quality correlation features from the preprocessed physicochemical data using a fully connected neural network, and outputs a fixed-dimensional physicochemical embedding vector. The channel-space dual attention fusion layer is used to perform physicochemically guided cross-modal gating fusion of the spectral feature vector and the physicochemical embedding vector and channel-space dual attention weighting, and output a deeply coupled fused feature vector; The chemical oxygen demand (COD) prediction output layer is used to perform global feature aggregation and nonlinear mapping on the fused feature vector to output the predicted COD value.
3. The method according to claim 2, characterized in that, The channel-space dual attention fusion layer includes a physicochemical guided cross-modal gating fusion unit, a feature splicing unit, and a channel-space dual attention weighting unit; The physicochemical-guided cross-modal gating fusion unit is used to convert the physicochemical embedding vector into a dynamic gating signal using a fully connected neural network, and then multiply the dynamic gating signal element-wise with the spectral feature vector to obtain the physicochemical-sensored spectral features. The feature splicing unit is used to splice and reshape the spectral features of the physicochemical perception and the physicochemical embedding vector in the channel dimension to obtain a two-dimensional tensor; The channel-space dual attention weighting unit is used to perform dual feature weighting of the two-dimensional tensor in both channel and spatial dimensions, and output a deeply coupled fused feature vector.
4. The method according to claim 1, characterized in that, Training samples were constructed based on the original datasets from each monitoring location, including: The preprocessed spectral and physicochemical data from the same monitoring location and time in the original dataset are used as input feature values for the samples, and the true value of chemical oxygen demand is used as the label value for the samples. The input feature values and label values are matched to obtain multiple sets of samples. The multiple sets of samples are divided into training set and validation set according to a preset ratio to form a sample set for model training.
5. The method according to claim 2 or 4, characterized in that, The physicochemical data includes water depth, temperature, turbidity, chlorophyll a concentration, and colored soluble organic matter concentration in the area to be tested. Preprocessing of the physicochemical data includes: Logarithmic transformations were performed on turbidity, chlorophyll a concentration, and colored soluble organic matter concentration to obtain the physicochemical characteristics of each parameter after logarithmic transformation. The water depth, temperature, and the logarithmically transformed features of each parameter are standardized to obtain preprocessed physicochemical data.
6. A method for determining chemical oxygen demand, characterized in that, The method includes: Based on the hydrological data of the area to be measured, multiple vertical monitoring profiles are determined within the area to be measured, and the vertical monitoring profiles are divided into multiple grids. Multiple monitoring locations are determined based on the grids. The vertical length of the grid is determined based on the relative water depth of the vertical monitoring profile. The underwater vehicle was used to collect samples at the monitoring locations to obtain spectral and physicochemical data for each location. The spectral data and physicochemical data are input into the chemical oxygen demand (COD) prediction model to obtain the predicted COD value. The COD prediction model is trained by the COD prediction model training method according to any one of claims 1-5.
7. A chemical oxygen demand (COD) measuring device, characterized in that, The device includes: The monitoring location determination module is used to determine multiple vertical monitoring profiles in the area to be measured based on the hydrological data of the area to be measured, divide the vertical monitoring profiles into multiple grids, and determine multiple monitoring locations based on the grids. The vertical length of the grid is determined based on the relative water depth of the vertical monitoring profile. The sampling module is used to take samples at the monitoring locations using the submersible to obtain spectral and physicochemical data for each monitoring location; The chemical oxygen demand (COD) measurement module is used to input the spectral data and physicochemical data into the COD prediction model to obtain the predicted COD value.
8. An electronic device, characterized in that, include: The device includes a memory and a processor, which are interconnected. The memory stores computer instructions, and the processor executes the computer instructions to perform the chemical oxygen demand prediction model training method according to any one of claims 1-5, or to perform the chemical oxygen demand determination method according to claim 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to execute the chemical oxygen demand prediction model training method according to any one of claims 1-5, or to execute the chemical oxygen demand measurement method according to claim 6.
10. A computer program product, characterized in that, The computer instructions include computer commands for causing the computer to execute the chemical oxygen demand prediction model training method according to any one of claims 1-5, or to execute the chemical oxygen demand measurement method according to claim 6.