XRF element quantitative analysis method based on GWO-BP
By using the Gray Wolf search algorithm to optimize the BP neural network in XRF element quantitative analysis, the complex relationship between element peak counting and content and interference problems are solved, the accuracy and stability of element quantitative analysis are improved, and more accurate element quantitative prediction is achieved.
Patent Information
- Application Number
- CN202210523685.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-13
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2042-05-13
AI Technical Summary
The existing XRF element quantitative analysis methods have complex relationships with element peak counting and content and many interferences, resulting in a decrease in detection accuracy, making it difficult to effectively conduct element quantitative analysis.
The backpropagation neural network (GWO-BP neural network) optimized based on the gray wolf search algorithm is adopted to improve the accuracy of element quantitative prediction by optimizing the initial weight and threshold of the BP neural network.
It improves the prediction accuracy and stability of element quantitative analysis, simplifies the operation process, can efficiently fit the complex relationship between element components and content, and significantly improves the accuracy of element quantitative prediction.
Smart Images

Figure CN115018045B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of X-ray fluorescence spectrum element detection, and in particular relates to an XRF element quantitative analysis method based on a GWO-BP neural network. Background Art
[0002] XRF spectroscopy (X-ray fluorescence spectroscopy) is a highly accurate, environmentally friendly, and non-destructive method for quantitative analysis of element content, making it popular in testing soil elements. However, due to the high complexity of the relationship between the peak counts of each element and its content and the mutual interference between elements, the detection accuracy is reduced, and an improved element quantitative analysis method is needed. Summary of the invention
[0003] In view of the problems existing in the above-mentioned prior art, the present invention proposes an XRF element quantitative analysis method based on GWO-BP neural network, which adopts the back propagation (BP) neural network algorithm optimized by the grey wolf search algorithm (GWO) to improve the accuracy of element quantitative prediction.
[0004] In order to achieve the above technical objectives, the technical solutions adopted by the present invention are as follows:
[0005] The XRF element quantitative analysis method based on the GWO-BP neural network includes the following steps:
[0006] Step 1: For n target samples, the peak value data and content data of the element to be measured, as well as the peak value data of m-1 interfering elements corresponding to the element to be measured are measured;
[0007] Step 2: Divide the test set and the training set. The data corresponding to the first k target samples are the training set, in which the peak data of the element to be tested and the peak data of the m-1 interfering elements corresponding to the element to be tested are the input of the training set, and the content data of the element to be tested is the output of the training set. The data corresponding to the last nk target samples are the test set, in which the peak data of the element to be tested and the peak data of the m-1 interfering elements corresponding to the element to be tested are the input of the test set, and the content data of the element to be tested is the output of the test set.
[0008] Step 3: Construct a BP neural network, including an input layer with a number of nodes, an output layer with b number of nodes, and a hidden layer with h number of nodes;
[0009] Step 4: Normalize the test set and training set data to the interval [-1, 1];
[0010] Step 5: Construct an initial gray wolf population matrix X consisting of U rows of gray wolf populations.
[0011]
[0012] Among them, dim = a·h+h+h·b+b, that is, each row of the gray wolf population includes a·h gray wolf individuals representing the weights of the connection between the input layer and the hidden layer, h gray wolf individuals representing the threshold of the hidden layer neurons, h·b gray wolf individuals representing the weights of the connection between the hidden layer and the output layer, and b gray wolf individuals representing the threshold of the output layer neurons; x uv ,u=1,...,U,v=1,...,dim is the gray wolf individual in the uth row and vth column in the initial gray wolf population matrix X, and its value is a random number between [0,1], 3≤q≤5;
[0013] Step 6: Use the gray wolf population in the uth row as the weight and threshold of the BP neural network, use the normalized training set to train the BP neural network, and obtain a BP neural network that has been preliminarily trained;
[0014] Step 7: Based on the GWO algorithm, perform N iterations on the initial gray wolf population matrix X and record the set F of fitness functions corresponding to each iteration; after N iterations, select the fitness function f with the lowest value in the set F of fitness functions. min , and use the corresponding row of gray wolf population as the weight and threshold of the BP neural network;
[0015] Step 8: Use the normalized training set to train the BP neural network obtained in step 7 to obtain the final trained BP neural network; based on the final trained BP neural network, predict the normalized test set to obtain and record the predicted value of the content of the element to be tested in the target sample of the nkth test set;
[0016] Step 9: Perform denormalization on the predicted values of the content of the elements to be measured in each target sample, compare them with the content data of the elements to be measured in the corresponding target sample, and calculate the determination coefficient R 2 ;
[0017]
[0018] Among them, y h is the content data of the element to be tested in the target sample of the hth test set; is the predicted value of the content of the element to be tested in the target sample of the hth test set after denormalization; It is the average value of the true value of the content of the element to be tested in all target samples of the test set;
[0019] Step 10: Denormalize the predicted values of the content of the elements to be tested in each target sample of the test set, compare them with the content data of the elements to be tested in the corresponding target samples, and calculate the determination coefficient R 2 :
[0020]
[0021] Among them, y h The content data of the elements to be tested in the target sample of the 14th test set; is the predicted value of the content of the element to be tested in the target sample of the hth test set after denormalization; It is the average value of the true value of the content of the element to be tested in all target samples of the test set.
[0022] Furthermore, in step 1, n>>m.
[0023] Furthermore, in step 2, k>nk.
[0024] Furthermore, in step 3, a=m, b=1, and h are determined by an empirical formula.
[0025] Furthermore, the empirical formula is as follows: Where c is a tuning constant ranging from 1 to 10.
[0026] Furthermore, in step 6, based on the BP neural network that has completed preliminary training, the element content corresponding to the normalized test set input is predicted, and the output prediction value is denormalized to obtain the difference between it and the test set output; the element content corresponding to the normalized training set input is predicted, and the output prediction value is denormalized to obtain the difference between it and the training set output; and then, the fitness function corresponding to the gray wolf population in the u-th row is calculated and the set F of fitness functions is obtained.
[0027] Furthermore, the fitness function is calculated as follows:
[0028] The gray wolf population in the uth row is used as the weight and threshold of the BP neural network, and the BP neural network is trained using the normalized training set to obtain a BP neural network that has been preliminarily trained.
[0029] Based on the BP neural network that has been initially trained, the element content corresponding to the normalized test set input is predicted, and the output prediction value is denormalized to s i ' u ,i=1,...,nk,u=1,...,U, get s i ' u ,i=1,...,nk,u=1,...,U and test set output y i ',i=1,...,nk difference y i '-s i ' u ,i=1,...,n,u=1,...,U; predict the element content corresponding to the normalized training set input, and the output prediction value is s after denormalization i ” u,i=1,...,k,u=1,...,U, get s i ” u ,i=1,...,k,u=1,...,U and the training set output y i ”,i=1,...,k difference y i ”-s i ” u ,i=1,...,k,u=1,...,U;
[0030] Then calculate the fitness function f u ,u=1,...,U:
[0031]
[0032] The set of fitness functions is:
[0033]
[0034] Furthermore, in step 7, N is not less than 10.
[0035] The beneficial effects of the present invention are:
[0036] The present invention proposes an XRF element quantitative analysis method based on a GWO-BP neural network. The initial weights and thresholds of the BP neural network are optimized by adopting a GWO algorithm, so that the optimized BP neural network can achieve better training effects during training, thereby improving prediction accuracy and stability. The present invention has a simple process and is easy to operate. The complex relationship between element component values and element contents can be efficiently fitted, and the elements contained in the object to be tested can be quantitatively predicted simply and effectively. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 The flowchart of the XRF element quantitative analysis method based on the GWO-BP neural network of the present invention;
[0038] Figure 2 This is a diagram of element content prediction results of Example 1 of the present invention;
[0039] Figure 3 This is the element content prediction result diagram of Comparative Example 1. DETAILED DESCRIPTION
[0040] In order to make the purpose, process and advantages of the present invention more clear, the present invention is further described in detail below in conjunction with the implementation modes and the accompanying drawings.
[0041] Example 1
[0042] like Figure 1As shown, the XRF element quantitative analysis method based on the GWO-BP neural network includes the following steps:
[0043] Step 1: Taking the prediction of Cu element as an example, n=59 national standard samples are used as target samples, and the peak data and content data of the element Cu to be measured in each target sample, as well as the peak data of the five interfering elements Fe, Ni, P, Co and Mn corresponding to the element Cu to be measured are measured by XRF fluorescence spectrometer.
[0044] Step 2: Divide the data into test set and training set. The data corresponding to the first 45 target samples are the training set, in which the peak data of the element to be tested and the peak data of the five interfering elements corresponding to the element to be tested are the input of the training set, and the content data of the element to be tested are the output of the training set. The data corresponding to the last 14 target samples are the test set, in which the peak data of the element to be tested and the peak data of the five interfering elements corresponding to the element to be tested are the input of the test set, and the content data of the element to be tested are the output of the test set.
[0045] Step 3: Construct a BP neural network in Matlab software, including an input layer with a node number a, an output layer with b node number and a hidden layer with h node number; since there is 1 element to be measured and 5 interference elements, the generated input layer is one layer, so the number of nodes in the input layer is a=6; the output layer is one layer, so the number of nodes in the output layer is b=1; the hidden layer is one layer, so the number of nodes in the hidden layer is h=8 according to the empirical formula.
[0046] Step 4: Normalize the data of the test set and training set to the interval [-1, 1].
[0047] Step 5: Generate the matrix:
[0048]
[0049] Among them, dim = a·h+h+h·b+b = 65, that is, each row of the gray wolf population includes a·h gray wolf individuals representing the weights of the connection between the input layer and the hidden layer, h gray wolf individuals representing the thresholds of the neurons in the hidden layer, h·b gray wolf individuals representing the weights of the connection between the hidden layer and the output layer, and b gray wolf individuals representing the thresholds of the neurons in the output layer; p uv ,u=1,...,U,U=30,v=1,...,dim,dim=65 is the gray wolf individual in the u-th row and v-th column in the initial gray wolf population matrix X, and its value is a random number between [-5,5].
[0050] Step 6: Use the gray wolf population in the uth row as the weight and threshold of the BP neural network, use the normalized training set to train the BP neural network, and obtain a BP neural network that has been preliminarily trained;
[0051] Based on the BP neural network that has been initially trained, the element content corresponding to the normalized test set input is predicted, and the output prediction value is denormalized to s i ' u ,i=1,...,nk,u=1,...,U, get s i ' u ,i=1,...,nk,u=1,...,U and test set output y i ',i=1,...,nk difference y i '-s i ' u ,i=1,...,n,u=1,...,U; predict the element content corresponding to the normalized training set input, and the output prediction value is s after denormalization i ” u ,i=1,...,k,u=1,...,U, get s i ” u ,i=1,...,k,u=1,...,U and the training set output y i ”,i=1,...,k difference y i ”-s i ” u ,i=1,...,k,u=1,...,U;
[0052] Then, calculate the fitness function f corresponding to the gray wolf population in row u u ,u=1,...,U:
[0053]
[0054] Get the set F of fitness functions:
[0055]
[0056] Step 7: Iterate the initial gray wolf population matrix X, specifically:
[0057] Select the fitness function f with the lowest value in the set F of fitness functions α , and take the corresponding row of gray wolf population as X t-1 α Population, t represents the current iteration number;
[0058] Select the fitness function f with the second lowest value in the set F of fitness functions β , and take the corresponding row of gray wolf population as X t-1 β Population, t represents the current iteration number;
[0059] Select the fitness function f with the third lowest value in the set F of fitness functions δ , and take the corresponding row of gray wolf population as X t-1 δ Population, t represents the current iteration number;
[0060] Iterate the initial gray wolf population matrix X and formula (4), (5), (6):
[0061]
[0062] Where t represents the current iteration number; is the gray wolf individual corresponding to the i-th row and j-th column at the t-th iteration. When t=1, is the gray wolf population corresponding to the i-th row and j-th column in the initial gray wolf population matrix X; A and C are coefficients, and the calculation formula is as follows:
[0063] Where a is the convergence factor, which decreases linearly from 2 to 0 as the number of iterations decreases, and r1 and r2 are random numbers between [0,1].
[0064] Step 8: Repeat step 7 until 30 iterations are reached, and record the set F of fitness functions corresponding to each iteration; after 30 iterations, select the fitness function f with the lowest value in the set F of fitness functions. min , and use the corresponding row of gray wolf population as the weight and threshold of the BP neural network.
[0065] Step 9: Use the normalized training set to train the BP neural network obtained in step 8 to obtain the final trained BP neural network; based on the final trained BP neural network, predict the normalized test set to obtain and record the predicted value of the content of the element to be tested in the target sample of the 14th test set.
[0066] Step 10: Denormalize the predicted values of the content of the elements to be tested in each target sample of the test set, compare them with the content data of the elements to be tested in the corresponding target samples, and calculate the determination coefficient R 2 :
[0067]
[0068] Among them, y h The content data of the elements to be tested in the target sample of the 14th test set; is the predicted value of the content of the element to be tested in the target sample of the hth test set after denormalization; It is the average value of the true value of the content of the element to be tested in all target samples of the test set.
[0069] The predicted results of soil Cu element obtained in this Example 1 are as follows Figure 2 As shown, R 2 It is 0.996.
[0070] Comparative Example 1
[0071] Only the BP neural network algorithm is used to predict the Cu element of the same soil sample to be tested. The prediction results are as follows Figure 3 As shown, R 2 It is 0.781.
[0072] contrast Figure 2 and Figure 3 , it can be seen that after the optimization of GWO algorithm, the accuracy and precision of prediction are improved, R 2 It can reach 0.996, which shows that the GWO-BP neural network algorithm effectively solves the problem of element interference, improves the accuracy of element quantitative analysis, and reflects the superiority of the method of the present invention.
[0073] 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 the disclosed features, or all the steps in the methods or processes, except for mutually exclusive features and / or steps, can be combined in any way.
Claims
1. XRF element quantitative analysis method based on GWO-BP neural network, characterized in that: The following steps are involved: Step 1: For n target samples, the peak value data and content data of the element to be measured, as well as the peak value data of m-1 interfering elements corresponding to the element to be measured are measured; Step 2: Divide the test set and the training set. The data corresponding to the first k target samples are the training set, in which the peak data of the element to be tested and the peak data of the m-1 interfering elements corresponding to the element to be tested are the input of the training set, and the content data of the element to be tested is the output of the training set. The data corresponding to the last nk target samples are the test set, in which the peak data of the element to be tested and the peak data of the m-1 interfering elements corresponding to the element to be tested are the input of the test set, and the content data of the element to be tested is the output of the test set. Step 3: Construct a BP neural network, including an input layer with a number of nodes, an output layer with b number of nodes, and a hidden layer with h number of nodes; Step 4: Normalize the test set and training set data to the interval [-1, 1]; Step 5: Construct an initial gray wolf population matrix X consisting of U rows of gray wolf populations. Among them, dim = a·h+h+h·b+b, that is, each row of the gray wolf population includes a·h gray wolf individuals representing the weights of the connection between the input layer and the hidden layer, h gray wolf individuals representing the threshold of the hidden layer neurons, h·b gray wolf individuals representing the weights of the connection between the hidden layer and the output layer, and b gray wolf individuals representing the threshold of the output layer neurons; x uv ,u=1,...,U,v=1,...,dim is the gray wolf individual in the uth row and vth column of the initial gray wolf population matrix X, and its value is a random number between [0,1], 3≤q≤5; Step 6: Use the gray wolf population in the uth row as the weight and threshold of the BP neural network, use the normalized training set to train the BP neural network, and obtain a BP neural network that has been preliminarily trained; Step 7: Based on the GWO algorithm, perform N iterations on the initial gray wolf population matrix X and record the set F of fitness functions corresponding to each iteration; after N iterations, select the fitness function f with the lowest value in the set F of fitness functions. min , and use the corresponding row of gray wolf population as the weight and threshold of the BP neural network; Step 8: Use the normalized training set to train the BP neural network obtained in step 7 to obtain the final trained BP neural network; based on the final trained BP neural network, predict the normalized test set to obtain and record the predicted value of the content of the element to be tested in the target sample of the nkth test set; Step 9: Perform denormalization on the predicted values of the content of the elements to be measured in each target sample, compare them with the content data of the elements to be measured in the corresponding target sample, and calculate the determination coefficient R 2 ; Among them, y h is the content data of the element to be tested in the target sample of the hth test set; is the predicted value of the content of the element to be tested in the target sample of the hth test set after denormalization; It is the average value of the true value of the content of the element to be tested in all target samples of the test set; Step 10: Denormalize the predicted values of the content of the elements to be tested in each target sample of the test set, compare them with the content data of the elements to be tested in the corresponding target samples, and calculate the determination coefficient R 2 : Among them, y h The content data of the elements to be tested in the target sample of the 14th test set; is the predicted value of the content of the element to be tested in the target sample of the hth test set after denormalization; It is the average value of the true value of the content of the element to be tested in all target samples of the test set.
2. The XRF element quantitative analysis method based on GWO-BP neural network according to claim 1 is characterized in that: In step 1, n>>m.
3. The XRF element quantitative analysis method based on GWO-BP neural network according to claim 1 is characterized in that: In step 2, k>nk.
4. The XRF element quantitative analysis method based on GWO-BP neural network according to claim 1 is characterized in that: In step 3, a=m, b=1, and h is determined by an empirical formula.
5. The XRF element quantitative analysis method based on GWO-BP neural network according to claim 4 is characterized in that: The empirical formula is as follows: Where c is a tuning constant ranging from 1 to 10.
6. The XRF element quantitative analysis method based on GWO-BP neural network according to claim 1 is characterized in that: In step 6, based on the BP neural network that has completed preliminary training, the element content corresponding to the normalized test set input is predicted, and the output prediction value is denormalized to obtain the difference between it and the test set output; the element content corresponding to the normalized training set input is predicted, and the output prediction value is denormalized to obtain the difference between it and the training set output; then, the fitness function corresponding to the gray wolf population in the u-th row is calculated and the set F of fitness functions is obtained.
7. The XRF element quantitative analysis method based on GWO-BP neural network according to claim 6 is characterized in that: The calculation method of the fitness function is: The gray wolf population in the uth row is used as the weight and threshold of the BP neural network, and the BP neural network is trained using the normalized training set to obtain a BP neural network that has been preliminarily trained. Based on the BP neural network that has been initially trained, the element content corresponding to the normalized test set input is predicted, and the output prediction value is denormalized to s i ' u ,i=1,...,nk,u=1,...,U, get s i ' u ,i=1,...,nk,u=1,...,U and test set output y i ',i=1,...,nk difference y i '-s i ' u ,i=1,...,n,u=1,...,U; predict the element content corresponding to the normalized training set input, and the output prediction value is s after denormalization i ” u ,i=1,...,k,u=1,...,U, get s i ” u ,i=1,...,k,u=1,...,U and the training set output y i ”,i=1,...,k difference y i ”-s i ” u ,i=1,...,k,u=1,...,U; Then calculate the fitness function f u ,u=1,...,U: The set of fitness functions is:
8. The XRF element quantitative analysis method based on GWO-BP neural network according to claim 1, characterized in that: In step 7, N is not less than 10.