Model training method and identification method, device and medium based on Raman spectroscopy
By introducing a logical operator network into a model training method based on Raman spectroscopy to process the first feature set, constraining the update of the first model, the existing model lacks ability to extract implicit features in complex Raman spectroscopy data. Problem, achieving higher recognition accuracy and robustness.
Patent Information
- Application Number
- CN202411651230.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-19
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2044-11-19
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence, and in particular to a model training method and recognition method, device, and medium based on Raman spectroscopy. Background Art
[0002] Raman spectroscopy is a molecular fingerprint vibration spectrum. Based on Raman spectroscopy, chemical, material and biological samples can be detected quickly, non-destructively and without labels. This makes Raman spectroscopy have application potential in the field of analysis. For example, chemicals can be identified non-destructively through Raman spectroscopy, the spatial distribution of components in materials can be identified through Raman spectroscopy imaging, bacterial species and subtypes can be identified using Raman spectroscopy, and the type and status of diseases can be identified using human body fluids or tissues.
[0003] In related technologies, Raman spectroscopy is combined with deep learning algorithms to establish a feature extraction model based on Raman spectroscopy for classification tasks. The training samples used are mostly Raman spectral data of a single object to be tested, with a single spectral background and low recognition difficulty. In practical applications, the samples to be tested are often complex in composition and require multiple classifications. This type of task has high requirements for the model's feature extraction capabilities.
[0004] In order to improve the accuracy of classification tasks, data enhancement is usually used, for example, artificially expanding the training set, or adding noise and / or baseline fluctuations to the original training samples by generating adversarial neural networks. However, the data enhancement method only superimposes noise and baseline fluctuations on the Raman spectrum of the training sample, and does not change the basic spectral peak shape. Although it can improve the generalization ability of the feature extraction model to a certain extent, when the Raman spectrum data of the test sample in the actual application is too different from the Raman spectrum data of the training sample, or when there is interference data in the Raman spectrum data of the test sample, the feature extraction model cannot extract effective implicit features in the face of these more complex Raman spectrum data. It can be seen that the robustness of the feature extraction model based on Raman spectrum in the related technology is poor. Summary of the invention
[0005] In order to solve the related technical problems, the embodiments of the present application provide a model training method and an identification method, device, and medium based on Raman spectroscopy.
[0006] The technical solution of the embodiment of the present application is implemented as follows:
[0007] The present application embodiment provides a model training method based on Raman spectroscopy, the method comprising:
[0008] The first model is called to process a plurality of training samples respectively to obtain a first feature of each training sample; the training samples are characterized as Raman spectral data, and the first feature represents an implicit feature of the Raman spectral data;
[0009] Calling the second model to process the multiple first feature sets respectively to obtain the second feature of each first feature set; each first feature set includes at least two first features selected from the first features of the multiple training samples; the second model includes one or more sub-networks for performing logical operations; the second model is used to constrain the first model through a first loss value and a second loss value; the first loss value represents the loss value of the implicit feature of the Raman spectral data; the second loss value represents the loss value of the classification result of the Raman spectral data;
[0010] Calculating the first loss value and calculating the second loss value;
[0011] Based on the calculated first loss value and the second loss value, the first model and the second model are updated.
[0012] In the above solution, the one or more sub-networks for performing logic operations include: a first sub-network and / or a second sub-network and / or a third sub-network; wherein,
[0013] The first sub-network is used to perform an intersection operation on at least two first features in the first feature set, the second sub-network is used to perform a union operation on at least two first features in the first feature set, and the third sub-network is used to perform a reduction operation on at least two first features in the first feature set.
[0014] In the above solution, the calling of the second model to process the multiple first feature sets to obtain the second feature of each first feature set includes:
[0015] Each sub-network of the second model is called to process each first feature set to obtain one or more second features of each first feature set; each second feature of the first feature set corresponds to a sub-network of the second model.
[0016] In the above solution, the calculating the first loss value includes:
[0017] Calling the first loss function corresponding to each sub-network of the second model, calculating the first features of the multiple training samples and the second features of the multiple first feature sets, and obtaining a third loss value corresponding to each sub-network;
[0018] A setting operation is performed on all the calculated third loss values to obtain the first loss value.
[0019] In the above solution, the calculating the second loss value includes:
[0020] Calling a second loss function to calculate the first label and the first classification result of each training sample in the multiple training samples to obtain a fourth loss value; wherein the first label represents the category of the corresponding training sample; and the first classification result represents the classification result obtained by calling the third model to classify the first feature of the corresponding training sample;
[0021] Calling a second loss function to calculate the second label of each first feature set in the multiple first feature sets and the second classification result to obtain a fifth loss value; wherein the second label represents the logical operation result of the target operation logic of each subnetwork of the second model on the first labels of at least two training samples corresponding to the corresponding first feature set; the second classification result represents the classification result obtained by calling the third model to classify the second feature of the corresponding first feature set;
[0022] The fourth loss value and the fifth loss value are summed to obtain the second loss value.
[0023] In the above solution, updating the first model and the second model based on the calculated first loss value and the second loss value includes:
[0024] Summing the first loss value and the second loss value to obtain a sixth loss value;
[0025] Calling the sixth loss value to perform back-propagation processing on the second model to update the second model, and propagating the sixth loss value to the first model;
[0026] The sixth loss value is called to perform back-propagation processing on the first model to update the first model.
[0027] The present application also provides a method for identifying Raman spectroscopy, the method comprising:
[0028] The fourth model is called to process the Raman spectrum data of the sample to be identified to obtain a fifth feature; the fifth feature represents an implicit feature of the Raman spectrum data of the sample to be identified;
[0029] Calling the fifth model to perform classification processing on the fifth feature to obtain a third classification result, wherein the third classification result represents the category of the Raman spectrum data of the sample to be identified;
[0030] The fourth model represents the first model trained based on any of the above-mentioned Raman spectroscopy-based model training methods.
[0031] The present application also provides a model training device based on Raman spectroscopy, including:
[0032] A first calling unit is used to call a first model to process a plurality of training samples respectively to obtain a first feature of each training sample; the training samples are characterized as Raman spectral data, and the first feature represents an implicit feature of the Raman spectral data;
[0033] The second calling unit is used to call the second model to process the multiple first feature sets respectively to obtain the second feature of each first feature set; each of the first feature sets includes at least two first features selected from the first features of the multiple training samples; the second model includes one or more sub-networks for performing logical operations; the second model is used to constrain the first model through a first loss value and a second loss value; the first loss value represents the loss value of the implicit feature of the Raman spectral data; the second loss value represents the loss value of the classification result of the Raman spectral data;
[0034] A calculation unit, used for calculating the first loss value and calculating the second loss value;
[0035] An updating unit is used to update the first model and the second model based on the calculated first loss value and the second loss value.
[0036] The present application also provides a Raman spectroscopy-based identification device, including:
[0037] A third calling unit is used to call the fourth model to process the Raman spectrum data of the sample to be identified, so as to obtain a fifth feature; the fifth feature represents an implicit feature of the Raman spectrum data of the sample to be identified;
[0038] a classification unit, configured to call a fifth model to perform classification processing on the fifth feature to obtain a third classification result, wherein the third classification result represents a category of the Raman spectrum data of the sample to be identified;
[0039] The fourth model represents the first model trained based on any of the above-mentioned Raman spectroscopy-based model training methods.
[0040] An embodiment of the present application further provides an electronic device, comprising: a first processor and a first memory for storing a computer program that can be run on the processor,
[0041] Wherein, the first processor is used to execute the steps of any of the above methods when running the computer program.
[0042] An embodiment of the present application further provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above methods are implemented.
[0043] An embodiment of the present application also provides a computer program product, including a computer program, which implements the steps of any of the above methods when executed by a processor.
[0044] In an embodiment of the present application, a first model is called to process multiple training samples to obtain a first feature of each training sample, and the first feature represents an implicit feature of the Raman spectral data; then, a second model is called to process multiple first feature sets to obtain a second feature of each first feature set, where each first feature set includes at least two first features selected from the first features of the multiple training samples, and the second model includes one or more sub-networks for performing logical operations. The second model is used to constrain the first model through a first loss value and a second loss value, and the first loss value represents the loss value of the implicit feature of the Raman spectral data, and the second loss value represents the loss value of the classification result of the Raman spectral data; then, the first loss value and the second loss value are calculated; and then based on the calculated first loss value and the second loss value, the first model and the second model are updated. In this way, the second model realizes the constraint on the update of the first model during the training process through the first loss value and the second loss value, thereby enhancing the implicit feature extraction ability of the first model for Raman spectral data after training. Compared with the related technology, the first model after training can extract effective implicit features in the face of complex Raman spectral data and has better robustness, thereby increasing the accuracy of identifying the samples to be tested based on Raman spectral data. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 A schematic diagram of an implementation flow of a model training method provided in an embodiment of the present application;
[0046] Figure 2 A schematic diagram of the structure of a training phase network provided in an embodiment of the present application;
[0047] Figure 3 A schematic diagram of an implementation flow of an identification method provided in an embodiment of the present application;
[0048] Figure 4 A schematic diagram of the structure of a recognition phase network provided in an embodiment of the present application;
[0049] Figure 5 A schematic diagram of the structure of a model training device provided in an embodiment of the present application;
[0050] Figure 6 A schematic diagram of the structure of an identification device provided in an embodiment of the present application;
[0051] Figure 7 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0052] Raman spectroscopy is a molecular fingerprint vibration spectrum. Based on Raman spectroscopy, chemical, material and biological samples can be detected quickly, non-destructively and without labels. This makes Raman spectroscopy have application potential in the field of analysis. For example, chemicals can be identified non-destructively through Raman spectroscopy, the spatial distribution of components in materials can be identified through Raman spectroscopy imaging, bacterial species and subtypes can be identified using Raman spectroscopy, and the type and status of diseases can be identified using human body fluids or tissues.
[0053] In related technologies, Raman spectroscopy is combined with deep learning algorithms to establish a feature extraction model based on Raman spectroscopy for classification tasks. The training samples used are mostly Raman spectral data of a single object to be tested, with a single spectral background and low recognition difficulty. In practical applications, the samples to be tested are often complex in composition and require multiple classifications. This type of task has high requirements for the model's feature extraction capabilities.
[0054] In order to improve the accuracy of classification tasks, data enhancement is usually used, for example, artificially expanding the training set, or adding noise and / or baseline fluctuations to the original training samples by generating adversarial neural networks. However, the data enhancement method only superimposes noise and baseline fluctuations on the Raman spectrum of the training sample, and does not change the basic spectral peak shape. Although it can improve the generalization ability of the feature extraction model to a certain extent, when the Raman spectrum data of the test sample in the actual application is too different from the Raman spectrum data of the training sample, or when there is interference data in the Raman spectrum data of the test sample, the feature extraction model cannot extract effective implicit features in the face of these more complex Raman spectrum data. It can be seen that the robustness of the feature extraction model based on Raman spectrum in the related technology is poor.
[0055] Based on this, in an embodiment of the present application, a first model is called to process multiple training samples to obtain a first feature of each training sample, and the first feature represents an implicit feature of the Raman spectral data; then, a second model is called to process multiple first feature sets to obtain a second feature of each first feature set, where each first feature set includes at least two first features selected from the first features of multiple training samples, and the second model includes one or more sub-networks for performing logical operations. The second model is used to constrain the first model through a first loss value and a second loss value, and the first loss value represents the loss value of the implicit feature of the Raman spectral data, and the second loss value represents the loss value of the classification result of the Raman spectral data; then, the first loss value and the second loss value are calculated; and then based on the calculated first loss value and the second loss value, the first model and the second model are updated. In this way, the second model realizes the constraint on the update of the first model during the training process through the first loss value and the second loss value, thereby enhancing the implicit feature extraction ability of the first model for Raman spectral data after training. Compared with the related technology, the first model after training can extract effective implicit features in the face of complex Raman spectral data and has better robustness, thereby increasing the accuracy of identifying the samples to be tested based on Raman spectral data.
[0056] The present application is further described in detail below in conjunction with the accompanying drawings and embodiments.
[0057] The embodiment of the present application provides a model training method based on Raman spectroscopy.
[0058] In practical applications, the training phase network can be trained based on this method until the set convergence condition is reached. Specifically, each time the method is executed, the training phase network is trained once, and each time the training process is completed, the model parameters of each model in the training phase network are updated, or it can also be described as iterating the training phase network once. In the process of training the training phase network, multiple iterations can be performed until the set convergence condition is reached, thereby completing the training of the training phase network, that is, completing the training of each model in the training phase network.
[0059] Executing this method once means executing one iteration of the network in the training phase. Figure 1 The method includes: step 101, step 102, step 103 and step 104.
[0060] In practical applications, the set convergence condition can be that the calculated loss value is less than a set threshold, wherein the loss value can be calculated in each iteration process, and the loss value represents the degree of inconsistency between the predicted value obtained based on the training sample during the training process and the target value expected based on the training sample.
[0061] In the embodiment of the present application, the training phase network consists of the following models:
[0062] The first model is used to extract implicit features of Raman spectral data. Therefore, the first model can also be called a feature extraction model.
[0063] The second model is used to enhance the implicit feature extraction capability of the first model, so the second model can also be called an implicit feature enhancement model. The third model is used to classify the output of the first model and the output of the second model, so the third model can also be called a classification model.
[0064] Based on this, the Raman spectroscopy-based model training method provided in the embodiment of the present application can also be understood as a collaborative training method for the first model, the second model and the third model.
[0065] In practical applications, after the first model is trained, the fourth model can be obtained. The fourth model can be understood as the first model after training, that is, the first model that has completed training. After the third model is trained, the fifth model can be obtained. The fifth model can be understood as the third model after training, that is, the third model that has completed training.
[0066] Step 101 , step 102 , step 103 and step 104 are described in detail below.
[0067] Step 101: calling the first model to process multiple training samples respectively to obtain the first feature of each training sample.
[0068] The training sample is represented as Raman spectrum data, and the first feature represents the implicit feature of the Raman spectrum data.
[0069] Here, implicit features characterize features that exist in the data but are not directly visible or difficult to separate, in contrast to explicit features that can be directly observed.
[0070] In practical applications, implicit features can better express the structure of data. Therefore, tasks such as data classification can be performed based on implicit features to improve the accuracy of the output results of tasks such as classification. For example, the implicit features of Raman spectral data of bacteria in human tissue fluid are classified to obtain accurate recognition results of the categories of Raman spectral data of bacteria corresponding to the implicit features, so as to realize the diagnosis of human diseases based on the recognition results. Effective implicit features have a better expression of data. It is understandable that the effectiveness of implicit features affects the accuracy of the output results of subsequent tasks.
[0071] Here, the first model is used to extract implicit features of Raman spectroscopy data, and can be called a feature extraction model.
[0072] It is understandable that before reaching the set convergence condition, the first model has not completed training, the implicit feature extraction capability of the untrained first model is relatively weak, and the extracted implicit features are not completely effective implicit features. For example, the extracted implicit features may contain interference data that interfere with the expression of data, or contain invalid features that have a poor effect in expressing data.
[0073] After reaching the set convergence condition, the first model completes training. The trained first model can extract effective implicit features of the Raman spectral data to be tested in practical applications, thereby providing support for accurate classification of the Raman spectral data to be tested. For example, the Raman spectral data to be tested may be Raman spectral data of bacteria in human tissue fluid.
[0074] In practical applications, the network type of the first model can be a perceptual neural network, a convolutional neural network, a transformer, or an attention mechanism network.
[0075] Step 102: calling the second model to process the multiple first feature sets respectively to obtain the second feature of each first feature set.
[0076] Each first feature set includes at least two first features selected from the first features of multiple training samples. Therefore, each first feature set can also be regarded as selected based on multiple training samples. The second model includes one or more subnetworks for performing logical operations, and the second model is used to constrain the first model through a first loss value and a second loss value. The first loss value represents the loss value of the implicit feature of the Raman spectral data; the second loss value represents the loss value of the classification result of the Raman spectral data.
[0077] In practical applications, a set number of first features can be randomly selected multiple times from the first features of multiple training samples, where the set number is at least 2, and then at least two first features selected at the same time are combined into a first feature set, thereby obtaining multiple first feature sets through multiple random selections.
[0078] Exemplarily, if there are four training samples in total, the first model is called to process the four training samples to obtain the first feature 1, the first feature 2, the first feature 3 and the first feature 4. Two first features are randomly selected twice from the four first features, wherein the first feature 1 and the first feature 2 are selected for the first time, and the first feature 1 and the first feature 3 are selected for the second time. Then, two first feature sets, the first feature set 1 and the first feature set 2, can be obtained, wherein the first feature set 1 includes the first feature 1 and the first feature 2, and the first feature set 2 includes the first feature 1 and the first feature 3.
[0079] Here, the second model includes one or more sub-networks for logical operations. In practical applications, the network type of each sub-network can be a perceptual neural network, a convolutional neural network, a Transformer or an attention mechanism network. If the second model has multiple sub-networks, the connection between these multiple sub-networks is parallel connection, and the network type connection within the same sub-network can be a residual connection or a skip connection.
[0080] Each sub-network in the second model can be used to perform a logical operation. In practical applications, each sub-network can be used to perform a logical operation on at least two first features in the first feature set. Exemplarily, the logical operation of each sub-network can be an intersection operation, a union operation, or a reduction operation.
[0081] In one embodiment, the one or more sub-networks for performing logic operations include: a first sub-network and / or a second sub-network and / or a third sub-network.
[0082] Among them, the first subnetwork is used to perform an intersection operation on at least two first features in the first feature set, the second subnetwork is used to perform a union operation on at least two first features in the first feature set, and the third subnetwork is used to perform a reduction operation on at least two first features in the first feature set.
[0083] Here, it can also be understood that the target operation logics of the first sub-network, the second sub-network and the third sub-network are intersection operation, union operation and reduction operation respectively.
[0084] In actual applications, the second model has not completed training before the set convergence conditions are reached. In this case, the sub-network in the second model cannot accurately output the operation results corresponding to the target operation logic; after the set convergence conditions are reached, the second model completes training and can accurately output the operation results corresponding to the target operation logic.
[0085] In one embodiment, calling the second model to process the plurality of first feature sets to obtain the second feature of each first feature set includes:
[0086] Each sub-network of the second model is called to process each first feature set to obtain one or more second features of each first feature set; each second feature of the first feature set corresponds to a sub-network of the second model.
[0087] Here, each second feature in the first feature set can be regarded as a logical operation result of a sub-network in the second model on at least two first features in the first feature set.
[0088] Exemplarily, if the first feature set 1 includes the first feature 1 and the first feature 2, and the second model includes a first subnetwork, a second subnetwork and a third subnetwork, then, by calling each subnetwork of the second model to process the first feature set 1, the second feature 1, the second feature 2 and the second feature 3 can be obtained respectively, among which the second feature 1 corresponds to the first subnetwork and can be regarded as the result of the intersection operation of the first feature 1 and the first feature 2 by the first subnetwork; the second feature 2 corresponds to the second subnetwork and can be regarded as the result of the union operation of the first feature 1 and the first feature 2 by the second subnetwork; the second feature 3 corresponds to the third subnetwork and can be regarded as the result of the reduction operation of the first feature 1 and the first feature 2 by the third subnetwork.
[0089] In practical applications, each sub-network can also be used to perform logical operations on a first feature and the first feature itself.
[0090] In practical applications, each subnetwork can also be used to perform logical operations on at least two second features. For example, if the structure of the second model refers to the previous example, the first subnetwork of the second model is called to process the first feature set 1 to obtain the second feature 1; the second subnetwork is called to process the first feature set 1 to obtain the second feature 2; then, the third subnetwork can be called to process the second feature 1 and the second feature 2 to obtain the result of the reduction operation on the second feature 1 and the second feature 2.
[0091] Here, the second model is used to constrain the first model through the first loss value and the second loss value. It can be understood that the calculation of the first loss value and the second loss value is constrained by the second model, and the second model passes the constraints to the first model through the first loss value and the second loss value, thereby constraining the update of the first model, so that the first model can extract effective implicit features of the Raman spectrum after training, thereby enhancing the implicit feature extraction capability of the first model for Raman spectrum data after training.
[0092] In the related art, the feature extraction model based on Raman spectroscopy can extract effective features of Raman spectroscopy data through data enhancement. However, when the Raman spectroscopy data of the sample to be tested in actual application differs too much from the Raman spectroscopy data of the training sample, or when there is interference data in the Raman spectroscopy data of the sample to be tested, the feature extraction model cannot extract effective implicit features in the face of these more complex Raman spectroscopy data. It can be seen that the robustness of the feature extraction model is poor. The reason is that data enhancement improves the adaptability of the feature extraction model to the data in the training sample, but does not intrinsically improve the implicit feature extraction capability of the feature extraction model. Therefore, the feature extraction model cannot process complex Raman spectroscopy data that differs greatly from the data pattern of the training sample.
[0093] In the embodiment of the present application, the second model uses the first loss value and the second loss value to implement constraints on the update of the first model during the training process, so that the first model after training can eliminate interference data and invalid features in the Raman spectral data and obtain effective implicit features, thereby enhancing the implicit feature extraction capability of the first model for Raman spectral data after training, rather than just adapting to the data in the training samples.
[0094] In practical applications, after training is completed, the second model is removed from the combination with the first model and the third model. The first model after training performs feature extraction of Raman spectral data independently of the second model, and the extracted implicit features can be directly used for classification processing to identify the category of the corresponding Raman spectral data. Therefore, when the first model after training is called to perform application processing such as disease diagnosis based on Raman spectral data, the operation of the second model is not involved, and the computing power burden of Raman spectral data processing is not increased, saving computing power resources.
[0095] Step 103: Calculate the first loss value and calculate the second loss value.
[0096] In actual applications, before calculating the second loss value, the third model can be called to process the first feature of each training sample in multiple training samples respectively to obtain the first classification result corresponding to each training sample, and the third model can be called to process the second feature of each first feature set in multiple first feature sets respectively to obtain the second classification result corresponding to each first feature set.
[0097] Here, both the first classification result and the second classification result can be understood as the classification results obtained by calling the third model for classification processing. Among them, each first classification result corresponds to a training sample, and each second classification result corresponds to a first feature set. If there are multiple subnetworks in the second model, then each first feature set has multiple second classification results, and each second classification result of the first feature set corresponds to a subnetwork.
[0098] Exemplarily, the third model may be a K-nearest neighbor (KNN) model, a convolutional neural network model, or the like.
[0099] In actual applications, before the set convergence conditions are reached, the third model has not completed training. In this case, the classification accuracy of the third model is low. After the set convergence conditions are reached, the third model completes training and can output accurate classification results.
[0100] In practical applications, a first loss value may be calculated based on the first features of multiple training samples and the second features of multiple first feature sets, and a second loss value may be calculated based on the first classification result and the second classification result.
[0101] Step 104: Update the first model and the second model based on the calculated first loss value and the second loss value.
[0102] In practical applications, the third model may also be updated based on the calculated first loss value and the second loss value.
[0103] In practical applications, the first loss value and the second loss value can be set to obtain the overall loss value of the network in the training phase, and the set operation can be a summation operation. Then, the overall loss value is fed back to the network in the training phase, and based on the overall loss value, the optimization algorithm is used to update the model parameters of the model in the network in the training phase until the set convergence condition is reached.
[0104] The model parameters represent the configuration variables within the model, which can be the weights and biases of each node of the model. The set convergence condition can be that the overall loss value is less than the set convergence threshold, or that the overall loss value no longer decreases. The optimization algorithm represents the algorithm that enables the network to reach the set convergence condition during the training phase. For example, the optimization algorithm can select the adaptive moment estimation method or the stochastic gradient descent method.
[0105] In one embodiment, updating the first model and the second model based on the calculated first loss value and the second loss value includes:
[0106] The first loss value and the second loss value are summed to obtain a sixth loss value;
[0107] Call the sixth loss value to perform back propagation processing on the second model to update the second model, and propagate the sixth loss value to the first model;
[0108] The sixth loss value is called to perform back-propagation processing on the first model to update the first model.
[0109] Here, the sixth loss value can be regarded as the overall loss value of the network in the training phase.
[0110] In actual applications, before calling the sixth loss value to perform back-propagation processing on the second model, the sixth loss value can also be called to perform back-propagation processing on the third model to update the third model and propagate the sixth loss value to the second model.
[0111] Calling the overall loss value to back-propagate the model means propagating the overall loss value layer by layer to each layer in the model through the chain rule, so that the model parameters of each layer can be updated through the optimization algorithm.
[0112] Taking the optimization algorithm using stochastic gradient descent as an example, the sixth loss value is called to perform back propagation processing on the third model, that is, the gradient values of each model parameter of the third model are calculated layer by layer based on the sixth loss value. Specifically, starting from the output layer of the third model, the gradient values of each layer of model parameters are calculated layer by layer toward the input layer. The gradient values of the model parameters of the previous layer can be used as input when calculating the gradient values of the model parameters of the next layer, which reduces the amount of calculation in the calculation process. Then, based on the calculated gradient values, the stochastic gradient descent method is used to update the model parameters of each layer.
[0113] Here, after the sixth loss value is propagated to the last layer of the third model, the sixth loss value can be propagated to the second model through the chain rule. Taking the optimization algorithm using the stochastic gradient descent method as an example, the sixth loss value is propagated from the third model to the second model, that is, the gradient of the model parameters of the input layer of the third model is used as the input when calculating the gradient of the model parameters of the output layer of the second model.
[0114] After propagating the sixth loss value to the second model, the first model is called to perform back-propagation processing on the sixth loss value to update the model parameters of each layer in the second model.
[0115] After the sixth loss value is propagated to the last layer of the second model, the sixth loss value can be propagated to the first model through the chain rule. Taking the optimization algorithm using stochastic gradient descent as an example, the sixth loss value is propagated from the second model to the first model, that is, the gradient of the model parameters of the input layer of the second model is used as the input when calculating the gradient of the model parameters of the output layer of the first model.
[0116] After propagating the sixth loss value to the first model, the first model is called to perform back-propagation processing on the sixth loss value to update the model parameters of each layer in the first model.
[0117] It can be seen that the training of the training phase network composed of the first model, the second model and the third model can also be regarded as the collaborative training of the first model, the second model and the third model. During the training process, the third model used for classification processing propagates the overall loss value to the second model through the chain rule, and the second model then propagates the overall loss value to the first model through the chain rule, so that the overall loss value can constrain the update of the first model.
[0118] In the embodiment of the present application, the second model implements the constraint on the update of the first model during the training process through the first loss value and the second loss value, thereby enhancing the implicit feature extraction capability of the first model for Raman spectral data after training. Compared with the related art, the first model after training can extract effective implicit features in the face of complex Raman spectral data, and has better robustness, thereby increasing the accuracy of identifying the sample to be tested based on Raman spectral data.
[0119] The calculation method of the first loss value and the second loss value is described in detail below.
[0120] In one embodiment, calculating the first loss value includes:
[0121] Calling the first loss function corresponding to each sub-network of the second model, calculating the first features of the plurality of training samples and the second features of the plurality of first feature sets, and obtaining a third loss value corresponding to each sub-network;
[0122] A setting operation is performed on all the calculated third loss values to obtain a first loss value.
[0123] Here, the first loss function corresponds to each sub-network of the second model.
[0124] To further illustrate the calculation method of the first loss value, an example of the first loss function is given below. For ease of understanding, the first feature set in the example includes two first features. In practical applications, the first feature set may include at least two first features.
[0125] Exemplarily, the first loss function corresponding to the first sub-network may be:
[0126] ,
[0127] in, Characterize the first subnetwork, Characterize the first model; A and B Represents two training samples corresponding to two first features in the same first feature set. right A Processed , right B Processed , and Characterizing two first features in the same first feature set; n Indicates the number of first feature sets selected from a plurality of training samples.
[0128] Here, for the convenience of description, is called the first feature A, It is called the first feature B.
[0129] Understandably, Characterizes the intersection operation result of the first sub-network on the first feature A and the first feature A itself. When the second model is trained to an ideal state, the first sub-network included in the second model should have accurate intersection operation capability. Specifically, the intersection operation result of the first sub-network on the first feature A and the first feature A itself should be equal to the first feature A itself, that is, The value of is zero. Similarly, when the second model is trained to an ideal state, The value of is zero.
[0130] Characterizes the result of the intersection operation of the first sub-network on the first feature A and the first feature B, Characterizes the result of the intersection operation of the first sub-network on the first feature B and the first feature A. It can be seen that and can represent the logical operation results of the first sub-network on the two first features in the first feature set. Therefore, and can all be considered as the second feature.
[0131] and The difference is that The corresponding intersection operation input order is: the first feature A first, and the first feature B later; The corresponding order of input parameters for the intersection operation is the first feature B first, followed by the first feature A. When the second model is trained to an ideal state, the intersection operation result of the first subnetwork included in the second model is not affected by the order of input parameters, that is, The value of is zero.
[0132] It can be seen that the first loss function corresponding to the first subnetwork in the example is Based on the characteristic design of the intersection operation of the first sub-network, it can be used to measure the intersection operation loss of the first sub-network. Therefore, can be considered as being constrained by the second model.
[0133] Exemplarily, the first loss function corresponding to the second sub-network may be:
[0134] ,
[0135] in, Characterize the second sub-network, Characterize the first model; A and BRepresents two training samples corresponding to two first features in the same first feature set. right A Processed , right B Processed , and Characterizing two first features in the same first feature set; n Indicates the number of first feature sets selected from a plurality of training samples.
[0136] Here, for the convenience of description, is called the first feature A, It is called the first feature B.
[0137] Understandably, Characterize the result of the second sub-network's operation on the union of the first feature A and the first feature A itself. When the second model is trained to an ideal state, the second sub-network included in the second model should have accurate union operation capability. Specifically, the result of the second sub-network's operation on the union of the first feature A and the first feature A itself is equal to the first feature A itself, that is, The value of is zero. Similarly, when the second model is trained to an ideal state, The value of is zero.
[0138] Represents the result of the second sub-network's operation on the union of the first feature A and the first feature B, Characterizes the result of the second sub-network's operation on the union of the first feature B and the first feature A. It can be seen that and can represent the logical operation results of the second sub-network on the two first features in the first feature set. Therefore, and can all be considered as the second feature.
[0139] and The difference is that The corresponding order of input parameters for the union operation is: the first feature A comes first, and the first feature B comes last; The corresponding order of input parameters for the union operation is the first feature B first, followed by the first feature A. When the second model is trained to an ideal state, the result of the union operation of the second subnetwork included in the second model is not affected by the order of input parameters, that is, The value of is zero.
[0140] It can be seen that the first loss function corresponding to the second sub-network Based on the characteristic design of the union operation of the second sub-network, it can be used to measure the union operation loss of the second sub-network. Therefore, can be considered as being constrained by the second model.
[0141] Exemplarily, the first loss function corresponding to the third sub-network may be:
[0142] ,
[0143] in, Characterize the third sub-network, Characterize the second sub-network, Characterize the first subnetwork, Characterize the first model; A and B Represents two training samples corresponding to two first features in the same first feature set. right A Processed , right B Processed , and Characterizing two first features in the same first feature set; n Indicates the number of first feature sets selected from a plurality of training samples.
[0144] Here, for the convenience of description, is called the first feature A, It is called the first feature B.
[0145] Understandably, Represents the result of the reduction operation of the third sub-network on the first feature A and the first feature B. For the convenience of description, It is called the second feature 1; Represents the result of the intersection operation of the first sub-network on the first feature A and the first feature B. For the convenience of description, It is called the second feature 2; Characterizes the result of the second sub-network's union operation on the second feature 1 and the second feature 2. When the second model is trained to an ideal state, the third sub-network included in the second model should have accurate reduction operation capabilities. Specifically, if the reduction operation result of the first feature A and the first feature B is combined with the intersection operation result of the first feature A and the first feature B, the obtained union operation result should be equal to the first feature A, that is, The value of is zero.
[0146] It can be seen that the first loss function corresponding to the third sub-network Based on the characteristic design of the reduction operation of the third sub-network, it can be used to measure the reduction operation loss of the third sub-network. Therefore, can be considered as being constrained by the second model.
[0147] Here, the first loss function corresponding to each sub-network of the second model is called to perform calculations to obtain the third loss value corresponding to each sub-network; then, a setting operation is performed on all the calculated third loss values to obtain the first loss value. In practical applications, the setting operation may be a summation operation.
[0148] Exemplarily, if the second model includes a first subnetwork, a second subnetwork, and a third subnetwork, then the overall loss function corresponding to the second model may be:
[0149] ,
[0150] in, Characterize the first loss function corresponding to the first sub-network, Characterize the first loss function corresponding to the second sub-network, Characterizes the first loss function corresponding to the third sub-network. Here, we can It is called the intersection-minus-union loss function.
[0151] Exemplarily, if the second model includes a first subnetwork and a second subnetwork, then the overall loss function corresponding to the second model may be:
[0152] ,
[0153] in, Characterize the first loss function corresponding to the first sub-network, Characterizes the first loss function corresponding to the second sub-network. Here, we can It is called the intersection-over-union loss function.
[0154] Exemplarily, if the second model includes only one first subnetwork, then the overall loss function corresponding to the second model can be , Characterize the first loss function corresponding to the first sub-network.
[0155] In the above example, the overall loss function represents a functional expression of the calculation method of the first loss value of the second model. It can be seen that the overall loss function combines the loss functions corresponding to each sub-network in the second model, is designed based on the logical operation characteristics of each sub-network in the second model, and can be used to measure the overall calculation loss of each sub-network in the second model for the first feature. Therefore, the overall loss function can be regarded as being constrained by the second model. Since the first feature represents the implicit feature of the Raman spectral data, the first loss value calculated according to the overall loss function can represent the loss value of the implicit feature of the Raman spectral data.
[0156] In an embodiment of the present application, the first loss function corresponding to each sub-network of the second model processes the first feature and the second feature to obtain a first loss value, wherein the overall loss function used to calculate the first loss value is constrained by the second model. Moreover, when calculating through the overall loss function, the processing of the second feature is involved, and the second feature is obtained based on the second model. Therefore, the data used to calculate the first loss value is also constrained by the second model. In this way, the second model can constrain the calculation of the first loss value, and then back-propagate the first loss value to the first model. By constraining the update of the first model during the training process through the first loss value, the implicit feature extraction capability of the first model for Raman spectral data after the training is enhanced.
[0157] In one embodiment, calculating the second loss value includes:
[0158] Calling the second loss function, calculating the first label and the first classification result of each training sample in the multiple training samples, and obtaining a fourth loss value; wherein the first label represents the category of the corresponding training sample; and the first classification result represents the classification result obtained by calling the third model to classify the first feature of the corresponding training sample;
[0159] Calling the second loss function, calculating the second label of each first feature set in the multiple first feature sets and the second classification result, to obtain a fifth loss value; wherein the second label represents the logical operation result of the target operation logic of each sub-network of the second model on the first labels of at least two training samples corresponding to the corresponding first feature set; the second classification result represents the classification result obtained by calling the third model to classify the second feature of the corresponding first feature set;
[0160] The fourth loss value and the fifth loss value are summed to obtain a second loss value.
[0161] Here, the first label represents the category of the corresponding training sample, and can also be called the original label of the training sample. In practical applications, the first label can be obtained through manual annotation.
[0162] In practical applications, the first label may be in the form of an array, and each element of the array represents a different candidate category. When the training sample belongs to a candidate category, the value of the array element corresponding to the candidate category in the array is 1, and when the training sample does not belong to a candidate category, the value of the array element corresponding to the candidate category in the array is 0.
[0163] Exemplarily, if the array of the first label has three elements, the first element to the third element represent candidate category A, candidate category B and candidate category C respectively, and training sample 1 belongs to candidate category A, and training sample 2 belongs to candidate category A and candidate category C, then the first label of training sample 1 is [1, 0, 0], and the first label of training sample 2 is [1, 0, 1].
[0164] The category of the training sample can also be understood as the attribute of the training sample, and the attribute can be used to distinguish the training samples.
[0165] Here, the second label represents the logical operation result of the first label of at least two training samples corresponding to the corresponding first feature set by the target operation logic of each sub-network of the second model. In practical applications, after selecting multiple first feature sets, according to the target operation logic of each sub-network of the second model, the first labels of at least two training samples corresponding to each first feature set can be subjected to corresponding logical operations to obtain the operation result corresponding to the target operation logic of each sub-network, and then the operation result is used as the second label. It can be understood that each second label has at least two corresponding training samples, so the second label can also be regarded as a description of the training sample, and can also be called an enhanced label of the training sample.
[0166] For example, if the first labels of the two training samples corresponding to the first feature set 1 are [1, 0, 1] and [0, 1, 1] respectively, in this example, the two first labels are referred to as first label 1 and first label 2 respectively, and the second model includes a first subnetwork, a second subnetwork and a third subnetwork, then the first labels of the two training samples corresponding to the first feature set 1, that is, the first label 1 and the first label 2, can be subjected to intersection, union and reduction processing to obtain [0, 0, 1], [1 , 1, 1], [1, 0, 0], and [0, 1, 0] are the four second labels, among which [0, 0, 1] corresponds to the result of the intersection operation, [1, 1, 1] corresponds to the result of the union operation, [1, 0, 0] and [0, 1, 0] correspond to the results of the reduction operation, and the order of input parameters for the reduction operation corresponding to [1, 0, 0] is: the first label 1 first, and the first label 2 later, and the order of input parameters for the reduction operation corresponding to [0, 1, 0] is: the first label 2 first, and the first label 1 later.
[0167] In practical applications, the second label can be obtained by directly performing corresponding logical operations on the first label through a logical operation device, rather than performing logical operations on the second model that has not been trained to obtain the second label. In this way, the accuracy of the second label is guaranteed.
[0168] In practical applications, the first label and the second label can be collectively referred to as the data label of the training sample, that is, the target classification result obtained by the third model based on the training sample is expected.
[0169] Here, the second loss function is called to measure the inconsistency between the classification result output by the third model and the data label of the training sample, and the second loss value representing the loss value of the classification result of the Raman spectroscopy data is obtained. Specifically, the second loss function is called to measure the inconsistency between the first classification result and the original label of the training sample, and the fourth loss value is obtained; and the second loss function is called to measure the inconsistency between the second classification result and the enhanced label of the training sample, and the fifth loss value is obtained. Then, the fourth loss value and the fifth loss value are combined to obtain the second loss value.
[0170] In practical applications, the second loss function can use the binary cross entropy loss function, that is,
[0171] ,
[0172] When the second loss function is called to calculate the first label and the first classification result of each training sample in the plurality of training samples, Represent a training sample, Characterize the network used to obtain the first classification result, here, It can be a combination of the first model and the third model; Characterization The first classification result of Characterization The first label of Represents the number of multiple training samples.
[0173] When the second loss function is called to calculate the second label of each of the first feature sets and the second classification result in the plurality of first feature sets, Characterize a first feature set, Characterize the network used to obtain the second classification result, here, It can be a combination of the first model, the second model and the third model; Characterization The second classification results; Characterization The second label of and The target operation logic of the corresponding sub-networks is the same; Characterizes the number of the plurality of first sample pairs.
[0174] In the related art, the classification loss value represents the loss value of the classification result of Raman spectral data, and the classification loss value is calculated as follows: calling the feature extraction network to process multiple training samples representing Raman spectral data to obtain spectral features corresponding to each training sample; then classifying each spectral feature to obtain a classification result corresponding to each training sample; then calling the loss function to process the classification results of multiple training samples and the original labels of multiple training samples to obtain the classification loss value.
[0175] In the embodiment of the present application, the second loss value represents the loss value of the classification result of the Raman spectral data. In the process of calculating the second loss value, the fourth loss value is calculated based on the first classification result of the training sample and the original label of the training sample, and the fifth loss value is calculated based on the second classification result of the first feature set and the enhanced label of the training sample. Compared with the related technology, the measurement of the loss value related to the second classification result is added, which is equivalent to expanding the data volume of the training sample, and can improve the generalization ability of the first model after the training is completed.
[0176] Furthermore, in the embodiment of the present application, the fifth loss value used to calculate the second loss value is obtained based on the second feature output by the second model, and therefore, the calculation of the second loss value is constrained by the second model, and the second loss value can optimize the logical operation correctness of the sub-network in the second model during the back propagation process. The second model back-propagates the second loss value to the first model, so that the second model can constrain the update of the first model during the training process through the second loss value, thereby enhancing the implicit feature extraction capability of the first model for Raman spectral data after training, and improving the robustness of the first model after training, thereby increasing the accuracy of identifying the sample to be tested based on Raman spectral data.
[0177] To further illustrate the Raman spectroscopy-based training method provided in the embodiments of the present application, an example is provided here.
[0178] Figure 2 A structure of a training phase network is provided, wherein the training phase network includes: a feature extraction network, an implicit feature enhancement network, and a classification network. The feature extraction network is equivalent to the first model in the embodiment of the present application, the implicit feature enhancement network is equivalent to the second model in the embodiment of the present application, and the classification network is equivalent to the third model in the embodiment of the present application.
[0179] The training of the network based on this training phase mainly includes the following steps:
[0180] Step 1: Call the feature extraction network to process the Raman spectrum data to obtain the first feature.
[0181] Among them, Raman spectral data is equivalent to multiple training samples.
[0182] Step 2: Call the implicit enhancement network to process multiple first feature sets to obtain second features.
[0183] Step 3: Call the classification network to process the first features of multiple training samples and the second features of multiple first feature sets to obtain the network prediction category.
[0184] Specifically, a classification network is called to process the first features of multiple training samples to obtain a label category for each training sample, wherein the label category is equivalent to the first classification result in the embodiment of the present application.
[0185] The classification network is called to process the second features of the plurality of first feature sets to obtain an enhanced category corresponding to each first feature set, wherein the enhanced category is equivalent to the second classification result in the embodiment of the present application.
[0186] In this example, the label category and the enhancement category can be collectively referred to as the network prediction category.
[0187] Step 4: Calculate the feature loss value based on the calculated first feature and second feature.
[0188] Among them, the characteristic loss value is equivalent to the first loss value in the embodiment of the present application.
[0189] Step 5: Calculate the classification loss value based on the network prediction category and data label.
[0190] Among them, the data label includes the original label and the enhanced label, the original label is equivalent to the first label in the embodiment of the present application, the enhanced label is equivalent to the second label in the embodiment of the present application, and the classification loss value is equivalent to the second loss value in the embodiment of the present application.
[0191] Step 6: Calculate the overall loss value based on the feature loss value and the classification loss value.
[0192] Specifically, the feature loss value and the classification loss value are summed to obtain the overall loss value.
[0193] Step 7: Based on the overall loss value, feedback is used to optimize the network during the training phase.
[0194] Specifically, based on the overall loss value, the classification network, implicit feature enhancement network, and feature extraction network are updated.
[0195] Step 8: Repeat the above steps 1 to 7 until the set convergence condition is reached. The set convergence condition may be that the overall loss value is less than a set threshold.
[0196] Based on the Raman spectroscopy-based model training method in the above-mentioned embodiment, the embodiment of the present application further provides a Raman spectroscopy-based recognition method.
[0197] Reference Figure 3 , the method comprising:
[0198] Step 301: calling the fourth model to process the Raman spectrum data of the sample to be identified to obtain the fifth feature; the fifth feature represents the implicit feature of the Raman spectrum data of the sample to be identified.
[0199] The fourth model represents the first model trained by the Raman spectroscopy-based model training method in any of the aforementioned embodiments.
[0200] Step 302: calling the fifth model to perform classification processing on the fifth feature to obtain a third classification result, where the third classification result represents the category of the Raman spectrum data of the sample to be identified.
[0201] In practical applications, the fifth model can represent the third model trained by the Raman spectroscopy-based model training method in any of the aforementioned embodiments.
[0202] Exemplarily, the fifth model may be a KNN model or a convolutional neural network model.
[0203] In practical applications, the sample to be identified may be a chemical, material, or biological sample, and for example, the sample to be identified may be bacteria. The sample to be identified may also be referred to as a sample to be tested.
[0204] To further illustrate the Raman spectroscopy-based identification method provided in the embodiments of the present application, an example is provided here.
[0205] Figure 4 A structure of a recognition phase network is provided, where the recognition phase network can also be expressed as an inference phase network, wherein the recognition phase network includes a feature extraction network and a classification network. The feature extraction network is equivalent to the fourth model in the embodiment of the present application, and the classification network is equivalent to the fifth model in the embodiment of the present application.
[0206] Based on the recognition phase network, the Raman spectrum data is recognized, which mainly includes the following steps:
[0207] Step 1: Call the feature extraction network to process the Raman spectrum data to obtain the fifth feature.
[0208] The Raman spectral data represent the Raman spectral data of the sample to be tested in actual application. For example, the Raman spectral data may be the Raman spectral data of bacteria.
[0209] Step 2: Call the classification network to process the fifth feature and obtain the network prediction category.
[0210] Among them, when the Raman spectral data is Raman spectral data of bacteria, the network prediction category is equivalent to the third classification result in the embodiment of the present application.
[0211] In the embodiment of the present application, the second model implements the constraint on the update of the first model during the training process through the first loss value and the second loss value, thereby enhancing the implicit feature extraction capability of the first model for Raman spectral data after training, that is, enhancing the implicit feature extraction capability of the fourth model for Raman spectral data. Compared with the related art, the fourth model can extract effective implicit features in the face of complex Raman spectral data and has better robustness. Therefore, the embodiment of the present application can identify the accurate classification results of the Raman spectral data of bacteria based on the extracted implicit features, thereby improving the recognition accuracy based on Raman spectroscopy.
[0212] Based on the above embodiments, the present application also provides a model training device based on Raman spectroscopy, referring to Figure 5 , the Raman spectroscopy-based model training device comprises:
[0213] A first calling unit 51 is used for calling a first model to process the plurality of training samples respectively, and obtain a first feature of each training sample; the first feature represents an implicit feature of the Raman spectrum data;
[0214] The second calling unit 52 is used to call the second model to process the multiple first feature sets respectively to obtain the second feature of each first feature set; each of the first feature sets includes at least two first features selected from the first features of the multiple training samples; the second model includes one or more sub-networks for performing logical operations; the second model is used to constrain the first model through a first loss value and a second loss value; the first loss value represents the loss value of the implicit feature of the Raman spectral data; the second loss value represents the loss value of the classification result of the Raman spectral data;
[0215] Calculation unit 53: used for calculating the first loss value and the second loss value;
[0216] An updating unit 54 is configured to update the first model and the second model based on the calculated first loss value and the second loss value.
[0217] In one embodiment, the one or more sub-networks for performing logic operations include: a first sub-network and / or a second sub-network and / or a third sub-network; wherein,
[0218] The first sub-network is used to perform an intersection operation on at least two first features in the first feature set, the second sub-network is used to perform a union operation on at least two first features in the first feature set, and the third sub-network is used to perform a reduction operation on at least two first features in the first feature set.
[0219] In one embodiment, the second calling unit 52 calls the second model to process the plurality of first feature sets to obtain the second feature of each first feature set, including:
[0220] Each sub-network of the second model is called to process each first feature set to obtain one or more second features of each first feature set; each second feature of the first feature set corresponds to a sub-network of the second model.
[0221] In one embodiment, the calculation unit 53 calculates the first loss value, including:
[0222] Calling the first loss function corresponding to each sub-network of the second model, calculating the first features of the multiple training samples and the second features of the multiple first feature sets, and obtaining a third loss value corresponding to each sub-network;
[0223] A setting operation is performed on all the calculated third loss values to obtain the first loss value.
[0224] In one embodiment, the calculating unit 53 calculates the second loss value, including:
[0225] Calling a second loss function to calculate the first label and the first classification result of each training sample in the multiple training samples to obtain a fourth loss value; wherein the first label represents the category of the corresponding training sample; and the first classification result represents the classification result obtained by calling the third model to classify the first feature of the corresponding training sample;
[0226] Calling a second loss function to calculate the second label of each first feature set in the multiple first feature sets and the second classification result to obtain a fifth loss value; wherein the second label represents the logical operation result of the target operation logic of each subnetwork of the second model on the first labels of at least two training samples corresponding to the corresponding first feature set; the second classification result represents the classification result obtained by calling the third model to classify the second feature of the corresponding first feature set;
[0227] The fourth loss value and the fifth loss value are summed to obtain the second loss value.
[0228] In one embodiment, the updating unit 54 updates the first model and the second model based on the calculated first loss value and the second loss value, including:
[0229] Summing the first loss value and the second loss value to obtain a sixth loss value;
[0230] Calling the sixth loss value to perform back-propagation processing on the second model to update the second model, and propagating the sixth loss value to the first model;
[0231] The sixth loss value is called to perform back-propagation processing on the first model to update the first model.
[0232] In actual application, the first calling unit 51, the second calling unit 52, the calculation unit 53 and the updating unit 54 can all be implemented by a processor in the model training device based on Raman spectroscopy.
[0233] It should be noted that: the model training device based on Raman spectroscopy provided in the above embodiment only uses the division of the above program modules as an example when performing model training. In actual applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the device is divided into different program modules to complete all or part of the processing described above. In addition, the model training device based on Raman spectroscopy provided in the above embodiment and the model training method embodiment based on Raman spectroscopy belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0234] Based on the above embodiments, the present application also provides a recognition device based on Raman spectroscopy, referring to Figure 6 , the identification device based on Raman spectroscopy comprises:
[0235] The third calling unit 61 is used to call the fourth model to process the Raman spectrum data of the sample to be identified, so as to obtain a fifth feature; the fifth feature represents an implicit feature of the Raman spectrum data of the sample to be identified;
[0236] A classification unit 62, configured to call a fifth model to perform classification processing on the fifth feature to obtain a third classification result, wherein the third classification result represents a category of the Raman spectrum data of the sample to be identified;
[0237] Among them, the fourth model represents the first model trained based on any of the aforementioned model training methods.
[0238] In actual application, the third calling unit 61 and the classification unit 62 can be implemented by a processor in the identification device based on Raman spectroscopy.
[0239] It should be noted that: the identification device based on Raman spectroscopy provided in the above embodiment only uses the division of the above program modules as an example when performing identification. In practical applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the device is divided into different program modules to complete all or part of the processing described above. In addition, the identification device based on Raman spectroscopy provided in the above embodiment and the identification method embodiment based on Raman spectroscopy belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0240] Based on the hardware implementation of the above program modules, and in order to implement the method of the embodiment of the present application, the present application also provides an electronic device, such as Figure 7 As shown, the electronic device includes:
[0241] The first communication interface 1 is capable of exchanging information with other devices;
[0242] The first processor 2 is connected to the first communication interface 1 to implement information exchange with other devices, and is used to execute the method provided by one or more technical solutions in the above embodiments when running a computer program. The computer program is stored in the first memory 3.
[0243] It should be noted that the specific processing process of the first communication interface 1 can be understood by referring to the above method.
[0244] Of course, in actual application, the various components in the electronic device are coupled together through the bus system 4. It can be understood that the bus system 4 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 4 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, Figure 7 Various buses are labeled as bus system 4.
[0245] The first memory 3 in the embodiment of the present application is used to store various types of data to support operations in the electronic device. Examples of such data include: any computer program used to operate on the electronic device.
[0246] The method disclosed in the above embodiment of the present application can be applied to the first processor 2, or implemented by the first processor 2. The first processor 2 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the first processor 2. The above-mentioned first processor 2 may be a general-purpose processor, a DSP, or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 2 can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor may be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present application, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in the first memory 3. The first processor 2 reads the information in the first memory 3 and completes the steps of the above method in combination with its hardware.
[0247] In an exemplary embodiment, the electronic device may be implemented by one or more ASICs, DSPs, PLDs, CPLDs, FPGAs, general purpose processors, controllers, MCUs, Microprocessors, or other electronic components to perform the aforementioned methods.
[0248] It can be understood that the first memory 3 of the embodiment of the present application can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a ferromagnetic random access memory, a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), and direct RAMbus random access memory (DRRAM, Direct Rambus Random Access Memory).The memories described in the embodiments of the present application are intended to include, but are not limited to, these and any other suitable types of memories.
[0249] In an exemplary embodiment, the present application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, for example, an electronic device storing a computer program, and the computer program can be executed by the first processor 2 of the electronic device to complete the steps of the aforementioned method. The computer-readable storage medium can be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface storage, optical disk, or CD-ROM.
[0250] In an exemplary embodiment, the embodiment of the present application further provides a computer program product, including a computer program, and the computer program can be executed by the first processor 2 of the electronic device to complete the steps of any of the aforementioned methods.
[0251] It should be noted that: "first", "second", etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0252] The term "and / or" herein is only a description of the association relationship of associated objects, indicating that there may be three relationships. For example, A and / or B may indicate the existence of A alone, A and B at the same time, and B alone. In addition, the term "one or more" herein indicates any combination of at least two of any one or more of a plurality. For example, including at least one of A, B, and C may indicate including any one or more elements selected from the set consisting of A, B, and C.
[0253] In addition, the technical solutions described in the embodiments of the present application can be combined arbitrarily without conflict.
[0254] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application.
Claims
1. A model training method based on Raman spectroscopy, characterized in that: The method comprises: The first model is called to process a plurality of training samples respectively to obtain a first feature of each training sample; the training samples are characterized as Raman spectral data, and the first feature represents an implicit feature of the Raman spectral data; Calling the second model to process the multiple first feature sets respectively to obtain the second feature of each first feature set; each first feature set includes at least two first features selected from the first features of the multiple training samples; the second model includes one or more sub-networks for performing logical operations; the second model is used to constrain the first model through a first loss value and a second loss value; the first loss value represents the loss value of the implicit feature of the Raman spectral data; the second loss value represents the loss value of the classification result of the Raman spectral data; Calculating the first loss value and calculating the second loss value; Based on the calculated first loss value and the second loss value, the first model and the second model are updated.
2. The method according to claim 1, characterized in that The one or more sub-networks for performing logic operations include: a first sub-network and / or a second sub-network and / or a third sub-network; wherein, The first sub-network is used to perform an intersection operation on at least two first features in the first feature set, the second sub-network is used to perform a union operation on at least two first features in the first feature set, and the third sub-network is used to perform a reduction operation on at least two first features in the first feature set.
3. The method according to claim 1, characterized in that The calling of the second model to process the plurality of first feature sets to obtain the second feature of each first feature set includes: Each sub-network of the second model is called to process each first feature set to obtain one or more second features of each first feature set; each second feature of the first feature set corresponds to a sub-network of the second model.
4. The method according to claim 1, characterized in that: The calculating the first loss value comprises: Calling the first loss function corresponding to each sub-network of the second model, calculating the first features of the multiple training samples and the second features of the multiple first feature sets, and obtaining a third loss value corresponding to each sub-network; A setting operation is performed on all the calculated third loss values to obtain the first loss value.
5. The method according to claim 1, characterized in that The calculating the second loss value comprises: Calling a second loss function to calculate the first label and the first classification result of each training sample in the multiple training samples to obtain a fourth loss value; wherein the first label represents the category of the corresponding training sample; and the first classification result represents the classification result obtained by calling the third model to classify the first feature of the corresponding training sample; Calling a second loss function to calculate the second label of each first feature set in the multiple first feature sets and the second classification result to obtain a fifth loss value; wherein the second label represents the logical operation result of the target operation logic of each subnetwork of the second model on the first labels of at least two training samples corresponding to the corresponding first feature set; the second classification result represents the classification result obtained by calling the third model to classify the second feature of the corresponding first feature set; The fourth loss value and the fifth loss value are summed to obtain the second loss value.
6. The method according to claim 1, characterized in that The updating of the first model and the second model based on the calculated first loss value and the second loss value includes: Summing the first loss value and the second loss value to obtain a sixth loss value; Calling the sixth loss value to perform back-propagation processing on the second model to update the second model, and propagating the sixth loss value to the first model; The sixth loss value is called to perform back-propagation processing on the first model to update the first model.
7. A method for identifying based on Raman spectroscopy, characterized in that: The method comprises: The fourth model is called to process the Raman spectrum data of the sample to be identified to obtain a fifth feature; the fifth feature represents an implicit feature of the Raman spectrum data of the sample to be identified; Calling the fifth model to perform classification processing on the fifth feature to obtain a third classification result, wherein the third classification result represents the category of the Raman spectrum data of the sample to be identified; The fourth model represents the first model trained by the Raman spectroscopy-based model training method according to any one of claims 1 to 6.
8. A model training device based on Raman spectroscopy, characterized in that: include: A first calling unit, used for calling the first model to process the plurality of training samples respectively to obtain a first feature of each training sample; The training sample is characterized as Raman spectrum data, and the first feature represents an implicit feature of the Raman spectrum data; The second calling unit is used to call the second model to process the multiple first feature sets respectively to obtain the second feature of each first feature set; each of the first feature sets includes at least two first features selected from the first features of the multiple training samples; the second model includes one or more sub-networks for performing logical operations; the second model is used to constrain the first model through a first loss value and a second loss value; the first loss value represents the loss value of the implicit feature of the Raman spectral data; the second loss value represents the loss value of the classification result of the Raman spectral data; A calculation unit, used for calculating the first loss value and calculating the second loss value; An updating unit is used to update the first model and the second model based on the calculated first loss value and the second loss value.
9. A recognition device based on Raman spectroscopy, characterized in that: include: A third calling unit is used to call the fourth model to process the Raman spectrum data of the sample to be identified to obtain a fifth feature; The fifth feature represents an implicit feature of the Raman spectrum data of the sample to be identified; a classification unit, configured to call a fifth model to perform classification processing on the fifth feature to obtain a third classification result, wherein the third classification result represents a category of the Raman spectrum data of the sample to be identified; The fourth model represents the first model trained by the Raman spectroscopy-based model training method according to any one of claims 1 to 6.
10. An electronic device, characterized in that: include: a first processor and a first memory for storing a computer program executable on the processor, Wherein, when the first processor is used to run the computer program, it executes the steps of the method described in any one of claims 1 to 6, or is used to execute the steps of the method described in claim 7.
11. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the computer program implements the steps of the method according to any one of claims 1 to 6, or implements the steps of the method according to claim 7.
12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the computer program implements the steps of the method according to any one of claims 1 to 6, or implements the steps of the method according to claim 7.
Citation Information
Patent Citations
Tumor detection method based on Raman spectrum and convolutional neural network
CN112200770A
Model training and image recognition method and device, equipment and storage medium
CN114445681A