Attention-based interpretable Raman spectroscopy recognition method, device and equipment

By using the attention network model to embedding and feature encoding Raman spectrum signals in Raman spectrum analysis, generating local and global semantic information, and calculating comprehensive category activation maps, we solve the problem of the interpretability of deep neural networks in Raman spectrum analysis. It solves the problem of insufficient accuracy and achieves accuracy and interpretability of Raman spectrum identification.

CN118468141BActive Publication Date: 2024-09-10TSINGHUA UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410917691.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-10
Publication Date
2024-09-10
Estimated Expiration
2044-07-10

AI Technical Summary

Technical Problem

In the existing technology, deep neural networks use end-to-end learning properties and highly abstract feature extraction in Raman spectroscopy analysis, which hinders humans' intuitive understanding of the results and the interpretability of the intrinsic mechanism of action, resulting in insufficient interpretability.

Method used

The attention-based interpretable Raman spectrum identification method is adopted, and by performing convolution embedding processing on the Raman spectrum signal, combined with the attention network model, spectral sequence representations and semantic sequence representations of local and global semantic information are generated, and comprehensive categories are calculated. Activation maps determine discriminative bands and enhance the interpretability of recognition.

Benefits of technology

The accuracy and interpretability of Raman spectrum recognition are achieved. Through the long-distance semantic dependence of the self-attention mechanism, the impact of different bands on the category prediction results can be clearly characterized, enhancing the understanding and interpretation of the results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118468141B
    Figure CN118468141B
Patent Text Reader

Abstract

The present application provides an attention-based interpretable Raman spectrum recognition method, device and equipment, the method comprising: performing convolution embedding processing on the Raman spectrum signal to obtain a spectrum embedding tag sequence based on the local neighborhood band characteristics; inputting the learnable semantic tag sequence and the spectrum embedding tag sequence into the attention network model for feature encoding to obtain a spectrum sequence representation with local semantic information and a semantic sequence representation with global semantic information; performing category prediction based on the spectrum sequence representation and the semantic sequence representation to obtain a category prediction result of the Raman spectrum; calculating a comprehensive category activation map with global semantic information and local semantic information based on the category prediction result, the spectrum sequence representation and the semantic sequence representation, and determining the discriminative band based on the comprehensive category activation map. In this way, an interpretable Raman spectrum recognition is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of Raman spectrum recognition, and in particular to an attention-based interpretable Raman spectrum recognition method, device and equipment. Background Art

[0002] Raman spectroscopy is a modern, rapid optical detection technology that provides chemical fingerprints of biological samples based on the inelastic scattering properties of light by vibrating molecules. Raman spectroscopy can quickly obtain the chemical composition of a substance, and can obtain most biomolecular information using simple spectral measurements. It can also obtain the chemical structure and composition of samples in a non-destructive manner. Due to its rapid, accurate, simple operation and high sensitivity, it has been widely used in the fields of chemical engineering, environment, medicine, etc.

[0003] There are many machine learning-based methods for diagnostic identification and classification of Raman spectra, such as support vector machines, principal component analysis, discriminant analysis, etc. Since spectra have complex composition information, such methods are often limited by insufficient representation capabilities, noise, or overfitting. Due to its powerful representation capabilities, deep learning technology has recently attracted widespread attention for automated feature learning and has been fully applied in the field of spectral analysis. The use of deep neural networks such as artificial neural networks, convolutional neural networks, and recurrent neural networks for Raman spectral analysis provides a fast and highly robust clinical application solution for Raman spectral analysis.

[0004] However, the end-to-end learning nature of deep neural networks and the highly abstract feature extraction hinders human intuitive understanding and the interpretability of the intrinsic mechanism of the results. Therefore, how to achieve interpretable Raman spectroscopy recognition is a technical problem that needs to be solved urgently. Summary of the invention

[0005] In view of the above problems, the embodiments of the present application provide an attention-based interpretable Raman spectrum recognition method, device and apparatus to overcome the above problems or at least partially solve the above problems.

[0006] In a first aspect of an embodiment of the present application, an attention-based interpretable Raman spectrum recognition method is disclosed, the method comprising:

[0007] Perform convolution embedding processing on the Raman spectrum signal to obtain a spectrum embedding tag sequence based on the local neighborhood band characteristics;

[0008] Inputting the learnable semantic tag sequence and the spectral embedded tag sequence into the attention network model for feature encoding to obtain a spectral sequence representation with local semantic information and a semantic sequence representation with global semantic information, wherein the number of semantic tags in the learnable semantic tag sequence is equal to the total number of Raman spectra categories;

[0009] Performing category prediction according to the spectral sequence representation and the semantic sequence representation to obtain a category prediction result of the Raman spectrum;

[0010] According to the category prediction results, the spectral sequence representation and the semantic sequence representation, a comprehensive category activation map with global semantic information and local semantic information is calculated, and discriminative bands are determined according to the comprehensive category activation map, wherein the comprehensive category activation map characterizes the degree of influence of different bands on the category prediction results.

[0011] Optionally, the learnable semantic tag sequence and the spectral embedded tag sequence are input into an attention network model for feature encoding to obtain a spectral sequence representation with local semantic information and a semantic sequence representation with global semantic information, including:

[0012] Performing attention interaction processing on each spectral embedding tag in the spectral embedding tag sequence and other spectral embedding tags to obtain a spectral sequence representation with local semantic information;

[0013] Each learnable semantic tag in the learnable semantic tag sequence is subjected to attention interaction processing with each spectral embedding tag in the spectral embedding tag sequence to obtain a semantic sequence representation with global semantic information.

[0014] Optionally, performing category prediction according to the spectral sequence representation and the semantic sequence representation to obtain a category prediction result of the Raman spectrum includes:

[0015] Based on a local multi-layer perceptron classification head, predicting the spectral sequence representation is performed to obtain a local category prediction result;

[0016] Based on a global multi-layer perceptron classification head, predicting the semantic sequence representation to obtain a global category prediction result;

[0017] A category prediction result of the Raman spectrum is obtained according to the local category prediction result and the global category prediction result.

[0018] Optionally, calculating a comprehensive category activation map with global semantics and local semantics according to the category prediction result, the spectral sequence representation and the semantic sequence representation includes:

[0019] Determining a gradient class activation map with local semantic information according to the local class prediction result and the spectral sequence representation, wherein the gradient class activation map represents the degree of influence of different local bands on the class prediction result;

[0020] Determining an attention category activation map having global semantic information according to the attention between the semantic sequence representation and the spectral sequence representation, wherein the attention category activation map represents the degree of influence of a global band on the category prediction result;

[0021] The gradient category activation map and the attention category activation map are fused to obtain a comprehensive category activation map with global semantic information and local semantic information.

[0022] Optionally, determining a gradient category activation map according to the local category prediction result and the spectral sequence representation includes:

[0023] According to the local category prediction result, calculating a gradient vector represented by the local category prediction result for the spectral sequence, the gradient vector representing the importance of different feature channels to the category prediction result;

[0024] A gradient class activation map is determined according to the weighted average of the gradient vector and the spectral sequence representation.

[0025] Optionally, determining an attention category activation map having global semantic information according to the attention between the semantic sequence representation and the spectral sequence representation comprises:

[0026] Processing the semantic sequence representation using a query linear mapping layer to obtain a first processing result, and processing the spectral sequence representation using a key linear mapping layer to obtain a second processing result;

[0027] A normalized index operation is performed on the first processing result, the first processing result, and the feature dimension to obtain an attention category activation map with global semantic information.

[0028] Optionally, the attention-based interpretable Raman spectrum recognition method is implemented through a Raman spectrum recognition network, and the Raman spectrum recognition network includes: a convolutional spectrum embedding model, an attention network model, a local multi-layer perceptron classification head and a global multi-layer perceptron classification head;

[0029] The Raman spectrum recognition network is trained according to the following steps:

[0030] Inputting the sample Raman spectrum signal into the Raman spectrum recognition network for processing to obtain the sample local category prediction result and the sample global category prediction result;

[0031] Calculating a local classification loss according to the local category prediction result of the sample and the true category label, and calculating a global classification loss according to the global category prediction result of the sample and the true category label;

[0032] According to the local classification loss and the global classification loss, the network parameters of the Raman spectrum recognition network are updated.

[0033] Optionally, convolution embedding processing of the Raman spectrum signal is implemented by a convolution spectrum embedding model, and the convolution spectrum embedding model includes multiple residual convolution layers and downsampling layers.

[0034] According to a second aspect of the embodiment of the present application, an attention-based interpretable Raman spectrum recognition device is disclosed, the device comprising:

[0035] A processing module, used for performing convolution embedding processing on the Raman spectrum signal to obtain a spectrum embedding tag sequence based on the local neighborhood band characteristics;

[0036] An encoding module, used for inputting a learnable semantic tag sequence and the spectral embedding tag sequence into an attention network model for feature encoding to obtain a spectral sequence representation with local semantic information and a semantic sequence representation with global semantic information, wherein the number of semantic tags in the learnable semantic tag sequence is equal to the total number of Raman spectra categories;

[0037] A prediction module, used for performing category prediction according to the spectral sequence representation and the semantic sequence representation to obtain a category prediction result of the Raman spectrum;

[0038] A calculation module is used to calculate a comprehensive category activation map with global semantic information and local semantic information according to the category prediction result, the spectral sequence representation and the semantic sequence representation, and determine the discriminative band according to the comprehensive category activation map, wherein the comprehensive category activation map represents the degree of influence of different bands on the category prediction result.

[0039] According to a third aspect of an embodiment of the present application, a computer-readable storage medium is disclosed, on which a computer program is stored. When the computer program is executed by a processor, the steps of the attention-based interpretable Raman spectroscopy recognition method described in the first aspect of the embodiment of the present application are implemented.

[0040] The embodiments of the present application include the following advantages:

[0041] In an embodiment of the present application, a convolution embedding process is performed on a Raman spectral signal to obtain a spectral embedding tag sequence based on local neighborhood band features; a learnable semantic tag sequence and the spectral embedding tag sequence are input into an attention network model for feature encoding to obtain a spectral sequence representation with local semantic information and a semantic sequence representation with global semantic information, wherein the number of semantic tags in the learnable semantic tag sequence is equal to the total number of categories of the Raman spectrum; category prediction is performed based on the spectral sequence representation and the semantic sequence representation to obtain a category prediction result of the Raman spectrum; based on the category prediction result, the spectral sequence representation and the semantic sequence representation, a comprehensive category activation map with global semantic information and local semantic information is calculated, and a discriminative band is determined based on the comprehensive category activation map, wherein the category activation map characterizes the degree of influence of different bands on the category prediction result.

[0042] Since the spectral sequence representation has local semantic information and the semantic sequence representation has global semantic information, accurate category prediction can be achieved based on the spectral sequence representation and the semantic sequence representation. In addition, through the long-distance semantic dependency of the self-attention mechanism, while realizing Raman spectrum recognition, a comprehensive category activation map with global and local semantic information is calculated based on the category prediction results, the spectral sequence representation and the semantic sequence representation, so as to deterministically discriminate the band based on the comprehensive category activation map, thereby enhancing the interpretability of Raman spectrum recognition. In this way, an interpretable Raman spectrum recognition is achieved.

[0043] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0045] Figure 1 is a flowchart of the steps of an attention-based interpretable Raman spectroscopy recognition method provided in an embodiment of the present application;

[0046] Figure 2 This is an overall architecture diagram of an attention-based interpretable Raman spectroscopy recognition method provided in an embodiment of the present application;

[0047] Figure 3It is a structural schematic diagram of an attention-based interpretable Raman spectroscopy recognition device provided in an embodiment of the present application;

[0048] Figure 4 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0049] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and understandable, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0050] Reference Figure 1 As shown, Figure 1 is a flowchart of the steps of an attention-based interpretable Raman spectrum recognition method provided in an embodiment of the present application. Figure 1 As shown, the method may include steps S110 to S140:

[0051] Step S110: performing convolution embedding processing on the Raman spectrum signal to obtain a spectrum embedding label sequence based on local neighborhood band characteristics.

[0052] In the embodiment of the present application, the Raman spectrum signal is a one-dimensional data sequence, and the Raman spectrum signal can be a Raman spectrum signal collected from samples of different forms (different forms refer to solid, liquid and gas). For example, the Raman spectrum signal can be expressed as ,in, represents the length of the Raman spectrum signal, It means that the Raman spectrum signal is a one-dimensional data sequence with a length of L.

[0053] In order to obtain local semantic information in the spectral neighborhood and reduce the length of the Raman spectral signal to reduce the computational complexity, the Raman spectral signal is subjected to convolution embedding processing to process the Raman spectral signal into a spectral embedding tag sequence consisting of multiple spectral embedding tags. In the spectral embedding tag sequence, each spectral embedding tag is used to represent a local neighborhood band, and all spectral embedding tags in the spectral embedding tag sequence jointly represent a complete Raman spectral signal.

[0054] Specifically, convolution embedding processing is performed on the Raman spectrum signal to obtain a spectrum embedding label sequence based on local neighborhood band characteristics, including: convolution embedding processing is performed on the Raman spectrum signal to obtain a spectrum embedding feature based on local neighborhood band characteristics, and the spectrum embedding feature is converted to obtain a spectrum embedding label sequence based on local neighborhood band characteristics.

[0055] For example, the spectral embedding feature is represented as:

[0056] ,

[0057] in, represents the spectral embedding feature, represents the length of the spectral embedding feature sequence, D represents the feature dimension, represents the convolution embedding process, and S represents the Raman spectrum signal.

[0058] Next, the spectral embedding features are converted into a spectral embedding tag sequence, which is expressed as:

[0059] ,

[0060] in, represents the spectral embedding tag sequence, represents the first spectrum embedding marker in the spectrum embedding marker sequence, represents the second spectrum embedding marker in the spectrum embedding marker sequence, represents the first Spectral embedding markers, represents the i-th spectral embedding token in the spectral embedding token sequence, and D represents the feature dimension.

[0061] Step S120: Input the learnable semantic tag sequence and the spectral embedded tag sequence into the attention network model for feature encoding to obtain a spectral sequence representation with local semantic information and a semantic sequence representation with global semantic information, wherein the number of semantic tags in the learnable semantic tag sequence is equal to the total number of Raman spectra categories.

[0062] In an embodiment of the present application, in order to obtain the global semantic information of the entire sequence (i.e., the spectral embedded tag sequence), a learnable semantic tag sequence is introduced so that each learnable semantic tag interacts with each spectral embedded tag in the spectral embedded tag sequence, thereby allowing the learnable semantic tag to learn the global semantic information.

[0063] For example, the learnable semantic tag sequence representation is:

[0064] ,

[0065] in, represents a learnable semantic tag sequence, represents the first learnable semantic tag in the learnable semantic tag sequence, represents the second learnable semantic tag in the learnable semantic tag sequence, represents the i-th learnable semantic tag in the learnable semantic tag sequence, represents the Cth learnable semantic marker in the learnable semantic marker sequence, C represents the number of semantic markers in the learnable semantic marker sequence, the value of C is equal to the total number of Raman spectra, and D represents the feature dimension.

[0066] After the learnable semantic tag sequence is concatenated with the spectral embedding tag sequence, the input features are obtained and input into the attention network model for feature encoding.

[0067] For example, the input features are represented as:

[0068] ,

[0069] in, represents the input features, represents the join operation, represents a learnable semantic tag sequence, represents the spectral embedding tag sequence, C represents the number of semantic tags in the learnable semantic tag sequence, represents the length of the spectral embedding feature sequence, and D represents the feature dimension.

[0070] Specifically, the input features are input into the attention network model for feature encoding as:

[0071] ,

[0072] in, Indicates The sequence potential representation of the layer, Indicates The intermediate representation of the layer sequence, Indicates The sequence potential representation of the layer, represents the layer normalization operation, and It represents the Self-Attention Mechanism, which is expressed as:

[0073] ,

[0074] in, Represents the query linear mapping layer, Represents the key linear mapping layer, Represents the value linear mapping layer, represents the normalized exponential operation (Soft-Max operation), and D represents the feature dimension.

[0075] In the embodiment of the present application, the attention network model includes L layers of attention coding. Each layer of attention coding includes multi-head attention, summation and normalization, and forward propagation. Finally, after L layers of self-attention coding, a spectral sequence representation with local semantic information is obtained. , and semantic sequence representation with global semantic information .

[0076] Specifically, the learnable semantic tag sequence and the spectral embedded tag sequence are input into the attention network model for feature encoding to obtain a spectral sequence representation with local semantic information and a semantic sequence representation with global semantic information, including: performing attention interaction processing on each spectral embedded tag in the spectral embedded tag sequence with other spectral embedded tags to obtain a spectral sequence representation with local semantic information; performing attention interaction processing on each learnable semantic tag in the learnable semantic tag sequence with each spectral embedded tag in the spectral embedded tag sequence to obtain a semantic sequence representation with global semantic information.

[0077] Step S130: performing category prediction according to the spectral sequence representation and the semantic sequence representation to obtain a category prediction result of the Raman spectrum.

[0078] In the embodiment of the present application, the category prediction result of the Raman spectrum is characterized by the probability of belonging to each category. For example, the total number of categories of the Raman spectrum is 5, and the category prediction result of the Raman spectrum is the probability of belonging to these 5 categories. Finally, the category with the largest category probability is determined as the category of the Raman spectrum. Since the spectral sequence representation has local semantic information and the semantic sequence representation has global semantic information, accurate category prediction can be achieved based on the spectral sequence representation and the semantic sequence representation.

[0079] Specifically, performing category prediction according to the spectral sequence representation and the semantic sequence representation to obtain a category prediction result of the Raman spectrum includes steps A1 to A3:

[0080] Step A1: Based on a local multi-layer perceptron classification head, the spectral sequence representation is predicted to obtain a local category prediction result.

[0081] In the embodiment of the present application, the spectral sequence representation has local semantic information, and the spectral sequence representation is further mapped after global average pooling using a local multi-layer perceptron classification head to obtain a local category prediction result. For example, the local category prediction result is represented as:

[0082] ,

[0083] in, represents the global average pooling operation, Represents the local category prediction result, represents the local multilayer perceptron classification head, represents the Soft-Max operation, Represents the spectral sequence representation.

[0084] Step A2: Based on the global multi-layer perceptron classification head, the semantic sequence representation is predicted to obtain a global category prediction result.

[0085] In the embodiment of the present application, the semantic sequence representation has global semantic information, and a global prediction is performed on the semantic sequence representation based on a global multi-layer perceptron classification head to obtain a global category prediction result. For example, the global category prediction result is expressed as:

[0086] ,

[0087] in, Represents the global category prediction result, represents the global multi-layer perceptron classification head, represents the Soft-Max operation, Table semantic sequence representation.

[0088] Step A3: Obtaining a category prediction result of the Raman spectrum according to the local category prediction result and the global category prediction result.

[0089] In the embodiment of the present application, the local category prediction result and the global category prediction result are weighted and summed to obtain the category prediction result of the Raman spectrum. In this way, global semantic information and local semantic information are obtained through spectral sequence representation and semantic sequence representation respectively, thereby realizing dual-stream semantic recognition based on global semantic information and local semantic information, and improving the accuracy of the category prediction result of the Raman spectrum.

[0090] Step S140: Calculate a comprehensive category activation map having global semantic information and local semantic information according to the category prediction result, the spectral sequence representation, and the semantic sequence representation, and determine discriminative bands according to the comprehensive category activation map, wherein the comprehensive category activation map represents the degree of influence of different bands on the category prediction result.

[0091] In the embodiment of the present application, after obtaining the category prediction result of the Raman spectrum, a comprehensive category activation map with global semantic information and local semantic information is calculated to visualize the model's inherent decision-making mechanism based on the comprehensive category activation map (i.e., the interpretability of the prediction result). Based on the long-distance dependency feature of the self-attention mechanism, a gradient-based activation map (containing local semantic information) and an attention-based activation map (containing global semantic information) are introduced to obtain important discriminative bands from both local and global levels.

[0092] Among them, the discriminative band refers to the band that has a greater impact on the category prediction result of the Raman spectrum. The comprehensive category activation map characterizes the degree of influence of different bands on the category prediction result. The comprehensive category activation map includes an activation area and a non-activation area, and the band that has a greater impact on the category prediction result is determined as an activation area. Therefore, determining the discriminative band according to the comprehensive category activation map means: determining the band within the activation area in the comprehensive category activation map as the discriminative band.

[0093] In an optional embodiment, a comprehensive category activation map with global semantics and local semantics is calculated according to the category prediction result, the spectral sequence representation and the semantic sequence representation, including steps B1 to B3:

[0094] Step B1: determining a gradient class activation map with local semantic information according to the local class prediction result and the spectral sequence representation, wherein the gradient class activation map represents the degree of influence of different local bands on the class prediction result.

[0095] In the embodiment of the present application, in the gradient class activation map with local semantic information, if the gradient is larger, it means that the corresponding band has a more important influence on the class prediction result, and if the gradient is smaller, it means that the corresponding band has a less important influence on the class prediction result. For the spectral sequence representation after attention encoding, the gradient class activation map is introduced to reveal the importance of different bands for the prediction behavior (i.e., the prediction result).

[0096] Specifically, determining a gradient category activation map according to the local category prediction result and the spectral sequence representation includes: calculating a gradient vector of the local category prediction result for the spectral sequence representation according to the local category prediction result, the gradient vector characterizing the importance of different feature channels to the category prediction result; and determining a gradient category activation map according to a weighted average of the gradient vector and the spectral sequence representation.

[0097] For example, for the local category prediction result Predicted behavior for each category , the gradient vector of the local category prediction result for the spectral sequence representation is expressed as:

[0098] ,

[0099] in, Indicates feature channels, Represents the spectrum sequence representation Middle The coding characteristics of the bands, Represents the gradient vector of the local category prediction result for the spectral sequence representation, that is, The overall importance of feature channels for predicting behavior.

[0100] Afterwards, according to the gradient vector and spectral sequence representation The weighted average of is used to obtain the gradient category activation map, which is expressed as:

[0101] ,

[0102] in, Represents the gradient class activation map.

[0103] Step B2: determining an attention category activation map with global semantic information according to the attention between the semantic sequence representation and the spectral sequence representation, wherein the attention category activation map represents the degree of influence of the global band on the category prediction result.

[0104] In the embodiment of the present application, the semantic sequence represents With spectral sequence representation The attention between them represents the long-range semantic interaction between them, and contains the global semantic information of all bands in the spectral sequence representation. Therefore, according to the attention between the semantic sequence representation and the spectral sequence representation, the attention category activation map is obtained.

[0105] Specifically, according to the attention between the semantic sequence representation and the spectral sequence representation, an attention category activation map with global semantic information is determined, including: using a query linear mapping layer to process the semantic sequence representation to obtain a first processing result, and using a key linear mapping layer to process the spectral sequence representation to obtain a second processing result; performing a normalized exponential operation on the first processing result, the first processing result, and a feature dimension to obtain an attention category activation map with global semantic information.

[0106] For example, the attention class activation map is represented as:

[0107] ,

[0108] in, represents the attention category activation map, D is the feature dimension, Represents the query linear mapping layer, Represents the key linear mapping layer, represents the normalized exponential operation (Soft-Max operation), Indicates the first processing result, Indicates the second processing result.

[0109] Step B3: Fusing the gradient category activation map and the attention category activation map to obtain a comprehensive category activation map with global semantic information and local semantic information.

[0110] In an embodiment of the present application, the gradient class activation map represents the degree of influence of different local bands on the class prediction result, and the attention class activation map represents the degree of influence of the global band on the class prediction result. Therefore, by fusing the gradient class activation map and the attention class activation map, a comprehensive class activation map with global semantic information and local semantic information can be obtained.

[0111] For example, the comprehensive category activation map is represented as:

[0112] ,

[0113] in, represents the comprehensive category activation map, represents the attention category activation map, Represents the gradient class activation map.

[0114] In this way, through the long-distance dependency features of the self-attention mechanism, gradient-based activation maps (i.e., gradient class activation maps) and attention-based activation maps (i.e., attention class activation maps) are introduced to obtain important discriminative bands from both local and global levels, thereby achieving the interpretability of Raman spectroscopy recognition.

[0115] In an optional embodiment, the attention-based interpretable Raman spectrum recognition method is implemented through a Raman spectrum recognition network, which includes: a convolutional spectrum embedding model, an attention network model, a local multi-layer perceptron classification head and a global multi-layer perceptron classification head.

[0116] The convolution embedding processing of the Raman spectrum signal is realized by a convolution spectrum embedding model, and the convolution spectrum embedding model includes a plurality of residual convolution layers and a downsampling layer.

[0117] Furthermore, the Raman spectrum recognition network is trained according to the following steps:

[0118] Step C1: Input the sample Raman spectrum signal into the Raman spectrum recognition network for processing to obtain the sample local category prediction result and the sample global category prediction result.

[0119] Specifically, the convolutional spectral embedding model in the Raman spectral recognition network processes the sample Raman spectral signal to obtain a sample embedded tag sequence, and then inputs the sample embedded tag sequence and the learnable semantic tag sequence into the attention network model for feature encoding to obtain a sample spectral sequence representation with local semantic information and a sample semantic sequence representation with global semantic information. Afterwards, based on the local multi-layer perceptron classification head, the sample spectral sequence representation is predicted and processed to obtain the sample local category prediction result; and based on the global multi-layer perceptron classification head, the sample semantic sequence representation is predicted and processed to obtain the sample global category prediction result.

[0120] Step C2: Calculate the local classification loss according to the local category prediction result of the sample and the true category label, and calculate the global classification loss according to the global category prediction result of the sample and the true category label.

[0121] Specifically, the cross entropy loss between the sample local category prediction result and the true category label is used as the local classification loss, and the local classification loss is expressed as:

[0122] ,

[0123] in, represents the local classification loss; during training, Represents the local category prediction result of the sample; Represents the true category label.

[0124] The cross entropy loss between the sample global category prediction result and the true category label is used as the local classification loss, and the global classification loss is expressed as:

[0125] ,

[0126] in, represents the global classification loss; during training, Represents the global category prediction result of the sample; Represents the true category label.

[0127] Step C3: updating the network parameters of the Raman spectrum recognition network according to the local classification loss and the global classification loss.

[0128] Specifically, the total classification loss is calculated according to the local classification loss and the global classification loss, and the network parameters of the Raman spectrum recognition network are updated according to the total classification loss. Under the condition of satisfying the training results, a trained Raman spectrum recognition network is obtained.

[0129] For example, the total classification loss It is expressed as:

[0130] ,

[0131] in, represents the local classification loss, represents the global classification loss.

[0132] In summary, the attention-based interpretable Raman spectrum recognition method provided by the embodiment of the present application can achieve accurate category prediction based on the spectral sequence representation and the semantic sequence representation because the spectral sequence representation has local semantic information and the semantic sequence representation has global semantic information. In addition, through the long-distance semantic dependency of the self-attention mechanism, while realizing Raman spectrum recognition, a comprehensive category activation map with global semantic information and local semantic information is calculated based on the category prediction results, the spectral sequence representation and the semantic sequence representation, so as to deterministically discriminate the band based on the comprehensive category activation map, thereby enhancing the interpretability of Raman spectrum recognition. In this way, an interpretable Raman spectrum recognition is realized.

[0133] For example, Figure 2 This is an overall architecture diagram of an attention-based interpretable Raman spectrum recognition method provided by an embodiment of the present application. Specifically, the Raman spectrum signal is convolutionally embedded through a convolutional spectrum embedding model to obtain a spectrum embedding tag sequence based on local neighborhood band features; thereby, the learnable semantic tag sequence and the spectrum embedding tag sequence are input into the attention network model for feature encoding (wherein the attention network model includes L layers of attention encoding, each layer of attention encoding includes multi-head attention, summation and normalization, and forward propagation), and a spectrum sequence representation with local semantic information and a semantic sequence representation with global semantic information are obtained.

[0134] Next, based on the local multi-layer perceptron classification head, the spectral sequence representation is predicted and processed to obtain the local category prediction result; based on the global multi-layer perceptron classification head, the semantic sequence representation is predicted and processed to obtain the global category prediction result; finally, based on the local category prediction result and the global category prediction result, the category prediction result of the Raman spectrum is obtained. At the same time, based on the category prediction result, the spectral sequence representation and the semantic sequence representation, the comprehensive category activation map with global semantic information and local semantic information is calculated to determine the discriminative band according to the comprehensive category activation map, so as to achieve the interpretability of Raman spectrum recognition.

[0135] Furthermore, when training the Raman spectrum recognition network, the local classification loss is calculated based on the sample local category prediction result and the true category label, and the global classification loss is calculated based on the sample global category prediction result and the true category label; thereby, the network parameters of the Raman spectrum recognition network are updated based on the local classification loss and the global classification loss.

[0136] The present application also provides an attention-based interpretable Raman spectrum recognition device, referring to Figure 3 As shown, Figure 3 : is a schematic diagram of the structure of an attention-based interpretable Raman spectrum recognition device provided in an embodiment of the present application, the device comprising:

[0137] The processing module 310 is used to perform convolution embedding processing on the Raman spectrum signal to obtain a spectrum embedding label sequence based on the local neighborhood band characteristics;

[0138] An encoding module 320 is used to input the learnable semantic tag sequence and the spectral embedding tag sequence into the attention network model for feature encoding to obtain a spectral sequence representation with local semantic information and a semantic sequence representation with global semantic information, wherein the number of semantic tags in the learnable semantic tag sequence is equal to the total number of Raman spectra categories;

[0139] A prediction module 330, configured to perform category prediction based on the spectral sequence representation and the semantic sequence representation to obtain a category prediction result of the Raman spectrum;

[0140] The calculation module 340 is used to calculate a comprehensive category activation map with global semantic information and local semantic information according to the category prediction result, the spectral sequence representation and the semantic sequence representation, and determine the discriminative band according to the comprehensive category activation map, wherein the comprehensive category activation map represents the degree of influence of different bands on the category prediction result.

[0141] In an optional embodiment, the encoding module includes:

[0142] A first interaction processing module is used to perform attention interaction processing on each spectral embedding mark in the spectral embedding mark sequence with other spectral embedding marks to obtain a spectral sequence representation with local semantic information;

[0143] The second interaction processing module is used to perform attention interaction processing on each learnable semantic tag in the learnable semantic tag sequence and each spectral embedding tag in the spectral embedding tag sequence to obtain a semantic sequence representation with global semantic information.

[0144] In an optional embodiment, the prediction module includes:

[0145] A first prediction processing module is used to perform prediction processing on the spectral sequence representation based on a local multi-layer perceptron classification head to obtain a local category prediction result;

[0146] A second prediction processing module is used to perform prediction processing on the semantic sequence representation based on a global multi-layer perceptron classification head to obtain a global category prediction result;

[0147] The prediction result module is used to obtain the category prediction result of the Raman spectrum according to the local category prediction result and the global category prediction result.

[0148] In an optional embodiment, the calculation module includes:

[0149] A first determination module is used to determine a gradient class activation map with local semantic information according to the local class prediction result and the spectral sequence representation, wherein the gradient class activation map represents the degree of influence of different local bands on the class prediction result;

[0150] A second determination module is used to determine an attention category activation map with global semantic information according to the attention between the semantic sequence representation and the spectral sequence representation, wherein the attention category activation map represents the influence of the global band on the category prediction result;

[0151] The activation map module is used to fuse the gradient category activation map and the attention category activation map to obtain a comprehensive category activation map with global semantic information and local semantic information.

[0152] In an optional embodiment, the first determining module includes:

[0153] A gradient vector module, used to calculate, according to the local category prediction result, a gradient vector of the local category prediction result for the spectral sequence, wherein the gradient vector represents the importance of different feature channels to the category prediction result;

[0154] A weighted average module is used to determine a gradient class activation map according to a weighted average of the gradient vector and the spectral sequence representation.

[0155] In an optional embodiment, the second determining module includes:

[0156] A linear processing module, configured to process the semantic sequence representation using a query linear mapping layer to obtain a first processing result, and to process the spectral sequence representation using a key linear mapping layer to obtain a second processing result;

[0157] A normalized index operation module is used to perform a normalized index operation on the first processing result, the first processing result, and the feature dimension to obtain an attention category activation map with global semantic information.

[0158] In an optional embodiment, the attention-based interpretable Raman spectrum recognition device is implemented by a Raman spectrum recognition network, and the Raman spectrum recognition network includes: a convolutional spectrum embedding model, an attention network model, a local multi-layer perceptron classification head, and a global multi-layer perceptron classification head;

[0159] The device includes a training module for training the Raman spectrum recognition network, and the training module includes:

[0160] A sample prediction module is used to input the sample Raman spectrum signal into the Raman spectrum recognition network for processing to obtain a sample local category prediction result and a sample global category prediction result;

[0161] A loss calculation module, used to calculate the local classification loss according to the local category prediction result of the sample and the true category label, and to calculate the global classification loss according to the global category prediction result of the sample and the true category label;

[0162] A parameter updating module is used to update the network parameters of the Raman spectrum recognition network according to the local classification loss and the global classification loss.

[0163] In an optional embodiment, the convolution embedding processing of the Raman spectrum signal is implemented by a convolution spectrum embedding model, and the convolution spectrum embedding model includes a plurality of residual convolution layers and downsampling layers.

[0164] The present application also provides an electronic device, referring to Figure 4 , Figure 4 Schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 4 As shown, the electronic device 400 includes: a memory 410 and a processor 420. The memory 410 and the processor 420 are connected via a bus communication. A computer program is stored in the memory 410. The computer program can be run on the processor 420 to implement the steps of the attention-based interpretable Raman spectroscopy recognition method described in the embodiment of the present application.

[0165] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0166] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, apparatuses and devices according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0167] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0168] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0169] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.

[0170] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

[0171] The above is a detailed introduction to the attention-based interpretable Raman spectroscopy identification method, device and equipment provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technicians in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. An attention-based interpretable Raman spectroscopy recognition method, characterized in that: The method comprises: Perform convolution embedding processing on the Raman spectrum signal to obtain a spectrum embedding tag sequence based on the local neighborhood band characteristics; Inputting the learnable semantic tag sequence and the spectral embedded tag sequence into the attention network model for feature encoding to obtain a spectral sequence representation with local semantic information and a semantic sequence representation with global semantic information, wherein the number of semantic tags in the learnable semantic tag sequence is equal to the total number of Raman spectra categories; Performing category prediction according to the spectral sequence representation and the semantic sequence representation to obtain a category prediction result of the Raman spectrum, including: performing prediction processing on the spectral sequence representation based on a local multi-layer perceptron classification head to obtain a local category prediction result; performing prediction processing on the semantic sequence representation based on a global multi-layer perceptron classification head to obtain a global category prediction result; and obtaining a category prediction result of the Raman spectrum according to the local category prediction result and the global category prediction result; According to the category prediction results, the spectral sequence representation and the semantic sequence representation, a comprehensive category activation map with global semantic information and local semantic information is calculated, and discriminative bands are determined according to the comprehensive category activation map, wherein the comprehensive category activation map characterizes the degree of influence of different bands on the category prediction results.

2. The attention-based interpretable Raman spectroscopy recognition method according to claim 1, characterized in that: Inputting the learnable semantic tag sequence and the spectral embedded tag sequence into the attention network model for feature encoding to obtain a spectral sequence representation with local semantic information and a semantic sequence representation with global semantic information, including: Performing attention interaction processing on each spectral embedding tag in the spectral embedding tag sequence and other spectral embedding tags to obtain a spectral sequence representation with local semantic information; Each learnable semantic tag in the learnable semantic tag sequence is subjected to attention interaction processing with each spectral embedding tag in the spectral embedding tag sequence to obtain a semantic sequence representation with global semantic information.

3. The attention-based interpretable Raman spectroscopy recognition method according to claim 1, characterized in that: According to the category prediction result, the spectral sequence representation and the semantic sequence representation, a comprehensive category activation map with global semantics and local semantics is calculated, including: Determining a gradient class activation map with local semantic information according to the local class prediction result and the spectral sequence representation, wherein the gradient class activation map represents the degree of influence of different local bands on the class prediction result; Determining an attention category activation map having global semantic information according to the attention between the semantic sequence representation and the spectral sequence representation, wherein the attention category activation map represents the degree of influence of a global band on the category prediction result; The gradient category activation map and the attention category activation map are fused to obtain a comprehensive category activation map with global semantic information and local semantic information.

4. The attention-based interpretable Raman spectroscopy recognition method according to claim 3, characterized in that: Determining a gradient category activation map according to the local category prediction result and the spectral sequence representation includes: According to the local category prediction result, calculating a gradient vector represented by the local category prediction result for the spectral sequence, the gradient vector representing the importance of different feature channels to the category prediction result; A gradient class activation map is determined according to the weighted average of the gradient vector and the spectral sequence representation.

5. The attention-based interpretable Raman spectroscopy recognition method according to claim 3, characterized in that: Determining an attention category activation map having global semantic information according to the attention between the semantic sequence representation and the spectral sequence representation, comprising: Processing the semantic sequence representation using a query linear mapping layer to obtain a first processing result, and processing the spectral sequence representation using a key linear mapping layer to obtain a second processing result; A normalized index operation is performed on the first processing result, the first processing result, and the feature dimension to obtain an attention category activation map with global semantic information.

6. The attention-based interpretable Raman spectroscopy recognition method according to claim 1, characterized in that: The attention-based interpretable Raman spectrum recognition method is implemented through a Raman spectrum recognition network, which includes: a convolutional spectrum embedding model, an attention network model, a local multi-layer perceptron classification head and a global multi-layer perceptron classification head; The Raman spectrum recognition network is trained according to the following steps: Inputting the sample Raman spectrum signal into the Raman spectrum recognition network for processing to obtain the sample local category prediction result and the sample global category prediction result; Calculating a local classification loss according to the local category prediction result of the sample and the true category label, and calculating a global classification loss according to the global category prediction result of the sample and the true category label; According to the local classification loss and the global classification loss, the network parameters of the Raman spectrum recognition network are updated.

7. The attention-based interpretable Raman spectroscopy recognition method according to claim 1, characterized in that: The convolution embedding processing of the Raman spectrum signal is realized by a convolution spectrum embedding model, and the convolution spectrum embedding model includes a plurality of residual convolution layers and a downsampling layer.

8. An attention-based interpretable Raman spectroscopy recognition device, characterized in that: The device comprises: A processing module, used for performing convolution embedding processing on the Raman spectrum signal to obtain a spectrum embedding tag sequence based on the local neighborhood band characteristics; An encoding module, used for inputting a learnable semantic tag sequence and the spectral embedding tag sequence into an attention network model for feature encoding to obtain a spectral sequence representation with local semantic information and a semantic sequence representation with global semantic information, wherein the number of semantic tags in the learnable semantic tag sequence is equal to the total number of Raman spectra categories; A prediction module is used to perform category prediction based on the spectral sequence representation and the semantic sequence representation to obtain a category prediction result of the Raman spectrum, including: based on a local multi-layer perceptron classification head, performing prediction processing on the spectral sequence representation to obtain a local category prediction result; based on a global multi-layer perceptron classification head, performing prediction processing on the semantic sequence representation to obtain a global category prediction result; and obtaining a category prediction result of the Raman spectrum based on the local category prediction result and the global category prediction result; A calculation module is used to calculate a comprehensive category activation map with global semantic information and local semantic information according to the category prediction result, the spectral sequence representation and the semantic sequence representation, and determine the discriminative band according to the comprehensive category activation map, wherein the comprehensive category activation map represents the degree of influence of different bands on the category prediction result.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the attention-based interpretable Raman spectroscopy recognition method described in any one of claims 1 to 7 are implemented.