A Raman spectroscopy detection method for mixed fishery drugs

Through the RA-CTNet model combined with the data enhancement method, the problem of inefficiency of Raman spectroscopy in fishery residue detection is solved, and the rapid and accurate nanomolar concentration detection of mixed fishery drugs is achieved, which improves the robustness and detection speed of the model.

CN119715492BActive Publication Date: 2025-08-29JIANGSU ACAD OF AGRI SCI
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411775246.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-05
Publication Date
2025-08-29
Estimated Expiration
2044-12-05

Smart Images

  • Figure CN119715492B_ABST
    Figure CN119715492B_ABST
Patent Text Reader

Abstract

The present invention discloses a Raman spectroscopy detection method for mixed fishery drugs that combines a data enhancement method and a RA‑CTNet model. The method expands data by combining a chemometric method and an experimental random error simulation method to reduce the cost of building a database and improve the robustness of the model. In model construction, the advantages of CNN in local feature extraction and the capabilities of Transformer in global feature modeling are fully utilized. The training strategies of pre-training and transfer learning are adopted, and the rich feature information of a single fishery drug is effectively utilized to improve the accuracy of mixed fishery drug prediction and realize the quantitative detection of nanomolar concentration mixtures under complex mixed samples. Compared with the existing technology, the technical solution of the present invention aims to detect banned fishery drugs in aquaculture water bodies and realize the quantitative detection of banned drugs at nanomolar concentrations under low data samples, aiming to improve the accuracy and robustness of Raman spectroscopy detection and to quickly conduct qualitative and quantitative analysis of mixed fishery drugs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of spectral analysis, and in particular to a Raman spectrum detection method for mixed fishery drugs. Background Art

[0002] Aquatic product safety is closely linked to human health and well-being, and excessive residues of fishery drugs are a major safety hazard. To accurately detect fishery drug residues in aquatic products, traditional methods for detecting fishery drug residues, including chromatography, immunoassays, and capillary electrophoresis, are used. However, these methods often suffer from technical challenges such as complexity, high costs, and time-consuming procedures. In practical applications, these methods struggle to meet the demands of rapid testing. Furthermore, the large diversity and complex composition of aquaculture water, which may contain large amounts of organic matter and protein, further complicates detection.

[0003] Raman spectroscopy is a rapid, non-destructive detection method that has garnered significant attention in the field of fishery drug residue detection in recent years. Its principle is to analyze the Raman scattering spectrum of a sample to be tested to obtain molecular information within the sample, enabling qualitative and quantitative analysis of the sample's structure, properties, and composition. However, because traditional Raman spectroscopy relies on the operator's practical experience, it often suffers from limitations such as low efficiency and high subjectivity. Furthermore, the large amount of Raman spectroscopy data analyzed and its high dimensionality make it difficult to effectively extract corresponding features and build models.

[0004] However, deep learning has powerful feature extraction and nonlinear modeling analysis capabilities. It can automatically learn the composition information of substances from massive spectral data, and achieve fast and accurate material composition identification and quantitative analysis. Therefore, by applying deep learning to traditional Raman spectroscopy, the limitations of traditional analysis can be overcome.

[0005] In this regard, the prior art has already produced Raman spectroscopy analysis algorithms based on deep learning. For example, the publication number CN113670894A discloses a method for quantitatively monitoring the content of a substance using Raman spectroscopy. By introducing big data means to process Raman spectroscopy data, quantitative monitoring of Raman spectroscopy is achieved. For another example, the patent authorization announcement number CN117935963B discloses a method for qualitative analysis of mixtures using Raman spectroscopy. By using the transformer deep model, qualitative analysis of the Raman spectroscopy of the mixture is achieved. However, the above-mentioned patent technical solutions all require a large amount of high-quality data for training. The data set construction is expensive and time-consuming, the model generalization ability is limited, and it is difficult to adapt to complex detection scenarios such as different temperatures or water samples. It is also limited to qualitative analysis and cannot calculate the absolute content of the mixture. In existing technologies, generative neural networks can be used to generate Raman spectral data to solve the data shortage problem. However, generating new Raman spectra through GAN requires training a high-quality generative model in advance, which requires a large amount of training data. Otherwise, the quality and diversity of the generated spectra will be difficult to guarantee. At the same time, the Raman spectral data generated by GAN may have data bias problems, and the generated data may differ from the real data distribution, thereby affecting the generalization performance of the model. Summary of the Invention

[0006] The main purpose of this invention is to propose a Raman spectroscopy detection method for mixed fishery drugs based on RA-CTNet, with the aim of detecting banned fishery drugs in aquaculture water, achieving quantitative detection of banned drugs at nanomolar concentrations under low data samples, improving the accuracy and robustness of Raman spectroscopy detection, and performing rapid qualitative and quantitative analysis of mixed fishery drugs.

[0007] To achieve the above object, the present invention proposes a Raman spectroscopy detection method for mixed fishery drugs, comprising the following steps:

[0008] Step S1: intercepting the full-band Raman spectrum according to the Raman spectral characteristics of the target substance and the detection band of the Raman spectrometer, and then correcting the baseline drift of the Raman spectrum in the sample to eliminate the intensity difference and random error between different spectra;

[0009] Step S2: After inputting the spectral data, the corresponding spectral data is converted into amplified data by adding random errors, simulating periodic environmental interference to amplify the data, and generating spectral data of different concentrations by chemometric methods to amplify the data;

[0010] Step S3: receiving the spectral data after preprocessing and data amplification, where the input spectral data is represented as a one-dimensional vector;

[0011] Step S4: Using the Raman spectral data of a single substance and its corresponding concentration labels, a pre-trained model is built after preprocessing and data enhancement;

[0012] Step S5: Input the pre-trained data set into the model, perform forward propagation, and calculate the predicted value;

[0013] Step S6: Read the predicted value of the substance concentration and calculate the loss function value; use the loss function value as a reference, backpropagate, update the model parameters, and repeat steps S5-S6 until the loss function value no longer decreases or the loss function value meets the prediction accuracy requirement. After pre-training is completed, save the model parameters for subsequent mixed sample transfer learning;

[0014] Step S7: Using the Raman spectral data of the mixed fishery drug and its corresponding concentration labels as the data set for transfer learning after preprocessing and data enhancement;

[0015] Step S8: Input the mixed sample data set into the model, load the pre-trained model parameters, freeze the parameters of the convolutional layer, train only the encoder and fully connected layers, perform forward propagation, and calculate the predicted value;

[0016] Step S9: For the concentration regression task of multiple fishery drugs, the mixed sample mean square error is used as the loss function;

[0017] Step S10: Based on the mixed sample mean square error value as a reference, back propagate, update the model parameters and repeat the steps S8-S9 process until the mixed sample mean square error value no longer decreases after multiple rounds, or the mixed sample mean square error value meets the prediction accuracy requirement. After training is completed, save the final model parameters.

[0018] Preferably, in step S1, the intensity difference and random error between different spectra are eliminated, and each sample point X of the original spectrum is converted to raw Enter the following formula to obtain the preprocessed spectral data and complete the spectral preprocessing;

[0019]

[0020] Among them, μ and σ are respectively raw The mean and standard deviation of Indicates moving average smoothing, with the window size set to W, where W ranges from 1 to 20;

[0021] and are the minimum and maximum values ​​of the smoothed data respectively.

[0022] Preferably, in step S2, the random error is added to transform the amplified data using the following transformation formula:

[0023] X aug1 =X norm +∈

[0024] Where ∈ is the simulated random noise parameter, which follows the distribution θ is the noise amplitude control parameter;

[0025] The simulated periodic environmental interference amplifies the data, and the amplified sample is a trigonometric function error. The simulated periodic environmental interference, the conversion formula is X aug2 =X norm +S, where S is the simulated periodic sinusoidal noise parameter. Its generation period is T, and T ranges from 10 to 1000. The parameter S obeys the following distribution:

[0026]

[0027] in is a random phase;

[0028] The method generates spectral data of different concentrations by chemometric method to amplify data. Based on the chemometric method, spectral data at different concentrations are generated by chemometric method; the range of fishery drug concentration Cmin to Cmax is determined, and multiple concentration points {C1, C2, ..., Cm} are generated within the above range. According to the exponential function relationship between the fishery drug concentration and the Raman peak intensity, the spectral data at different concentrations are simulated, and the characteristic peak intensity corresponding to the concentration point Ci is calculated as I j,i :

[0029]

[0030] Among them, I j,i is the intensity of the jth Raman peak at Ci concentration, Ci is the concentration of fishery drugs, k j is the proportional constant; j is a random error term that obeys normal distribution; using the generated peak intensity I j,i and the Raman peak Gaussian shape to reconstruct the new spectral data X aug3 (υ), the formula is as follows:

[0031]

[0032] Where υ is the Raman shift, v j is the position of the jth Raman peak, σ j is the standard deviation of the j-th Raman peak, indicating the peak width, and Noise(υ) is the background Gaussian noise of the entire spectrum.

[0033] Preferably, in step S2,

[0034] In outdoor scenarios or when the equipment is unstable and there are many random errors in the original data, the data volume is amplified by adding random errors, simulating periodic environmental interference to amplify the data volume, and generating spectral data of different concentrations through chemometric methods to amplify the data volume in a ratio of 4:3:2;

[0035] When periodic interference is significant and the equipment has a large impact, the ratio of adding random errors to convert the amplified data volume, simulating periodic environmental interference to amplify the data volume, and generating different concentration spectral data by chemometric method to amplify the data volume is 2:4:3;

[0036] When the experimental random error is very small and the importance of the chemometric data is high, the ratio of adding random error to convert the amplified data volume, simulating periodic environmental interference to amplify the data volume, and generating different concentration spectral data through chemometric method to amplify the data volume is 3:3:3.

[0037] Preferably, in step S3, the input spectral data is represented as a one-dimensional vector X∈R N , where N is the number of Raman spectral data points, ranging from 300 to 3000.

[0038] Preferably, in step S5, one-dimensional convolution is used to extract local features of the spectrum, with a convolution kernel size of k, a number of convolution kernels of c, a step size of s, and a padding of p. The output of the convolution layer is calculated as follows:

[0039] H CNN =ReLU(Conv1D(X,W CNN )+b CNN )

[0040] Where W CNN is the convolution kernel weight, b CNN is the bias term, ReLU is the activation function;

[0041] The global features and long-distance dependencies of spectral data are captured by the Transformer encoder, which consists of a multi-head self-attention mechanism and a feedforward neural network. The input feature sequence is linearly transformed H CNN Get the query Q, key K and value V matrices:

[0042] Q=H CNN W Q ,K=H CNN W K ,V=H CNN W Q

[0043] Among them, W Q ,W K ,W Q is a learnable weight matrix;

[0044] Then calculate the attention weight and get the attention output:

[0045]

[0046] where d k is the dimension of the key vector, which is set according to the spectral information; several groups of attention weights are calculated at different spectral bands and spliced ​​into multi-head self-attention output;

[0047] Input the multi-head self-attention output into the feedforward neural network to perform nonlinear transformation on the attention output;

[0048] Add residual connections to each sub-layer and perform layer normalization to stabilize model training;

[0049] The output features of the encoder are passed through a fully connected layer and mapped to the predicted value of the substance concentration.

[0050] Preferably, in step S6, the substance concentration prediction value is read and the loss function value is calculated using the mean square error method, and the formula is as follows:

[0051]

[0052] Among them L pre Represents the error value obtained after calculation. The larger the value, the worse the prediction effect. N is the number of samples, y i is the true concentration of the i-th sample, is the concentration predicted by the model.

[0053] Preferably, in step S9, the loss function value is calculated. For the concentration regression task of multiple fishery drugs, the mixed sample mean square error is used as the loss function, which is defined as follows:

[0054]

[0055] Among them, M is the number of species contained in the mixed sample, y i,j is the true concentration of the jth substance in the i-th sample, is the concentration predicted by the model.

[0056] The technical solution of the present invention has the following advantages over the prior art:

[0057] The technical solution of the present invention proposes a Raman spectroscopy detection method for mixed fishery drugs that combines data augmentation methods with the RA-CTNet model. By combining chemometric methods and experimental random error simulation methods to expand data, the cost of database construction is reduced and the model robustness is improved. In model construction, the advantages of CNN in local feature extraction and the ability of Transformer in global feature modeling are fully utilized. A training strategy of pre-training and transfer learning is adopted to effectively utilize the rich feature information of single fishery drugs, improve the accuracy of mixed fishery drug prediction, and achieve quantitative detection of nanomolar concentrations in complex mixed samples. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the structures shown in these drawings without paying any creative work.

[0059] Figure 1 This is a flow chart of the Raman spectroscopic detection method for mixed fishery drugs of the present invention;

[0060] Figure 2 This is a model framework diagram for predicting the concentration of mixed fishery drugs based on Raman spectroscopy of the present invention;

[0061] Figure 3 This is a graph showing the quantitative detection performance evaluation of a single pre-trained sample of the present invention;

[0062] Figure 4 This is the MSE result diagram of the RA-CTNet model of the present invention;

[0063] Figure 5 The figure compares the results of the RA-CTNet model and the traditional partial least squares discriminant analysis algorithm.

[0064] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings and in conjunction with the embodiments. DETAILED DESCRIPTION

[0065] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0066] The present invention proposes a Raman spectrum detection method for mixed fishery drugs, see Figures 1 to 5 .

[0067] Sample preparation and Raman spectrum acquisition

[0068] By adjusting the concentration of ofloxacin, sulfathiazole and malachite green in the range of 10 -5 M to 10 -9 M, are dissolved separately in the water used for aquaculture to prepare multiple solutions of single fishery medicines.

[0069] By using surface enhanced Raman spectroscopy (SERS) technology to detect single fishery drug samples at each concentration, 5-15 spectral data were collected at each concentration, and finally 300 single fishery drug sample data were obtained.

[0070] Then, any two of the above three fishery drugs with different concentrations were extracted and mixed to prepare a two-mixed solution. Raman spectroscopy was used for analysis, and finally 20 two-mixed fishery drug sample data were collected.

[0071] The three fishery drugs mentioned above were then mixed at different concentrations and analyzed using Raman spectroscopy to prepare 50 three-mixed fishery drug sample data.

[0072] Data preprocessing

[0073] According to the Raman spectrum analysis of the single fishery drug sample, the two-mixed fishery drug sample and the three-mixed fishery drug sample obtained above, the Raman spectrum characteristics and the detection band of the Raman spectrometer were obtained, and the full-wavelength Raman spectrum was intercepted, and the 800cm -1 ~1490cm -1 The bands within the range are analyzed and 690 feature points are obtained.

[0074] At the same time, the Raman spectra in the sample were corrected for baseline drift to eliminate the intensity differences and random errors between different spectra.

[0075] Eliminate the intensity differences and random errors between different spectra, and transform each sample point X of the original spectrum raw Enter the following formula to obtain the preprocessed spectral data and complete the spectral preprocessing;

[0076]

[0077] Among them, μ and σ are respectively raw The mean and standard deviation of Indicates moving average smoothing, with the window size set to W, where W ranges from 1 to 20; and are the minimum and maximum values ​​of the smoothed data respectively.

[0078] Standardize the spectral data to achieve mean normalization of all sample data;

[0079] After normalizing the mean of the sample data, a moving average smoothing method is used, and the window size W is set to 5 to achieve smoothing of the sample data to reduce the interference of noise;

[0080] The smoothed data is normalized to the minimum and maximum values, and the data is scaled to the data interval of [0, 1] for normalization.

[0081] Data augmentation

[0082] Actual Raman spectral data is often interfered with by various random or periodic noises during the acquisition process. For random noises such as instrument noise and environmental noise, adding random errors can effectively simulate the impact of these uncontrollable factors on spectral data, enhance the model's robustness to noise, and improve its generalization ability in practical applications.

[0083] Periodic interference, such as power supply frequency fluctuations and mechanical vibrations of the spectrometer, often manifests as periodic signals. By introducing trigonometric function errors, we can simulate the impact of these periodic interferences on spectral data, helping the model identify and mitigate the negative effects of such interference.

[0084] The amount of data collected by the technical solution of the present invention is not massive. In order to expand the scale of the data set and improve the robustness of the entire data model, the technical solution of the present invention simultaneously adopts three data augmentation methods to amplify the original data.

[0085] Since the data collected in the laboratory environment has a small data error and the experimental sample size is small, the technical solution of the present invention can amplify the data volume by a total of nine times through three data amplification methods.

[0086] To add random error to the amplification data, use the following transformation formula:

[0087] X aug1 =X norm +∈

[0088] Where ∈ is the simulated random noise parameter, which follows the distribution θ is the noise amplitude control parameter.

[0089] After inputting spectral data, the corresponding spectral data is converted into amplified data by adding random errors, simulating periodic environmental interference to amplify the data, and generating spectral data of different concentrations through chemometric methods to amplify the data. The technical solution of the present invention uses random error addition for data amplification, adding random noise to the original spectral data with an error range of 8% of the original value to amplify the data three times.

[0090] Specifically, a random noise matrix with uniform distribution was generated with a noise amplitude of 8% of the original data. The generated random noise was added to the original spectral data to obtain amplified data, and the amplification type was marked as "GAUSSIAN_0.08".

[0091] The simulated periodic environmental interference amplifies the data, and the amplified sample is a trigonometric function error. The simulated periodic environmental interference, the conversion formula is X aug2 =X norm +S, where S is the simulated periodic sinusoidal noise parameter. Its generation period is T, and T ranges from 10 to 1000. The parameter S obeys the following distribution:

[0092]

[0093] in is a random phase.

[0094] Specifically, the present invention performs data amplification by adding a sinusoidal function error, adding periodic noise in the form of a sinusoidal function to the original spectral data to simulate periodic environmental interference, wherein the period can be selected as 100 and the maximum amplitude is 8% of the original value, thereby amplifying three times the data.

[0095] Specifically, by generating the horizontal coordinate array X, randomly generating the phase offset φ, and calculating the sinusoidal noise in The average value of each sample is obtained by adding sinusoidal noise to the original spectral data, and the amplified data is marked as "SIN_0.08".

[0096] The present invention also generates spectral data of different concentrations by chemometric method to amplify data. Based on the chemometric generation, spectral data at different concentrations are generated by chemometric method; the range of fishery drug concentration Cmin to Cmax is determined, and multiple concentration points {C1, C2, ..., Cm} are generated within the above range. According to the exponential function relationship between the fishery drug concentration and the Raman peak intensity, the spectral data at different concentrations are simulated, and the characteristic peak intensity corresponding to the concentration point Ci is calculated as I j,i :

[0097]

[0098] Among them, I j,i is the intensity of the jth Raman peak at Ci concentration, Ci is the concentration of fishery drugs, k j is the proportional constant; j is a random error term that obeys normal distribution; using the generated peak intensity I j,i and the Raman peak Gaussian shape to reconstruct the new spectral data X aug3(υ), the formula is as follows:

[0099]

[0100] Where υ is the Raman shift, v j is the position of the jth Raman peak, σ j is the standard deviation of the j-th Raman peak, indicating the peak width, and Noise(υ) is the background Gaussian noise of the entire spectrum.

[0101] The present invention performs data amplification based on a chemometrics method. By using the principles of chemometrics and establishing a correlation between concentration values ​​and Raman peak intensities according to a known concentration range, the spectral data at different concentrations is simulated and amplified three times the data.

[0102] Specifically, in the concentration range of 10 -5 M to 10 -9 M, generate multiple concentration values, calculate the intensity of the characteristic peak at each concentration based on the exponential function relationship between concentration and Raman peak intensity, and then use the Voigt function to simulate the Raman peak shape to generate each characteristic peak. By superimposing all characteristic peaks, adding background signals, noise and baseline drift, finally construct complete simulated spectral data. The generated simulated spectral data is used as the amplified data, and the amplification type is marked as "CHEMOMETRIC".

[0103] The present invention generates spectral data at different concentrations through chemometric methods, which can expand sample diversity and cover more possible chemical states. This is especially true for mixed-component samples, which are limited by sample size, detection difficulty, and workload, and cannot simulate spectral data for every concentration mixture. Simultaneously, chemometric simulation is based on Raman spectroscopy theory. The generated data input data set not only increases the data volume but also incorporates physical and chemical mechanisms as prior information into the model, enriching the chemical information of the data. This helps the model more accurately capture the relationship between substance concentration and spectral characteristics, increasing model interpretability.

[0104] A single amplification method can often only solve the problem of insufficient data of a specific type. In real-world scenario data, random errors and periodic errors are coupled with each other, exist in large quantities in the data, and cannot be completely eliminated by data preprocessing alone. At the same time, although the data generation method based on chemometrics can deepen the model's understanding of physical and chemical theories and effectively amplify data that lacks experiments, there is a certain error between the data generated by chemometrics and the actual results, and its applicability needs to be enhanced with the help of a large amount of real-world scenario data. The combined use of these three methods is necessary to fully cover the various factors of variation in the data, improve the diversity and authenticity of the amplified data, and thus significantly improve the performance and robustness of the model.

[0105] Adjustments should be made based on the original sample size, data characteristics, and specific model requirements, including:

[0106] Balance data diversity with amplification performance, ensuring that each amplification method is appropriately represented in the data to cover different types of variants.

[0107] According to the noise level of the original data, if the original data has more noise, the proportion of random error addition can be appropriately increased; if the periodic interference is significant, the proportion of periodic interference simulation can be increased.

[0108] Based on experimental experience and model verification, the effects of different amplification ratios on model performance were tested through methods such as cross-validation, and the optimal ratio combination was selected.

[0109] In outdoor scenarios or when the device is unstable and the raw data contains significant random errors, the ratio of adding random errors to amplify the data volume, simulating periodic environmental interference to amplify the data volume, and generating spectral data of varying concentrations using chemometric methods to amplify the data volume is 4:3:2. Increasing the ratio of adding random errors to amplify the data volume helps the model better cope with and generalize noise in the data.

[0110] When periodic interference is significant and the impact of the equipment is large, random errors are added to convert the amplified data volume, periodic environmental interference is simulated to amplify the data volume, and spectral data of different concentrations are generated by chemometric methods to amplify the data volume in a ratio of 2:4:3. The ratio of the amplified data volume to simulate periodic environmental interference is used to make the model more capable of coping with periodic changes.

[0111] When the experimental random error is very small and the importance of the chemometric data is high, adding random error conversion to amplify the data volume, simulating periodic environmental interference to amplify the data volume, and generating different concentration spectral data through chemometric methods to amplify the data volume in a ratio of 3:3:3 can enhance the model's understanding and application of physical and chemical theories.

[0112] When the original data is extremely limited and the data error is small, it is recommended to add random error conversion to amplify the data volume, simulate periodic environmental interference to amplify the data volume, and generate spectral data of different concentrations through chemometric methods to amplify the data volume in a ratio of 3:3:3. With a smaller sample size, various methods should be amplified in a balanced manner to maximize data diversity and improve the generalization ability of the model.

[0113] Merge amplification data

[0114] The data amplified by the three methods above need to be merged to form the final amplified data set, which is a table format file named with a specific name.

[0115] After completing data preprocessing and data amplification, the present invention is used to predict the concentration of mixed fishery medicine Raman spectra. First, the preprocessed and amplified Raman spectrum data is input into the convolutional neural network to extract local features of the spectrum, such as the shape and position of the characteristic peak. The convolution layer uses a one-dimensional convolution operation, which can effectively capture the local pattern of the spectral data. Then, the feature sequence extracted by the convolution layer is input into the Transformer encoder. Transformer uses a multi-head self-attention mechanism to model the global correlation of spectral data and capture long-distance feature dependencies. By superimposing multiple layers of Transformer encoders, the model can deeply understand the complex characteristics of spectral data. Finally, after the fully connected layer, the extracted features are mapped to the concentration prediction values ​​of each fishery medicine. The training of the model is divided into two stages: pre-training and transfer learning, so as to make full use of the data of single fishery medicine and mixed fishery medicine and improve the generalization ability of the model.

[0116] Pre-training phase

[0117] The deep learning model RA-CTNet based on the combination of convolutional neural network (CNN) and transformer network is used to predict the concentration of mixed fishery drugs based on Raman spectra. The model framework is shown in the figure below. Figure 2 shown.

[0118] The model was first pre-trained using Raman spectral data from a single fishery drug and its corresponding concentration labels. The dataset was divided into a training set and a validation set with an 80%:20% ratio, and the input data was normalized. The RA-CTNet model architecture was then defined, consisting of an input layer, two one-dimensional convolutional layers, and a fully connected layer to extract local spectral features. The model was then trained using the Adam optimizer, using the mean squared error (MSE) as the loss function. During training, the validation set loss was monitored, and the model parameters with the lowest validation loss were retained until the predetermined number of training rounds was reached or the prediction accuracy requirement was met.

[0119] Transfer learning stage,

[0120] The present invention applies the pre-trained model to the Raman spectral data of mixed fishery drugs, and the specific steps are as follows:

[0121] The dataset of mixed fishery drugs was divided into training and validation sets in a ratio of 80%:20%, and the same normalization method as the pre-training stage was used; by loading the pre-training model parameters, the parameters of the convolutional layer were frozen, and only the Transformer encoder and output layer were trained; the multi-task mean square error was defined as the loss function, and the model was trained for the concentration regression task of the three fishery drugs; during the training process, the loss of the validation set was monitored, and the model parameters with the smallest validation loss were saved until the predetermined number of training rounds was reached or the prediction accuracy requirements were met.

[0122] Model evaluation and prediction

[0123] The present invention uses the trained RA-CTNet model to predict unknown samples. The specific steps are as follows:

[0124] The Raman spectral data of the samples to be tested were preprocessed and amplified in a manner consistent with the training data; the processed data were input into the RA-CTNet model to quickly obtain the concentration prediction values ​​of each fishery drug; the mean square error method was used to calculate the loss between the predicted value and the true value to evaluate the prediction accuracy and robustness of the model.

[0125] Pre-training single sample quantitative detection performance evaluation

[0126] like Figure 3 As shown in Figure 2, in the single sample quantitative detection, the mean square error (MSE) of the model reached 0.0024. The quantitative value is expressed as the negative logarithm of the concentration C. -5 M to 10 -9 Under the fishery drug sample of M, the classification accuracy of the model reached 100%.

[0127] Performance evaluation of quantitative detection of mixed samples

[0128] When processing mixed fishery drug samples, the MSE results of the RA-CTNet model are as follows: Figure 4 As shown, the mean of the three samples is 0.4, which is higher than the traditional partial least squares discriminant analysis (PLS-DA) algorithm (MSE = 0.5, such as Figure 5 This result shows that the model of the present invention has higher prediction accuracy and robustness in processing mixed samples with complex background noise.

[0129] Computing platform configuration:

[0130] The training and testing of the model of the present invention are carried out on the following hardware configuration: CPU using The Gold6226R CPU @ 2.90GHz supports large-scale data processing and complex computing needs. The GPU uses the NVIDIA GeForce RTX3090, which provides efficient parallel processing capabilities and greatly accelerates the training process of deep learning models.

[0131] Processing time evaluation

[0132] Under the above hardware configuration, the total time consumed by this model in testing 10 data pieces is 0.412 seconds, and the average time for identifying a piece of spectral data does not exceed 0.05 seconds, which meets the needs of most practical application scenarios.

[0133] Iterative optimization of loss function

[0134] Over 1,000 training iterations, the model's loss showed a continuous downward trend, demonstrating continued improvement in performance. This nonlinear decrease in loss reflects the influence of random data and does not lead to unstable model performance, demonstrating good generalization capabilities.

[0135] The technical solution of the present invention has been successfully applied to the identification of binary and ternary mixtures, showing a strong recognition ability for more complex quaternary and quinary mixtures, and providing strong technical support for complex scenarios in practical applications. The present invention realizes the efficient detection of the absolute concentration Raman spectrum of the mixture through the above steps, which can reduce the cost of building a data set. Through the data amplification method, it reduces the demand for large-scale real data and reduces the cost of building a database; improves the detection accuracy, and the model architecture based on the convolutional neural network and the Transformer network makes full use of local and global features to improve the prediction accuracy of the model. It can also improve the detection speed. Compared with the traditional chemometric method, the model achieves a microsecond prediction speed for the data after construction, and does not require complex preprocessing steps; enhances the robustness of the model, and through a variety of data amplification methods, improves the model's adaptability to different noises and interferences, ensuring stability and accuracy in complex detection scenarios.

[0136] The above description is only a preferred embodiment of the present invention and does not limit the patent scope of the present invention. All equivalent structural transformations made by using the contents of the present invention description and drawings under the concept of the present invention, or direct / indirect application in other related technical fields are included in the patent protection scope of the present invention.

Claims

1. A Raman spectroscopy detection method for mixed fishery drugs, characterized in that: The following steps are involved: Step S1: intercepting the full-band Raman spectrum according to the Raman spectral characteristics of the target substance and the detection band of the Raman spectrometer, and then correcting the baseline drift of the Raman spectrum in the sample to eliminate the intensity difference and random error between different spectra; Step S2: After inputting the spectral data, the corresponding spectral data is converted and amplified by adding random errors, simulating periodic environmental interference, and generating spectral data of different concentrations by chemometric method to amplify the data; the chemometric method generates reconstructed spectral data based on Raman peak intensity and shape; In outdoor scenarios or when the equipment is unstable and there are many random errors in the original data, the data volume is amplified by adding random errors, simulating periodic environmental interference to amplify the data volume, and generating spectral data of different concentrations through chemometric methods to amplify the data volume in a ratio of 4:3:2; When periodic interference is significant and the equipment has a large impact, the ratio of adding random errors to convert the amplified data volume, simulating periodic environmental interference to amplify the data volume, and generating different concentration spectral data by chemometric method to amplify the data volume is 2:4:3; When the experimental random error is very small and the importance of the chemometric data is high, the ratio of adding random error to convert the amplified data volume, simulating periodic environmental interference to amplify the data volume, and generating different concentration spectral data by chemometric method to amplify the data volume is 3:3:3; Step S3: receiving the spectral data after preprocessing and data amplification, where the input spectral data is represented as a one-dimensional vector; Step S4: Using the Raman spectral data of a single substance and its corresponding concentration labels, a pre-trained model is built after preprocessing and data enhancement; Step S5: Input the pre-trained data set into the model, perform forward propagation, and calculate the predicted value; Step S6: Read the predicted value of the substance concentration and calculate the loss function value; use the loss function value as a reference, backpropagate, update the model parameters, and repeat steps S5-S6 until the loss function value no longer decreases or the loss function value meets the prediction accuracy requirement. After pre-training is completed, save the model parameters for subsequent mixed sample transfer learning; Step S7: Using the Raman spectral data of the mixed fishery drug and its corresponding concentration labels as the data set for transfer learning after preprocessing and data enhancement; Step S8: Input the mixed sample data set into the model, load the pre-trained model parameters, freeze the parameters of the convolutional layer, train only the encoder and fully connected layers, perform forward propagation, and calculate the predicted value; Step S9: For the concentration regression task of multiple fishery drugs, the mixed sample mean square error is used as the loss function; Step S10: Based on the mixed sample mean square error value as a reference, back propagate, update the model parameters and repeat the steps S8-S9 process until the mixed sample mean square error value no longer decreases after multiple rounds, or the mixed sample mean square error value meets the prediction accuracy requirement. After training is completed, save the final model parameters.

2. The Raman spectroscopy detection method for mixed fishery drugs according to claim 1, wherein: In step S1, the intensity difference and random error between different spectra are eliminated, and each sample point X of the original spectrum is converted to raw Enter the following formula to obtain the preprocessed spectral data and complete the spectral preprocessing; Among them, μ and σ are respectively raw The mean and standard deviation of Indicates moving average smoothing, with the window size set to W, where W ranges from 1 to 20; )and ) are the minimum and maximum values ​​of the smoothed data respectively.

3. The Raman spectroscopy detection method for mixed fishery drugs according to claim 1, wherein: In step S2, the random error is added to transform the amplified data using the following transformation formula: X aug1 =X norm +∈ Where ∈ is the simulated random noise parameter, which follows the distribution θ is the noise amplitude control parameter; The simulated periodic environmental interference amplifies the data, and the amplified sample is a trigonometric function error. The simulated periodic environmental interference, the conversion formula is X aug2 =X norm +S, where S is the simulated periodic sinusoidal noise parameter. Its generation period is T, and T ranges from 10 to 1000. The parameter S obeys the following distribution: in is a random phase; The method generates spectral data of different concentrations by chemometric method to amplify data. Based on the chemometric method, spectral data at different concentrations are generated by chemometric method; the range of fishery drug concentration Cmin to Cmax is determined, and multiple concentration points {C1, C2, ..., Cm} are generated within the above range. According to the exponential function relationship between the fishery drug concentration and the Raman peak intensity, the spectral data at different concentrations are simulated, and the characteristic peak intensity corresponding to the concentration point Ci is calculated as I j,i : Among them, I j,i is the intensity of the jth Raman peak at Ci concentration, Ci is the concentration of fishery drugs, k j is the proportional constant; j is a random error term that obeys normal distribution; using the generated peak intensity I j,i and the Raman peak Gaussian shape to reconstruct the new spectral data X aug3 (υ), the formula is as follows: Where υ is the Raman shift, v j is the position of the jth Raman peak, σ j is the standard deviation of the j-th Raman peak, indicating the peak width, and Noise(υ) is the background Gaussian noise of the entire spectrum.

4. The Raman spectroscopy detection method for mixed fishery drugs according to claim 1, wherein: In step S3, the input spectral data is represented as a one-dimensional vector X∈R N , where N is the number of Raman spectral data points, ranging from 300 to 3000.

5. The Raman spectroscopy detection method for mixed fishery drugs according to claim 1, wherein: In step S5, one-dimensional convolution is used to extract local features of the spectrum. The convolution kernel size is k, the number of convolution kernels is c, the step size is s, and the padding is p. The output of the convolution layer is calculated as follows: H CNN =ReLU(Conv1D(X,W CNN )+b CNN ) Where W CNN is the convolution kernel weight, b CNN is the bias term, ReLU is the activation function; The global features and long-distance dependencies of spectral data are captured by the Transformer encoder, which consists of a multi-head self-attention mechanism and a feedforward neural network. The input feature sequence is linearly transformed H CNN Get the query Q, key K and value V matrices: Q=H CNN ·W Q ,K=H CNN ·W K ,V=H CNN ·W Q Among them, W Q ,W K ,W Q is a learnable weight matrix; Then calculate the attention weight and get the attention output: where d k is the dimension of the key vector, which is set according to the spectral information; several groups of attention weights are calculated at different spectral bands and spliced ​​into multi-head self-attention output; Input the multi-head self-attention output into the feedforward neural network to perform nonlinear transformation on the attention output; Add residual connections to each sub-layer and perform layer normalization to stabilize model training; The output features of the encoder are passed through a fully connected layer and mapped to the predicted value of the substance concentration.

6. The Raman spectroscopy detection method for mixed fishery drugs according to claim 1, characterized in that: In step S6, the predicted value of the substance concentration is read and the loss function value is calculated using the mean square error method, which is as follows: Among them L pre Represents the error value obtained after calculation. The larger the value, the worse the prediction effect. N is the number of samples, y i is the true concentration of the i-th sample, is the concentration predicted by the model.

7. The Raman spectroscopy detection method for mixed fishery drugs according to claim 1, wherein: In step S9, the loss function value is calculated. For the concentration regression task of multiple fishery drugs, the mixed sample mean square error is used as the loss function, which is defined as follows: Among them, M is the number of species contained in the mixed sample, y i,j is the true concentration of the jth substance in the i-th sample, is the concentration predicted by the model.

Citation Information

Patent Citations

  • Method for quantitatively monitoring substance content by Raman spectroscopy

    CN113670894A

  • A mixture Raman spectroscopy qualitative analysis method, system and device

    CN117935963B