XRF element quantitative analysis method based on transformer-cnn

The feature mining coordination module of the Transformer-CNN neural network solved the matrix effect and spectral line overlap problems in soil XRF analysis, realizing efficient and simple quantitative analysis of soil heavy metal elements.

CN117238392BActive Publication Date: 2025-11-07YANGTZE DELTA REGION INST OF UNIV OF ELECTRONICS SCI & TECH OF CHINE (HUZHOU)
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311193431.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-15
Publication Date
2025-11-07
Estimated Expiration
2043-09-15

AI Technical Summary

Technical Problem

Existing technologies for soil XRF analysis suffer from matrix effects, spectral overlap, and noise, resulting in low analytical accuracy. Furthermore, the preprocessing is complex and lacks a high degree of automation.

Method used

A feature mining coordination module, consisting of a global spectral attention module and a local multi-scale feature extraction module, was constructed using a Transformer-CNN neural network to predict the content of heavy metal elements in soil, thus simplifying the spectral data processing workflow.

Benefits of technology

It improves the accuracy and stability of predicting soil heavy metal content, simplifies data processing steps, and enables efficient quantitative elemental analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117238392B_ABST
    Figure CN117238392B_ABST
Patent Text Reader

Abstract

The application discloses a kind of XRF element quantitative analysis methods based on Transform-CNN, belongs to X fluorescence spectrum element detection technical field, comprising the following steps, step 1: obtaining XRF spectrum, determine element content;Step 2: channel intercept and data standardization processing;Step 3: division training set and test set;Step 4: construct feature mining coordination module;Step 5: build Transform-CNN deep learning model;Step 6: training set trains Transform-CNN model;Step 7: test set predicts target element content;Step 8: evaluation index evaluates model prediction effect.The application does not need to carry out complex pretreatment to XRF spectrum, can accurately, nondestructively, effectively detect the content of heavy metal element in soil.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of X fluorescence spectrum element detection, and particularly relates to an XRF element quantitative analysis method based on a Transformer-CNN. BACKGROUND

[0002] An accurate and effective analysis method for measuring the content of heavy metal elements in soil is of great significance for soil pollution control and ecological system restoration. X-ray fluorescence spectroscopy is considered as a hot means for soil analysis due to its advantages of non-destructive, rapid and in-situ measurement. However, the XRF of soil has complex matrix effect and spectral overlap phenomenon, and at the same time, the instrument measurement and transmission can also introduce background noise, which seriously interferes with the analysis accuracy. In order to solve these problems, T. Tavares et al. (Agronomy, 10 (2020) 787-808) used Compton normalization and multivariate regression to overcome the soil matrix effect, thereby improving the prediction accuracy of key soil properties; Yang et al. (Analytical methods, 14 (2022) 3944-3952) introduced an iterative adaptive window empirical wavelet transform as a background subtraction method to extract effective counts of characteristic peaks to obtain "clean characteristic peaks"; Lu et al. (Chemo metrics and Intelligent Laboratory Systems, 15 (2023) 104842-104854) proposed an iterative variational mode decomposition framework for the continuous background interference in soil XRF spectrum. The corrected spectrum is used for quantitative analysis of heavy metals; R.O. Bastos et al. (X-Ray Spectrometry, 41 (2012) 304-307) also proposed a method for correcting the influence of soil moisture on in-situ XRF analysis using low-energy background; although the above methods effectively alleviate the matrix effect and spectral overlap problem, the entire pretreatment is very complex and requires more prior knowledge, and the intelligence degree is not high, and the engineering application is not strong. It can be seen that we need an intelligent and effective element quantitative analysis method to alleviate the matrix effect, spectral overlap and noise problems of XRF spectrum, and thereby improve the analysis accuracy of element content. Therefore, the application combines the XRF non-destructive detection technology to propose an effective deep learning method to accurately determine the heavy metal elements in soil. SUMMARY

[0003] In view of the problems existing in the prior art, the application proposes a feature mining coordination module, which is composed of a global spectral attention module and a local multi-scale feature extraction module, and can realize the overall attention and local feature modeling of the spectrum. Based on the feature mining coordination module, a Transformer-CNN deep spectrum prediction model is proposed to accurately predict the content of heavy metal elements in soil.

[0004] The technical solutions adopted by the present application are as follows:

[0005] The XRF element quantitative analysis method based on the Transformer-CNN neural network comprises the following steps:

[0006] Step 1: Obtain the XRF spectrum and determine the element content;

[0007] Step 2: Channel interception and data standardization processing;

[0008] Step 3: Divide the training set and the test set;

[0009] Step 4: Build a feature mining coordination module;

[0010] Step 5: Build a Transformer-CNN deep learning model;

[0011] Step 6: Train the Transformer-CNN model with the training set;

[0012] Step 7: Predict the target element content with the test set;

[0013] Step 8: Evaluate the model prediction effect with evaluation indexes.

[0014] Further, in step 1, obtaining the XRF spectrum and determining the element content comprises the following contents: selecting P standard soil samples as target samples, and obtaining P groups of spectrum data x original =[x1,x2,...,x 2048 ] containing 2048 channels and standard content data y of target elements y 270 =[y1,y2,...,y 800 ].

[0015] Further, the method of channel interception and data standardization processing in step 2 comprises the following steps:

[0016] First, the spectrum data is intercepted, and the spectrum data of channels 1-800 is selected as the research object, i.e. x 800 =[x1,x2,...,x

[0017] Then, the spectrum data is preprocessed. The original spectrum data has magnitude difference, so the magnitude difference between the spectrum intensity values is eliminated through standardization processing. Here, Z-score standardization is selected, and the calculation formula is as shown in formula (1) and formula (2):

[0018]

[0019]

[0020] For the original spectrum sequence x = [x1, x2,..., xN], the standardization is performed by formula (1), wherein xi represents the intensity value corresponding to the i-th spectrum channel, 800 i is the corresponding xi is the corresponding xi i is the corresponding xi output is the corresponding xi

[0021] Further, the step 3 of dividing the training set and the test set comprises the following contents:

[0022] The spectrum data is divided into the training set and the test set in the proportion of 8:2 by the KS algorithm; the KS algorithm regards all samples as the training set candidate samples, and sequentially selects samples into the training set; firstly, the two samples with the farthest Euclidean distance are selected into the training set, and then the two samples farthest and closest to the selected samples are found by calculating the Euclidean distance of each remaining sample to each known sample in the training set, and the two samples are selected into the training set, and the above steps are repeated until the number of samples reaches the requirement.

[0023] Further, the step 4 of constructing the feature mining coordination module comprises the following contents:

[0024] The feature mining coordination module is designed based on the Pytorch framework, and the feature mining coordination module comprises a global spectrum attention module and a local multi-scale feature extraction module; the module adopts a parallel structure to improve the calculation efficiency, and simultaneously realizes local feature extraction and global dependence modeling to mine deep spectrum features.

[0025] Further, the step 5 of building the Transformer-CNN deep learning model comprises the following contents:

[0026] The input data is a one-dimensional spectrum sequence Firstly, the convolution layer 1 and the convolution layer 2 are used to realize preliminary feature extraction and spatial dimension control, and the dimensions are 8 and 8 respectively, so that the spectrum feature I is obtained;

[0027] Secondly, after the preliminary feature extraction, the spectrum feature vector I is sent to the feature mining coordination module to realize deep feature mining and feature compensation, and the global attention of the global spectrum attention module and the local effective feature extraction of the local multi-scale feature extraction module are realized, so that the deep spectrum feature I output is obtained.

[0028] Thirdly, the enhanced spectrum feature is sent to the convolution layer 3 and the convolution layer 4 to realize further expansion of the dimension and compression of the spectrum feature vector.

[0029] Finally, the soil heavy metal content is accurately predicted through three fully connected layers (FC1, FC2 and FC3).

[0030] Furthermore, the three fully connected layers are FC1, FC2 and FC3, with FC1 having 128 neurons, FC2 having 32 neurons and FC3 having 1 neuron.

[0031] Furthermore, step 6, training the Transformer-CNN model on the training set, includes the following:

[0032] The training data is fed into the Transformer-CNN regression model for training. The model's parameters are optimized using the Adam optimizer, and the loss function is SmoothL1 Loss, calculated as follows:

[0033]

[0034] Where e represents the actual value y and the predicted value of the element content. The difference between them, namely

[0035] Furthermore, step 7, in which the test set predicts the content of the target element, includes the following:

[0036] Input the test data into the trained regression model, and it will output the predicted content of the target element.

[0037] Furthermore, the evaluation indicators in step 8 for evaluating the model's predictive performance include the following:

[0038] Choose the coefficient of determination Mean absolute error (MAE) and root mean square error (RMSE) are used to evaluate prediction performance. The formulas for calculating these indicators are as follows:

[0039]

[0040]

[0041]

[0042] Where y i Let i be the true value of the content of the target element in the i-th sample. Let i be the predicted content of the target element in the i-th sample. It is the average of the true content of the target element in all samples in the test set, and k is the number of samples in the test set.

[0043] The beneficial effects of this invention are as follows:

[0044] The application provides an XRF element quantitative analysis method based on a Transformer-CNN neural network, which deeply mines spectral features through a global attention mechanism and a parallel structure of local feature extraction, and thus improves prediction accuracy and stability; the application is an end-to-end spectral prediction model based on deep learning, has the characteristics of simplicity and effectiveness, does not need to perform complex pretreatment such as denoising on spectral data, can efficiently extract the complex correlation between spectral information and element content, and simply and effectively quantitatively predicts the elements contained in a to-be-measured object. BRIEF DESCRIPTION OF DRAWINGS

[0045] Figure 1 is a flowchart of the XRF element quantitative analysis method based on the Transformer-CNN neural network of the application;

[0046] Figure 2 is a structural diagram of a feature mining coordination module;

[0047] Figure 3 is a structural diagram of a Transformer-CNN deep learning model;

[0048] Figure 4 is an element content prediction result diagram of the embodiment 1 of the application. DETAILED DESCRIPTION

[0049] In order to make the purpose, process and advantages of the application clearer, the application is further described in detail below by combining embodiments and drawings.

[0050] In the embodiment of the application, the XRF element quantitative analysis method based on the Transformer-CNN neural network comprises the following steps:

[0051] Step 1: Obtain an XRF spectrum and determine element content. P standard soil samples are selected as target samples, and P groups of spectral data x containing 2048 channels x original =[x1,x2,...,x 2048 ] and standard element content data y 270 =[y1,y2,...,y 800 ] are obtained through experiments.

[0052] Step 2: Channel interception and data standardization processing.

[0053] First, the spectral data are subjected to channel interception. The original spectral data contain 2048 channels, and the spectral counts of channels after 800 have no actual physical meaning and no element characteristic peak. Therefore, the spectral data of channels 1-800 are selected as the research object, that is, x 800 .

[0054] Then the spectral data is preprocessed. The original spectral data has magnitude difference, so the magnitude difference between spectral intensity values is eliminated by standardization processing, here we choose Z-score standardization, the calculation formula is as formula (1), (2):

[0055]

[0056]

[0057] For the original spectral sequence x = [x1, x2, …, xN], the standardization processing is carried out by formula (1), wherein x 800 represents the intensity value corresponding to the i-th spectral channel, i is the corresponding x i The spectral intensity value after standardization, μ and σ are the mean and standard deviation of the original spectral sequence x respectively. Therefore, the spectral data after standardization is

[0058] Step 3: Divide the training set and the test set. The spectral data is divided into training set and test set in the ratio of 8:2 by kennard-stone (KS) algorithm. KS algorithm regards all samples as training set candidate samples, and selects samples into the training set in turn. First, select the two samples with the farthest Euclidean distance into the training set, then find the two samples farthest and closest to the selected samples by calculating the Euclidean distance of each remaining sample to each known sample in the training set, and select these two samples into the training set, repeat the above steps until the number of samples reaches the requirement.

[0059] Step 4: Construct the feature mining coordination module. The feature mining coordination module is designed based on the Pytorch framework, which includes the global spectral attention module and the local multi-scale feature extraction module. The module adopts parallel structure to improve the calculation efficiency, which can realize local feature extraction and global dependence modeling at the same time to mine deep spectral features.

[0060] For the global spectral attention module, first, the input spectral feature I ∈ R L×1×C is segmented. The size of the segmented feature block is p × 1 × C (in the present application, p is set to 16), so N = L / p is the effective spectral sequence length. XRF spectral data has high dimensionality, and direct calculation will introduce more parameter quantity and calculation complexity. Therefore, dividing the input spectral data into a series of feature blocks can speed up the inference efficiency. Then the feature block is flattened into a one-dimensional vector and subjected to linear mapping for spectral position embedding. The purpose of position embedding is to ensure the spatial continuity of spectral information, which can be achieved by random initialization of one-dimensional vector embedding. The above operations can be summarized as:​

[0061] I' = PE(LP(Split(I))) (3)

[0062] where I is the input of the global spectral attention module, Split is the split operation, LP represents the linear mapping, and PE is the position encoding for the unfolded feature vector. The spectral feature I' with position information is obtained through the above operations.

[0063] The spectral feature with position information is sent to the feature encoder to calculate the global correlation of the spectral feature. I' is first subjected to layer normalization to stabilize the distribution of parameters, and then linear transformation is performed to generate the query matrix Q, the key matrix K, and the value matrix V, respectively. Based on Q, K, V, the multi-head self-attention mechanism uses these matrix vectors to calculate the similarity scores of each spectral feature vector with other spectral feature vectors, and then generates a new representation of the spectral feature through a normalization method. Specifically, the similarity matrix of the spectral feature is first obtained by the dot product of the Q matrix and the K matrix, and then the feature is normalized to a probability distribution through the normalized exponential function, and finally weighted into the V matrix to obtain the output attention graph. The above operation can be represented as:

[0064]

[0065] where d is the scale factor used to stabilize the gradient distribution. It is obtained by the ratio of the dimension of the feature block to the number of attention heads. K T represents the transpose of the K matrix, Attention(Q, K, V) is the output of the multi-head self-attention, and Softmax is the normalized exponential function, whose formula is:

[0066]

[0067] where N = L / p is the effective spectral sequence length.

[0068] The output attention graph is connected with the input vector through residual learning, which can effectively prevent feature degradation. Thus, the intermediate output I * :

[0069] I * = I' + Attention(Q, K, V) (6)

[0070] The intermediate output is subjected to a multi-layer perceptron (MLP) to realize further interaction of the features, which is conducive to the spectral features to establish deeper dependency relationships. Finally, the output vector is reconstructed into the same shape as the input size for subsequent processing. This step can be summarized as:

[0071] I output1 = Reshape(MLP(I*)) (7)

[0072] where I*∈R p×1×N , I output ∈R L×1×C . MLP is a three-layer network structure containing one hidden layer, and the number of hidden layer neurons is twice the number of input neurons. Reshape is a Python built-in function that can reshape the output vector to the same shape as the input size to get the final output I output1 .

[0073] The local multi-scale feature extraction module is mainly composed of two one-dimensional convolutional layers with different scales, and the convolution kernel sizes are 7x1 and 5x1. For an input spectral sequence I∈R L×1×C with length L and channel number C, the first large kernel convolutional layer maps the spectral features to a higher dimension 2C while extracting local large-scale features. The second small kernel convolutional layer extracts more rich local features in a higher dimension, and then maps the dimension to the input size. After each convolution, batch normalization and ReLU activation function operations follow, batch normalization can normalize the convolution parameters, and ReLU activation function is used to increase nonlinearity. Finally, the residual connection integrates multi-scale features to prevent effective feature loss. The above operations can be represented as:

[0074] I output2 = Conv1D 5×1 (Conv1D 7×1 (I)) + I (8)

[0075] where Conv1D 7×1 represents one-dimensional convolution operation with convolution kernel size 7x1. Conv1D 5×1 represents one-dimensional convolution operation with convolution kernel size 5x1, and I output2 is the output of the local multi-scale feature extraction module.

[0076] The output I output of the feature mining coordination module is the concatenation of the outputs of the global spectral attention module and the local multi-scale feature extraction module along the channel direction:

[0077] I output = Concatenate(I output1 , I output2 ) (9)

[0078] where Concatenate represents the operation of concatenating along the channel direction.

[0079] Step 5: Build a Transformer-CNN deep learning model. The input data is a one-dimensional spectral sequence Firstly, the preliminary extraction of features and the control of spatial dimensions are realized through convolution layer 1 and convolution layer 2, and the dimensions are 8 and 8 respectively, to obtain the spectral feature I. A convolution operation, a batch normalization layer, a ReLU activation function layer and a pooling layer together constitute a convolution layer. Secondly, after the preliminary feature extraction, the spectral feature vector I is sent to the feature mining coordination module to realize deep feature mining and feature compensation, which is realized through global attention of the global spectral attention module and local effective feature extraction of the local multi-scale feature extraction module, to obtain the deep spectral feature I output , and the dimension is 16. Thirdly, the enhanced spectral feature is sent to convolution layer 3 and convolution layer 4 to realize further expansion of the dimension and compression of the spectral feature vector, and the dimensions are 32 and 64 respectively. Finally, through three fully connected layers (FC1, FC2 and FC3), the precise prediction of the content of the soil heavy metal element is realized, the number of neurons of FC1 is 128, the number of neurons of FC2 is 32, and the number of neurons of FC3 is 1, that is, the predicted value of the content of the target element, wherein the Dropout layer is added to FC1 to prevent overfitting. The convolution kernel size of convolution layer 1 is 1, and the step is 1. The convolution kernel size of convolution layer 2, convolution layer 3 and convolution layer 4 is 3*1, and the step is 1.

[0080] Step 6: Train the Transformer-CNN model. The training data is sent to the Transformer-CNN regression model for training, and the batch size of the training process is 15 and the iteration number is 300. The model is optimized by the Adam optimizer. The loss function is SmoothL1 Loss. The calculation formula is:

[0081]

[0082] Where e is the difference between the true value y and the predicted value of the element content, that is,

[0083] Step 7: Predict the content of the target element in the test set. The test data is input into the trained regression model, and the predicted content of the target element

[0084] Step 8: Evaluate the prediction effect of the model. The coefficient of determination , the mean absolute error (MAE) and the root mean square error (RMSE) are selected to evaluate the prediction effect. is the square of the correlation between the predicted value and the true value, which represents the explanatory power of the independent variable to the dependent variable in the model. The closer to 1, the better the fitting effect of the model. MAE more intuitively reflects the difference between the true value and the predicted value, and RMSE reflects the degree of deviation of the predicted value from the true value. The smaller the value of RMSE, the higher the prediction accuracy of the model. The calculation formula of the above indexes is as follows:

[0085]

[0086]

[0087]

[0088] where y i is the true value of the target element content of the i-th sample, is the predicted value of the target element content of the i-th sample, y is the average value of the true content of the target element of all samples in the test set, and k is the number of samples in the test set.

[0089] The following is described by more specific embodiments.

[0090] Example 1

[0091] As Figure 1 shown, the XRF element quantitative analysis method based on the Transformer-CNN neural network includes the following steps:

[0092] Step 1: Obtain the XRF spectrum and determine the element content. Taking the prediction of Mn and Cu elements as an example, 270 standard soil samples are selected as target samples, and 270 groups of spectral data x original =[x1,x2,...,x 2048 ] containing 2048 channels and standard content data y of Mn and Cu elements y = [y1,y2,...,y 270 ] are obtained by experiment.

[0093] Step 2: Channel interception and data standardization. For the original spectral data original spectral sequence x original =[x1,x2,...,x 2048 ], the spectral data of channels 1-800 are selected as the research object, i.e. x = [x1,x2,...,x 800 ], and the spectral data is standardized to obtain the standardized spectral data

[0094] Step 3: Divide the training set and the test set. The spectral data is divided into a training set and a test set in a ratio of 8:2 by the kennard-stone (KS) algorithm. The training set has a total of 216 samples, and the test set has a total of 54 samples.

[0095] Step 4: Construct the feature mining coordination module. A feature mining coordination module was designed based on the PyTorch framework. (See Feature Mining Coordination Module). Figure 2 This includes the global spectral attention module (see...). Figure 2 (a)) and the local multi-scale feature extraction module (see Figure 2 (b)). This module employs a parallel structure to improve computational efficiency, enabling simultaneous local feature extraction and global dependency modeling to uncover deeper spectral features.

[0096] Step 5: Build the Transformer-CNN deep learning model, see... Figure 3 The input data is a one-dimensional spectral sequence. First, convolutional layers 1 and 2 perform preliminary feature extraction and spatial dimension control (8 dimensions each), yielding spectral feature I. A convolutional layer consists of a convolution operation, a batch normalization layer, a ReLU activation function layer, and a pooling layer. Next, after preliminary feature extraction, the spectral feature vector I is fed into the feature mining coordination module for deep feature mining and feature compensation. This is achieved through global attention from the global spectral attention module and local effective feature extraction from the local multi-scale feature extraction module, resulting in the deep spectral feature I. output Its dimension is 16. Third, the enhanced spectral features are fed into convolutional layers 3 and 4 to further expand the dimension and compress the spectral feature vector, with dimensions of 32 and 64 respectively. Finally, three fully connected layers (FC1, FC2, and FC3) are used to accurately predict the content of heavy metal elements in the soil. FC1 has 128 neurons, FC2 has 32 neurons, and FC3 has 1 neuron, representing the predicted content of the target element. FC1 also includes a Dropout layer to prevent overfitting. Convolutional layer 1 has a kernel size of 1 and a stride of 1, while convolutional layers 2, 3, and 4 have kernel sizes of 3*1 and a stride of 1.

[0097] Step 6: Train the Transformer-CNN model using the training set. Feed the training data into the Transformer-CNN regression model for training. The batch size is 15, and the number of iterations is 300. The model's parameters are optimized using the Adam optimizer. The loss function is SmoothL1 Loss.

[0098] Step 7: Predict the content of target elements using the test set. Feed the test data into the trained regression model, which will output the predicted content of the target elements Mn and Cu, respectively.

[0099] Step 8: Evaluate the model's predictive performance using evaluation indicators. The coefficient of determination was selected. The mean absolute error (MAE) and root mean square error (RMSE) are used to evaluate the prediction effect.

[0100] The prediction results of the soil Mn and Cu elements obtained in this example are shown in the following table 1. Figure 4 For the Mn element, 0.9627, the MAE is 0.6837, and the RMSE is 0.9679. For the Cu element, 0.9658, the MAE is 0.0754, and the RMSE is 0.1088.

[0101] Comparative Example 1

[0102] The PLSR, ANN and 1D-CNN neural network algorithms are used to predict the Mn and Cu elements of the same soil samples to be tested, and the prediction results are shown in Table 1. It can be seen from the comparison that the PLSR model has the worst effect, because PLSR is a statistical method and cannot well fit the nonlinear characteristics from the original data with spectral line interference and matrix effect. ANN and 1D-CNN are deep learning models, which can establish nonlinear relationships from complex input data, so their effects are better than that of the PLSR model. However, ANN and 1D-CNN lack attention to important information and do not establish long-range dependencies and local correlations. Finally, the accuracy and precision of the prediction are improved based on the parallel structure of the global attention mechanism and the CNN local feature extraction of the Transformer-CNN, which shows that the Transformer-CNN neural network algorithm effectively solves the problems of spectral line interference and complex matrix effect of soil, improves the accuracy and precision of element quantitative analysis, and embodies the superiority of the method of the present application.

[0103]

[0104] The above is only a specific embodiment of the present application, and any feature disclosed in this specification can be replaced by other equivalent or similar purpose alternative features unless specifically described. All features disclosed, or steps in all methods or processes, except for mutually exclusive features and / or steps, can be combined in any way.

Claims

1. A method for XRF elemental quantitative analysis based on a Transformer-CNN neural network, characterized in that, Comprising the following steps: Step 1: Obtain XRF spectrum, determine element content; Step 2: Channel interception and data standardization processing; Step 3: Divide training set and test set; Step 4: Build feature mining coordination module; Step 5: Build Transformer-CNN deep learning model; Step 6: Train the training set Transformer-CNN model; Step 7: Test set to predict the target element content; Step 8: Evaluation index evaluates the prediction effect of the model; The feature mining coordination module built in step 4 includes the following contents: Based on the Pytorch framework, the feature mining coordination module is designed, which includes a global spectrum attention module and a local multi-scale feature extraction module. This module adopts a parallel structure to improve computational efficiency, while realizing local feature extraction and global dependence modeling to mine deep spectrum features; The Transformer-CNN deep learning model built in step 5 includes the following contents: The input data is a one-dimensional spectral sequence First, the initial feature extraction and spatial dimension control are realized through the convolution layer 1 and the convolution layer 2, the dimensions are 8 and 8 respectively, and the spectral feature I is obtained. Secondly, after the initial feature extraction, the spectral feature vector I is sent to the feature mining coordination module to realize deep feature mining and feature compensation, and through the global attention of the global spectral attention module and the local effective feature extraction of the local multi-scale feature extraction module, the deep spectral feature I is obtained output ; Third, the enhanced spectral features are sent to convolution layer 3 and convolution layer 4 to further expand the dimension and compress the spectral feature vector; Finally, through three fully connected layers, the soil heavy metal element content is accurately predicted.

2. The Transformer-CNN neural network based XRF elemental quantitative analysis method according to claim 1, wherein, The XRF spectrum obtained in step 1 is used to determine the element content, including the following: P standard soil samples are selected as target samples, and P sets of spectrum data x containing 2048 channels are obtained by experiment original = [x1, x2,..., x 2048 ] and the standard content data y of the target element y = [y1, y2,..., y 270 ].

3. The Transformer-CNN neural network based XRF elemental quantitative analysis method of claim 1, wherein, The method of channel interception and data standardization processing in step 2 includes the following steps: Firstly, the channel interception is carried out on the spectral data, and the spectral data of channels 1-800 is selected as the research object, i.e. x = [x1, x2, …, x 800 ] Then the spectral data is preprocessed, the original spectral data has magnitude difference, so the magnitude difference between spectral intensity values is eliminated through standardization processing, here Z-score standardization is selected, the calculation formula is as formula (1), formula (2): For the original spectral sequence x = [x1, x2,..., xN], the normalization is performed by equation (1), where xi represents the intensity value corresponding to the i-th spectral channel, 800 i is the corresponding xi i is the normalized spectral intensity value, μ and σ are the mean and standard deviation of the original spectral sequence x, respectively. Thus, the normalized spectral data is ​​ 4. The Transformer-CNN neural network based XRF elemental quantitative analysis method of claim 1, wherein, The division of training set and test set in step 3 includes the following contents: Through KS algorithm, the spectral data is divided into training set and test set according to the ratio of 8:2; KS algorithm regards all samples as training set candidate samples, and selects samples from them in turn into the training set; First, select the two samples with the farthest Euclidean distance into the training set, then calculate the Euclidean distance between each remaining sample and each known sample in the training set, find the two samples farthest and closest to the selected samples, and select these two samples into the training set, repeat the above steps until the number of samples reaches the requirement.

5. The Transformer-CNN neural network based XRF elemental quantitative analysis method of claim 1, wherein, The three fully connected layers are FC1, FC2 and FC3, the number of neurons of FC1 is 128, the number of neurons of FC2 is 32, and the number of neurons of FC3 is 1.

6. The Transformer-CNN neural network based XRF elemental quantitative analysis method of claim 1, wherein, The training set Transformer-CNN model in step 6 includes the following contents: The training data is sent into the Transformer-CNN regression model for training, the model is optimized by Adam optimizer, the loss function is SmoothL1 Loss, and the calculation formula is: where e is the difference between the true value y of the element content and the predicted value ​ 7. The Transformer-CNN neural network based XRF elemental quantitative analysis method of claim 1, wherein, The test set to predict the target element content in step 7 includes the following contents: inputting test data into the trained regression model outputs a predicted content of the target element 8. The Transformer-CNN neural network based XRF elemental quantitative analysis method of claim 1, wherein, The evaluation index for evaluating the prediction effect of the model in step 8 includes the following contents: Selection decision coefficient The mean absolute error (MAE) and the root mean square error (RMSE) are used to evaluate the prediction effect, and the calculation formulas of the above indexes are as follows: where y i is the true value of the target element content of the i-th sample, is the predicted value of the target element content of the i-th sample, is the average value of the true content of the target element of all samples in the test set, and k is the number of samples in the test set.

Citation Information

Patent Citations

  • Hyperspectral soil available boron content prediction method

    CN116578851A

  • A calibration method of a spectroscopy device comprising a plurality of sensors and of transfer of spectral information obtained from at least two calibrated spectroscopy devices

    US20220074863A1