LIBS inversion method based on EMA-CNN and weighted loss function

By introducing EMA-CNN and a weighted loss function into the LIBS inversion method, the problems of low accuracy and high computational complexity in LIBS quantitative inversion are solved, and efficient collaborative prediction and stable inversion of multi-component content are achieved.

CN122024928BActive Publication Date: 2026-07-07SHANGHAI INSTITUTE OF TECHNICAL PHYSICS CHINESE ACADEMY OF SCIENCES

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHANGHAI INSTITUTE OF TECHNICAL PHYSICS CHINESE ACADEMY OF SCIENCES
Filing Date
2026-01-29
Publication Date
2026-07-07

AI Technical Summary

Technical Problem

Existing LIBS quantitative inversion methods suffer from low accuracy, low computational efficiency, and high computational complexity when dealing with complex nonlinear mapping relationships and the synergistic prediction of multi-component content.

Method used

We employ the LIBS inversion method based on EMA-CNN and a weighted loss function, introduce an efficient multi-scale attention mechanism and a weighted mean square error loss function, construct a deep convolutional neural network model, and optimize the training process and prediction performance.

Benefits of technology

It improves the accuracy and stability of LIBS spectral quantitative inversion, reduces computational complexity, and is suitable for multi-component synchronous inversion tasks in scenarios with large data volumes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122024928B_ABST
    Figure CN122024928B_ABST
Patent Text Reader

Abstract

The application discloses a LIBS inversion method based on EMA-CNN and a weighted loss function, and relates to deep learning and spectral analysis.A LIBS spectral inversion model is constructed based on a deep convolutional neural network (CNN), an efficient multi-scale attention mechanism (EMA) is introduced, a weighted mean square error loss function is designed, and multi-component content collaborative prediction is realized.Conventional deep learning methods adopt equal attention allocation for all spectral features, the EMA module of the application can effectively guide the model to focus more reasonable attention, and the extraction and learning efficiency of key features are significantly improved.The conventional loss function is prone to the problem of unbalanced loss components caused by the order of magnitude difference of each component content, and the loss function of the application can weight the corresponding loss components of each component to collaboratively improve the prediction accuracy of all components.The method has the advantages of accuracy, stability and high efficiency, and is suitable for LIBS multi-component synchronous inversion tasks in a large data volume scene.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the technical fields of deep learning and spectral analysis, and in particular to a LIBS inversion method based on EMA-CNN and a weighted loss function. This method constructs a LIBS spectral inversion model based on a deep convolutional neural network (CNN), innovatively introduces an efficient multi-scale attention mechanism (EMA), and designs a novel weighted mean square error loss function, enabling collaborative prediction of multi-component content. Background Technology

[0002] Laser-induced breakdown spectroscopy (LIBS) is an atomic emission spectrometry technique that uses a high-power pulsed laser to irradiate the sample surface, exciting plasma and capturing its emission spectrum using a spectrometer. The composition and content of the sample are then qualitatively analyzed and quantitatively determined based on the spectral morphology and intensity. Due to its superior long-range detection capabilities, ability to detect without sample pretreatment, ease of implementation, rapid response, ability to minimize sample damage, and simultaneous multi-element analysis, LIBS is widely used in industrial testing, environmental monitoring, biomedicine, and geological surveys. Its unique advantage of long-range detection has made LIBS particularly prominent in deep space exploration, having been successfully applied in multiple Mars missions and holding promise for exploration of the Moon, Venus, Jupiter, and other extraterrestrial bodies.

[0003] Based on LIBS spectral data, chemometric models can be used to identify, classify, and quantitatively detect the chemical composition of substances such as soil and rocks on the Martian surface. Chemometric models can be broadly categorized into qualitative analysis and quantitative inversion. Qualitative analysis refers to analyzing the types of elements contained in the sample by using the wavelength positions of characteristic LIBS spectral lines; quantitative inversion refers to using the intensity values ​​of characteristic spectral lines to invert the content of corresponding elements or substances in the sample, establishing a mathematical relationship model between the two. Through LIBS spectral data inversion, the substances in the sample can be identified, classified, and their component content can be detected.

[0004] Due to the prevalent matrix effects in spectroscopic measurements and the potential for self-absorption in LIBS spectral detection, the relationship between the intensity of LIBS characteristic spectral lines and the concentration of the corresponding elements is often complex and nonlinear. Furthermore, in addition to the discrete characteristic spectral lines generated by electronic energy level transitions, LIBS spectra also include a continuous background spectrum produced by bremsstrahlung and recombination radiation, which adds further complexity to the characterization of characteristic spectral line intensities. Moreover, the LIBS detection process is highly sensitive to instrument performance, laser parameters (e.g., light intensity, pulse width, focal spot size), experimental environment (e.g., temperature, pressure, gas composition), detection distance, and sample physicochemical properties, leading to low stability and repeatability of LIBS spectra. These LIBS spectral characteristics pose a significant challenge to quantitative inversion models.

[0005] The development of data-driven LIBS quantitative inversion methods has evolved from simple linear calibration to machine learning and then to deep learning algorithms. Early LIBS quantitative inversion models were often based on traditional linear algorithms, such as calibration curve method and partial least squares algorithm (PLS). In 2013, Wiens et al. attempted to use partial least squares algorithm to construct quantitative inversion models for each major element oxide, train and optimize them separately, and used it as the official quantitative inversion scheme for ChemCam Mars LIBS spectra until 2017 [1].

[0006] With the development of machine learning, the powerful learning and generalization capabilities of artificial neural networks have been widely recognized. Advanced algorithms, such as backpropagation neural network (BPNN) and ensemble learning algorithms, have been used to construct LIBS quantitative inversion models, significantly enhancing the fitting ability of the nonlinear mapping relationship between LIBS spectral signal intensity and target element content. In 2022, a variety of machine learning algorithms were used for SuperCam Mars in-situ LIBS spectral quantitative inversion, including gradient boosting regression, random forest, elastic network, local elastic network, minimum absolute shrinkage and selection operator (LASSO), etc. [2]. Based on the performance of each machine learning algorithm on different major element oxide content prediction tasks, the SuperCam team selected the most suitable quantitative inversion scheme for each major element oxide.

[0007] To address the inherent linear fitting defects of early traditional classical algorithms and the serious dependence of conventional machine learning algorithms on manual feature engineering, researchers have gradually applied deep learning algorithms to LIBS quantitative inversion research. Deep learning models, represented by deep convolutional neural networks, deep belief networks, and Transformer models, have brought new breakthroughs to LIBS quantitative inversion performance through their powerful nonlinear mapping capabilities and end-to-end autonomous learning mechanisms. In 2020, Li et al. first applied deep convolutional neural networks to LIBS spectral quantitative inversion tasks and achieved overall performance superior to BPNN and PLS models, providing a new solution for LIBS quantitative analysis [3]. These models can directly extract key feature information from raw or simply preprocessed LIBS spectra and accurately establish high-dimensional complex functional relationships between them and element content, promoting the leap of LIBS quantitative inversion work towards intelligence.

[0008] The disadvantages of the three existing methods mentioned above are as follows:

[0009] For the LIBS quantitative inversion method based on simple linear calibration in reference [1], it is required that the intensity of the spectral signal and the content of the target element have a linear relationship within a certain range. However, due to the influence of various key factors such as matrix effect, self-absorption effect, and experimental conditions, the intensity of the LIBS spectral signal and the content of the target element usually exhibit a complex nonlinear mapping relationship, which greatly limits the accuracy and universality of the quantitative inversion model.

[0010] The LIBS quantitative inversion method based on machine learning in reference [2] lacks end-to-end learning capability for the original spectral signal. Its model performance limit is not only determined by the structure of the algorithm itself, but also heavily depends on the quality of feature engineering and prior knowledge. Researchers need to manually complete the selection of spectral features, dimensionality reduction and construction of input feature vectors, which requires a large amount of manpower and experience.

[0011] For the LIBS quantitative inversion method based on deep convolutional neural networks in reference [3], although it has shown significant advantages over simple linear calibration methods and machine learning algorithms, its in-depth application in the LIBS field is still constrained by the model's own architecture and training mechanism: 1. Conventional deep convolutional neural network structures allocate equal attention to the numerous feature maps extracted, which makes key LIBS spectral features and invalid noise interference features equally processed in the back-end layer, reducing the model's perception and processing depth of key features, thereby weakening the model's accuracy. At the same time, because all feature maps are calculated indiscriminately, unnecessary computational burden is brought about, thereby weakening the model's computational efficiency; 2. When the model is used for multi-component content collaborative prediction, there are significant differences in the convergence speed and loss function magnitude of different output tasks (e.g., quantitative inversion of components with different content distribution ranges). Conventional loss functions simply sum the loss components of each output task, which can easily lead to the model optimization process being dominated by one or a few tasks, thereby sacrificing the model's performance on other tasks and causing an imbalance in the overall prediction accuracy.

[0012] References

[0013] [1] Wiens RC, Maurice S, Lasue J, et al. Pre-flight calibration and initial data processing for the ChemCam laser-induced breakdown spectroscopy instrument on the Mars Science Laboratory rover[J]. Spectrochimica Acta PartB: Atomic Spectroscopy, 2013, 82: 1-27.

[0014] [2] Anderson RB, Forni O, Cousin A, et al. Post-landing majorelement quantification using SuperCam laser induced breakdown spectroscopy[J]. Spectrochimica Acta Part B: Atomic Spectroscopy, 2022, 188: 106347.

[0015] [3] Li LN, Liu XF, Xu WM, et al. A laser-induced breakdownspectroscopy multi-component quantitative analytical method based on a deepconvolutional neural network[J]. Spectrochimica Acta Part B: AtomicSpectroscopy, 2020, 169: 105850. Summary of the Invention

[0016] To address the aforementioned background and shortcomings of existing technologies, this invention proposes a LIBS inversion method based on EMA-CNN and a weighted loss function. The EMA module effectively guides the model to focus its attention more effectively, significantly improving the extraction and learning efficiency of key features. The novel weighted loss function weights the loss components for each element, synergistically enhancing the prediction accuracy of all components. This method offers advantages such as accuracy, stability, and efficiency, making it suitable for LIBS multi-component synchronous inversion tasks in scenarios with large datasets.

[0017] To achieve the above objectives, the technical solution adopted in this invention is: a LIBS inversion method based on EMA-CNN and a weighted loss function, characterized in that a LIBS spectral inversion model is constructed based on a deep convolutional neural network (CNN), an efficient multi-scale attention mechanism (EMA) is introduced to form an EMA-CNN model, and a weighted mean square error loss function is designed to achieve accurate collaborative prediction of the content of multiple components.

[0018] Furthermore, the LIBS inversion method based on EMA-CNN and weighted loss function includes the following steps:

[0019] S1. Preliminary preparation: Prepare standard samples for collecting laser-induced breakdown spectroscopy (LIBS), record the name and composition information of each sample, create a summary table of composition contents covering all N samples, determine the true content of L target components in each sample based on the quantitative task, and construct a target component content label vector.

[0020] S2. Using a LIBS spectral detection device, at a fixed detection distance, the LIBS spectra of all the samples were collected, and the experimentally collected LIBS spectra were defined as the original spectral dataset.

[0021] S3. Preprocess the LIBS spectra in the original spectral dataset. The preprocessing steps usually include dark background removal, wavelength calibration, radiometric calibration, invalid pixel removal, and channel stitching. The LIBS spectra after preprocessing are defined as the LIBS spectral dataset.

[0022] S4. Sort all samples according to the content of a target component from largest to smallest, and use a systematic sampling strategy to divide the LIBS spectral dataset into P LIBS spectral data subsets, defined as Fold 1 ~ P respectively, to ensure that the number of samples in each LIBS spectral data subset is basically the same and that the data are in the same distribution condition.

[0023] S5. Construct a deep convolutional neural network model that integrates EMA modules, defined as the EMA-CNN model. The EMA-CNN model structure is designed as follows: Layer 1 is a batch normalization layer; Layers 2, 4, 6, 7, and 9 are convolutional layers with ReLU activation function; Layers 3, 5, and 8 are pooling layers with max pooling strategy; Layer 10 inserts an EMA module; Layer 11 is a flattened layer; Layer 12 is a fully connected layer with ReLU activation function; Layer 13 is a fully connected layer.

[0024] S6. Design a weighted mean square error loss function Weighted_MSELoss. Calculate the weights of the corresponding loss components based on the content distribution range of each substance. During the training of the EMA-CNN model, minimize the Weighted_MSELoss value as the model optimization objective.

[0025] S7. Use the K-fold cross-validation strategy to train and validate the EMA-CNN model on the LIBS spectral data subsets Fold1 to Fold P-1, and optimize the training hyperparameters of the EMA-CNN model.

[0026] S8. Input the unknown LIBS spectra of the test set into the trained and validated EMA-CNN model to predict the content of the target substance in the corresponding sample, and evaluate the quantitative inversion performance of the EMA-CNN model from multiple perspectives based on two sets of evaluation indicators: root mean square error of prediction and coefficient of determination.

[0027] Furthermore, in step S1, from the total list of substance content of all N known component samples, the true content of L target substances in each sample is selected. Then, the component content label vector C of each sample is represented as a 1×L matrix, and the component label vector C of sample i is... i for

[0028]

[0029] Where c i1c represents the content of the first component in sample i, expressed as a mass percentage (wt.%), where 0 ≤ c i1 ≤ 100 wt.%; c i2 The meanings of other component content label vectors can be deduced similarly.

[0030] Furthermore, in step S2, when the LIBS spectral detection device is used for spectral acquisition, all key device parameters are set to fixed values, including the number of spectral acquisitions, integration time, delay time, and focusing position; relevant environmental parameters are monitored in real time and maintained in a stable state, including detection distance, ambient temperature, air pressure, and gas composition.

[0031] Further, in step S3, the dark background removal operation refers to subtracting the dark background spectrum from the original LIBS spectrum to obtain the effective spectrum, where the dark background spectrum refers to the spectrum of the spectrometer response without laser excitation; wavelength calibration refers to converting the spectrometer pixel number into wavelength value using a multivariate quadratic fitting function; radiometric calibration refers to converting the spectrometer pixel response into spectral radiance using a multivariate linear fitting function; invalid pixel screening refers to removing the pixel response values ​​of each band of the LIBS spectrum that are outside the wavelength range; and channel splicing refers to splicing the multiple bands of LIBS spectrum that have been screened out of invalid pixels into a single line in wavelength order.

[0032] Furthermore, in step S4, the LIBS spectral dataset partitioning process adopts a systematic sampling scheme. All samples in the LIBS spectral dataset are sorted according to the content of a target component from highest to lowest. The first P samples are taken as the starting point of P subsets, and one sample is taken every P samples and placed into the corresponding subset. This ensures that all subsets meet the data distribution condition, so that the LIBS spectral dataset is divided into P subsets. At the same time, the LIBS spectral dataset partitioning scheme strictly follows the highest principle of "sample dimensional independence", that is, all LIBS spectra of any sample are assigned to only one subset, ensuring absolute isolation between subsets.

[0033] Furthermore, in step S5, the EMA module adopts a parallel dual-branch structure, namely a 1×1 convolutional kernel branch for extracting cross-channel relationships and a 1×3 convolutional kernel branch for capturing local spatial structural context information. The outputs of the two branches are first subjected to global average pooling and softmax normalization operations, respectively, to obtain their respective channel encoding vectors and basic attention maps. Then, the basic attention map of each branch and the channel encoding vector of the other branch are multiplied by a matrix to generate two attention maps enhanced by cross-scale spatial-channel information interaction. Finally, the two are added together and calculated by the Sigmoid activation function to obtain the final attention map based on multi-scale feature information perception. Then, the attention map and the input feature map sequence are multiplied element-wise and output to the next layer of the network. Here, "channel" refers to the dimension name of the feature map sequence, and each channel represents an independent feature map. The EMA-CNN model structure is adjusted and optimized according to the specific characteristics of the LIBS spectral dataset and task requirements.

[0034] Furthermore, in step S6, the weighting design scheme of Weighted_MSELoss comprehensively considers the content distribution range of each target component and assigns a specific weight coefficient w to the corresponding loss component. l The loss component refers to the mean squared error between the predicted and true values ​​of a target component content. The weighted_MSELoss calculation method is as follows: Let R be the component content label vector of a sample, and let M LIBS spectra be collected from the sample by the LIBS spectral detection device. Let P be the component content prediction vector output by the EMA-CNN model for the j-th LIBS spectrum of the sample. j Vectors R and P j Each has L values, where the l-th value is denoted as R. l and P jl The formula for calculating Weighted_MSELoss is:

[0035]

[0036] Weighting coefficient w l The initial range is determined based on the ratio between the loss components of the target component, and the final value is determined by manual selection.

[0037] Further, in step S7, the EMA-CNN model training employs a K-fold cross-validation strategy, and the training iterative optimizer uses the AdamW algorithm with corrected weight decay, with a loss function of Weighted_MSELoss. First, one subset of the LIBS spectral data (Fold1 to Fold P-1) is selected sequentially as the validation set to monitor the performance changes of the EMA-CNN model during training in real time. The remaining P-2 subsets are used as the training set to train the EMA-CNN model. After P-1 iterations, the performance results of the EMA-CNN model on all subsets are obtained. For the training process, the input is the LIBS spectral samples of the training set and the component content label vector corresponding to each LIBS spectral sample. The output is the predicted target component content value output by the EMA-CNN model for each training set LIBS spectral sample, with the objective of minimizing the Weighted_MSELoss value between the predicted target component content value and the true value. The AdamW algorithm is used to optimize the weight parameters of the EMA-CNN model. For the validation process, the input is the LIBS spectral samples of the validation set. The output is the predicted content of the target component output by the EMA-CNN model for the validation set LIBS spectral samples. Subsequently, based on the performance of the EMA-CNN model on the validation set, the relevant training hyperparameters are optimized, including batch size, initial learning rate, number of iterations, and print interval. In the process of optimizing the training hyperparameters, a grid search algorithm is used to find the optimal combination of the above four training hyperparameters. That is, all permutations and combinations are performed in the preset multidimensional search space, and an exhaustive search is performed. A complete model training and validation process is started independently for each set of training hyperparameter combinations. Finally, the Weighted_MSELoss value on the validation set is used as the performance evaluation criterion, and the training hyperparameter combination that minimizes the Weighted_MSELoss value is selected as the optimal combination, thus completing the training of the EMA-CNN model.

[0038] Further, in step S8, all LIBS spectra in the LIBS spectral data subset Fold P are input into the trained and validated EMA-CNN model to obtain the predicted content of the target substance components of the corresponding samples; the LIBS spectral data subset Fold P is defined as the test set, and the LIBS spectra in this test set are not involved in the training-validation process of the EMA-CNN model; the root mean square error of prediction (RMSEP) and the coefficient of determination (R²) are used. 2 Two sets of evaluation metrics are used to quantitatively analyze the quantitative inversion performance of the EMA-CNN model on the test set from two complementary perspectives: prediction accuracy and goodness of fit. This objectively reflects the performance of the EMA-CNN model in practical applications.

[0039] After completing the construction of the EMA-CNN model and designing the weighted mean square error loss function Weighted_MSELoss to train and optimize the EMA-CNN model, the EMA-CNN model can be used to perform multi-component synchronous inversion of unknown LIBS spectra.

[0040] In view of the above technical features, the advantages of the present invention compared with the prior art are:

[0041] 1. Compared with LIBS quantitative inversion methods based on simple linear calibration, this invention is more suitable for analyzing the complex nonlinear relationship between LIBS spectra and the content of material components. At the same time, it does not require manual searching for the characteristic spectral lines of the target elements, thus significantly improving the quantitative inversion performance and reducing labor costs and empirical errors.

[0042] 2. Compared with the LIBS quantitative inversion method based on machine learning, this invention greatly reduces the number of model parameters, computational complexity and resource consumption through convolution-pooling structure and weight sharing mechanism; at the same time, it eliminates the need for manual preprocessing of spectra, selection of spectral features, dimensionality reduction and construction of input feature vectors, which greatly reduces labor costs and empirical errors.

[0043] 3. Compared with existing LIBS quantitative inversion methods based on deep CNN, this invention fully considers the differences in the impact of key features and invalid noise interference features on the learning and inference of the model's back-end layers, as well as the order-of-magnitude differences in the loss components of each component with different content distribution ranges. By introducing an efficient multi-scale attention mechanism and designing a novel weighted mean square error loss function, the model's ability to focus on key features is improved, ensuring the balance in the collaborative prediction process of multi-component content.

[0044] In summary, this invention constructs a LIBS spectral inversion model based on deep CNNs, innovatively introduces an efficient multi-scale attention mechanism, and designs a novel weighted mean square error loss function, enabling accurate collaborative prediction of multi-component content. The EMA-CNN method proposed in this invention has the advantages of accuracy, stability, and efficiency, and is suitable for LIBS multi-component synchronous inversion tasks in scenarios with large amounts of data.

[0045] Currently, no LIBS quantitative analysis technique combining attention mechanism and weighted mean square error loss function has been reported. Therefore, this invention is of great value to the field of laser spectroscopy analysis. Attached Figure Description

[0046] Figure 1 This is a schematic diagram of the overall process of a LIBS inversion method based on EMA-CNN and a weighted loss function in Specific Implementation 1.

[0047] Figure 2This is a violin plot showing the distribution of oxide contents of the eight major elements in all samples of the LIBS spectral dataset in Specific Example 1.

[0048] Figure 3 This is a schematic diagram of the EMA-CNN model in specific embodiment 1.

[0049] Figure 4 The average RMSEP values ​​of the EMA-CNN model and the seven control models in Specific Implementation 1 on the independent test set.

[0050] Figure 5 The average R-values ​​of the EMA-CNN model and the seven control models in Specific Implementation 1 on the independent test set are... 2 value. Detailed Implementation

[0051] The present invention will be further described below with reference to specific embodiments. It should be understood that these embodiments are for illustrative purposes only and are not intended to limit the scope of the invention. Furthermore, it should be understood that after reading the teachings of this invention, those skilled in the art can make various alterations or modifications to the invention, and these equivalent forms also fall within the scope defined by the appended claims.

[0052] See Figures 1 to 5 Specific embodiment 1: This embodiment 1 provides a LIBS inversion method based on EMA-CNN and weighted loss function. The feature is that a LIBS spectral inversion model is constructed based on a deep convolutional neural network (CNN), an efficient multi-scale attention mechanism (EMA) is introduced to form an EMA-CNN model, and a weighted mean square error loss function is designed to achieve accurate collaborative prediction of the content of multiple components.

[0053] The LIBS inversion method based on EMA-CNN and weighted loss function includes the following steps:

[0054] S1. Preliminary Preparation: Prepare standard samples for laser-induced breakdown spectroscopy (LIBS) acquisition, record the name and composition information of each sample, create a summary table of composition contents covering all N samples, determine the true content of L target components for each sample based on the quantitative task, and construct a target component content label vector; In step S1, from the summary table of composition contents of all N samples with known components, select the true content of L target components for each sample. Then, the component content label vector C of each sample is represented as a 1×L matrix, and the component label vector C of sample i is... i for

[0055]

[0056] Where c i1c represents the content of the first component in sample i, expressed as a mass percentage (wt.%), where 0 ≤ c i1 ≤ 100 wt.%; c i2 The meanings of other component content label vectors can be deduced similarly.

[0057] In this Example 1, a variety of representative geological samples and mixed samples were selected based on the target mission system. A total of 643 standard samples (N = 643) were used for laser-induced breakdown spectroscopy (LIBS) collection, including national standard materials, common Martian rocks / minerals, and mixed samples of various hydrous minerals. All samples were processed into powder with a particle size ≤ 100 μm. Subsequently, the sample powder was pressed into cake-shaped standard samples with a diameter of 40 mm and a thickness of 6 mm using a tablet press for subsequent LIBS detection. The tablet press pressure was 238 MPa, and the pressing time was 2 min.

[0058] The prepared pie-shaped standard samples were then placed in sample bags and labeled with sample information, recording the name and composition of each sample. Subsequently, a summary table of the composition of all 643 samples was created. Based on the quantitative task, the true content of the target component in each sample was determined, and a target component content label vector was constructed. In this example, eight major element oxides were used as the target components for the quantitative task, including SiO2, TiO2, Al2O3, and FeO. T MgO, CaO, Na2O, K2O. Specifically, from the total list of the content of substances in all 643 samples with known components, the true content of the eight target substances in each sample is selected. The component content label vector C for each sample is then represented as a 1×8 matrix. The violin plot showing the distribution of the target substance content in the 643 samples is shown below. Figure 2 As shown. Taking a clay sample as an example, its target material component content label vector C is...

[0059]

[0060] The target material composition label vectors indicate that the contents of the oxides of the eight major elements in the clay sample are 49.98 wt.%, 0.70 wt.%, 26.27 wt.%, 9.50 wt.%, 0.46 wt.%, 0.13 wt.%, 0.06 wt.%, and 0.79 wt.%, respectively. The meanings of the label vectors for other components can be deduced similarly.

[0061] S2. Using a LIBS spectral detection device, LIBS spectra of all samples are acquired at a fixed detection distance. The experimentally acquired LIBS spectra are defined as the raw spectral dataset. In step S2, when acquiring spectra using the LIBS spectral detection device, all key device parameters are set to fixed values, including the number of spectral acquisitions, integration time, delay time, and focusing position. Relevant environmental parameters are monitored in real time and maintained in a stable state, including detection distance, ambient temperature, air pressure, and gas composition, to ensure that each LIBS spectral acquisition process is carried out under highly consistent experimental conditions, thus guaranteeing the basic reliability of subsequent quantitative analysis.

[0062] In this embodiment 1, the LIBS spectral detection device is a ground backup prototype of the Mars Surface Composition Detector (MarSCoDe) payload. The laser single-pulse energy is approximately 9 mJ, the laser wavelength is 1064 nm, the delay time is 0 μs, and the integration time is 1 ms. The detection distance is set to 2 m, and the experimental environment is set to simulate the Martian environment, namely: the cabin is filled with a mixture of 95.73% CO2, 2.67% N2, and 1.60% Ar, the gas pressure is controlled at 810 ± 1 Pa, and the temperature is set to laboratory room temperature of 22°C. Under the above experimental conditions, 30 LIBS spectra (excluding dark background spectra) were continuously collected for each sample, and 15 LIBS spectra were selected as spectra to be processed, totaling 9645 spectra. These spectra constitute the original spectral dataset.

[0063] S3. Preprocess the LIBS spectra in the original spectral dataset. Preprocessing typically includes dark background removal, wavelength calibration, radiometric calibration, invalid pixel removal, and channel stitching. The preprocessed LIBS spectra are defined as the LIBS spectral dataset. In step S3, dark background removal refers to subtracting the dark background spectrum from the original LIBS spectrum to obtain the effective spectrum. The dark background spectrum refers to the spectrum of the spectrometer response without laser excitation. Wavelength calibration involves converting the spectrometer pixel index into wavelength values ​​using a multivariate quadratic fitting function. Radiometric calibration involves converting the spectrometer pixel response into spectral radiance using a multivariate linear fitting function. Invalid pixel removal involves removing pixel response values ​​from each band of the LIBS spectrum that exceed the wavelength range. Channel stitching involves stitching multiple bands of LIBS spectra that have undergone invalid pixel removal into a single channel in wavelength order.

[0064] In this embodiment 1, the MarSCoDe payload ground backup prototype used for LIBS detection includes three spectral channels, each with 1800 pixels, totaling 5400 pixels. In the dark background removal step, the original LIBS spectrum is subtracted from the dark background spectrum acquired without LIBS signal excitation. In the wavelength calibration step, the pixel index of each LIBS spectrum is converted into a wavelength value using a set wavelength calibration function. In the radiometric calibration step, the pixel response value of each LIBS spectrum is converted into spectral radiance using a set radiometric calibration function. In the invalid pixel removal step, 300, 301, and 292 invalid pixel data points are removed from the three channels, respectively. In the channel stitching step, the remaining valid pixel data points from the three channels are arranged and stitched in wavelength order. Each LIBS spectrum contains 4507 data points, which can be represented as a 4507×1 matrix.

[0065] S4. Sort all samples according to the content of a target component from highest to lowest, and use a systematic sampling strategy to divide the LIBS spectral dataset into P LIBS spectral data subsets, defined as Fold 1 to P, to ensure that the number of samples in each LIBS spectral data subset is basically the same and satisfies the condition of identical data distribution. In step S4, the LIBS spectral dataset partitioning process adopts a systematic sampling scheme, sorting all samples in the LIBS spectral dataset according to the content of a target component from highest to lowest, and taking the first P samples as the starting point of the P subsets. Every P samples are then taken and placed into the corresponding subset, ensuring that all subsets satisfy the condition of identical data distribution, so that the LIBS spectral dataset is divided into P subsets. At the same time, the LIBS spectral dataset partitioning scheme strictly follows the highest principle of "sample dimensional independence", that is, all LIBS spectra of any sample are assigned to only one subset, ensuring absolute isolation between subsets.

[0066] In this embodiment 1, all samples in the LIBS spectral dataset are sorted according to their SiO2 content. A systematic sampling strategy is adopted, with the first 7 samples serving as the starting point for 7 subsets. Every 7 samples are then taken and placed into the corresponding subset. The number of samples in the 7 subsets are 92, 92, 92, 92, 92, 92, and 91, respectively, and are defined as Fold 1 to 7.

[0067] S5. Construct a deep convolutional neural network model that integrates the EMA module, defined as the EMA-CNN model. The EMA-CNN model structure is designed as follows: Layer 1 is a batch normalization layer; Layers 2, 4, 6, 7, and 9 are convolutional layers with ReLU activation function; Layers 3, 5, and 8 are pooling layers with max pooling strategy; Layer 10 inserts the EMA module; Layer 11 is a flattened layer; Layer 12 is a fully connected layer with ReLU activation function; Layer 13 is a fully connected layer. The EMA module adopts a parallel dual-branch structure, namely a 1×1 convolutional kernel branch for extracting cross-channel relationships and a 1×3 convolutional kernel branch for capturing local spatial structural context information. The outputs of the two branches are fused through a cross-spatial dimension interactive modeling scheme to generate a sense of multi-scale feature information. The attention map (i.e., the outputs of the two branches are first subjected to global average pooling and softmax normalization operations to obtain their respective channel encoding vectors and basic attention maps, then the basic attention map of each branch and the channel encoding vector of the other branch are matrix multiplied to generate two attention maps enhanced by cross-scale spatial-channel information interaction, and finally the two are added and calculated by the Sigmoid activation function to obtain the final attention map based on multi-scale feature information perception), then the attention map and the input feature map sequence are multiplied element-wise and output to the next layer of the network. Here, "channel" refers to the dimension name of the feature map sequence, and each channel represents an independent feature map; in step S5, the EMA-CNN model structure is adjusted and optimized according to the specific characteristics of the LIBS spectral dataset and the task requirements.

[0068] In this embodiment 1, a deep convolutional neural network model integrating the EMA module is constructed based on the PyTorch deep learning framework, defined as the EMA-CNN model. The structural diagram of the EMA-CNN model is shown below. Figure 3As shown. The specific calculation process of the EMA module is as follows: 1) Input the feature map sequence into the two branches of the EMA module in parallel. For the 1×1 convolution kernel branch, its output is subjected to global average pooling and softmax normalization operations to obtain the channel encoding vector Ch1 and the basic attention map At1. For the 1×3 convolution kernel branch, its output is subjected to the same operations to obtain Ch2 and At2; 2) Multiply Ch2 and At1 by matrix to obtain a cross-scale spatial-channel information interaction enhanced attention map CSAt1. Multiply Ch1 and At2 by matrix to obtain CSAt2. Use CSAt1+CSAt2 as the final multi-scale feature information perception attention map AtMap; 3) Multiply AtMap and the input feature map sequence element-wise and output. The EMA module achieves adaptive capture of the correlation between features at different scales and the content of target material components through the above operations. Based on the correlation, it selectively increases the attention value of key features and reduces the attention value of invalid noise interference features during model optimization. This results in the value of key features being amplified after element-wise multiplication of the input feature map sequence and the attention map, while the value of invalid noise interference features is suppressed to an extremely low level. This effectively guides the model to concentrate computational resources on key features, significantly improving the extraction and learning efficiency of key features.

[0069] S6. Design a weighted mean squared error loss function, Weighted_MSELoss. Calculate the weights of the corresponding loss components based on the content distribution range of each substance. During the EMA-CNN model training process, minimizing the Weighted_MSELoss value is used as the model optimization objective. In step S6, the weight design scheme of Weighted_MSELoss comprehensively considers the content distribution range of each target component and assigns specific weight coefficients w to the corresponding loss components. l The loss component refers to the mean squared error between the predicted and true values ​​of a target component content. The weighted_MSELoss calculation method is as follows: Let R be the component content label vector of a sample, and let M LIBS spectra be collected from the sample by the LIBS spectral detection device. Let P be the component content prediction vector output by the EMA-CNN model for the j-th LIBS spectrum of the sample. j Vectors R and P j Each has L values, where the l-th value is denoted as R. l and P jl The formula for calculating Weighted_MSELoss is:

[0070]

[0071] In this embodiment 1, the calculation method of Weighted_MSELoss is as follows: the component content label vector of a sample is R, the LIBS spectral detection device collects a total of 15 LIBS spectra of the sample, and the component content prediction vector output by the EMA-CNN model for the j-th LIBS spectrum of the sample is Pj. Vectors R and Pj are used to predict the component content. j Each has 8 values, where the l-th value is denoted as R. l and P jl The formula for calculating Weighted_MSELoss is:

[0072]

[0073] Weighting coefficient w l The initial range is determined based on the ratio between the loss components of the target component, and the final value is determined by manual selection.

[0074] S7. Train and validate the EMA-CNN model on the LIBS spectral data subsets Fold1 to Fold P-1 using a K-fold cross-validation strategy, and optimize the training hyperparameters of the EMA-CNN model. In step S7, the EMA-CNN model is trained using a K-fold cross-validation strategy, and the training iterative optimizer uses the AdamW algorithm with corrected weight decay, with the loss function being Weighted_MSELoss. First, select the LIBS spectral data subsets Fold1 to Fold P-1 in sequence. One subset of P-1 is used as the validation set to monitor the performance changes of the EMA-CNN model during training in real time. The remaining P-2 subsets are used as the training set to train the EMA-CNN model. After P-1 rounds of iteration, the performance results of the EMA-CNN model on all subsets are obtained. For the training process, the input is the LIBS spectral samples of the training set samples and the component content label vector corresponding to each LIBS spectral sample. The output is the target component content prediction value output by the EMA-CNN model for each training set LIBS spectral sample. The goal is to minimize the Weighted_MSELoss value between the target component content prediction value and the true value. The AdamW algorithm is used to optimize the weight parameters of the EMA-CNN model. For the validation process, the input is the LIBS spectral samples of the validation set samples. The output is the predicted content of the target component output by the EMA-CNN model for the validation set LIBS spectral samples. Subsequently, based on the performance of the EMA-CNN model on the validation set, the relevant training hyperparameters are optimized, including batch size, initial learning rate, number of iterations, and print interval. In the process of optimizing the training hyperparameters, a grid search algorithm is used to find the optimal combination of the above four training hyperparameters. That is, all permutations and combinations are performed in the preset multidimensional search space, and an exhaustive search is performed. A complete model training and validation process is started independently for each set of training hyperparameter combinations. Finally, the Weighted_MSELoss value on the validation set is used as the performance evaluation criterion, and the training hyperparameter combination that minimizes the Weighted_MSELoss value is selected as the optimal combination, thus completing the training of the EMA-CNN model.

[0075] In this embodiment 1, a 6-fold cross-validation scheme is used to train the EMA-CNN model. Specifically, one subset from Fold 1 to Fold 6 is selected sequentially as the validation set for evaluating the model, while the remaining five subsets are used as the training set. After six rounds of iteration, each subset serves as the validation set, yielding the model's performance. The final model performance metric is obtained by averaging the performance metrics obtained from the six rounds, aiming to reduce bias caused by different data partitions and thus more robustly analyze the model's performance on the overall data. The training iterative optimizer uses the AdamW algorithm with corrected weight decay, and the loss function is Weighted_MSELoss. In each training-validation round, the training set consists of 460 LIBS spectra from the five subsets, totaling 6900 spectra; the validation set consists of 92 LIBS spectra from the remaining subset, totaling 1380 spectra.

[0076] During the training of the EMA-CNN model, we employ a grid search algorithm to find the optimal combination of training hyperparameters. Specifically, for the four key training hyperparameters—batch size, initial learning rate, number of iterations, and print interval—we perform a full permutation and exhaustive search within a predefined multidimensional search space, as shown in Table 1. For each hyperparameter combination, we independently initiate a complete model training and validation process. Finally, using the average Weighted_MSELoss value on the validation set as the performance evaluation criterion, we select the training hyperparameter combination that minimizes the Weighted_MSELoss value as the optimal combination, thus accurately identifying the EMA-CNN model with the best quantitative inversion performance.

[0077] Table 1 Search space of hyperparameters for training EMA-CNN model

[0078] Batch size Initial learning rate Number of iterations Printing interval Maximum value 1024 <![CDATA[1×10 -5 ]]> 1501 1 Minimum value 128 <![CDATA[9×10 -4 ]]> 301 10 Sampling interval 128 <![CDATA[5×10 -5 ]]> 100 1

[0079] S8. Input the unknown LIBS spectra from the test set into the trained and validated EMA-CNN model to predict the content of the target substance in the corresponding sample, and calculate the prediction based on the root mean square error (RMSEP) and coefficient of determination (R²). 2 Two sets of evaluation metrics were used to comprehensively assess the quantitative inversion performance of the EMA-CNN model. In step S8, all LIBS spectra in the LIBS spectral data subset Fold P were input into the trained and validated EMA-CNN model to obtain the predicted content of the target substance components of the corresponding samples. The LIBS spectral data subset Fold P was defined as the test set, and the LIBS spectra in this test set were not involved in the training-validation process of the EMA-CNN model. RMSEP and R... 2Two sets of evaluation metrics are used to quantitatively analyze the quantitative inversion performance of the EMA-CNN model on the test set from two complementary perspectives: prediction accuracy and goodness of fit. These metrics objectively reflect the performance of the EMA-CNN model in quantitative inversion of unknown LIBS spectra in practical applications. A lower RMSEP value indicates a smaller overall absolute deviation between the model's predicted values ​​and the actual component content values, and higher prediction accuracy. 2 The higher the value, the stronger the linear correlation between the model's predicted value and the actual content value of the component, and the higher the consistency trend across the entire content range.

[0080] In this Example 1, to further objectively evaluate the performance advantages of the EMA-CNN model, we additionally selected seven mainstream LIBS quantitative inversion schemes as a control group, covering deep learning (classic convolutional neural network CNN), machine learning (backpropagation neural network BPNN, elastic network Elastic Net), ensemble learning (gradient boosting regression algorithm GBR, natural gradient boosting regression algorithm NGBoost), and traditional linear fitting methods (partial least squares regression algorithms PLS1, PLS2). Through multi-dimensional comparative analysis, we comprehensively evaluated the accuracy, stability, and generalization ability of the EMA-CNN model on the LIBS spectral quantitative inversion task, clarifying the effectiveness and significance of its performance improvement.

[0081] The seven control models are:

[0082] 1) CNN comparison model: The quantitative inversion model of CNN proposed in reference [3] was constructed and trained in the PyTorch framework. The model structure consists of a combination of batch normalization layer, convolutional layer, pooling layer, flattening layer, random deactivation layer and fully connected layer, and is trained using the Adam optimizer algorithm.

[0083] 2) BPNN comparison model: It includes one batch normalization layer and two fully connected layers. The number of neurons in the fully connected layers are 1024 and 8 respectively. It is trained using the Adam optimizer algorithm and the relevant work is also completed in the PyTorch framework.

[0084] 3) GBR and Elastic Net control models: built using the Scikit-learn package. For the GBR control model, after optimization, the number of decision trees was determined to be 100, the learning rate to be 0.1, the maximum depth of a single decision tree to be 3, and the remaining parameters were set to default values. For the Elastic Net control model, the α parameter was set to 0.123 × 10⁻⁶. -5 The L1 ratio is 0.99.

[0085] 4) NGBoost control model: Based on the ngboost package, the number of decision trees was determined to be 100 after optimization, and the other parameters were taken as default values.

[0086] 5) PLS1 and PLS2 comparison models: For the partial least squares regression algorithm, we constructed PLS1 and PLS2 comparison models based on Matlab R2021b. The principles of these two comparison models are basically the same. The difference is that the PLS1 comparison model fits the oxide content of a single major element in sequence, while the PLS2 comparison model fits the oxide content of 8 major elements at once.

[0087] The root mean square error (RMSEP) of predictions is a commonly used metric to measure the deviation between model predictions and actual values. It effectively reflects the prediction accuracy and stability of the LIBS quantitative inversion model on the test set data, and is expressed as a percentage of mass (wt.%). A smaller RMSEP value indicates higher prediction accuracy. The formula for calculating the RMSEP value for a specific major element oxide is as follows:

[0088]

[0089] in, This represents the true value of the target major element oxide content of the sample corresponding to the i-th LIBS spectrum. The representative model calculates the predicted content of the corresponding target major element oxides for the i-th LIBS spectrum. To test the number of LIBS spectral lines.

[0090] Coefficient of determination R 2 R is a metric used in statistics to measure the goodness of fit of a regression model to observed data. 2 The value of is between 0 and 1. The closer the value is to 1, the better the model's fit and the stronger its quantitative inversion performance; conversely, the smaller the value, the worse the model's fit. The calculation formula is as follows:

[0091]

[0092] in, This represents the average true content of the target major element oxides corresponding to all tested LIBS spectra.

[0093] Figure 4 The average RMSEP of the EMA-CNN model and seven control models on independent test sets is presented. The results show that the EMA-CNN model significantly outperforms the other control models in prediction accuracy for most major element oxides, particularly SiO2, TiO2, Al2O3, and FeO. TFor SiO2, the EMA-CNN model showed an average RMSEP reduction of at least 0.15 wt.% (CNN control model) and a maximum reduction of 4.27 wt.% (PLS2 control model) compared to other control models, with an average reduction of 2.06 wt.%. This exceeds the average RMSEP value (5.06 wt.%) predicted by the EMA-CNN model for SiO2 content by 40%. This statistically significant reduction in average RMSEP value demonstrates the substantial improvement in quantitative inversion accuracy of the EMA-CNN model, and fully reflects its superior performance compared to other control models for major element oxides, which are difficult to quantify. However, for MgO, CaO, and K2O, although the relative advantage of the EMA-CNN model is not significant, it still maintains strong competitiveness. Only a few control models showed similar or even slightly better predictive performance for these three major element oxides. For example, for MgO, the average RMSEP value of the EMA-CNN model was only 0.34 wt.% higher than the optimal GBR control model; for CaO, the EMA-CNN model was only 0.27 wt.% higher than the optimal PLS2 control model; and for K2O, the EMA-CNN model was only 0.09 wt.% higher than the optimal GBR control model, reflecting that other control models still have unique advantages in quantitative inversion tasks of a few major element oxides. Furthermore, from... Figure 4 As can be seen from the error bars of the RMSEP values ​​of each model, the EMA-CNN model has a significantly smaller fluctuation range in the evaluation results at different folds than most control models, and its error bars are generally shorter, indicating that the EMA-CNN model is also at an advanced level in terms of prediction stability, that is, the EMA-CNN model has better prediction stability.

[0094] Figure 5 Furthermore, the average R-values ​​of the EMA-CNN model and seven control models on the independent test set are demonstrated. 2 Comparing the results, the average R for each model 2 The study revealed the overall prediction bias of the EMA-CNN model across the full content range of major element oxides. The results showed that the EMA-CNN model exhibited biases in predicting the content of SiO2, TiO2, Al2O3, and FeO. T The EMA-CNN model exhibits excellent fitting performance across the entire content range of Na2O, only showing similar performance to the GBR control model for MgO and K2O, and similar performance to the PLS2 control model for CaO. Specifically, for SiO2, the average R-value of the EMA-CNN model is [missing information]. 2 The result was 0.92, which is at least an improvement of 0.01 (CNN control model) and at most 0.18 (PLS2 control model) compared to other control models, with an average improvement of 0.08; for MgO, the average R-value of the EMA-CNN model is... 2The result was 0.93, only 0.02 lower than the best GBR control model; for CaO, the average R-value of the EMA-CNN model was... 2 The result was 0.95, slightly lower than the optimal GBR control model, but the difference was only 0.01; for K2O, the average R of the EMA-CNN model was... 2 The result was 0.84, which was 0.03 lower than the optimal GBR control model, but still within an acceptable range. This result corroborates the results of the aforementioned RMSEP analysis. Furthermore, from... Figure 5 Each model R 2 The error bar distribution shows that the EMA-CNN model exhibits significantly smaller fluctuations in results across different folds compared to most control models. Its error bars are generally shorter and more concentrated, further demonstrating the stability of the EMA-CNN model. Notably, as a complex nonlinear modeling method based on deep learning, the EMA-CNN model's stability is comparable to traditional linear fitting methods (PLS1, PLS2), proving that while retaining the powerful learning capabilities of deep learning, it effectively overcomes the performance fluctuations often caused by data randomness in deep learning algorithms.

[0095] Furthermore, for the quantitative inversion task of the eight major element oxides in this example, the EMA-CNN model can complete multi-component collaborative prediction in one go, and the single training-validation process only takes 137 seconds, demonstrating significant advantages in modeling efficiency and deployment simplicity. GBR, Elastic Net, NGBoost, and PLS2 models require training a separate quantitative inversion model for each major element oxide, and their labor costs and cumulative modeling time increase linearly with the increase in the number of target substance components. At the same time, the time consumed in a single training-validation process is also much longer than that of the EMA-CNN model.

[0096] After completing the construction of the EMA-CNN model and designing the weighted mean square error loss function Weighted_MSELoss to train and optimize the EMA-CNN model, the EMA-CNN model can be used to perform multi-component synchronous inversion of unknown LIBS spectra.

[0097] In summary, the LIBS inversion method based on EMA-CNN and weighted loss function in this embodiment 1 has the advantages of accuracy, stability and efficiency. It is suitable for LIBS multi-component synchronous inversion tasks in large data scenarios and has important value for the field of laser spectral analysis technology.

[0098] The working principle of the LIBS inversion method based on EMA-CNN and weighted loss function in this embodiment 1 is as follows:

[0099] For conventional deep learning models, an equal attention allocation is typically applied to all spectral features by default; for conventional loss functions, a simple summation strategy is usually applied to the loss components of multiple output tasks by default. The core innovation of this invention is the innovative introduction of an efficient multi-scale attention mechanism (EMA) and the design of a novel weighted mean square error loss function, which enables accurate, stable, and efficient collaborative prediction of multi-component content. The overall design concept is as follows:

[0100] For the feature map sequence extracted by a deep CNN model, invalid noise interference features derived from the spectral background baseline and instrument noise not only fail to provide effective information related to the final output vector, but may also introduce biases during the learning process of the model's back-end layers, thus negatively impacting the accuracy of quantitative inversion. Meanwhile, key features derived from the target element's spectral lines are the core learning objects of the model's back-end layers, highly correlated with the target element's content, and require the model's focused attention. Therefore, introducing an efficient multi-scale attention mechanism into a deep CNN model can dynamically strengthen the weights of key features during model learning and inference, suppress invalid noise interference features, significantly improve model performance, and reduce computational consumption. The efficient multi-scale attention mechanism (EMA) module used in this invention employs a parallel dual-branch structure: a 1×1 convolutional kernel branch for extracting cross-channel relationships and a 1×3 convolutional kernel branch for capturing local spatial structure context information. It generates attention maps based on multi-scale feature information perception through cross-spatial dimension interactive modeling. The 1×1 convolutional kernel branch borrows from and extends the idea of ​​coordinate attention mechanism. While achieving cross-channel interaction through the 1×1 convolutional kernel, it uses two global average pooling operations along the spatial dimension to embed spatial location encoding in the channel information, enhancing its spatial perception ability. The 1×3 convolutional kernel branch further expands the spatial receptive field to capture a wider range of spectral context information using the 1×3 convolutional kernel. The outputs of the two branches are first subjected to global average pooling and Softmax normalization operations, respectively, to obtain their respective channel encoding vectors and basic attention maps. Then, the basic attention map of each branch and the channel encoding vector of the other branch are matrix multiplied to generate two attention maps enhanced by cross-scale spatial-channel information interaction. Finally, the two are added together and calculated using the Sigmoid activation function to obtain the final attention map. Then, it is multiplied element-wise with the input feature map sequence and output to the next layer of the network. The EMA module adaptively captures the correlation between features at different scales and the content of target material components through the aforementioned operations. Based on the correlation, it selectively increases the attention value of key features and decreases the attention value of invalid noise interference features during model optimization. This results in the value of key features being amplified after element-wise multiplication of the input feature map sequence and the attention map, while the value of invalid noise interference features is suppressed to a very low level, effectively guiding the model to concentrate computational resources on key features. Among these, the lightweight design schemes such as parallel dual-branch structure, small-sized convolutional kernels, global average pooling operation, and fusion addition operation greatly improve the computational efficiency of the EMA module in generating attention maps, and significantly improve the key feature focusing ability of deep CNN models with minimal parameter cost. At the same time, convolutional kernels of different scales resolve the contradiction that traditional single receptive fields cannot capture details and globals simultaneously, further improving the deep CNN model's ability to understand complex abstract features.Furthermore, the output feature map of the EMA module is completely consistent with the input in terms of channel dimension and spatial size, which allows it to be flexibly embedded in different deep learning model architectures, providing high flexibility and scalability for model architecture design.

[0101] For multi-component content collaborative prediction tasks, the convergence speed and loss function magnitudes differ significantly for component content prediction tasks with different content distribution ranges. Conventional loss functions simply sum the loss components of each output task, which can easily lead to the optimization process being dominated by one or a few tasks, thus sacrificing the model's performance on other tasks and causing an imbalance in overall prediction accuracy. Therefore, it is necessary to design a novel weighted mean squared error loss function (Weighted_MSELoss) that reasonably calculates the weights of the corresponding loss components based on the content distribution range of each substance, ensuring that the loss components of each output task are at similar orders of magnitude. This ensures that during the backpropagation optimization process, gradient updates are not dominated by one or a few tasks, but rather respond evenly to the loss components of all tasks.

[0102] The above description is merely a preferred embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.

Claims

1. A LIBS inversion method based on EMA-CNN and a weighted loss function, characterized in that, A LIBS spectral inversion model was constructed based on a deep convolutional neural network (CNN). An efficient multi-scale attention mechanism (EMA) was introduced to form an EMA-CNN model. A weighted mean square error loss function was designed to achieve accurate collaborative prediction of the content of multiple components. The LIBS inversion method based on EMA-CNN and weighted loss function includes the following steps: S1. Preliminary preparation: Prepare standard samples for collecting laser-induced breakdown spectroscopy (LIBS), record the name and composition information of each sample, create a summary table of composition contents covering all N samples, determine the true content of L target components in each sample based on the quantitative task, and construct a target component content label vector. S2. Using a LIBS spectral detection device, at a fixed detection distance, the LIBS spectra of all the samples were collected, and the experimentally collected LIBS spectra were defined as the original spectral dataset. S3. Preprocess the LIBS spectra in the original spectral dataset. The preprocessing steps include dark background removal, wavelength calibration, radiometric calibration, invalid pixel removal, and channel stitching. The LIBS spectra after preprocessing are defined as the LIBS spectral dataset. S4. Sort all samples according to the content of a target component from largest to smallest, and use a systematic sampling strategy to divide the LIBS spectral dataset into P LIBS spectral data subsets, defined as Fold 1 ~ P respectively, to ensure that the number of samples in each LIBS spectral data subset is basically the same and that the data are in the same distribution condition. S5. Construct a deep convolutional neural network model incorporating the EMA module, defined as the EMA-CNN model. The EMA-CNN model structure is designed as follows: Layer 1 is a batch normalization layer; Layers 2, 4, 6, 7, and 9 are convolutional layers with ReLU activation function; Layers 3, 5, and 8 are pooling layers with max pooling strategy; Layer 10 inserts the EMA module; Layer 11 is a flattened layer; Layer 12 is a fully connected layer with ReLU activation function; Layer 13 is a fully connected layer. In step S5, the EMA module adopts a parallel dual-branch structure, namely a 1×1 convolutional kernel branch for extracting cross-channel relationships and a 1×3 convolutional kernel branch for capturing... In terms of local spatial structure context information, the outputs of the two branches are first subjected to global average pooling and softmax normalization operations to obtain their respective channel encoding vectors and basic attention maps. Then, the basic attention map of each branch and the channel encoding vector of the other branch are multiplied by a matrix to generate two attention maps enhanced by cross-scale spatial-channel information interaction. Finally, the two are added and processed by the Sigmoid activation function to obtain the final attention map based on multi-scale feature information perception. Then, the attention map and the input feature map sequence are multiplied element-wise and output to the next layer of the network. The EMA-CNN model structure is adjusted and optimized according to the specific characteristics of the LIBS spectral dataset and task requirements. S6. Design a weighted mean squared error loss function, Weighted_MSELoss. Calculate the weights of the corresponding loss components based on the content distribution range of each substance. During the EMA-CNN model training process, minimizing the Weighted_MSELoss value is used as the model optimization objective. In step S6, the weight design scheme for Weighted_MSELoss comprehensively considers the content distribution range of each target component and assigns specific weight coefficients w to the corresponding loss components. l The loss component refers to the mean squared error between the predicted and true values ​​of a target component content. The weighted_MSELoss calculation method is as follows: Let R be the component content label vector of a sample, and let M LIBS spectra be collected from the sample by the LIBS spectral detection device. Let P be the component content prediction vector output by the EMA-CNN model for the j-th LIBS spectrum of the sample. j Vectors R and P j Each has L values, where the l-th value is denoted as R. l and P jl The formula for calculating Weighted_MSELoss is: Weighting coefficient w l The initial range is determined based on the ratio between the loss components of the target component, and the final value is determined by manual selection. S7. Use the K-fold cross-validation strategy to train and validate the EMA-CNN model on the LIBS spectral data subsets Fold1 to Fold P-1, and optimize the training hyperparameters of the EMA-CNN model. S8. Input the unknown LIBS spectra of the test set into the trained and validated EMA-CNN model to predict the content of the target substance in the corresponding sample, and evaluate the quantitative inversion performance of the EMA-CNN model from multiple perspectives based on two sets of evaluation indicators: root mean square error of prediction and coefficient of determination.

2. The LIBS inversion method based on EMA-CNN and weighted loss function as described in claim 1, characterized in that: In step S1, from the total list of the content of the substances in all N known component samples, the true content of L target substances in each sample is selected. Then, the component content label vector C of each sample is represented as a 1×L matrix, and the component label vector C of sample i is... i for Where c i1 c represents the content of the first component in sample i in the material composition information table, i.e., the mass percentage (wt.%), where 0 ≤ c i1 ≤ 100 wt.%; c i2 The meanings of other component content label vectors can be deduced similarly.

3. The LIBS inversion method based on EMA-CNN and weighted loss function as described in claim 1, characterized in that: In step S2, when the LIBS spectral detection device is used for spectral acquisition, all key device parameters are set to fixed values, including the number of spectral acquisitions, integration time, delay time, and focusing position; relevant environmental parameters are monitored in real time and maintained in a stable state, including detection distance, ambient temperature, air pressure, and gas composition.

4. The LIBS inversion method based on EMA-CNN and weighted loss function as described in claim 1, characterized in that: In step S3, the dark background removal operation refers to subtracting the dark background spectrum from the original LIBS spectrum to obtain the effective spectrum, where the dark background spectrum refers to the spectrum of the spectrometer response without laser excitation; wavelength calibration refers to converting the spectrometer pixel number into wavelength value using a multivariate quadratic fitting function; radiometric calibration refers to converting the spectrometer pixel response into spectral radiance using a multivariate linear fitting function; invalid pixel removal refers to removing the pixel response values ​​of each band of the LIBS spectrum that are outside the wavelength range; and channel splicing refers to splicing the multiple bands of LIBS spectrum that have been removed from invalid pixel removal into a single line in wavelength order.

5. The LIBS inversion method based on EMA-CNN and weighted loss function as described in claim 1, characterized in that: In step S4, the LIBS spectral dataset partitioning process adopts a systematic sampling scheme. All samples in the LIBS spectral dataset are sorted according to the content of a target component from highest to lowest. The first P samples are used as the starting point for P subsets. Every P samples are taken and placed into the corresponding subset, ensuring that all subsets meet the data distribution condition, so that the LIBS spectral dataset is divided into P subsets. At the same time, the LIBS spectral dataset partitioning scheme strictly follows the highest principle of "sample dimensional independence", that is, all LIBS spectra of any sample are assigned to only one subset, ensuring absolute isolation between subsets.

6. The LIBS inversion method based on EMA-CNN and weighted loss function as described in claim 1, characterized in that: in In step S7, the EMA-CNN model is trained using a K-fold cross-validation strategy. The training iterative optimizer employs the AdamW algorithm with corrected weight decay, and the loss function is Weighted_MSELoss. First, one subset of the LIBS spectral data (Fold1 to Fold P-1) is selected sequentially as the validation set to monitor the performance changes of the EMA-CNN model during training. The remaining P-2 subsets are used as the training set to train the EMA-CNN model. After P-1 iterations, the performance results of the EMA-CNN model on all subsets are obtained. For the training process, the input is the LIBS spectral samples of the training set and the component content label vector corresponding to each LIBS spectral sample. The output is the predicted target component content value output by the EMA-CNN model for each training set LIBS spectral sample. The goal is to minimize the Weighted_MSELoss value between the predicted target component content value and the true value, and the AdamW algorithm is used to optimize the weight parameters of the EMA-CNN model. For the validation process, the input is the LIBS spectral samples of the validation set. The output is the predicted content of the target component output by the EMA-CNN model for the validation set LIBS spectral samples. Subsequently, based on the performance of the EMA-CNN model on the validation set, the relevant training hyperparameters are optimized, including batch size, initial learning rate, number of iterations, and print interval. In the process of optimizing the training hyperparameters, a grid search algorithm is used to find the optimal combination of the above four training hyperparameters. That is, all permutations and combinations are performed in the preset multidimensional search space, and an exhaustive search is performed. A complete model training and validation process is started independently for each set of training hyperparameter combinations. Finally, the Weighted_MSELoss value on the validation set is used as the performance evaluation criterion, and the training hyperparameter combination that minimizes the Weighted_MSELoss value is selected as the optimal combination, thus completing the training of the EMA-CNN model.

7. The LIBS inversion method based on EMA-CNN and weighted loss function as described in claim 1, characterized in that: In step S8, all LIBS spectra in the LIBS spectral data subset Fold P are input into the trained and validated EMA-CNN model to obtain the predicted content of the target substance components of the corresponding samples; the LIBS spectral data subset Fold P is defined as the test set, and the LIBS spectra in this test set are not involved in the training-validation process of the EMA-CNN model; the root mean square error of prediction (RMSEP) and the coefficient of determination (R²) are used. 2 Two sets of evaluation metrics are used to quantitatively analyze the quantitative inversion performance of the EMA-CNN model on the test set from two complementary perspectives: prediction accuracy and goodness of fit. This objectively reflects the performance of the EMA-CNN model in practical applications. After completing the construction of the EMA-CNN model and designing the weighted mean square error loss function Weighted_MSELoss to train and optimize the EMA-CNN model, the EMA-CNN model can be used to perform multi-component synchronous inversion of unknown LIBS spectra.