A Raman spectroscopy abnormal data detection method and system based on deep learning
Through deep learning methods combined with peak and multi-scale attention mechanisms, the problem of insufficient feature extraction and adaptability in Raman spectral anomaly data detection is solved, and efficient and accurate anomaly detection is achieved.
Patent Information
- Application Number
- CN202510429388.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-08
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2045-04-08
AI Technical Summary
The existing Raman spectral anomaly data detection methods lack special optimization of Raman spectral characteristics, rely on complex preprocessing processes, cannot effectively identify and utilize key features of the spectrum, and lack adaptive mechanisms, which affect the accuracy and robustness of the detection.
Using a deep learning-based method, Raman spectral features are extracted through peak attention guidance and multi-scale attention mechanism, combined with multi-layer gradual dimensionality reduction and reconstruction error analysis, end-to-end abnormal data detection is achieved.
It improves the extraction efficiency and robustness of Raman spectral features, reduces the omission of abnormal spectra, simplifies the processing flow, and improves the recall and accuracy of the model.
Smart Images

Figure CN119939226B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical fields of Raman spectroscopy analysis and anomaly detection, and more particularly to a method and system for detecting abnormal Raman spectroscopy data based on deep learning. Background Technique
[0002] As a non-destructive and fast molecular structure characterization method, Raman spectroscopy technology has been widely used in the fields of materials science, biomedicine, food safety, etc. However, in practical applications, Raman spectroscopy data collected by instruments are often affected by various factors and show anomalies, mainly including: signal saturation, instrument noise, baseline drift, flattening phenomenon, etc.
[0003] These abnormal data will seriously affect subsequent data analysis and interpretation work, and reduce the reliability of detection results. Therefore, the detection of abnormal Raman spectroscopy data is of great significance for subsequent Raman spectroscopy analysis and detection.
[0004] Existing spectroscopy detection technologies generally rely on traditional statistical methods and machine learning methods, and there are some challenges:
[0005] First of all, most existing anomaly detection methods are simple applications of general algorithms, lacking special optimization for the characteristics of Raman spectroscopy. Especially when dealing with the most characteristic peak information in spectroscopy data, these key features cannot be effectively identified and utilized, ignoring the unique physical and chemical significance of Raman spectroscopy;
[0006] Secondly, traditional methods rely too much on complex data preprocessing processes. Before anomaly detection, multiple preprocessing steps such as baseline correction, noise filtering, and peak extraction are often required. This not only increases the processing time and computational cost, but also may introduce additional errors during the preprocessing process. This method that relies on preprocessing seriously affects the practicability and reliability of the system.
[0007] Thirdly, existing methods are relatively mechanical and fixed in feature extraction and attention strategies. Whether it is traditional statistical methods or general deep learning methods, they all adopt a unified feature extraction strategy, lacking an adaptive attention mechanism for different spectral regions. This causes the model to be unable to dynamically adjust its attention focus according to the data characteristics, affecting the accuracy and robustness of anomaly detection.
[0008] Finally, existing methods lack a dynamic adaptation mechanism. Most methods use fixed judgment criteria and thresholds, and cannot be adaptively adjusted according to the actual data distribution characteristics, which to a certain extent affects the generalization ability of the model in different application scenarios.
[0009] Therefore, how to improve the existing spectral detection technology and provide a method and system for detecting abnormal data in Raman spectroscopy is an urgent problem to be solved by those skilled in the art. Summary of the Invention
[0010] In view of this, the present invention provides a method and system for detecting abnormal data in Raman spectroscopy based on deep learning, which is used to solve at least some of the technical problems in the background technology.
[0011] In order to achieve the above object, the present invention adopts the following technical solutions:
[0012] The present invention first discloses a method for detecting abnormal data in Raman spectroscopy based on deep learning, including:
[0013] Obtaining a corresponding peak attention guidance coefficient according to the peak position of the original spectral data in the dataset;
[0014] Obtaining a corresponding multi-scale attention coefficient according to the local enhanced features and global features of the original spectral data in the dataset;
[0015] Combining the peak attention guidance coefficient and the multi-scale attention coefficient of the original spectral data, and multiplying the combined attention coefficient with the corresponding original spectral data to obtain attention Raman spectral feature data;
[0016] Performing multi-layer step-by-step dimensionality reduction on the attention Raman spectral feature data to obtain a dimensionality reduction dataset composed of dimensionality-reduced Raman spectral feature data;
[0017] Performing a dimensionality reduction operation on the dimensionality reduction dataset by using the t-SNE dimensionality reduction algorithm to obtain a two-dimensional Raman spectral dataset;
[0018] Performing dimensionality increase on the dimensionality-reduced Raman spectral feature data to obtain reconstructed Raman spectral data with the same length as the original spectral data, and forming a reconstructed dataset;
[0019] Calculating the reconstruction error loss between the reconstructed Raman spectral data and the corresponding original spectral data, and forming a reconstruction error set;
[0020] Correspondingly splicing the two-dimensional Raman spectral dataset and the reconstruction error set to obtain a multi-dimensional feature dataset;
[0021] Performing classification prediction on the multi-dimensional feature dataset to obtain an abnormal data detection result.
[0022] Further, in a specific embodiment, obtaining a corresponding peak attention guidance coefficient according to the peak position of the original spectral data in the dataset specifically includes:
[0023] The peak position detection is performed on each original spectrum in the dataset by using a peak searching function to obtain the position and prominence of the characteristic peaks in each original spectrum;
[0024] A Raman peak region with a set width is generated based on the position of each characteristic peak;
[0025] The ratio of the prominence of the characteristic peak to the maximum prominence in the corresponding original spectrum is determined as the peak attention guidance coefficient of the Raman peak region;
[0026] The peak attention guidance coefficient of the non-Raman peak region in the original spectrum is set to 0;
[0027] The peak attention guidance coefficient of the Raman peak region and the peak attention guidance coefficient of the non-Raman peak region are combined into the peak attention guidance coefficient corresponding to the original spectrum data.
[0028] Furthermore, after obtaining the peak attention guidance coefficient, it further includes:
[0029] The obtained peak attention guidance coefficient is sequentially smoothed and normalized by using Gaussian filtering to obtain the smoothed peak attention guidance coefficient.
[0030] Furthermore, in a specific embodiment, the corresponding multi-scale attention coefficients are obtained according to the local enhancement features and global features of the original spectrum data in the dataset, specifically including:
[0031] Obtain the local enhancement features of the original spectrum data:
[0032] The original spectrum data is sequentially passed through a one-dimensional convolution kernel with a length of 3, a ReLU activation function layer, a one-dimensional convolution kernel with a length of 3, and a Sigmoid activation function layer to obtain local enhancement features with the same length as the original spectrum data;
[0033] Obtain the global features of the original spectrum data:
[0034] The original spectrum data is input into a first fully connected layer, a ReLU activation function layer, a second fully connected layer, and a Sigmoid activation function layer connected in sequence to obtain the global features of the original spectrum data;
[0035] Obtain the multi-scale attention coefficients:
[0036] The obtained local enhancement features and global features are multiplied element by element to obtain multi-scale attention coefficients with the same length as the input spectrum.
[0037] Furthermore, in a specific embodiment, the peak attention guidance coefficient and the multi-scale attention coefficient of the original spectrum data are combined, specifically including using the following combination formula: ;
[0038] wherein is the final attention coefficient obtained by combination, is the multi-scale attention coefficient, is the peak attention guidance coefficient.
[0039] Furthermore, in a specific embodiment, in the multi-layer step-by-step dimensionality reduction of the attention Raman spectral feature data, it specifically includes:
[0040] Using 4 sequentially connected fully connected layers, the attention Raman spectral feature data is gradually reduced in dimension from the original length to a 64-length feature vector in the order of 1024, 512, 256, and 64, and each fully connected layer includes a ReLu non-linear activation function.
[0041] Furthermore, in a specific embodiment, calculate the reconstruction error loss Loss total of the reconstructed Raman spectral data and the corresponding original spectral data, specifically including the following calculation formula: ;
[0042] wherein, is the mean square error loss between the corresponding original spectrum and the reconstructed Raman spectrum, is the cosine similarity loss between the corresponding original spectrum and the reconstructed Raman spectrum.
[0043] Furthermore, in a specific embodiment, the step of corresponding splicing of the two-dimensional Raman spectral dataset and the reconstruction error set specifically includes:
[0044] Splice each two-dimensional Raman spectral data in the two-dimensional Raman spectral dataset with the reconstruction error loss data of the corresponding original spectral data in the reconstruction error set according to a weight ratio of 6:4 to obtain multi-dimensional feature data, and form multi-dimensional feature data.
[0045] Furthermore, in a specific embodiment, classify and predict the multi-dimensional feature dataset to obtain the abnormal data detection result, specifically including the following steps:
[0046] Use the Kmeans clustering analysis algorithm to perform clustering analysis on the multi-dimensional feature dataset to obtain negative pre-classification label data and positive pre-classification label data, where the negative pre-classification label data corresponds to the pre-classification data of normal Raman spectra, and the positive pre-classification label data corresponds to the pre-classification data of abnormal Raman spectra;
[0047] Set an adaptive error threshold for the negative pre-classification label data;
[0048] Samples of the negative pre-classification label data with a reconstruction error loss less than the adaptive error threshold are determined as negative data, and those greater than or equal to the adaptive error threshold are determined as positive data, where the negative data corresponds to normal Raman spectrum data and the positive data corresponds to abnormal Raman spectrum data.
[0049] On the other hand, the present invention also discloses a Raman spectrum abnormal data detection system based on deep learning, including:
[0050] A peak attention guidance module for obtaining corresponding peak attention guidance coefficients according to the peak positions of the original spectrum data in the dataset;
[0051] A dual-branch attention perception module for obtaining corresponding multi-scale attention coefficients according to the local enhancement features and global features of the original spectrum data in the dataset;
[0052] An attention mechanism Raman spectrum acquisition module for combining the peak attention guidance coefficients and multi-scale attention coefficients of the original spectrum data, and multiplying the combined attention coefficients with the corresponding original spectrum data to obtain attention Raman spectrum feature data;
[0053] A dimensionality reduction network module for performing multi-layer step-by-step dimensionality reduction on the attention Raman spectrum feature data to obtain a dimensionality reduction dataset composed of dimensionality-reduced Raman spectrum feature data;
[0054] A t-SNE dimensionality reduction module for performing dimensionality reduction operations on the dimensionality reduction dataset to obtain a two-dimensional Raman spectrum dataset;
[0055] A dimensionality increase reconstruction network module for increasing the dimensionality of the dimensionality-reduced Raman spectrum feature data to obtain reconstructed Raman spectrum data with the same length as the original spectrum data, and forming a reconstruction dataset;
[0056] A reconstruction error loss module for calculating the reconstruction error loss between the reconstructed Raman spectrum data and the corresponding original spectrum data, and forming a reconstruction error set;
[0057] A multi-dimensional feature acquisition module for correspondingly splicing the two-dimensional Raman spectrum dataset and the reconstruction error set to obtain a multi-dimensional feature dataset;
[0058] An abnormal detection module for classifying and predicting the multi-dimensional feature dataset to obtain an abnormal data detection result.
[0059] Through the above technical solutions, compared with the prior art, the present invention discloses a method and system for detecting abnormal Raman spectrum data based on deep learning, having the following beneficial effects:
[0060] Through the Peak-Aware Attention mechanism, the present invention can simultaneously analyze the overall features and small-scale characteristic peaks of Raman spectra, and has strong pertinence and improvement in the extraction and reconstruction of Raman spectral features.
[0061] The present invention proposes an attention guidance module. By introducing the characteristic peaks searched by the peak search algorithm to assist model learning, the enhanced extraction of spectral peak features is realized through prior knowledge, improving the feature extraction efficiency and robustness of the model.
[0062] The present invention innovatively combines multi-dimensional features, including reconstruction error and multi-dimensional features, to achieve more comprehensive anomaly determination. And using the secondary determination based on the adaptive reconstruction threshold can greatly improve the "recall rate" of the model. For the anomaly spectrum detection scenario, it can greatly reduce the omission of anomaly spectra. And it improves the robustness of the model.
[0063] The present invention does not require complex preprocessing steps. The model can learn and process the original spectral data end-to-end, greatly simplifying the application process. Description of the Drawings
[0064] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only the embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained according to the provided drawings without creative efforts.
[0065] Figure 1 It is a schematic diagram of the overall flow of the detection method provided by the present invention.
[0066] Figure 2 It is a schematic diagram of the overall system architecture corresponding to the detection method provided by the present invention.
[0067] Figure 3 It is a schematic diagram of the architecture of the Raman spectral feature extraction module provided by the present invention.
[0068] Figure 4 It is a schematic diagram of the architecture of the anomaly detection module provided by the present invention.
[0069] Figure 5 It is a schematic diagram of the original spectrum and its reconstructed spectrum of a normal sample provided by an embodiment of the present invention.
[0070] Figure 6 It is a schematic diagram of the original spectrum and its reconstructed spectrum of an abnormal sample provided by an embodiment of the present invention.
[0071] Figure 7Schematic diagram of the effects of different dimensionality reduction methods provided by the embodiments of the present invention.
[0072] Figure 8 Schematic diagram of the classification result provided by the embodiments of the present invention. Detailed implementation manners
[0073] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0074] The embodiments of the present invention disclose a Raman spectroscopy abnormal data detection method based on deep learning, mainly including two steps: Raman spectroscopy feature extraction and abnormal spectrum detection. The overall architecture of this method can be referred to Figure 1 、 Figure 2 。
[0075] In the Raman spectroscopy feature extraction step, by designing a spectroscopy feature extraction network, the input Raman raw spectrum is realized, and the extracted spectroscopy features are obtained.
[0076] Specifically, as Figure 3 shown, the embodiments of the present invention perform Raman spectroscopy feature extraction through the designed spectroscopy feature extraction module. This spectroscopy feature extraction module includes a peak attention guidance module, a dual-branch multi-scale attention module, a multi-layer step-by-step dimensionality reduction module, and a dimensionality increase and reconstruction module.
[0077] Among them, the peak attention guidance module proposed by the present invention mainly includes a peak finding function sub-module, a peak attention guidance coefficient generation sub-module, and a Gaussian smoothing processing sub-module.
[0078] Specifically, first, the peak finding function sub-module performs preliminary peak position detection on a single raw spectrum using the peak finding function (scipy.signal.find_peaks). To ensure that the detected peaks have significant physical meanings, the peak prominence is set to more than 50% of the maximum intensity of the spectrum. This high threshold setting can effectively filter out the main peaks with significant Raman scattering characteristics and avoid the interference of weak peaks and noise peaks.
[0079] Then, the peak attention guidance coefficient generation sub-module generates a sequence with the same length as the original spectrum, and its initial values are all 0. For each characteristic peak detected by the peak detection function, the peak attention guidance module generates a region with a width of 10 (5 lengths before and after the peak position) at its corresponding position. The width of this region is set to include Raman peaks with more appropriate peak widths, and the attention guidance coefficients within this region are set to 1, indicating that these regions have important spectral feature information. An 01 sequence with peak position guidance information is obtained as the peak attention guidance coefficient.
[0080] Generate a Raman peak region with a set width based on the position of each characteristic peak, and set the attention guidance coefficient of the Raman peak region to the ratio of the peak prominence of this peak to the maximum prominence. The attention guidance coefficient of the non-Raman peak region is set to the initial value 0; for the Raman peak region, there is: ; where I is the attention guidance coefficient of the Raman peak region, is the peak prominence of this peak, is the maximum prominence in this spectrum.
[0081] Subsequently, the Gaussian smoothing processing sub-module smooths the peak attention guidance coefficient through Gaussian filtering (gaussian_filter1d). The kernel function of Gaussian filtering is defined as:
[0082] ;
[0083] where: x is the position from the peak center, σ is the standard deviation of the Gaussian kernel, which controls the smoothing degree (σ = 2 in this embodiment), and exp is the natural exponential function.
[0084] Gaussian filtering achieves the smoothing effect through the convolution operation of the kernel function and the original attention guidance coefficient:
[0085] ;
[0086] where: is the smoothed attention coefficient, w(n) is the original attention coefficient, and i is the position index of the convolution kernel. The smoothing process makes the attention have a continuous and smooth transition in the peak region, and this processing is more in line with the physical characteristics of the spectral peak. Finally, the peak attention guidance coefficient corresponding to the characteristic peak is obtained. This attention guidance mechanism based on prior knowledge can effectively guide the model to focus on the most characteristic peak regions in the spectrum, improving the model's learning and extraction ability of normal spectral features.
[0087] The dual-branch multi-scale attention module proposed by the present invention includes two parallel sub-structures: a local peak branch and a global feature branch. Among them, the local peak branch adopts a one-dimensional convolutional network structure. First, the original spectrum is expanded into 8-channel small-scale features through a small-scale convolutional layer with a kernel size of 3 to enhance the expression ability of local features. After non-linearly activating through the ReLU function, the above 8-channel small-scale features are compressed into single-channel features through a second small-scale convolutional layer with a kernel size of 3, and then normalized through the Sigmoid function, so as to obtain local peak features with the same length as the input spectrum, thereby adaptively learning the local peak feature distribution in the spectrum. The global feature branch is designed using a multi-layer perceptron structure, and its network architecture includes 2 linear layers and corresponding activation functions:
[0088] 1. The first fully connected layer: keeping the input dimension of the original spectrum unchanged, mapping the data to a feature space of the same dimension for learning the global features of the spectral data.
[0089] 2. ReLU activation function: introducing non-linear transformation ability to enhance the feature expression ability of the network.
[0090] 3. The second fully connected layer: also keeping the dimension unchanged and further extracting the global feature correlation.
[0091] 4. Sigmoid activation function: mapping the output to the interval (0, 1) to obtain the normalized global feature weight.
[0092] The original spectrum passes through the local peak branch and the global feature branch in the multi-scale attention module respectively to obtain the corresponding local peak features and global feature weights. Then, the obtained local peak features are multiplied element by element with the global feature weights to obtain multi-scale attention coefficients with the same length as the input spectrum. The specific formula is as follows:
[0093] ;
[0094] where is the multi-scale attention coefficient, is the global feature weight, is the local peak feature. This dual-branch structure is fused through the way of feature multiplication, which not only retains the local peak features but also considers the global spectral information, realizing the multi-scale feature enhancement of spectral data.
[0095] After the original spectrum obtains the corresponding peak attention guidance coefficient and multi-scale attention coefficient through the peak attention guidance module and the dual-branch multi-scale attention module respectively, the model will combine the two coefficients to obtain the final attention coefficient. The specific formula is as follows:
[0096] ;
[0097] Among them is the final attention coefficient, is the multi-scale attention coefficient, is the peak attention guidance coefficient. The module will retain 30% of the multi-scale attention coefficient as the self-learning space, and adjust the attention distribution under the guidance of the peak, so that the spectral feature extraction network can improve the model's perception ability of spectral features on the basis of the peak guidance information. Finally, the attention coefficient is multiplied by the original spectrum to obtain the Raman spectrum after being concerned by the attention mechanism.
[0098] After obtaining the Raman spectrum after being concerned by the attention mechanism, a multi-layer step-by-step dimensionality reduction method is adopted to gradually reduce the original spectrum with a larger scale into a Raman spectrum feature with a smaller scale. Specifically, 4 fully connected layers with ReLu non-linear activation are connected in sequence to form a dimensionality reduction network, and the original spectrum (length 1500) is gradually reduced into a feature vector with a length of 64 in the order of 1024, 512, 256, and 64. Correspondingly, there is a spectral reconstruction network (dimensionality increase network) symmetric to the structure of the layer-by-layer dimensionality reduction, which is composed of 4 fully connected layers with ReLu non-linear activation, and the spectral features are used for spectral reconstruction in the order of lengths of 64, 256, 512, 1024, and 1500. During this process, the weighted value of the mean square error (mse) and cosine similarity of the reconstructed spectrum is calculated as the reconstruction loss Loss total , and the specific formula is as follows:
[0099] ;
[0100] Among them is the mean square error loss between the original spectrum and the reconstructed spectrum, is the cosine similarity loss between the original spectrum and the reconstructed spectrum. In the reconstruction loss, the mean square error loss pays more attention to the similarity of corresponding points, and the specific formula of the mean square error loss is as follows:
[0101] ;
[0102] Among them, N is the dimension of the spectral data, x i is the value of the original spectral data at position i, is the value of the reconstructed spectral data at position i.
[0103] The cosine similarity loss pays more attention to the similarity of the overall spectral shape, and its specific formula is as follows:
[0104]
[0105] Among them, x represents the original spectral vector, represents the reconstructed spectral vector, · represents the inner product of vectors, and ||x|| represents the L2 norm of the vector. The detection model constructed by the present invention will automatically learn the feature representation of normal spectra according to the loss function.
[0106] In the abnormal spectrum detection step, the Raman spectral features after dimensionality reduction and the reconstruction error (the calculation is the same as the above reconstruction loss, but it is more appropriate to name it "reconstruction loss" during model training, and the reconstruction error is used hereinafter) are jointly determined to obtain the determination result of the abnormal spectrum. The specific process of the abnormal detection step in the present invention can be referred to Figure 4 the schematic diagram of the abnormal detection module architecture shown.
[0107] Specifically, the embodiment of the present invention uses t-SNE dimensionality reduction to reduce the dimensionality-reduced Raman spectral feature data to 2D, which can better retain local features compared with other mainstream dimensionality reduction methods (such as u-map, pca, etc.). The decoder calculates the reconstruction error between the reconstructed spectrum and the original spectrum: the weighted value of 0.7 * mean square error mse + 0.3 * cosine similarity.
[0108] Specifically, after the embodiment of the present invention obtains the t-SNE dimensionality reduction features and the reconstruction error, the multi-dimensional information fusion is realized through feature splicing. Different weight coefficients are assigned to the t-SNE dimensionality reduction features and the reconstruction error (t-SNE features: reconstruction error = 6:4) and then spliced to flexibly adjust the weights according to the actual situation.
[0109] Specifically, for the spliced multi-dimensional features, the embodiment of the present invention uses a method of joint determination with dual indicators. First, Kmeans clustering analysis is performed on the multi-dimensional features (the number of clusters = 2, normal spectra and abnormal spectra). Due to the design of the spectral feature extraction network S1, the spectral feature extraction network S1 has better feature extraction ability for normal data than abnormal spectra. On the multi-dimensional features, the normal spectra will be clustered near a cluster, while the remaining abnormal data will be far from this cluster due to feature differences. The Kmeans algorithm will obtain negative and positive pre-classification labels (corresponding to normal spectra and abnormal spectra respectively). Then, the method of adaptive reconstruction error threshold is used for the second index determination. For the data pre-classified as negative (normal data) labels, the reconstruction error will be statistically calculated and the reconstruction error value at the 95% percentile will be adaptively selected as the adaptive error threshold. The data with a reconstruction error less than this threshold is determined as negative data, and the samples with a reconstruction error greater than this threshold are determined as positive data.
[0110] The following describes the specific application of the present invention through more specific embodiments.
[0111] Example 1:
[0112] In Example 1, a number of samples were first collected using a handheld spectrometer, including 1000 normal samples. The abnormal samples consisted of saturated spectra, noise spectra, and flat spectra, with a total of about 400 cases (the proportion of abnormal samples would not be so high during normal collection, and such a design can test the robustness of the model). The length of each sample was 1500.
[0113] Then, by designing a spectral feature extraction network module, the input Raman raw spectrum was processed to obtain the extracted spectral features. There was also a decoding network with a corresponding symmetric structure for spectral reconstruction and reconstruction error calculation.
[0114] Specifically, as Figure 3 shown, the spectral feature extraction network module designed in Example 1 included a peak attention guidance module, a peak perception attention module, a multi-layer stepwise dimensionality reduction module, etc.
[0115] Specifically, for the peak attention guidance module proposed by the present invention for spectral feature extraction, a peak finding function (scipy.signal.find_peaks) was used to detect the initial peak positions and widths. For each detected peak position, the algorithm generated an influence region around it. The width of this region was the detected feature peak width, and the attention guidance coefficient within this region was set to 1.0, indicating that these regions had important spectral feature information. Subsequently, the attention coefficient distribution was smoothed through Gaussian filtering (gaussian_filter1d) to make the attention have a continuous and smooth transition in the peak region, which was more in line with the physical characteristics of spectral peaks. Finally, the peak attention guidance corresponding to the feature peaks was obtained. This attention guidance mechanism based on prior knowledge could effectively guide the model to focus on the most characteristic peak regions in the spectrum, significantly improving the model's ability to learn and extract normal spectral features.
[0116] Specifically, the dual-branch peak perception attention module proposed by the present invention for spectral feature extraction included two parallel sub-structures: a peak detection branch and a feature attention branch. Among them, the peak detection branch adopted a one-dimensional convolutional network structure. First, a small-scale convolutional layer with a kernel size of 3 was used to expand the input signal to 8 channels to enhance the expression ability of local features. After passing through the ReLU activation, a second convolutional layer was used to compress the features back to a single channel and normalize them through the Sigmoid function, so as to adaptively learn the peak feature distribution in the spectrum. The feature attention branch adopted a fully connected layer design and learned the global feature correlation of the spectrum through two non-linear transformations. The Sigmoid function was also used to output the normalized feature weights. This dual-branch structure was fused by means of feature multiplication, which not only retained the local peak features but also considered the global spectral information, realizing multi-scale feature enhancement of spectral data.
[0117] Specifically, for the spectral feature extraction step of the present invention, when fusing the attentions of the peak attention guidance module and the peak perception attention module, the module will retain 30% of the self-learning space and adjust the attention distribution under the guidance of the peak, so that the spectral feature extraction network can improve the model's perception ability of spectral features on the basis of the peak guidance information.
[0118] Specifically, after combining the output of the attention module with the original spectrum, the present invention adopts a method of multi-layer stepwise dimensionality reduction. In this embodiment, the gradients of 1024, 512, 256, and 64 are used for dimensionality reduction, that is, the 1500-length spectrum is gradually reduced to 64-length, and the original spectrum with a larger scale is gradually reduced to a small-scale Raman spectral feature. Correspondingly, there is a spectral reconstruction network (64, 256, 512, 1024, 1500) symmetric to the structure of the layer-by-layer dimensionality reduction to reconstruct the spectrum using the spectral features. During this process, the mean square error (mse) of the reconstructed spectrum is calculated, and the cosine similarity is used as the reconstruction loss and optimized, so that the model can automatically learn the feature representation of the normal spectrum.
[0119] Figure 5 and Figure 6 demonstrates the feature extraction and reconstruction capabilities of the spectral feature extraction network trained by the above samples. Among them, Figure 5 are the original spectrum and its reconstructed spectrum of the normal sample, Figure 6 are the original spectrum and its reconstructed spectrum of the abnormal sample. For the normal spectrum, the reconstructed spectrum (red dotted line) better reproduces the characteristic peaks of the Raman spectrum. And in Figure 6 , the difference between the reconstructed spectrum and the original spectrum is relatively large. The pink dotted line is the guidance coefficient of the attention guidance mechanism. It can be seen that this mechanism has a good recognition ability for the main characteristic peaks of the spectrum and provides better prior information for the feature extraction of normal samples. Comparing the normal spectrum Figure 5 and the reconstructed result of the abnormal spectrum Figure 6 , it can be seen that the spectral feature extraction network has a better reconstruction ability for the normal spectrum, and the reconstruction loss (weighted loss of mse and cosine similarity loss) is smaller; the reconstruction loss for the abnormal spectrum is large, and the reconstruction ability is also weaker than that of the normal spectrum, which lays a good classification foundation for the joint classification module.
[0120] Immediately afterwards, the above-mentioned dimension-reduced Raman spectral features and the reconstruction error are used for joint determination to obtain the determination result of the abnormal spectrum.
[0121] Specifically, t-SNE dimensionality reduction is used to reduce the dimension of the dimension-reduced Raman spectral feature data to 2D. The comparison of the dimensionality reduction results with the uniform manifold approximation and projection dimensionality reduction method (UMAP) and the principal component analysis dimensionality reduction method (PCA) is as Figure 7As shown, it can be seen that after adopting the dimensionality reduction method of this application, the normal samples (blue scatter points) and abnormal samples (red scatter points) each cluster close to form a cluster, showing a certain degree of separability. However, for the other two dimensionality reduction methods, the normal and abnormal samples are aliased, which is not conducive to further classification. It can be concluded that the dimensionality reduction scheme adopted in this study is effective.
[0122] Specifically, after obtaining the t-SNE dimensionality reduction features and reconstruction errors, the fusion of multi-dimensional information is achieved through feature splicing. Among them, different weight coefficients are assigned to the t-SNE dimensionality reduction features and reconstruction errors (t-SNE features: reconstruction error = 6:4), and then splicing is performed to flexibly adjust the weights according to the actual situation.
[0123] Specifically, for the spliced multi-dimensional features, a method of joint determination with two indicators is adopted. First, Kmeans clustering analysis is performed on the multi-dimensional features (number of clusters = 2, normal spectrum and abnormal spectrum). Due to the design of the spectral feature extraction network, the spectral feature extraction network has a better ability to extract features from normal data than abnormal spectra. On the multi-dimensional features, it will be shown that the normal spectra cluster near a cluster, while the remaining abnormal data will be far from this cluster due to feature differences. The Kmeans algorithm will obtain negative and positive pre-classification labels (corresponding to normal spectra and abnormal spectra respectively). Then, the method of an adaptive reconstruction error threshold is used for the second indicator determination. For the data pre-classified as negative (normal data) labels, the reconstruction errors will be statistically analyzed and the 95th percentile of the reconstruction error value will be adaptively selected as the adaptive error threshold. Samples with a reconstruction error less than this threshold are determined to be negative data, and samples with a reconstruction error greater than this threshold are determined to be positive data.
[0124] The classification results are as Figure 8 shown, where Figure 8 in (a) is the distribution of spectral data with true labels in the dimensionality reduction space. Figure 8 in (b) is the prediction result of the detection model disclosed in the present invention. It can be observed that the prediction effect of this application is relatively excellent. Figure 8 in (c) shows the reconstruction error distribution of normal and abnormal samples. It can be seen that the reconstruction errors of the normal samples of the model are indeed all less than those of the abnormal data, but the reconstruction errors of a small part of the normal data and abnormal data are similar, which also illustrates the importance of joint determination. The setting of the error threshold (red dashed line) is relatively correct, and it can ensure the correct classification of most normal data while giving up a very small part of the easily misjudged data. Figure 8 in (d) is the distribution of the reconstruction errors of different samples in the dimensionality reduction space. It can be seen that most of the normal data with smaller reconstruction errors (dark scatter points) are distributed in the lower left area, but there are also some normal samples with slightly larger reconstruction errors mixed in. By adopting the method of joint determination, the misjudgment of these samples can be avoided, improving the accuracy of this scheme.
[0125] The following explanations are provided for the data set of this embodiment:
[0126] Recall = 1.0000: The recall rate reaches 100%, that is, the goal of "not missing any anomalies" is achieved;
[0127] Precision = 0.8901: Approximately 89% of the samples determined to be anomalies are indeed anomalies, and the false positive rate is relatively low;
[0128] Accuracy = 0.9647: The overall accuracy is very high;
[0129] F1-Score = 0.9419: It shows that the model achieves a good balance between precision and recall.
[0130] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same and similar parts among the various embodiments, reference can be made to each other. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple. For the relevant parts, reference can be made to the description in the method section.
[0131] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be obvious to those skilled in the art. The general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to these embodiments shown herein, but rather to the broadest scope consistent with the principles and novel features disclosed herein.
Claims
1. A Raman spectrum abnormal data detection method based on deep learning, characterized in that, It includes the following steps: Obtain the corresponding peak attention guidance coefficient according to the peak positions of the original spectral data in the dataset; Specifically, it includes: Use a peak-finding function to detect the peak positions of each original spectrum in the dataset, and obtain the positions and prominences of the characteristic peaks in each original spectrum; Generate a Raman peak region with a set width based on the position of each characteristic peak; Determine the ratio of the prominence of the characteristic peak to the maximum prominence in the corresponding original spectrum as the peak attention guidance coefficient of the Raman peak region; Set the peak attention guidance coefficient of the non-Raman peak region in the original spectrum to 0; Combine the peak attention guidance coefficient of the Raman peak region and the peak attention guidance coefficient of the non-Raman peak region to form the peak attention guidance coefficient corresponding to the original spectral data; Obtain the corresponding multi-scale attention coefficient according to the local enhancement features and global features of the original spectral data in the dataset; Combine the peak attention guidance coefficient and the multi-scale attention coefficient of the original spectral data, and multiply the combined attention coefficient with the corresponding original spectral data to obtain the attention Raman spectral feature data; Perform multi-layer step-by-step dimensionality reduction on the attention Raman spectral feature data to obtain a dimensionality-reduced dataset composed of dimensionality-reduced Raman spectral feature data; Use the t-SNE dimensionality reduction algorithm to perform dimensionality reduction on the dimensionality-reduced dataset to obtain a two-dimensional Raman spectral dataset; Perform dimensionality increase on the dimensionality-reduced Raman spectral feature data to obtain reconstructed Raman spectral data with the same length as the original spectral data, and form a reconstructed dataset; Calculate the reconstruction error loss between the reconstructed Raman spectral data and the corresponding original spectral data, and form a reconstruction error set; Correspondingly splice the two-dimensional Raman spectral dataset and the reconstruction error set to obtain a multi-dimensional feature dataset; Perform classification prediction on the multi-dimensional feature dataset to obtain the abnormal data detection result.
2. The Raman spectrum abnormal data detection method based on deep learning according to claim 1, characterized in that It also includes: Use Gaussian filtering to sequentially smooth and normalize the obtained peak attention guidance coefficient to obtain the smoothed peak attention guidance coefficient.
3. A Raman spectroscopy abnormal data detection method based on deep learning according to claim 1, characterized in that, Obtain the corresponding multi-scale attention coefficient according to the local enhancement features and global features of the original spectral data in the dataset. Specifically, it includes: Obtain the local enhancement features of the original spectral data: Pass the original spectral data through a one-dimensional convolutional kernel of length 3, a ReLU activation function layer, a one-dimensional convolutional kernel of length 3, and a Sigmoid activation function layer in sequence to obtain local enhancement features with the same length as the original spectral data; Obtain the global features of the original spectral data: Input the original spectral data into a first fully connected layer, a ReLU activation function layer, a second fully connected layer, and a Sigmoid activation function layer connected in sequence to obtain the global features of the original spectral data; Obtain the multi-scale attention coefficient: Element-wise multiply the obtained local enhancement features and global features to obtain a multi-scale attention coefficient with the same length as the input spectrum.
4. A Raman spectroscopy abnormal data detection method based on deep learning according to claim 1, characterized in that, Combine the peak attention guidance coefficient and the multi-scale attention coefficient of the original spectral data. Specifically, use the following combination formula: I attention = I mix * I guide + I mix * 0.3 Among which I attention is the final attention coefficient obtained by combination, I mix is the multi-scale attention coefficient, I guide is the peak attention guidance coefficient.
5. A Raman spectroscopy abnormal data detection method based on deep learning according to claim 1, characterized in that, In the step of performing multi-layer step-by-step dimensionality reduction on the attention Raman spectral feature data, specifically, it includes: Using four sequentially connected fully connected layers, the attention Raman spectral feature data is gradually reduced in dimension from the original length to a 64-length feature vector in the order of 1024, 512, 256, and 64. Each fully connected layer contains a ReLu non-linear activation function.
6. The Raman spectrum abnormal data detection method based on deep learning according to claim 1, wherein Calculate the reconstruction error loss between the reconstructed Raman spectral data and the corresponding original spectral data, which specifically includes the following calculation formula: Loss total = 0.7 × Loss MSE + 0.3 × Loss cosine Among them, Loss MSE is the mean square error loss corresponding to the original spectrum and the reconstructed Raman spectrum, and Loss cosine is the cosine similarity loss corresponding to the original spectrum and the reconstructed Raman spectrum.
7. A Raman spectroscopy abnormal data detection method based on deep learning according to claim 1, characterized in that, Perform the corresponding splicing step on the two-dimensional Raman spectral dataset and the reconstruction error set, which specifically includes: For each two-dimensional Raman spectral data in the two-dimensional Raman spectral dataset, splice it with the reconstruction error loss data corresponding to the original spectral data in the reconstruction error set according to a weight ratio of 6:4 to obtain multi-dimensional feature data, and form a multi-dimensional feature dataset.
8. A Raman spectrum abnormal data detection method based on deep learning according to claim 1, characterized in that Perform classification prediction on the multi-dimensional feature dataset to obtain the abnormal data detection result, which specifically includes the following steps: Use the Kmeans clustering analysis algorithm to perform clustering analysis on the multi-dimensional feature dataset to obtain negative pre-classification label data and positive pre-classification label data, where the negative pre-classification label data corresponds to the pre-classification data of normal Raman spectra, and the positive pre-classification label data corresponds to the pre-classification data of abnormal Raman spectra; Set an adaptive error threshold for the negative pre-classification label data; Determine the sample data with a reconstruction error loss less than the adaptive error threshold in the negative pre-classification label data as negative data, and the sample data greater than or equal to the adaptive error threshold as positive data, where the negative data corresponds to normal Raman spectral data and the positive data corresponds to abnormal Raman spectral data.
9. A Raman spectroscopy abnormal data detection system based on deep learning, characterized in that, Including: A peak attention guidance module for obtaining the corresponding peak attention guidance coefficient according to the peak position of the original spectral data in the dataset; Specifically including: Use a peak searching function to detect the peak position of each original spectrum in the dataset to obtain the position and prominence of the characteristic peaks in each original spectrum; Generate a Raman peak region with a set width based on the position of each characteristic peak; Determine the ratio of the prominence of the characteristic peak to the maximum prominence in the corresponding original spectrum as the peak attention guidance coefficient of the Raman peak region; Set the peak attention guidance coefficient of the non-Raman peak region in the original spectrum to 0; Combine the peak attention guidance coefficient of the Raman peak region and the peak attention guidance coefficient of the non-Raman peak region to form the peak attention guidance coefficient corresponding to the original spectral data; A dual-branch attention perception module for obtaining the corresponding multi-scale attention coefficient according to the local enhancement feature and the global feature of the original spectral data in the dataset; An attention mechanism Raman spectrum acquisition module for combining the peak attention guidance coefficient and the multi-scale attention coefficient of the original spectral data, and multiplying the combined attention coefficient with the corresponding original spectral data to obtain the attention Raman spectral feature data; A dimensionality reduction network module for performing multi-layer step-by-step dimensionality reduction on the attention Raman spectral feature data to obtain a dimensionality reduction dataset composed of dimensionality-reduced Raman spectral feature data; A t-SNE dimensionality reduction module for performing dimensionality reduction operations on the dimensionality reduction dataset to obtain a two-dimensional Raman spectral dataset; The dimensionality-raising reconstruction network module raises the dimensionality of the dimension-reduced Raman spectral feature data to obtain reconstructed Raman spectral data with the same length as the original spectral data, and forms a reconstructed data set; The reconstruction error loss module is used to calculate the reconstruction error loss between the reconstructed Raman spectral data and the corresponding original spectral data, and forms a reconstruction error set; The multi-dimensional feature acquisition module is used to perform corresponding splicing on the two-dimensional Raman spectral data set and the reconstruction error set to obtain a multi-dimensional feature data set; The anomaly detection module is used to perform classification prediction on the multi-dimensional feature data set to obtain an anomaly data detection result.
Citation Information
Patent Citations
Raman spectrum classification method based on self-attention mechanism
CN115130566A
Raman spectrum quantitative analysis method and analysis system based on deep learning
CN117542446A