Raman spectrum abnormal data detection method and system based on deep learning

Through deep learning-based peak attention and multi-scale attention mechanism, combined with multi-layer dimensionality reduction and reconstruction error analysis, the problem of insufficient optimization of existing Raman spectral anomaly data detection methods is solved, and more efficient and robust anomaly data detection effect is achieved.

CN119939226AActive Publication Date: 2025-05-06CHINA JILIANG UNIV

Patent Information

Application Number
CN202510429388.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-08
Publication Date
2025-05-06
Estimated Expiration
2045-04-08

AI Technical Summary

Technical Problem

The existing Raman spectral anomaly data detection methods lack special optimization of Raman spectral characteristics, rely on complex preprocessing processes, feature extraction and attention strategies are relatively mechanical and fixed, and lack dynamic adaptation mechanisms, which affect the accuracy and robustness of the detection.

Method used

Using a deep learning-based method, the characteristics of the Raman spectrum are extracted through the peak attention guidance mechanism and the multi-scale attention mechanism, and multi-layer gradual dimensionality reduction and reconstruction error calculation are carried out, and the end-to-end abnormal data detection is achieved by combining t-SNE dimensionality reduction and Kmeans clustering analysis.

Benefits of technology

It improves the extraction and reconstruction capabilities of Raman spectral features, reduces dependence on complex preprocessing steps, enhances the robustness and adaptability of the model, and improves the accuracy and recall of abnormal data detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119939226A_ABST
    Figure CN119939226A_ABST
Patent Text Reader

Abstract

The invention discloses a Raman spectrum abnormal data detection method and system based on deep learning, and belongs to the technical field of Raman spectrum abnormal detection. The method comprises the following steps: obtaining a corresponding peak attention guidance coefficient according to a detected spectrum peak position; obtaining a multi-scale attention coefficient based on the local enhancement feature and the global feature of the original spectral data; combining the peak attention guidance coefficient and the multi-scale attention coefficient, and obtaining attention Raman spectrum characteristic data on the basis; performing multi-layer step-by-step dimensionality reduction on the attention Raman spectrum characteristic data by using a dimensionality reduction network, and performing reconstruction by using a dimensionality raising network; and obtaining a Raman spectrum abnormal data detection result by using the dimension-reduced Raman spectrum characteristic data and the reconstructed Raman spectrum data. According to the method, the attention mechanism is perceived through the peak value, the overall characteristics and small-scale characteristic peaks of the Raman spectrum can be analyzed at the same time, and the extraction and reconstruction of the Raman spectrum characteristics are highly targeted and improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of Raman spectroscopy analysis and anomaly detection, and more specifically to a Raman spectroscopy anomaly data detection method and system based on deep learning. Background Art

[0002] As a non-destructive and rapid method for characterizing molecular structures, Raman spectroscopy has been widely used in materials science, biomedicine, food safety and other fields. However, in practical applications, Raman spectroscopy data collected by instruments are often affected by a variety of factors and become abnormal, mainly including: signal saturation, instrument noise, baseline drift, flattening phenomenon, etc.

[0003] These abnormal data will seriously affect the subsequent data analysis and interpretation work and reduce the reliability of the test results. Therefore, the detection of abnormal data in Raman spectroscopy is of great significance for the subsequent Raman spectroscopy analysis and detection.

[0004] Existing spectral detection technologies are generally based on traditional statistical methods and machine learning methods, which have some challenges:

[0005] First, most of the existing anomaly detection methods are simple applications of general algorithms, lacking specialized optimization of Raman spectral characteristics. In particular, when processing the most characteristic peak information in spectral 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, which not only increases processing time and computing costs, but may also introduce additional errors during the preprocessing process. This method that relies on preprocessing seriously affects the practicality and reliability of the system.

[0007] Third, existing methods are relatively mechanical and fixed in feature extraction and attention strategies. Both traditional statistical methods and general deep learning methods use a unified feature extraction strategy and lack an adaptive attention mechanism for different spectral regions. This makes it impossible for the model to dynamically adjust its focus according to the characteristics of the data, affecting the accuracy and robustness of anomaly detection.

[0008] Finally, existing methods lack dynamic adaptation mechanisms. Most methods use fixed judgment criteria and thresholds and cannot be adaptively adjusted according to the actual data distribution characteristics, which to some extent affects the generalization ability of the model in different application scenarios.

[0009] Therefore, how to improve the existing spectrum detection technology and provide a method and system for detecting abnormal data of Raman spectrum 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 Raman spectroscopy abnormal data detection method and system based on deep learning, which is used to at least solve some of the technical problems in the background technology.

[0011] In order to achieve the above object, the present invention adopts the following technical solution:

[0012] The present invention first discloses a method for detecting abnormal Raman spectroscopy data based on deep learning, comprising:

[0013] According to the peak position of the original spectral data in the data set, the corresponding peak attention guidance coefficient is obtained;

[0014] The corresponding multi-scale attention coefficients are obtained according to the local enhanced features and global features of the original spectral data in the dataset;

[0015] The peak attention guidance coefficient and the multi-scale attention coefficient of the original spectral data are combined, and the attention coefficient obtained by the combination is multiplied by the original spectral data to obtain the attention Raman spectral feature data;

[0016] Performing multi-layer step-by-step dimensionality reduction on the attention Raman spectrum feature data to obtain a dimensionality reduction data set consisting of dimensionality-reduced Raman spectrum feature data;

[0017] The t-SNE dimensionality reduction algorithm is used to reduce the dimensionality of the data set to obtain a two-dimensional Raman spectroscopy data set;

[0018] The reduced-dimensional Raman spectral feature data is upgraded to obtain reconstructed Raman spectral data with the same length as the original spectral data, and the reconstructed data set is formed;

[0019] Calculate the reconstruction error loss between the reconstructed Raman spectrum data and the corresponding original spectrum data, and form a reconstruction error set;

[0020] The two-dimensional Raman spectrum data set and the reconstruction error set are concatenated correspondingly to obtain a multi-dimensional feature data set;

[0021] Perform classification prediction on multi-dimensional feature data sets to obtain abnormal data detection results.

[0022] Furthermore, in a specific embodiment, the corresponding peak attention guidance coefficient is obtained according to the peak position of the original spectral data in the data set, specifically including:

[0023] The peak position of each original spectrum in the data set is detected using the peak-finding function to obtain the position and prominence of the characteristic peak in each original spectrum;

[0024] Generate a Raman peak region of set width 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 was 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 spectral data.

[0028] Furthermore, after obtaining the peak attention guidance coefficient, it also includes:

[0029] The obtained peak attention guidance coefficient is smoothed and normalized in turn using Gaussian filtering to obtain the smoothed peak attention guidance coefficient.

[0030] Furthermore, in a specific embodiment, the corresponding multi-scale attention coefficient is obtained according to the local enhancement features and global features of the original spectral data in the data set, specifically including:

[0031] Get local enhancement features of raw spectral data:

[0032] The original spectral 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 a local enhancement feature with the same length as the original spectral data;

[0033] Get global features of raw spectral data:

[0034] The original spectral data is input into the first fully connected layer, the ReLU activation function layer, the second fully connected layer, and the Sigmoid activation function layer connected in sequence to obtain the global features of the original spectral data;

[0035] Get multi-scale attention coefficients:

[0036] The obtained local enhanced features are element-wise multiplied with the global features to obtain a multi-scale attention coefficient 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 spectral data are combined, specifically including using the following combination formula: ;

[0038] in 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, the step of performing multi-layer stepwise dimensionality reduction on the attention Raman spectrum feature data specifically includes:

[0040] Using four sequentially connected fully connected layers, the attention Raman spectrum feature data is gradually reduced from the original length to a feature vector of length 64 in the order of 1024, 512, 256, and 64, where each fully connected layer contains a ReLu nonlinear activation function.

[0041] Furthermore, in a specific embodiment, the reconstruction error loss Loss between the reconstructed Raman spectrum data and the corresponding original spectrum data is calculated. total , specifically including the following calculation formula: ;

[0042] in, is the mean square error loss between the original spectrum and the reconstructed Raman spectrum, is the cosine similarity loss between the original spectrum and the reconstructed Raman spectrum.

[0043] Furthermore, in a specific embodiment, the two-dimensional Raman spectrum data set and the reconstruction error set are subjected to corresponding stitching steps, specifically including:

[0044] Each piece of two-dimensional Raman spectrum data in the two-dimensional Raman spectrum data set is concatenated with the reconstruction error loss data of the corresponding original spectrum data in the reconstruction error set in a weight ratio of 6:4 to obtain multi-dimensional feature data and form multi-dimensional feature data.

[0045] Furthermore, in a specific embodiment, classification prediction is performed on the multi-dimensional feature data set to obtain abnormal data detection results, which specifically includes the following steps:

[0046] The Kmeans clustering analysis algorithm is used to perform cluster analysis on the multi-dimensional feature data set to obtain negative pre-classification label data and positive pre-classification label data, wherein the negative pre-classification label data corresponds to normal Raman spectrum pre-classification data, and the positive pre-classification label data corresponds to abnormal Raman spectrum pre-classification data;

[0047] For negative pre-classified label data, an adaptive error threshold is set;

[0048] Sample data whose reconstruction error loss in the negative pre-classified label data is less than the adaptive error threshold is determined as negative data, and sample data whose reconstruction error loss is greater than or equal to the adaptive error threshold is determined as positive data, wherein negative data corresponds to normal Raman spectral data, and positive data corresponds to abnormal Raman spectral data.

[0049] On the other hand, the present invention also discloses a Raman spectroscopy abnormal data detection system based on deep learning, comprising:

[0050] A peak attention guidance module is used to obtain a corresponding peak attention guidance coefficient according to the peak position of the original spectral data in the data set;

[0051] A dual-branch attention perception module is used to obtain the corresponding multi-scale attention coefficients based on the local enhanced features and global features of the original spectral data in the dataset;

[0052] The attention mechanism Raman spectrum acquisition module is used to combine the peak attention guidance coefficient and the multi-scale attention coefficient of the original spectrum data, and multiply the combined attention coefficient with the original spectrum data to obtain the attention Raman spectrum feature data;

[0053] A dimension reduction network module is used to perform multi-layer step-by-step dimension reduction on the attention Raman spectrum feature data to obtain a dimension reduction data set composed of the reduced-dimensional Raman spectrum feature data;

[0054] The t-SNE dimension reduction module is used to perform dimension reduction operations on the dimensionality reduction data set to obtain a two-dimensional Raman spectroscopy data set;

[0055] The dimension-upgrading and reconstruction network module performs dimension-upgrading on the reduced-dimensional Raman spectral feature data to obtain reconstructed Raman spectral data with the same length as the original spectral data and form a reconstructed data set;

[0056] A reconstruction error loss module is used to calculate the reconstruction error loss between the reconstructed Raman spectrum data and the corresponding original spectrum data, and form a reconstruction error set;

[0057] A multi-dimensional feature acquisition module is used to correspondingly concatenate the two-dimensional Raman spectrum data set and the reconstruction error set to obtain a multi-dimensional feature data set;

[0058] The anomaly detection module is used to classify and predict multi-dimensional feature data sets to obtain anomaly data detection results.

[0059] It can be seen from the above technical solutions that, compared with the prior art, the present invention discloses a method and system for detecting abnormal Raman spectroscopy data based on deep learning, which has the following beneficial effects:

[0060] The present invention uses a peak-aware attention mechanism to simultaneously analyze the overall characteristics and small-scale characteristic peaks of the Raman spectrum, and has strong pertinence and improvement in the extraction and reconstruction of Raman spectrum features.

[0061] The present invention proposes an attention guidance module, which assists model learning by introducing the characteristic peaks searched by the peak-finding algorithm, realizes the enhanced extraction of spectral peak features through prior knowledge, and improves the feature extraction efficiency and robustness of the model.

[0062] The present invention innovatively combines multi-dimensional features, including reconstruction errors and multi-dimensional features, to achieve more comprehensive abnormality judgment. And the use of secondary judgment based on adaptive reconstruction threshold can greatly improve the "recall rate" of the model, and for abnormal spectrum detection scenarios, it can greatly reduce the omission of abnormal spectra. And improve the robustness of the model.

[0063] The present invention does not require complicated preprocessing steps, and the model can learn and process raw spectral data end-to-end, greatly simplifying the application process. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0065] Figure 1 This is a schematic diagram of the overall process of the detection method provided by the present invention.

[0066] Figure 2 This is a schematic diagram of the overall system architecture corresponding to the detection method provided by the present invention.

[0067] Figure 3 This is a schematic diagram of the Raman spectrum feature extraction module architecture provided by the present invention.

[0068] Figure 4 This is a schematic diagram of the anomaly detection module architecture provided by the present invention.

[0069] Figure 5 A schematic diagram of the original spectrum of a normal sample and its reconstructed spectrum provided by an embodiment of the present invention.

[0070] Figure 6 Schematic diagram of the original spectrum of an abnormal sample and its reconstructed spectrum provided by an embodiment of the present invention.

[0071] Figure 7Schematic diagram of the effects of different dimensionality reduction methods provided in embodiments of the present invention.

[0072] Figure 8 A schematic diagram of classification results provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0073] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0074] The embodiment of the present invention discloses a method for detecting abnormal Raman spectroscopy data based on deep learning, which mainly includes two steps: Raman spectroscopy feature extraction and abnormal spectrum detection. The overall architecture of the method can be referred to Figure 1 , Figure 2 .

[0075] In the Raman spectrum feature extraction step, a spectrum feature extraction network is designed to input the original Raman spectrum and obtain the extracted spectrum features.

[0076] Specifically, Figure 3 As shown, the embodiment of the present invention performs Raman spectral feature extraction through a designed spectral feature extraction module, and the spectral feature extraction module includes a peak attention guidance module, a dual-branch multi-scale attention module, a multi-layer gradual dimensionality reduction module, and a dimensionality increase reconstruction module.

[0077] Among them, the peak attention guidance module proposed in the present invention mainly includes a peak finding function submodule, a peak attention guidance coefficient generation submodule and a Gaussian smoothing processing submodule.

[0078] Specifically, the peak finding function submodule first uses the peak finding function (scipy.signal.find_peaks) to perform preliminary peak position detection on a single original spectrum. In order to ensure that the detected peak has significant physical significance, 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 interference from weak peaks and noise peaks.

[0079] Then the peak attention guidance coefficient generation submodule 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 search 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 can be set to include Raman peaks with a relatively suitable peak width, and the attention guidance coefficient in this region is set to 1, indicating that these regions have important spectral feature information. The 01 sequence with peak position guidance information is obtained as the peak attention guidance coefficient.

[0080] A Raman peak region of set width is generated based on the position of each characteristic peak, and the attention guidance coefficient of the Raman peak region is set to the ratio of the peak prominence to the maximum prominence, and the attention guidance coefficient of the non-Raman peak region is set to the initial value 0; for the Raman peak region: ; Where I is the attention guidance coefficient of the Raman peak area, is the peak prominence, is the maximum prominence in the spectrum.

[0081] Subsequently, the Gaussian smoothing submodule smoothes 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 degree of smoothing (σ=2 in this embodiment), and exp is the natural exponential function.

[0084] Gaussian filtering achieves a smoothing effect by performing a convolution operation on the kernel function and the original attention guidance coefficient:

[0085] ;

[0086] in: is the smoothed attention coefficient, w(n) is the original attention coefficient, and i is the position index of the convolution kernel. Smoothing allows attention to have a continuous and smooth transition in the peak area, which 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 area in the spectrum and improve the model's ability to learn and extract normal spectral features.

[0087] The dual-branch multi-scale attention module proposed in the present invention includes two parallel substructures: 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 to 8-channel small-scale features through a small-scale convolution layer with a kernelsize of 3 to enhance the expression ability of local features. After nonlinear activation by the ReLU function, the above 8-channel small-scale features are compressed into single-channel features through a second small-scale convolution layer with a kernel size of 3, and normalized by the Sigmoid function to obtain a local peak feature with the same length as the input spectrum, thereby adaptively learning the distribution of local peak features in the spectrum. The global feature branch adopts a multi-layer perceptron structure design, and its network architecture includes 2 linear layers and corresponding activation functions:

[0088] 1. The first fully connected layer: maintains the input dimension of the original spectrum unchanged and maps the data to a feature space of the same dimension to learn the global features of the spectral data.

[0089] 2. ReLU activation function: introduces nonlinear transformation capabilities and enhances the network's feature expression capabilities.

[0090] 3. The second fully connected layer: also maintains the dimension unchanged and further extracts global feature associations.

[0091] 4. Sigmoid activation function: maps the output to the (0,1) interval to obtain the normalized global feature weight.

[0092] The original spectrum is passed through the local peak branch and the global feature branch in the multi-scale attention module to obtain the corresponding local peak features and global feature weights. Then the local peak features are multiplied element by element with the global feature weights to obtain a multi-scale attention coefficient with the same length as the input spectrum. The specific formula is as follows:

[0093] ;

[0094] in is the multi-scale attention coefficient, is the global feature weight, This dual-branch structure is fused by feature product, which not only retains the local peak features but also takes into account the global spectral information, thus achieving 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] in is the final attention coefficient, is the multi-scale attention coefficient, is the peak attention guidance coefficient. The module will reserve 30% of the multi-scale attention coefficient as the autonomous learning space, adjust the attention distribution under the peak guidance, so that the spectral feature extraction network can improve the model's perception of spectral features based on the peak guidance information. Multiplying it with the original spectrum gives us the Raman spectrum after the attention mechanism.

[0098] After obtaining the Raman spectrum after the attention mechanism, a multi-layer step-by-step dimensionality reduction method is used to gradually reduce the original spectrum with a larger scale into a small-scale Raman spectrum feature. Specifically, four fully connected layers with ReLu nonlinear activation are connected in sequence to form a dimensionality reduction network, and the original spectrum (1500 length) is gradually reduced to a feature vector of 64 length in the order of 1024, 512, 256, and 64. Correspondingly, there is a spectral reconstruction network (dimensionality increase network) composed of four fully connected layers with ReLu nonlinear activation, which is symmetrical to the structure of the layer-by-layer dimensionality reduction. The spectrum is reconstructed using spectral features in the order of lengths of 64, 256, 512, 1024, and 1500. In this process, the mean square error (mse) of the reconstructed spectrum and the weighted value of the cosine similarity are calculated as the reconstruction loss Loss total , the specific formula is as follows:

[0099] ;

[0100] in 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 focuses more on the similarity of corresponding points. The specific formula of the mean square error loss is as follows:

[0101] ;

[0102] Where 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 focuses more on the similarity of the overall spectral shape, and its specific formula is as follows:

[0104]

[0105] Where x represents the original spectrum vector, represents the reconstructed spectrum vector, represents the vector inner product, and ||x|| represents the L2 norm of the vector. The detection model constructed by the present invention automatically learns the characteristic representation of the normal spectrum according to the loss function.

[0106] In the abnormal spectrum detection step, the Raman spectrum features after dimensionality reduction and the reconstruction error (calculation is the same as the reconstruction loss above, but it is more appropriate to name it "reconstruction loss" in model training, and the reconstruction error is used below) are used for joint judgment to obtain the judgment result of the abnormal spectrum. The specific process of the abnormal detection step in the present invention can be referred to Figure 4 Schematic diagram of the anomaly detection module architecture shown.

[0107] Specifically, the embodiment of the present invention uses t-SNE dimensionality reduction to reduce the reduced Raman spectrum feature data to 2 dimensions, which can better retain local features compared with other mainstream dimensionality reduction methods (u-map, pca, etc.). The decoder calculates the reconstruction error between the reconstructed spectrum and the original spectrum: 0.7*mean square error mse+0.3*weighted value of cosine similarity.

[0108] Specifically, after obtaining the t-SNE dimension reduction features and reconstruction errors, the embodiment of the present invention realizes the fusion of multi-dimensional information through feature splicing. The t-SNE dimension reduction features and reconstruction errors are given different weight coefficients (t-SNE features: reconstruction error = 6:4) before splicing, so as to flexibly adjust the weights according to the actual situation.

[0109] Specifically, the embodiment of the present invention adopts a dual-index joint determination method for the multi-dimensional features after splicing. First, Kmeans cluster analysis is performed on the multi-dimensional features (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. In the multi-dimensional features, it will be shown that the normal spectra are clustered near a cluster, while the remaining abnormal data will be far away from this cluster due to the difference in features. 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 indicator determination. For the data pre-classified as negative (normal data) labels, the reconstruction error will be statistically reconstructed and the reconstruction error value of the 95% percentile will be adaptively selected as the adaptive error threshold. The reconstruction error is less than the threshold and is determined as negative data, and the sample is greater than the threshold and is determined as positive data.

[0110] The specific application of the present invention is described below through more specific embodiments.

[0111] Embodiment 1:

[0112] In Example 1, a handheld spectrometer was first used to collect several samples, including 1000 normal samples and about 400 abnormal samples consisting of saturated spectra, noise spectra, and flat spectra (the proportion of abnormal samples will not be so high during normal collection, so this design can test the robustness of the model). The sample length is 1500.

[0113] Then, by designing a spectral feature extraction network module, the original Raman spectrum is input to obtain the extracted spectral features. A corresponding symmetrical decoding network is used for spectral reconstruction and reconstruction error calculation.

[0114] Specifically, Figure 3 As shown, the spectral feature extraction network module designed in Example 1 includes a peak attention guidance module, a peak perception attention module, a multi-layer gradual dimensionality reduction module, etc.

[0115] Specifically, the peak attention guidance module proposed by the present invention for spectral feature extraction uses the peak finding function (scipy.signal.find_peaks) to perform preliminary peak position and width detection. For each peak position detected, the algorithm generates an influence area around it. The width of the area is the width of the detected characteristic peak, and the attention guidance coefficient in the area is set to 1.0, indicating that these areas have important spectral feature information. Subsequently, the attention coefficient distribution is smoothed by Gaussian filtering (gaussian_filter1d) so that the attention has a continuous and smooth transition in the peak area. This processing is more in line with the physical properties of the spectral peak. Finally, the peak attention guidance corresponding to the characteristic peak is obtained. This attention guidance mechanism based on prior knowledge can effectively guide the model to pay attention to the most characteristic peak area in the spectrum, significantly improving the model's ability to learn and extract normal spectral features.

[0116] Specifically, the dual-branch peak-aware attention module proposed in the present invention for spectral feature extraction includes two parallel substructures: a peak detection branch and a feature attention branch. Among them, the peak detection branch adopts a one-dimensional convolutional network structure. First, the input signal is expanded to 8 channels through a small-scale convolution layer with a kernel size of 3 to enhance the expression ability of local features. After ReLU activation, the feature is compressed back to a single channel through a second convolution layer, and normalized by a Sigmoid function, so as to adaptively learn the peak feature distribution in the spectrum. The feature attention branch adopts a fully connected layer design, learns the global feature association of the spectrum through two layers of nonlinear transformation, and also uses the Sigmoid function to output normalized feature weights. This dual-branch structure is integrated by feature multiplication, which not only retains the local peak features, but also takes into account the global spectral information, and realizes multi-scale feature enhancement of spectral data.

[0117] Specifically, for the spectral feature extraction step of the present invention, when the attention of the peak attention guidance module and the peak perception attention module are integrated, the module will reserve 30% of the autonomous learning space, adjust the attention distribution under the peak guidance, so that the spectral feature extraction network improves the model's perception ability of spectral features based on the peak guidance information.

[0118] Specifically, after combining the output of the attention module with the original spectrum, the present invention adopts a multi-layer step-by-step dimensionality reduction method. This embodiment uses a gradient of 1024, 512, 256, and 64 for dimensionality reduction, that is, the 1500-length spectrum is gradually reduced to 64 lengths, and the larger-scale original spectrum is gradually reduced to small-scale Raman spectrum features. Correspondingly, there is a spectral reconstruction network (64, 256, 512, 1024, 1500) with a symmetrical structure with the layer-by-layer dimensionality reduction, which uses spectral features to reconstruct the spectrum. In 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 automatically learns the feature representation of the normal spectrum.

[0119] Figure 5 and Figure 6 The feature extraction and reconstruction capabilities of the spectral feature extraction network trained by the above samples are demonstrated. Figure 5 are the original spectrum of the normal sample and its reconstructed spectrum, Figure 6 The original spectrum of the abnormal sample and its reconstructed spectrum. For the normal spectrum, the reconstructed spectrum (red dotted line) reproduces the characteristic peaks of the Raman spectrum well. Figure 6 In the figure, the difference between the reconstructed spectrum and the original spectrum is large. The pink dotted line is the guidance coefficient of the attention guidance mechanism. It can be seen that the mechanism has a good recognition ability for the main characteristic peaks of the spectrum, providing good prior information for feature extraction of normal samples. Compared with the normal spectrum Figure 5 And the abnormal spectrum reconstruction results Figure 6 It can be seen that the spectral feature extraction network has a good reconstruction ability for normal spectra, and the reconstruction loss (the weighted loss of MSE and cosine similarity loss) is small; the reconstruction loss of abnormal spectra is large, and the reconstruction ability is weaker than that of normal spectra, which lays a good classification foundation for the joint classification module.

[0120] Next, the Raman spectrum features after dimensionality reduction and the reconstruction error are used for joint judgment to obtain the judgment result of the abnormal spectrum.

[0121] Specifically, t-SNE is used to reduce the dimensionality of the Raman spectrum feature data to 2 dimensions, and the dimensionality reduction results are compared with those of the uniform manifold approximation and projection method (UMAP) and the principal component analysis method (PCA). Figure 7As shown in the figure, it can be seen that after the dimensionality reduction method of this application is adopted, the normal samples (blue scattered points) and the abnormal samples (red scattered points) are close to each other in a cluster, which has a certain degree of separability, while the normal and abnormal samples of the other two dimensionality reduction methods are mixed, 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. The t-SNE dimensionality reduction features and reconstruction errors are given different weight coefficients (t-SNE features: reconstruction error = 6:4) before splicing, so as to flexibly adjust the weights according to the actual situation.

[0123] Specifically, for the multi-dimensional features after splicing, a dual-index joint judgment method is adopted. First, Kmeans cluster analysis is performed on the multi-dimensional features (number of clusters = 2, normal spectra and abnormal spectra). Due to the design of the spectral feature extraction network, the spectral feature extraction network has better feature extraction ability for normal data than abnormal spectra. In the multi-dimensional features, it will be shown that the normal spectra are clustered near a cluster, while the remaining abnormal data will be far away from this cluster due to the difference in features. 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 judgment. For the data pre-classified as negative (normal data) labels, the reconstruction error will be counted and the reconstruction error value of the 95% percentile will be adaptively selected as the adaptive error threshold. The reconstruction error is less than the threshold and is judged as negative data, and the sample is greater than the threshold and is judged as positive data.

[0124] The classification results are as follows Figure 8 As shown, Figure 8 (a) shows the distribution of spectral data with true labels in the dimensionality reduction space. Figure 8 (b) is the prediction result of the detection model disclosed in the present invention. It can be observed that the prediction effect of the present application is relatively good. Figure 8 (c) shows the reconstruction error distribution of normal and abnormal samples. It can be seen that the reconstruction error of normal samples of the model is indeed smaller than that of abnormal data, but the reconstruction errors of a small part of normal data and abnormal data are similar, which also illustrates the importance of joint judgment. The error threshold (red dotted line) is set correctly, which can ensure the correct division of most normal data while abandoning a very small part of data that is easy to misjudge. Figure 8 (d) is the distribution of 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 scattered points) are distributed in the lower left area, but there are also normal samples with slightly larger reconstruction errors in the lower part. The joint judgment method can avoid the misjudgment of these samples and improve the accuracy of this solution.

[0125] The data set of this embodiment has the following description:

[0126] Recall = 1.0000: The recall rate reaches 100%, which means that the goal of "not missing any anomalies" is achieved;

[0127] Precision = 0.8901: About 89% of the samples judged as abnormal are indeed abnormal, and the false positive rate is low;

[0128] Accuracy = 0.9647: The overall accuracy is very high;

[0129] F1-Score = 0.9419: This indicates that the model has achieved a good balance between precision and recall.

[0130] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0131] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may 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 the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for detecting abnormal Raman spectroscopy data based on deep learning, characterized in that: The following steps are involved: According to the peak position of the original spectral data in the data set, the corresponding peak attention guidance coefficient is obtained; The corresponding multi-scale attention coefficients are obtained according to the local enhanced features and global features of the original spectral data in the dataset; The peak attention guidance coefficient and the multi-scale attention coefficient of the original spectral data are combined, and the attention coefficient obtained by the combination is multiplied by the original spectral data to obtain the attention Raman spectral feature data; Performing multi-layer step-by-step dimensionality reduction on the attention Raman spectrum feature data to obtain a dimensionality reduction data set consisting of dimensionality-reduced Raman spectrum feature data; The t-SNE dimensionality reduction algorithm is used to reduce the dimensionality of the data set to obtain a two-dimensional Raman spectroscopy data set; The reduced-dimensional Raman spectral feature data is upgraded to obtain reconstructed Raman spectral data with the same length as the original spectral data, and the reconstructed data set is formed; Calculate the reconstruction error loss between the reconstructed Raman spectrum data and the corresponding original spectrum data, and form a reconstruction error set; The two-dimensional Raman spectrum data set and the reconstruction error set are concatenated correspondingly to obtain a multi-dimensional feature data set; Perform classification prediction on multi-dimensional feature data sets to obtain abnormal data detection results.

2. The method for detecting abnormal Raman spectroscopy data based on deep learning according to claim 1, characterized in that: According to the peak position of the original spectral data in the data set, the corresponding peak attention guidance coefficient is obtained, including: The peak position of each original spectrum in the data set is detected using the peak-finding function to obtain the position and prominence of the characteristic peak in each original spectrum; Generate a Raman peak region of set width based on the position of each characteristic peak; 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; The peak attention guidance coefficient of the non-Raman peak region in the original spectrum was set to 0; 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 spectral data.

3. The method for detecting abnormal Raman spectroscopy data based on deep learning according to claim 2, characterized in that: Also includes: The obtained peak attention guidance coefficient is smoothed and normalized in turn using Gaussian filtering to obtain the smoothed peak attention guidance coefficient.

4. The method for detecting abnormal Raman spectroscopy data based on deep learning according to claim 1, characterized in that: The corresponding multi-scale attention coefficients are obtained according to the local enhanced features and global features of the original spectral data in the dataset, including: Get local enhancement features of raw spectral data: The original spectral 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 a local enhancement feature with the same length as the original spectral data; Get global features of raw spectral data: The original spectral data is input into the first fully connected layer, the ReLU activation function layer, the second fully connected layer, and the Sigmoid activation function layer connected in sequence to obtain the global features of the original spectral data; Get multi-scale attention coefficients: The obtained local enhanced features are element-wise multiplied with the global features to obtain a multi-scale attention coefficient with the same length as the input spectrum.

5. The method for detecting abnormal Raman spectroscopy data based on deep learning according to claim 1, characterized in that: The peak attention guidance coefficient and the multi-scale attention coefficient of the original spectral data are combined, specifically including using the following combination formula: ; in is the final attention coefficient obtained by combination, is the multi-scale attention coefficient, is the peak attention guidance coefficient.

6. The method for detecting abnormal Raman spectroscopy data based on deep learning according to claim 1, characterized in that: The multi-layer step-by-step dimensionality reduction steps for the attention Raman spectral feature data specifically include: Using four sequentially connected fully connected layers, the attention Raman spectrum feature data is gradually reduced from the original length to a feature vector of length 64 in the order of 1024, 512, 256, and 64, where each fully connected layer contains a ReLu nonlinear activation function.

7. The method for detecting abnormal Raman spectroscopy data based on deep learning according to claim 1, characterized in that: The reconstruction error loss between the reconstructed Raman spectrum data and the corresponding original spectrum data is calculated, specifically including the following calculation formula: ; in, is the mean square error loss between the original spectrum and the reconstructed Raman spectrum, is the cosine similarity loss between the original spectrum and the reconstructed Raman spectrum.

8. The method for detecting abnormal Raman spectroscopy data based on deep learning according to claim 1, characterized in that: The two-dimensional Raman spectral data set and the reconstruction error set are spliced ​​in corresponding steps, specifically including: Each piece of two-dimensional Raman spectrum data in the two-dimensional Raman spectrum data set is concatenated with the reconstruction error loss data of the corresponding original spectrum data in the reconstruction error set in a weight ratio of 6:4 to obtain multi-dimensional feature data and form a multi-dimensional feature data set.

9. The method for detecting abnormal Raman spectroscopy data based on deep learning according to claim 1, characterized in that: Classify and predict the multi-dimensional feature data set to obtain abnormal data detection results, which specifically includes the following steps: The Kmeans clustering analysis algorithm is used to perform cluster analysis on the multi-dimensional feature data set to obtain negative pre-classification label data and positive pre-classification label data, wherein the negative pre-classification label data corresponds to normal Raman spectrum pre-classification data, and the positive pre-classification label data corresponds to abnormal Raman spectrum pre-classification data; For negative pre-classified label data, an adaptive error threshold is set; Sample data whose reconstruction error loss in the negative pre-classified label data is less than the adaptive error threshold is determined as negative data, and sample data whose reconstruction error loss is greater than or equal to the adaptive error threshold is determined as positive data, wherein negative data corresponds to normal Raman spectrum data, and positive data corresponds to abnormal Raman spectrum data.

10. A Raman spectroscopy abnormal data detection system based on deep learning, characterized in that: include: A peak attention guidance module is used to obtain a corresponding peak attention guidance coefficient according to the peak position of the original spectral data in the data set; A dual-branch attention perception module is used to obtain the corresponding multi-scale attention coefficients based on the local enhanced features and global features of the original spectral data in the dataset; The attention mechanism Raman spectrum acquisition module is used to combine the peak attention guidance coefficient and the multi-scale attention coefficient of the original spectrum data, and multiply the attention coefficient obtained by the combination with the original spectrum data to obtain the attention Raman spectrum feature data; A dimension reduction network module is used to perform multi-layer step-by-step dimension reduction on the attention Raman spectrum feature data to obtain a dimension reduction data set composed of the reduced-dimensional Raman spectrum feature data; The t-SNE dimension reduction module is used to perform dimension reduction operations on the dimensionality reduction data set to obtain a two-dimensional Raman spectroscopy data set; The dimension-upgrading and reconstruction network module performs dimension-upgrading on the reduced-dimensional Raman spectral feature data to obtain reconstructed Raman spectral data with the same length as the original spectral data and form a reconstructed data set; A reconstruction error loss module is used to calculate the reconstruction error loss between the reconstructed Raman spectrum data and the corresponding original spectrum data, and form a reconstruction error set; A multi-dimensional feature acquisition module is used to correspondingly concatenate the two-dimensional Raman spectrum data set and the reconstruction error set to obtain a multi-dimensional feature data set; The anomaly detection module is used to classify and predict multi-dimensional feature data sets to obtain anomaly data detection results.

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

  • Universal self-supervised learning Raman spectrum noise reduction method, device and equipment

    CN119441721A

  • Raman spectrum classification method based on BiLSTM Multi-Head Attention

    CN119475133A

Cited By

  • Spectral information correction method and system for spectrum abnormal region

    CN120217270A

  • Method and system for correcting spectral information in spectral abnormality areas

    CN120217270B