Heavy metal element standard exceeding judgment method based on EADC-Net model
By combining XRF detection technology and deep learning, the EADC-Net model is used to determine the excess standard of heavy metal elements in soil, which solves the problem of low discrimination accuracy in the context of complex spectral, and achieves qualitative analysis of high accuracy and reliability.
Patent Information
- Application Number
- CN202411559219.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2025-02-25
AI Technical Summary
When traditional X-ray fluorescence (XRF) detection methods face complex spectral backgrounds and overlapping peaks, it is easy to have low discrimination accuracy, and it is difficult to accurately judge the excess of heavy metal elements in the soil.
The heavy metal element over-standard discrimination method based on the EADC-Net model is adopted, and XRF non-destructive detection technology is combined with deep learning. Through the coding attention mechanism and deformable convolutional network, a heavy metal element over-standard discrimination model is established to improve the accuracy of qualitative analysis.
Highly accurate qualitative judgment of heavy metal elements exceeding the standard is achieved, overfitting and gradient disappearance problems are reduced, and the reliability and efficiency of soil quality monitoring are improved.
Smart Images

Figure BDA0005117424610000042 
Figure BDA0005117424610000044 
Figure BDA0005117424610000051
Abstract
Description
Technical Field
[0001] The present invention relates to the field of element detection, and in particular to a method for judging excessive heavy metal elements based on an EADC-Net model. Background Art
[0002] With the rapid development of industrialization and urbanization, the problem of heavy metal pollution in soil is becoming increasingly serious. The appropriate concentration level of heavy metal elements in soil is crucial to the development of plants and ecosystems. When the concentration of heavy metal elements in soil exceeds its risk screening value, it indicates an increase in ecological risks and potential risks to human health, and careful monitoring and scientific evaluation are urgently needed. In particular, the excessive concentration of harmful elements such as lead and cadmium will cause serious harm to the ecological environment and human health. X-ray fluorescence (XRF) spectroscopy analysis technology, as a non-destructive, multi-element analysis detection method, is widely used in the detection of heavy metal elements in soil. However, due to the complexity of soil composition and the difference in signal intensity of different heavy metal elements, traditional XRF detection methods are prone to low discrimination accuracy when facing complex spectral backgrounds and overlapping peaks.
[0003] Therefore, in order to improve the detection accuracy, it is urgently necessary to introduce a more intelligent method to judge the excessive concentration of heavy metal elements, to solve the problems of inaccurate calculation and low accuracy of traditional methods, and to provide an alternative inspection method for the qualitative analysis of heavy metal elements. Summary of the invention
[0004] In view of the problems existing in the above-mentioned prior art, the present invention provides a deformable convolutional network (EADC-Net) model based on the encoded attention mechanism to determine the excessive concentration of heavy metal elements contained in the test object. The method combines XRF non-destructive testing technology with deep learning, and builds an EADC-Net heavy metal element excessive discrimination model by establishing the relationship between the peak information (peak intensity) of the spectrum and the excessive concentration of elements, and finally achieves qualitative discrimination of the excessive concentration of heavy metal elements contained in the material, improves the accuracy of the qualitative analysis results, reduces overfitting, and prevents gradient disappearance.
[0005] To achieve the above object, the present invention proposes a method for judging excessive heavy metal elements based on the EADC-Net model, the method comprising the following steps:
[0006] A soil sample set is obtained, and an element set and sample information are determined based on the soil sample set, and a spectrum peak intensity and element concentration of a sample to be tested in the soil sample set are identified using an XRF spectrometer.
[0007] Build a heavy metal element excessive standard discrimination model based on EADC-Net, and determine the input and output of the heavy metal element excessive standard discrimination model of the EADC-Net.
[0008] The heavy metal element excessive discrimination model based on EADC-Net was trained.
[0009] The excessive concentration of heavy metal elements can be judged to complete the qualitative analysis of the excessive concentration of heavy metal elements in the test samples.
[0010] The step of obtaining a soil sample set and determining an element set and sample information based on the soil sample set comprises the following steps:
[0011] A sample set is determined, wherein there are n samples to be tested, and the union of all elements that can be identified by an energy dispersive X-ray fluorescence spectrometer, namely, an XRF spectrometer, is taken to form an element set A contained in the n samples to be tested.
[0012] Read in the spectrum peak intensity and element concentration, use the XRF spectrometer to test n samples, call a certain element that needs qualitative analysis the target element, and obtain the peak intensity matrix X of the n samples and the target element concentration vector Y in the element set A.
[0013] Divide the n soil samples into training sets and test sets according to the ratio of 7:3. The data corresponding to r training samples are used as training sets, and the remaining nr samples are used as test sets.
[0014] The construction of the heavy metal element excessive discrimination model based on EADC-Net includes the following steps:
[0015] Determine the input of the EADC-Net model, and use the peak intensity matrix X of n samples to be tested as the input of the model.
[0016] Determine the output of the EADC-Net model, compare the target element concentrations of n samples to be tested with the element risk screening values, and mark the target element concentration vector Y. When the element in the soil sample exceeds the risk screening value, it means that there is a heavy metal pollution risk of the element in the soil, that is, the pollution risk is judged as "yes", and the target value is set to "0". When the element in the soil sample does not exceed the risk screening value, it means that there is no heavy metal pollution risk of the element in the soil, that is, the pollution risk is judged as "no", and the target value is set to "1", thereby obtaining the target element concentration excess situation vector Z as the output of the model;
[0017] Build EADC-Net, which mainly includes 1 encoder layer, 1 self-attention layer, 2 deformable convolution layers, and 2 fully connected layers.
[0018] The encoding layer is used to extract the spatial features of the input. The encoding layer is mainly composed of the first fully connected layer, the Dropout layer, the second fully connected layer, the batch normalization layer and the third fully connected layer, and is used to capture the effective feature information and nonlinear characteristics in the spectral sequence through residual connection.
[0019] First, the input features are linearly transformed through the first fully connected layer, and an activation function is introduced to increase the nonlinear expression capability. The calculation formula of the first fully connected layer is as follows:
[0020] A1=f(W1·X+b1) (1)
[0021] Where A1 represents the output of the first fully connected layer, W1 represents the weight of the first fully connected layer, b1 represents the bias of the first fully connected layer, f represents the activation function, and X represents the peak intensity matrix.
[0022] Next, the output of the fully connected layer is passed through the Dropout layer to prevent overfitting. The generalization ability of the model is enhanced by randomly "discarding" some neurons. The calculation formula is:
[0023] A2=Dropout(A1,p drop ) (2)
[0024] In the formula, Dropout represents the regularization operation, p drop represents the discard rate, A1 represents the output of the first fully connected layer, and A2 represents the output after regularization.
[0025] The output after Dropout passes through the second fully connected layer to further extract feature information. The calculation formula is as follows:
[0026] A3=f(W2·A2+b2) (3)
[0027] Where A3 represents the output of the second fully connected layer, W2 represents the weight of the second fully connected layer, b2 represents the bias of the second fully connected layer, f represents the activation function, and A2 represents the output after regularization.
[0028] Then, the output of the second fully connected layer is batch normalized through the batch normalization layer. The calculation formula of batch normalization is as follows:
[0029] A4=BN(A3) (4)
[0030] Where A3 represents the output of the second fully connected layer, BN represents the batch normalization operation, and A4 represents the output after batch normalization.
[0031] Next, the batch normalized output is passed to the third fully connected layer to further process the features. The calculation formula is:
[0032] A5=f(W3·A4+b3) (5)
[0033] Where A4 represents the output after batch normalization, W3 represents the weight of the third fully connected layer, b3 represents the bias of the third fully connected layer, f represents the activation function, and A5 represents the output after the third fully connected layer.
[0034] In order to improve the training effect of deep networks, the encoding layer adopts a residual connection mechanism to add the input matrix X to the output A5 of the third fully connected layer:
[0035] A res =A5+X (6)
[0036] In the formula, A res represents the output features of the encoding layer after residual connection, and A5 represents the output of the third fully connected layer.
[0037] The feature information extracted from the coding layer is input into the Self-Attention layer. The Self-Attention layer optimizes the weight allocation according to the attention scores of each input and output element, and assigns probability weights to the extracted features. The Self-Attention layer calculates the attention score of each feature through the query, key, and value, and inputs the feature information A extracted from the coding layer into the Self-Attention layer. res The query Q, key K and value V are obtained through three different linear transformations, and the calculation formula is as follows:
[0038] Q=W Q A res (7)
[0039] K=W K A res (8)
[0040] V=W V A res (9)
[0041] Where W Q , W K , W V Denote the weight matrices of query, key, and value, respectively. res It represents the output features of the encoding layer after residual connection, Q, K, and V represent query, key, and value respectively.
[0042] Then, the dot product between the query Q and the key K is calculated to measure the similarity between different features. Divide it by To avoid the dot product value being too large, the attention weight α is calculated by the Softmax function ij , and its calculation formula is as follows:
[0043]
[0044] In the formula, α ij represents the attention weight, that is, the attention score between the i-th query and the j-th key, i and j represent the ordinal number of the feature, softmax represents the normalized exponential function, and d k represents the dimension of key K, Q i represents the query vector obtained by linear transformation of the i-th query, Represents the transpose of the key vector obtained by linear transformation of the j-th key.
[0045] According to the attention weight α ij The value V is weighted and summed to get the output of the Self-Attention layer, which is calculated as follows:
[0046]
[0047] In the formula, O i Represents the output of the i-th query after self-attention weight allocation.
[0048] The output after self-attention weight allocation is expressed as O = [O1, ...O i ,...O n ], where n represents the number of samples.
[0049] The deformable convolution layer extracts and learns the features of the output of the Self-Attention layer, and establishes a mapping relationship between the multi-dimensional input parameters and the prediction target to predict the output; compared with the ordinary convolution layer, the deformable convolution layer has an additional offset to adjust the position of the convolution kernel. Specifically, the convolution operation is no longer a fixed sampling, but a dynamic adjustment of the sampling position. The output of the first deformable convolution is calculated as follows:
[0050] y(p1)=DeformConv(O,Δp1) (12)
[0051] Where y(p1) represents the output of the first deformable convolution, DeformConv represents the deformable convolution operation, Δp1 represents the offset of the first deformable convolution layer, and O represents the output after self-attention weight allocation.
[0052] Next, the output y(p1) of the first deformable convolution is passed to the second deformable convolution layer, and the same convolution kernel and offset mechanism are used to further extract features. The output of the second deformable convolution is calculated as follows:
[0053] y(p2)=DeformConv(y(p1),Δp2) (13)
[0054] Where y(p2) represents the output of the second deformable convolution, DeformConv represents the deformable convolution operation, Δp2 represents the offset of the second deformable convolution layer, and y(p1) represents the output of the first deformable convolution.
[0055] The fourth and fifth fully connected layers are used to integrate the features after encoding, self-attention mechanism and deformable convolution processing, and map them to a lower-dimensional space, and finally output the element excess classification results.
[0056] The training of the heavy metal element excessive discrimination model based on EADC-Net includes the following steps:
[0057] Send the training set samples to the EADC-Net model for training to obtain a trained EADC-Net model;
[0058] The number of iterations in the training process is 100, the loss function is the cross entropy loss function, the model is optimized by the Adam optimizer, and the drop rate is set to 0.5. The size of the convolution kernel and the learning rate are optimized by the particle swarm algorithm.
[0059] The determination of excessive concentration of heavy metal elements and the completion of qualitative analysis of excessive concentration of heavy metal elements in the test sample include the following steps:
[0060] Send the test set samples to the trained EADC-Net model and output the over-standard discrimination results of the target elements;
[0061] Four evaluation indicators are used: Accuracy, Recall, Precision, and F1-score. Accuracy is one of the most direct performance metrics. It measures the proportion of correctly predicted samples among all samples, that is, the percentage of correctly predicted samples to the total number of samples. Precision indicates the proportion of positive samples among the instances predicted by the model, which helps evaluate the model's ability to avoid false positives. Recall indicates the proportion of positive samples successfully predicted by the model among all actual positive samples, which measures the model's ability to find all positive samples. F1-score, as the harmonic mean of precision and recall, provides a single performance indicator that balances the two. The calculation formulas for the above four indicators are as follows:
[0062]
[0063] Where TP refers to true positive (predicted to be positive and actually positive), TN refers to true negative (predicted to be negative and actually negative), FP refers to false positive (predicted to be positive but actually negative), and FN refers to false negative (predicted to be negative but actually positive).
[0064] Beneficial effects of the present invention: The present invention discloses a method for judging excessive heavy metal elements based on the EADC-Net model. The method combines XRF nondestructive testing technology with deep learning, and the encoder extracts local features and effectively captures the detailed information in the spectrum. Then, the Self-Attention mechanism is used to effectively focus on the most relevant feature area in the global range, thereby enhancing the model's ability to capture important information. Finally, the deformable convolution can adapt to complex spectral signal features and improve the model's ability to distinguish complex spectra, thereby achieving effective element excessive judgment decisions and improving the reliability and accuracy of qualitative analysis. The operation method of the present invention has the characteristics of nondestructiveness and high accuracy, and can solve the problems of overlapping interference of X-ray fluorescence energy spectrum peaks and low accuracy of traditional methods, which is of great significance for improving soil quality and protecting human health. The present invention is scientific and reasonable, with a simple process and low cost. It has the characteristics of nondestructiveness and high accuracy, and can solve the problems of overlapping interference of X-ray fluorescence energy spectrum peaks and low accuracy of traditional methods, and can effectively, quickly and accurately judge whether the concentration of heavy metal elements contained in the sample to be tested exceeds the standard. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] Figure 1 The present invention is a flow chart of a method for judging excessive heavy metal elements based on the EADC-Net model.
[0066] Figure 2 Schematic diagram of the EADC-Net structure in an embodiment of the present invention. DETAILED DESCRIPTION
[0067] The specific implementation manner and working principle of the present invention are further described in detail below with reference to the accompanying drawings.
[0068] This embodiment provides a method for judging excessive heavy metal elements based on the EADC-Net model. The workflow is as follows: Figure 1 As shown, the specific steps are as follows:
[0069] Step S1: determine the soil sample set, and use 57 national standard soil samples as samples to be tested, namely sample 1, sample 2, ..., sample 57. Take all elements that can be identified by the ED-XRF spectrometer to form the element set A contained in the soil sample, and finally obtain 57 element sets A1 to A57, that is, take the union of A1 to A57 to obtain the element set A with concentration in the soil sample set, and the element set A is the element library of elements 12 to 92 in the periodic table.
[0070] Step 2: Determine that the target element in this embodiment is lead (Pb), and use an XRF spectrometer to test 57 soil samples to obtain the peak intensity matrix X of the 57 samples and the target element concentration vector Y in the element set A.
[0071] Step 3: Divide the training set and the test set. Divide the 57 soil samples into training samples and test samples in a ratio of 7:3. The data corresponding to 40 samples are used as the training set, and the remaining 17 samples are used as the test set.
[0072] Step 3: Determine the input of the EADC-Net model, take the peak intensity matrix X of n samples to be tested as the input of the model, and input the spectrum peak intensity matrix with a matrix size of 57×2048.
[0073] Step 4: Determine the output of the EADC-Net model, compare the target element concentrations of the 57 samples to be tested with the Pb element risk screening value (90ppm), and mark the target element concentration vector Y. When the Pb element in the soil sample exceeds its risk screening value (90ppm), it means that there is a risk of heavy metal pollution of the Pb element in the soil, that is, the pollution risk is judged as "yes", and the target value is set to "0". When the Pb element in the soil sample does not exceed its risk screening value (90ppm), it means that there is no heavy metal pollution risk of the element in the soil, that is, the pollution risk is judged as "no", and the target value is set to "1", thereby obtaining the target element concentration exceeding the standard situation vector Z as the output of the model, and outputting the element concentration exceeding the standard situation vector with a matrix size of 57×1.
[0074] Step 6: Build EADC-Net, which mainly includes 1 encoder layer, 1 self-attention layer, 2 deformable convolution layers, and 2 fully connected layers, such as Figure 2 shown.
[0075] Step 7: The encoding layer is used to extract the spatial features of the input. The encoding layer is mainly composed of the first fully connected layer, the Dropout layer, the second fully connected layer, the batch normalization layer and the third fully connected layer, and is connected through residual connections to capture the effective feature information and nonlinear characteristics in the spectral sequence.
[0076] First, the input features are linearly transformed through the first fully connected layer, and an activation function is introduced to increase the nonlinear expression capability. The calculation formula of the first fully connected layer is as follows:
[0077] A1=f(W1·X+b1) (1)
[0078] Where A1 represents the output of the first fully connected layer, W1 represents the weight of the first fully connected layer, b1 represents the bias of the first fully connected layer, f represents the activation function, and X represents the peak intensity matrix.
[0079] Step 8: Pass the output of the fully connected layer through the Dropout layer to prevent overfitting. The generalization ability of the model is enhanced by randomly "discarding" a part of the neurons. The calculation formula is:
[0080] A2=Dropout(A1,p drop ) (2)
[0081] In the formula, Dropout represents the regularization operation, p drop represents the discard rate, A1 represents the output of the first fully connected layer, and A2 represents the output after regularization.
[0082] Step 9: The output after Dropout passes through the second fully connected layer to further extract feature information. The calculation formula is as follows:
[0083] A3=f(W2·A2+b2) (3)
[0084] Where A3 represents the output of the second fully connected layer, W2 represents the weight of the second fully connected layer, b2 represents the bias of the second fully connected layer, f represents the activation function, and A2 represents the output after regularization.
[0085] Step 10: The output of the second fully connected layer is batch normalized through the batch normalization layer. The calculation formula of batch normalization is as follows:
[0086] A4=BN(A3) (4)
[0087] Where A3 represents the output of the second fully connected layer, BN represents the batch normalization operation, and A4 represents the output after batch normalization.
[0088] Step 11: The normalized output is then passed to the third fully connected layer for further feature processing. The calculation formula is:
[0089] A5=f(W3·A4+b3) (5)
[0090] Where A4 represents the output after batch normalization, W3 represents the weight of the third fully connected layer, b3 represents the bias of the third fully connected layer, f represents the activation function, and A5 represents the output after the third fully connected layer.
[0091] Step 12: In order to improve the training effect of the deep network, the encoding layer adopts the residual connection mechanism to add the input matrix X to the output A5 after the third fully connected layer:
[0092] Ares =A5+X (6)
[0093] In the formula, A res It represents the output feature of the coding layer after residual connection, and A5 represents the output after the third fully connected layer.
[0094] Step 13: Input the feature information extracted from the coding layer into the Self-Attention layer. The Self-Attention layer optimizes the weight allocation according to the attention scores of each input and output element, and assigns probability weights to the extracted features. The Self-Attention layer calculates the attention score of each feature through the query, key, and value, and inputs the feature information A extracted from the coding layer into the Self-Attention layer. res The query Q, key K and value V are obtained through three different linear transformations, and the calculation formula is as follows:
[0095] Q=W Q A res (7)
[0096] K=W K A res (8)
[0097] V=W V A res (9)
[0098] Where W Q , W K , W V Denote the weight matrices of query, key, and value, respectively. res It represents the output features of the encoding layer after residual connection, Q, K, and V represent query, key, and value respectively.
[0099] Step 14: Calculate the dot product between the query Q and the key K to measure the similarity between different features. Divide it by To avoid the dot product value being too large, the attention weight α is calculated by the Softmax function ij , and its calculation formula is as follows:
[0100]
[0101] In the formula, α ij represents the attention weight, that is, the attention score between the i-th query and the j-th key, i and j represent the ordinal number of the feature, softmax represents the normalized exponential function, and d k represents the dimension of key K, Q i represents the query vector obtained by linear transformation of the i-th query, Represents the transpose of the key vector obtained by linear transformation of the j-th key.
[0102] Step 15: According to the attention weight α ij The value V is weighted and summed to get the output of the Self-Attention layer, which is calculated as follows:
[0103]
[0104] In the formula, O i Represents the output of the i-th query after self-attention weight allocation.
[0105] The output after self-attention weight allocation is expressed as O = [O1, ...O i ,...O n ], where n represents the number of samples.
[0106] Step 16: The deformable convolution layer extracts and learns the features of the output of the Self-Attention layer, and establishes a mapping relationship between the multi-dimensional input parameters and the prediction target to predict the output; compared with the ordinary convolution layer, the deformable convolution layer has an additional offset to adjust the position of the convolution kernel. Specifically, the convolution operation is no longer a fixed sampling, but a dynamic adjustment of the sampling position. The output of the first deformable convolution is calculated as follows:
[0107] y(p1)=DeformConv(O,Δp1) (12)
[0108] Where y(p1) represents the output of the first deformable convolution, DeformConv represents the deformable convolution operation, Δp1 represents the offset of the first deformable convolution layer, and O represents the output after self-attention weight allocation.
[0109] Step 17: Next, the output y(p1) of the first deformable convolution is passed to the second deformable convolution layer, and the same convolution kernel and offset mechanism are used to further extract features. The output of the second deformable convolution is calculated as follows:
[0110] y(p2)=DeformConv(y(p1),Δp2) (13)
[0111] Where y(p2) represents the output of the second deformable convolution, DeformConv represents the deformable convolution operation, Δp2 represents the offset of the second deformable convolution layer, and y(p1) represents the output of the first deformable convolution.
[0112] Step 18: Use the fourth and fifth fully connected layers to integrate the features after encoding, self-attention mechanism and deformable convolution, and map them to a lower-dimensional space, and finally output the element excess classification results.
[0113] Step 19: Send the training set samples to the EADC-Net model for training to obtain a trained EADC-Net model;
[0114] Step 20: Send the test set samples to the trained EADC-Net model and output the over-standard discrimination results of the target elements;
[0115] Step 21: Use four evaluation indicators: Accuracy, Recall, Precision, and F1-score. Accuracy is one of the most direct performance metrics. It measures the proportion of correctly predicted samples among all samples, that is, the percentage of correctly predicted samples to the total number of samples. Precision indicates the proportion of positive samples among the instances predicted by the model, which helps to evaluate the model's ability to avoid false positives. Recall indicates the proportion of positive samples successfully predicted by the model among all actual positive samples, which measures the model's ability to find all positive samples. F1-score, as the harmonic mean of precision and recall, provides a single performance indicator that balances the two. The calculation formulas for the above four indicators are as follows:
[0116]
[0117]
[0118] Where TP refers to true positive (predicted to be positive and actually positive), TN refers to true negative (predicted to be negative and actually negative), FP refers to false positive (predicted to be positive but actually negative), and FN refers to false negative (predicted to be negative but actually positive).
[0119] The traditional random forest (RF) method and the EADC-Net method described in the present invention are compared. The data uses 57 national standard soil samples, the target element is Pb, and the prediction results of the training set and the test set are shown in Table 1.
[0120] Table 1 Comparison of the results of heavy metal element concentration prediction
[0121]
[0122] Compared with the traditional random forest (RF) method, the heavy metal element excessive discrimination results based on EADC-Net have higher accuracy, precision, recall rate and F1-score, which means that the EADC-Net model has obvious advantages in qualitative discriminant analysis, effectively solves the problem of spectral line overlap, and improves the accuracy of element qualitative analysis results, which reflects the superiority of the method of the present invention.
[0123] The above description is only a specific implementation mode of the present invention. Any feature disclosed in this specification, unless otherwise stated, can be replaced by other alternative features that are equivalent or have similar purposes; all disclosed features, or all steps in the methods or processes, except for mutually exclusive features and / or steps, can be combined in any way; any non-essential additions and substitutions made by technicians in this field based on the technical features of the technical solution of the present invention belong to the protection scope of the present invention.
Claims
1. A method for judging excessive heavy metal elements based on the EADC-Net model, characterized in that: The method comprises the following steps: Step S1: obtaining a soil sample set, determining an element set and sample information based on the soil sample set, and identifying the spectrum peak intensity and element concentration of the sample to be tested in the soil sample set by using an XRF spectrometer; Step S2: constructing a heavy metal element excessive discrimination model based on EADC-Net, and determining the input and output of the heavy metal element excessive discrimination model of the EADC-Net; Step S3: training a heavy metal element excessive discrimination model based on EADC-Net; Step S4: Determination of excessive concentration of heavy metal elements, completing the qualitative analysis of excessive concentration of heavy metal elements in the test sample.
2. The method for determining excessive heavy metal elements based on the EADC-Net model according to claim 1, characterized in that: The step of obtaining a soil sample set and determining an element set and sample information based on the soil sample set comprises the following steps: Step S11: determining a sample set, wherein the sample set includes n samples to be tested, taking the union of all elements that can be identified by the XRF spectrometer to form an element set A contained in the n samples to be tested; Step S12: read in the peak intensity and element concentration of the spectrum, use the XRF spectrometer to test n samples to be tested, call a certain element that needs to be qualitatively analyzed the target element, and obtain the peak intensity matrix X of the n samples to be tested and the target element concentration vector Y in the element set A; Step S12: Divide the obtained n soil samples into training samples and test samples in a ratio of 7:3, the data corresponding to r training samples are used as the training set, and the remaining nr samples are used as the test set.
3. The method for determining excessive heavy metal elements based on the EADC-Net model according to claim 1, characterized in that: The construction of the EADC-Net model includes the following steps: Step S21: Determine the input of the EADC-Net model, and use the peak intensity matrix X of n samples to be tested as the input of the model; Step S22: Determine the output of the EADC-Net model, compare the target element concentration of n samples to be tested with the element risk screening value, and mark the target element concentration vector Y; when the element in the soil sample exceeds the risk screening value, it means that there is a heavy metal pollution risk of the element in the soil, that is, the pollution risk is judged as "yes", and the target value is set to "0"; when the element in the soil sample does not exceed the risk screening value, it means that there is no heavy metal pollution risk of the element in the soil, that is, the pollution risk is judged as "no", and the target value is set to "1", thereby obtaining the target element concentration exceeding the standard situation vector Z as the output of the model; Step S23: Building an EADC-Net model, which includes 1 encoding layer, 1 self-attention layer, 2 deformable convolutional layers, and 2 fully connected layers; Step S24: The output result after the deformable convolution layer is placed in the fully connected layer, and discrimination and classification are performed to obtain the excessive discrimination result of the target element concentration.
4. The method for determining excessive heavy metal elements based on the EADC-Net model according to claim 2, characterized in that: The encoding layer is used to extract the spatial features of the input. The encoding layer consists of a first fully connected layer, a Dropout layer, a second fully connected layer, a batch normalization layer, and a third fully connected layer, and is connected through residuals to capture effective feature information and nonlinear characteristics in the spectral sequence. First, the input features are linearly transformed through the first fully connected layer, and an activation function is introduced to increase the nonlinear expression ability; the calculation formula of the first fully connected layer is as follows: A1=f(W1·X+b1) (1) Where A1 represents the output of the first fully connected layer, W1 represents the weight of the first fully connected layer, b1 represents the bias of the first fully connected layer, f represents the activation function, and X represents the peak intensity matrix; Next, the output of the fully connected layer is passed through the Dropout layer to prevent overfitting; its calculation formula is: A2=Dropout(A1,p drop ) (2) In the formula, Dropout represents the regularization operation, p drop represents the discard rate, A1 represents the output of the first fully connected layer, and A2 represents the output after regularization; The output after Dropout passes through the second fully connected layer to further extract feature information. The calculation formula is as follows: A3=f(W2·A2+b2) (3) Where A3 represents the output of the second fully connected layer, W2 represents the weight of the second fully connected layer, b2 represents the bias of the second fully connected layer, f represents the activation function, and A2 represents the output after regularization; Then, the output of the second fully connected layer is batch normalized through the batch normalization layer. The calculation formula of batch normalization is as follows: A4=BN(A3) (4) Where A3 represents the output of the second fully connected layer, BN represents the batch normalization operation, and A4 represents the output after batch normalization; Next, the batch normalized output is passed to the third fully connected layer to further process the features. The calculation formula is: A5=f(W3·A4+b3) (5) Where A4 represents the output after batch normalization, W3 represents the weight of the third fully connected layer, b3 represents the bias of the third fully connected layer, f represents the activation function, and A5 represents the output after the third fully connected layer; The encoding layer uses a residual connection mechanism to add the input matrix X to the output A5 after the third fully connected layer: A res =A5+X (6) In the formula, A res represents the output features of the encoding layer after residual connection, and A5 represents the output of the third fully connected layer.
5. The method for determining excessive heavy metal elements based on the EADC-Net model according to claim 3, characterized in that: The feature information extracted from the encoding layer is input into the self-attention layer, and the self-attention layer optimizes the weight allocation according to the attention scores of each input and output element, and assigns probability weights to the extracted features; The self-attention layer calculates the attention score of each feature through the query, key and value parts, and converts the feature information A extracted by the encoding layer into res The query Q, key K and value V are obtained through three different linear transformations, and the calculation formula is as follows: Q=W Q A res (7) K=W K A res (8) V=W V A res (9) Where W Q , W K , W V Denote the weight matrices of query, key, and value, respectively. res represents the output features of the encoding layer after residual connection, Q, K, and V represent query, key, and value respectively; Then, the dot product between the query Q and the key K is calculated to measure the similarity between different features; it is divided by To avoid the dot product value being too large, the attention weight α is calculated by the softmax function ij , and its calculation formula is as follows: In the formula, α ij represents the attention weight, that is, the attention score between the i-th query and the j-th key, i and j represent the ordinal number of the feature, softmax represents the normalized exponential function, and d k represents the dimension of key K, Q i represents the query vector obtained by linear transformation of the i-th query, represents the transpose of the key vector obtained by linear transformation of the j-th key; According to the attention weight α ij The value V is weighted and summed to get the output of the self-attention layer, which is calculated as follows: In the formula, O i represents the output of the i-th query after self-attention weight allocation; The output after self-attention weight allocation is expressed as O = [O1, ...O i ,...O n ], where n represents the number of samples.
6. The method for determining excessive heavy metal elements based on the EADC-Net model according to claim 4, characterized in that: The deformable convolution layer extracts and learns the features of the output of the self-attention layer, and establishes a mapping relationship between the multi-dimensional input parameters and the prediction target to predict the output; the calculation formula of the first deformable convolution is as follows: y(p1)=DeformConv(O,Δp1) (12) Where y(p1) represents the output of the first deformable convolution, DeformConv represents the deformable convolution operation, and Δp1 represents the offset of the first deformable convolution layer; Next, the output y(p1) of the first deformable convolution is passed to the second deformable convolution. The calculation formula of the second deformable convolution is as follows: y(p2)=DeformConv(y(p1),Δp2) (13) Where y(p2) represents the output of the second deformable convolution, DeformConv represents the deformable convolution operation, Δp2 represents the offset of the second deformable convolution layer, and y(p1) represents the output of the first deformable convolution.
7. The method for determining excessive heavy metal elements based on the EADC-Net model according to claim 6, characterized in that: The fourth and fifth fully connected layers are used to integrate the features processed by the encoding layer, self-attention layer, and deformable convolution layer, and map them to a lower-dimensional space, and finally output the element excess classification results.
8. The method for determining excessive heavy metal elements based on the EADC-Net model according to claim 1, characterized in that: The training based on the EADC-Net model includes the following steps: Step S31: sending the training set samples into the EADC-Net model for training to obtain a trained EADC-Net model; Step S32: The number of iterations in the training process is 100, the loss function is the cross entropy loss function, the model is optimized by the Adam optimizer, and the drop rate is set to 0.5; the size of the convolution kernel and the learning rate are optimized by the particle swarm algorithm.
9. The method for determining excessive heavy metal elements based on the EADC-Net model according to claim 1, characterized in that: The heavy metal element concentration prediction analysis comprises the following steps: Step S41: sending the test set samples to the trained EADC-Net model and outputting the over-standard discrimination result of the target element; Step S42: using four evaluation indicators: accuracy, recall, precision and F1-score; the calculation formulas of the four indicators are as follows: Where TP refers to true positive, TN refers to true negative, FP refers to false positive, and FN refers to false negative.