Three-dimensional fluorescence spectrum generation method for water pollutant identification
By improving the WAE model, converting the three-dimensional fluorescence spectrum data into image format and combining it with the RMT module to extract features, the problem of insufficient number of samples in water pollutant identification is solved, real and diverse data are generated, and the model's versatility and versatility are improved. Recognition accuracy reduces over-fitting.
Patent Information
- Application Number
- CN202410659644.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-27
- Publication Date
- 2024-09-03
AI Technical Summary
In the existing technology, the insufficient number of samples in water pollutant identification results in poor model generalization ability, and over-fitting is prone to occur during data processing, making it difficult to generate real and diverse three-dimensional fluorescence spectrum data.
Based on the Wasserstein Auto-Encoder (WAE) model improvement, a WAE-RMT model is proposed, which converts three-dimensional fluorescence spectrum data into image format, and uses a convolutional network to extract local features and an RMT module with a self-attention-preserving mechanism to extract global features. features, combined to generate realistic and diverse three-dimensional fluorescence spectral data.
It effectively expands the number of samples of three-dimensional fluorescence spectrum data, improves the versatility and recognition accuracy of the model, reduces the over-fitting phenomenon, and enhances the ability to generate water environmental pollutants.
Smart Images

Figure CN118587589A
Abstract
Description
Technical Field
[0001] The invention belongs to the field of water pollution detection and relates to a three-dimensional fluorescence spectrum generation method for water pollutant identification. Background Art
[0002] Water plays an important role in the survival of animals, plants and humans, and is one of the most important material resources essential for human survival and development. In recent years, as water pollution has become increasingly serious, it is crucial to quickly identify the types of pollutants and take corresponding treatment measures. Three-dimensional fluorescence spectroscopy technology has been widely studied and applied in the field of water environment monitoring due to its advantages such as high sensitivity, strong selectivity, rich information, fast detection speed, and qualitative and quantitative analysis.
[0003] Three-dimensional fluorescence spectroscopy technology uses the principle that molecules emit characteristic emission light under the irradiation of excitation light of a specific wavelength to conduct qualitative and quantitative analysis of the substance to be tested. The three-dimensional fluorescence spectrum reflects the fluorescence characteristics of the sample and can provide information about the chemical composition, structure and environment of the sample. And according to the different characteristics of the sample, different excitation wavelengths and detection wavelengths can be selected to obtain a large amount of multidimensional information of the substance. With the development of deep learning technology, recognition models have begun to be used in the field of water pollutant identification. In reality, there are relatively few real contaminated water samples that can be collected, and it takes a lot of time and effort to collect the original samples. In the process of data processing, insufficient sample size will cause overfitting, resulting in unsatisfactory results when establishing the recognition model. Therefore, solving the problem of insufficient samples is one of the hot topics in current research.
[0004] At present, one common method to increase the number of samples is data enhancement. By randomly transforming the training data, such as rotating, flipping, scaling, etc., the diversity of training samples is increased, which helps to improve the generalization ability of the model, but this method is generally used for image processing. Another method is interpolation, which selects feasible virtual samples based on a series of criteria. However, experimental measurements in laboratories and real water systems are complicated and expensive, and the expanded samples are prone to information loss.
[0005] Therefore, it is necessary to further study the generation method of three-dimensional fluorescence spectrum data as a sample preprocessing process in order to generate more realistic and diverse three-dimensional fluorescence spectrum data. Summary of the invention
[0006] In order to overcome the shortcomings of the prior art and generate more diverse three-dimensional fluorescence spectrum data, the present invention improves the Wasserstein Auto-Encoder (WAE) model and proposes a three-dimensional fluorescence spectrum generation method based on the WAE-RMT model. In the encoding stage, the three-dimensional fluorescence spectrum data is used as input data. On the one hand, local features are extracted by convolution; on the other hand, global features are obtained by the RMT module with a self-attention mechanism. The two are combined to finally obtain the target features, which are placed in the decoder to generate real and diverse three-dimensional fluorescence spectrum data. Figure 1 This generation method has good universality and is conducive to the generation of various types of water environmental pollutants, solving the problem of insufficient sample quantity.
[0007] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0008] A method for generating a three-dimensional fluorescence spectrum for identifying water pollutants comprises the following steps:
[0009] 1) Convert the three-dimensional fluorescence spectrum data into image format and save it. The process is as follows:
[0010] The three-dimensional fluorescence spectrum data as a two-dimensional array does not meet the input requirements of the generative model. Therefore, the spectrum data is normalized according to formula (1) and then converted into grayscale values according to formula (2), which is equivalent to analogizing the fluorescence intensity of the substance to the pixel value of the image, avoiding the non-convergence problem caused by the data set format;
[0011]
[0012] P=F*255 (2)
[0013] Where, f is the three-dimensional fluorescence spectrum data, F is the normalized fluorescence intensity value, std(x) is the standard deviation of the spectrum data, mean(x) is the mean of the spectrum data, and P is the pixel value after conversion to an image. Since the spectrum data is a two-dimensional array, its mean and standard deviation are for the entire matrix. To ensure the accuracy of the training set, the image should be saved in tiff format so that decimals can be retained, that is, the three-dimensional fluorescence spectrum image dataset Real;
[0014] 2) Encode the three-dimensional fluorescence spectrum image dataset Real, the process is as follows:
[0015] 21) The local feature U is extracted using the convolutional network structure. The convolutional network structure in the inference network contains 4 convolutional layers and 2 fully connected layers. The data set is mapped to a low-order latent space through the convolutional network and retained as the extracted local feature U for subsequent needs.
[0016] 22) Using the RMT module to extract global features, the data must first be split into tokens through the Patch framework, then passed through the ReSA framework to implement the self-attention mechanism, and the DWC framework to implement the local information enhancement mechanism, and then further enriched global feature information through the LN framework and FFN framework;
[0017] 3) Integrate the local features and global features of step 21) and step 22), the process is:
[0018] Calculated by formula (3), the elements in the feature information are added together to obtain the final value feature M;
[0019] M[k]=U[k]+T[k] (3)
[0020] Where k = 1, 2, 3...W, W is the dimension parameter, that is, the number of elements;
[0021] 4) Decoding to obtain the three-dimensional fluorescence spectrum generated data Fake. The decoder is composed of 4 deconvolution layers and 1 fully connected layer. The final value feature M enters the decoder to recover the information to obtain the three-dimensional fluorescence spectrum generated data Fake;
[0022] 5) Calculate the loss and optimize the parameters. The process is:
[0023] The total loss function can be regarded as the reconstruction loss Recon_loss plus the MMD loss MMD_loss:
[0024] D WAE =Recon_loss+MMD_loss (4)
[0025] The reconstruction loss is calculated by the cross entropy loss function, as shown in formula (5):
[0026]
[0027] Among them, Fake i Generate data for 3D fluorescence spectroscopy, Real i It is the real data of three-dimensional fluorescence spectrum;
[0028] The MMD loss is calculated by the maximum mean difference, as shown in formula (6):
[0029]
[0030] Among them, M i is the final value feature of the three-dimensional fluorescence spectrum data after passing through the encoder, n is the dimension length of the final value feature, N J is a standard normal distribution random number with the same dimension as the three-dimensional fluorescence spectrum data, and m is the dimension length of the three-dimensional fluorescence spectrum data;
[0031] The Adam optimizer is used, the interval adjustment method (StepLR) is used to adjust the learning rate, and the model parameters are updated through back propagation, and finally the trained WAE-RMT generation model is obtained.
[0032] Further, the process of 22) is as follows:
[0033] 221) The Patch framework is used to divide the image data into tokens. The Patch framework contains 4 convolutional layers, which divide the image data into tokens by downsampling. i , i∈R, which is convenient for placing in the subsequent RMT module;
[0034] 222) The self-attention mechanism is retained through the ReSA framework. The process is as follows:
[0035] The attention score in the length direction is calculated as shown in formula (7) and formula (8): H and display the attenuation matrix D H ;
[0036]
[0037]
[0038] The attention score in the width direction is calculated by formula (9) and formula (10): W and display the attenuation matrix D W ;
[0039]
[0040]
[0041] The attenuation coefficient γ is calculated by formula (11);
[0042] γ=ln(1-2 -2-arange(0,h) ) (11)
[0043] Among them, Q, K, and V are tokens i Through the linear layer projection to the query, key and value space, Q H , k H is the decomposed value of Q and K along the length; Q W , K W is the decomposition value of Q and K along the width, (x n ,y n ) represents the nth token n The two-dimensional coordinates of (x m ,y m) represents the mth token m The two-dimensional coordinates of Q, K, and V; arange(0, h) represents the one-dimensional tensor expanded by the number of heads of Q, K, and V;
[0044] Finally, the attention weighted score ReSAd(X) is calculated by formula (12). The higher the score, the richer the information in this part, and the model should give this part of the token a greater weight.
[0045] ReSAd(X)=Attnentino H (Attnentino W V) T (12)
[0046] 223) The local information enhancement mechanism is realized through the DWC framework, and the DWC framework is realized through a convolutional layer;
[0047] 224) integrate to obtain the global features, and calculate the global feature information T extracted by RMT through formula (13);
[0048] T=FFN(LN(ReSAd(X)+DWC(V))) (13)
[0049] Among them, X is token i , i∈R, V is the value mentioned above; and further enriched global feature information T is obtained through the LN framework and FFN framework;
[0050] 225) The global feature information T is parameterized through a fully connected layer, and the dimension parameter W of T is adjusted through two fully connected layers to make it the same as the local feature dimension.
[0051] Preferably, in the above 222), the number of heads is 5, and the calculated attenuation coefficient γ=(-0.28, -0.13, -0.06, -0.03, -0, 01).
[0052] More preferably, in step 3), the dimension parameter W, i.e. the maximum number of elements, is 1024.
[0053] More preferably, in the step 5), in calculating the MMD loss, n is 8 and m is 77.
[0054] In the present invention, the two-dimensional data of three-dimensional fluorescence spectrum is converted into image data format as input to meet the needs of traditional models and avoid the phenomenon that the loss function does not converge and causes distorted results; the basic model structure uses the WAE framework, which is suitable for three-dimensional fluorescence spectrum data; the RMT module is introduced to simultaneously extract local features and global features, combining the advantages of convolution and retaining self-attention mechanism.
[0055] The present invention not only expands the number of three-dimensional fluorescence spectral data samples and makes them have certain differences, but the model is also versatile. In the subsequent identification of water pollutants, it is beneficial to generate various types of water environment pollutants, solves the problem of insufficient data volume, and also solves certain overfitting phenomena, thereby improving the recognition accuracy and robustness of the model.
[0056] The beneficial effects of the present invention are:
[0057] 1. Converting three-dimensional fluorescence spectrum data into image data not only meets the needs of traditional models and avoids non-convergence, but also increases versatility and facilitates subsequent recognition operations.
[0058] 2. The present invention is based on the WAE framework. In terms of loss calculation, the introduced Wasserstein distance is more suitable for three-dimensional fluorescence spectral data than the KL divergence, and the accuracy is improved compared with the general generation method.
[0059] 3. The present invention adds the RMT module, combines the advantages of convolution and self-attention mechanism, and combines global features with local features, so that the generation effect is not only accurate but also rich and diverse. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 is a flow chart of the method of the present invention.
[0061] Figure 2 This is the structure diagram of the RMT module.
[0062] Figure 3 is a three-dimensional fluorescence contour map, among which (A) is a true three-dimensional fluorescence contour map of fluorescent whitening agent, (B) is a true three-dimensional fluorescence contour map of salicylic acid, (C) is a true three-dimensional fluorescence contour map of aniline, and (D) is a true three-dimensional fluorescence contour map of a mixture of salicylic acid and aniline.
[0063] Figure 4 Three-dimensional fluorescence contour map, wherein (A) is the generated three-dimensional fluorescence contour map of fluorescent whitening agent, (B) is the generated three-dimensional fluorescence contour map of salicylic acid, (C) is the generated three-dimensional fluorescence contour map of aniline, and (D) is the generated three-dimensional fluorescence contour map of a mixture of salicylic acid and aniline. DETAILED DESCRIPTION
[0064] The technical solution of the present invention is further described below in conjunction with the accompanying drawings.
[0065] Reference Figure 1 to Figure 4A three-dimensional fluorescence spectrum generation method for water pollutant identification. The method first needs to convert the two-dimensional data of the three-dimensional fluorescence spectrum into images as data sets and input them into Real; based on the generation model WAE, an RMT module is added to its encoder part to extract local and global features at the same time; the information with features is sent to the decoder to obtain the generated data; the loss function between the generated data and the real data is calculated, and the model parameters are optimized through back propagation.
[0066] This embodiment generates samples of three-dimensional fluorescence spectra of 10 mg / L fluorescent whitening agent, salicylic acid, aniline, and a mixed aqueous solution of salicylic acid and aniline, respectively. Taking the fluorescent whitening agent as an example, the process includes the following steps:
[0067] A: Convert the two-dimensional data to be generated and use the image data as input;
[0068] The three-dimensional fluorescence spectrum two-dimensional data is converted into image data as follows:
[0069]
[0070] P=F*255 (2)
[0071] Where f is the three-dimensional fluorescence data of the fluorescent whitening agent, F is the normalized fluorescence intensity value, std(f) is the standard deviation, mean(f) is the mean, and P is the pixel value after conversion to an image. Save as the dataset Real;
[0072] B: Improve the structure of the encoder and decoder in the WAE-RMT generation model and adjust the model parameters;
[0073] B1. Adjust the convolutional network part in the encoder, which consists of 4 convolutional layers and 1 fully connected layer. The specific parameters are listed in Table 1. Table 1 shows some parameters of the convolutional network;
[0074]
[0075] Table 1
[0076] B2. The data must first be split into tokens through the Patch framework and then sent to the subsequent RMT module. Table 2 shows some parameters of the Patch framework;
[0077]
[0078] Table 2
[0079] B3. The RMT module in the encoder includes the DWC framework, LN framework, ReSA framework and FFN framework. The DWC framework contains a convolutional layer. Table 3 shows some parameters of the DWC framework.
[0080]
[0081] Table 3
[0082] The ReSA framework contains four fully connected layers and a DWC framework. Table 4 shows some parameters of the ReSA framework;
[0083]
[0084] Table 4
[0085] The fully connected layers Q, K, and V are three different linear projection layers that project the input to obtain three parameters: query Q, key K, and value V. The attenuation coefficient γ is calculated by formula (11), where arange(0, h) represents the one-dimensional tensor of the number of heads of Q, K, and V.
[0086] γ=ln(1-2 -2-arange(0,h) ) (11)
[0087] Taking h=5, calculate the attenuation coefficient γ=(-0.28, -0.13, -0.06, -0.03, -0, 01).
[0088] Then, the display attenuation matrix D that retains the position relationship is further obtained by formula (8) and formula (10): H and D W .
[0089]
[0090]
[0091] Where (x n ,y n ) indicates token n The two-dimensional coordinates of (x m ,y m ) indicates token m The two-dimensional coordinates of .
[0092] The attention weighted score ReSAd(X) is obtained by the following formula:
[0093]
[0094] After the final fully connected layer OUT and through formula (13), rich global feature information T is obtained.
[0095] T=FFN(LN(ReSAd(X)+DWC(V))) (13)
[0096] The LN framework is directly implemented by the LN layer, and the FFN framework contains one convolutional layer and two fully connected layers. Table 5 shows some parameters of the FFN framework;
[0097]
[0098] Table 5
[0099] B4. The extracted global features are parameterized through two fully connected layers so that they can be integrated with the local features. Table 6 shows some parameters of the global feature adjustment framework.
[0100]
[0101] Table 6
[0102] B5. The generated network structure in the decoder consists of 4 deconvolution layers and 1 fully connected layer. The parameters are listed in Table 7. Finally, nonlinear mapping is performed through the Sigmoid function. Table 7 shows some parameters of the deconvolution network.
[0103]
[0104] Table 7
[0105] B6. Get the generated sample Fake of fluorescent whitening agent through the decoder.
[0106] C: Calculate the loss function and update the optimization model parameters;
[0107] The reconstruction loss Recon_loss is to calculate the cross entropy between the real sample Real and the generated sample Fake of the fluorescent whitening agent:
[0108]
[0109] MMD loss MMD_loss is used to calculate the final feature M generated by Real after passing through the encoder. i With standard normal data distribution N J The maximum mean difference between
[0110]
[0111] The final loss is the sum of reconstruction loss and MMD loss.
[0112] D WAE =Recon_loss+MMD_loss (4)
[0113] The Adam optimizer is used to optimize the model parameters, and the learning rate is 0.001. The StepLR method is used to adjust the learning rate, with an adjustment interval of 30 and a gamma of 0.5. The model parameters are updated through back propagation. The training epoch is 10000 and the batch is 4, and the trained generative model is obtained.
[0114] D: The generated data of the fluorescent whitening agent sample obtained by the WAE-RMT generation model, as shown in the reference Figure 4 (A).
[0115] The method of this embodiment can expand the number of samples and have certain differences. In the subsequent identification of water pollutants, it not only solves the problem of insufficient data, but also solves certain overfitting phenomena. It is conducive to enriching the database and improving the recognition accuracy and robustness of the model.
[0116] like Figure 3 Shown are three-dimensional fluorescence contour maps of real fluorescent brightener, salicylic acid, aniline, and a mixture of salicylic acid and aniline. Figure 4 Shown are the three-dimensional fluorescence contour maps of the generated fluorescent brightener, salicylic acid, aniline, and a mixture of salicylic acid and aniline. Figure 3 and Figure 4 Obviously, the three-dimensional fluorescence spectrum data generated by the WAE-RMT generation model not only has high similarity, but also has a certain degree of diversity. It can play a greater role in subsequent identification. The generated data obtained by the model is used to enrich the database, and it is used as a training set to train the recognition model, so that the trained recognition model has a higher recognition accuracy in the process of water pollutant identification.
[0117] The contents described in the embodiments of this specification are merely an enumeration of the implementation forms of the inventive concept. The protection scope of the present invention should not be regarded as limited to the specific forms described in the embodiments. The protection scope of the present invention also extends to equivalent technical means that can be conceived by those skilled in the art based on the inventive concept.
Claims
1. A method for generating a three-dimensional fluorescence spectrum for identifying water pollutants, characterized in that: The method comprises the following steps: 1) Convert the three-dimensional fluorescence spectrum data into image format and save it. The process is as follows: The spectral data is normalized according to formula (1), and then converted into grayscale values according to formula (2); P=F*255 (2) Among them, f is the three-dimensional fluorescence spectrum data, F is the normalized fluorescence intensity value, std(x) is the standard deviation of the spectrum data, mean(x) is the mean of the spectrum data, and P is the pixel value after conversion to an image. To ensure the accuracy of the training set, the image should be saved in tiff format so that decimals can be retained, that is, the three-dimensional fluorescence spectrum image dataset Real; 2) Encode the three-dimensional fluorescence spectrum image dataset Real, the process is as follows: 21) The local feature U is extracted using the convolutional network structure. The convolutional network structure in the inference network contains 4 convolutional layers and 2 fully connected layers. The data set is mapped to a low-order latent space through the convolutional network and retained as the extracted local feature U for subsequent needs. 22) Using the RMT module to extract global features, the data must first be split into tokens through the Patch framework, then passed through the ReSA framework to implement the self-attention mechanism, and the DWC framework to implement the local information enhancement mechanism, and then further enriched global feature information through the LN framework and FFN framework; 3) Integrate the local features and global features of step 21) and step 22), the process is: Calculated by formula (3), the elements in the feature information are added together to obtain the final value feature M; M[k]=U[k]+T[k] (3) Where k = 1, 2, 3…W, W is the dimension parameter, that is, the number of elements; 4) Decoding to obtain the three-dimensional fluorescence spectrum generated data Fake. The decoder is composed of 4 deconvolution layers and 1 fully connected layer. The final value feature M enters the decoder to recover the information to obtain the three-dimensional fluorescence spectrum generated data Fake; 5) Calculate the loss and optimize the parameters. The process is: The total loss function is regarded as the reconstruction loss Recon_loss plus the MMD loss MMD_loss: D WAE =Recon_loss+MMD_loss (4) The reconstruction loss is calculated by the cross entropy loss function, as shown in formula (5): Among them, Fake i Generate data for 3D fluorescence spectroscopy, Real i It is the real data of three-dimensional fluorescence spectrum; The MMD loss is calculated by the maximum mean difference, as shown in formula (6): Among them, M i is the final value feature of the three-dimensional fluorescence spectrum data after passing through the encoder, n is the dimension length of the final value feature, N J is a standard normal distribution random number with the same dimension as the three-dimensional fluorescence spectrum data, and m is the dimension length of the three-dimensional fluorescence spectrum data; The Adam optimizer is used, the interval adjustment method StepLR is used to adjust the learning rate, and the model parameters are updated through back propagation, and finally the trained WAE-RMT generation model is obtained.
2. A method for generating a three-dimensional fluorescence spectrum for water pollutant identification according to claim 1, characterized in that: The process of 22) is as follows: 221) The Patch framework is used to divide the image data into tokens. The Patch framework contains 4 convolutional layers, which divide the image data into tokens by downsampling. i ,i∈R, convenient for placing into the subsequent RMT module; 222) The self-attention mechanism is retained through the ReSA framework. The process is as follows: The attention score in the length direction is calculated as shown in formula (7) and formula (8): H and display the attenuation matrix D H ; The attention score in the width direction is calculated by formula (9) and formula (10): W and display the attenuation matrix D W ; The attenuation coefficient γ is calculated by formula (11); γ=ln(1-2 -2-arange(0,h) ) (11) Among them, Q, K, and V are tokens i Through the linear layer projection to the query, key and value space, Q H ,K H is the decomposed value of Q and K along the length; Q W ,K W is the decomposition value of Q and K along the width, (x n ,y n ) represents the nth token n The two-dimensional coordinates of (x m ,y m ) represents the mth token m The two-dimensional coordinates of Q, K, and V; arange(0,h) represents the one-dimensional tensor expanded by the number of heads of Q, K, and V; Finally, the attention weighted score ReSAd(X) is calculated by formula (12). The higher the score, the richer the information in this part, and the model should give this part of the token a greater weight. ReSAd(X)=Attnentino H (Attnentino W V) T (12) 223) The local information enhancement mechanism is realized through the DWC framework, and the DWC framework is realized through a convolutional layer; 224) integrate to obtain the global features, and calculate the global feature information T extracted by RMT through formula (13); T=FFN(LN(ReSAd(X)+DWC(V))) (13) Among them, X is token i , i∈R, V is the value mentioned above; and further enriched global feature information T is obtained through the LN framework and FFN framework; 225) The global feature information T is parameterized through a fully connected layer, and the dimension parameter W of T is adjusted through two fully connected layers to make it the same as the local feature dimension.
3. A method for generating a three-dimensional fluorescence spectrum for water pollutant identification according to claim 2, characterized in that: In the above 222), the number of heads is 5, and the attenuation coefficient γ is calculated to be (-0.28, -0.13, -0.06, -0.03, -0,01).
4. A method for generating a three-dimensional fluorescence spectrum for water pollutant identification according to any one of claims 1 to 3, characterized in that: In step 3), the dimension parameter W, i.e. the maximum number of elements, is 1024.
5. A three-dimensional fluorescence spectrum generation method for water pollutant identification according to any one of claims 1 to 3, characterized in that: In the step 5), in calculating the MMD loss, n is 8 and m is 77.
Citation Information
Cited By
Water pollutant feature extraction and recognition method, device and equipment and storage medium
CN122084591A
Overlapped pollutant identification method based on three-dimensional fluorescence spectrum rotation structure perception
CN122545457A
