Soil quantitative modeling method based on position coding, spectrum and neural network

The method addresses the lack of contextual band information in chemometric models by using trigonometric position coding and neural networks to enhance soil quantitative modeling accuracy and precision.

CN119230015APending Publication Date: 2024-12-31NORTHEASTERN UNIV CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411019194.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-29
Publication Date
2024-12-31

AI Technical Summary

Technical Problem

Existing chemometric models fail to effectively utilize the contextual information and relationship between different bands in spectral data, leading to suboptimal performance in soil quantitative modeling.

Method used

A soil quantitative modeling method based on position coding and neural networks, utilizing trigonometric position coding to encode spectral data, constructing a random vector functional link network with fusion matrices and angles based on spectral and content vectors, and improving the model with deep random vector function chains.

Benefits of technology

Enhances the performance of soil quantitative modeling by incorporating absolute position coding and spectral continuity, significantly improving model accuracy and precision.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119230015A_ABST
    Figure CN119230015A_ABST
Patent Text Reader

Abstract

The invention provides a soil quantitative modeling method based on position coding, a spectrum and a neural network, and relates to the technical field of chemometrics. The invention provides a trigonometric function type position coding method based on a spectrum matrix and a content vector, and four position coding methods based on the combination of a sample position sequence number or a sample content, and a wave band sequence number or a wave band value. The position relation of different wavebands is obtained based on spectral continuity, and the position relation of different samples is obtained based on content sorting; the fusion mode of the position matrix and the spectrum matrix comprises element-by-element addition, element-by-element multiplication and a rotary position coding mode; constructing a novel argument based on the absolute position code and the reflectivity or absorptivity, and taking the novel argument as the input of a random vector function chain neural network model; realizing position coding of a hidden layer and a neuron by using trigonometric function expression position coding based on a hidden layer sequence number and a neuron sequence number; according to the method, the model performance is remarkably improved by utilizing the continuity and position relation of the spectrum.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of chemometrics, and in particular to a soil quantitative modeling method based on position coding, spectrum and neural network. Background Art

[0002] Chemometrics includes spectral preprocessing, band selection, feature extraction, model building and other steps. Model building requires sufficient samples, and each sample contains content or category and corresponding spectrum. Spectra are used to indirectly obtain content or category. Spectra have different reflectance or absorbance values ​​in different bands, and the change of reflectance or absorbance is continuous with the increase of bands. The machine learning model inputs and infers the spectra of all bands at the same time, and regards the spectra belonging to the sequence data as independent features. This ignores the relationship between different bands and does not consider the band information, that is, the position information. There is a possibility that the reflectance or absorbance of different bands has the same value, and the reflectance or absorbance has different meanings for different bands. Therefore, introducing the contextual information of the band and considering the relationship between different bands are of great significance to improving the performance of the machine learning model.

[0003] Introducing the contextual information of the band and considering the relationship between different bands can reflect the characteristics of the spectrum as a sequence data through position encoding, and introduce the position relationship between different bands. Although a variety of position encoding methods have been developed in the field of natural language processing and applied to fields such as two-dimensional images, there are still challenges in how these methods can be applied to spectral data. Therefore, it is worth further study how to learn from the position encoding algorithm of natural language to realize the position encoding of the spectrum. Summary of the invention

[0004] The technical problem to be solved by the present invention is to address the deficiencies of the above-mentioned prior art and provide a soil quantitative modeling method based on position coding, spectrum and neural network, realize the application of absolute position coding in spectrum, construct a new type of angle based on absolute position coding and reflectivity or absorptivity, and realize position coding of hidden layers and neurons of deep random vector functional link network (dRVFL).

[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is:

[0006] A soil quantitative modeling method based on position coding, spectrum and neural network includes the following steps:

[0007] Step 1: obtain soil samples through field collection, and obtain a soil data set through spectral measurement and content test; the soil data set includes several soil samples, and each soil sample includes spectral data and content data;

[0008] Step 2: Based on the soil data set, the trigonometric position coding based on the spectral matrix and the content vector is used to obtain the position matrix through the spectral matrix. The fusion matrix based on the spectral matrix and the position matrix is ​​obtained by element-by-element addition, element-by-element multiplication, and rotation position coding. The soil quantitative model based on the random vector function chain neural network is constructed with the feature-processed fusion matrix as input. The evaluation indicators are the root mean square error RMSE and the determination coefficient R 2 ;

[0009] Step 3: The position matrix obtained by the spectral matrix is ​​encoded by trigonometric function based on the spectral matrix and the content vector, so as to obtain a new type of angle based on absolute position and reflectance or absorptivity. The soil quantitative model based on random vector function chain neural network is constructed with the new angle processed by features as input. The evaluation indicators are root mean square error RMSE and determination coefficient R 2 ;

[0010] Step 4: Improve the deep random vector function chain neural network with trigonometric position coding based on hidden layer number and neuron number and construct a soil quantitative model. The input variables can be the spectral matrix of step 2, the fusion matrix based on spectral matrix and position matrix of step 2, the angle based on band and reflectance or absorptivity of step 3, and the new angle of step 3. The evaluation indicators are root mean square error RMSE and determination coefficient R 2 ;

[0011] Step 5: Select the optimal soil quantitative model from the soil quantitative models obtained in steps 2, 3 and 4; the optimal soil quantitative model is the one with the smallest root mean square error RMSE of the test set and the coefficient of determination R of the test set. 2 The largest quantitative soil model.

[0012] Furthermore, in step 2 and step 3, the spectrum matrix has a single sample in each row, a single band in each column, the number of rows is the number of samples, the number of columns is the number of bands, and the elements are the spectrum data;

[0013] The position matrix has a single sample in each row, a single band in each column, the number of rows is the number of samples, the number of columns is the number of bands, and the elements are position data;

[0014] The feature processing method adopts partial least squares regression belonging to feature extraction;

[0015] In the random vector function chain neural network, the input weights and biases between the input layer and the hidden layer are randomly valued and kept fixed, the output weights from the hidden layer to the output layer are solved by the Moore-Penrose generalized inverse, and there is a direct link between the input layer and the output layer.

[0016] Furthermore, in step 2, the soil quantitative model based on the random vector function chain neural network is constructed by taking the feature-processed fusion matrix as input as follows:

[0017] Step A1: Set the model's operating environment and parameters;

[0018] Step A2: Processing the fusion matrix based on the spectrum matrix and the position matrix by a feature processing method;

[0019] Step A3: Use 10-fold cross validation to divide the feature-processed fusion matrix and soil content into training set and test set;

[0020] Step A4: perform maximum and minimum normalization on the fusion matrix and soil content after feature processing in the training set and the test set respectively;

[0021] Step A5: Use the normalized training set and test set to train and test the random vector function chain neural network. After 10 training processes with 10-fold cross validation, calculate the mean of the root mean square error RMSE of the training set and the coefficient of determination R of the training set. 2 The mean of the root mean square error RMSE of the test set and the coefficient of determination R of the test set are calculated after 10 tests of the 10-fold cross validation process. 2 The mean of , respectively, is used to obtain the completed model for training and testing.

[0022] Furthermore, in the step 2, the trigonometric position coding based on the spectral matrix and the content vector considering the content obtains four position coding methods based on the combination of the sample position number or the sample content, the band number or the band value through the ordered relationship of the band itself and the ordered relationship of the sample sorted based on the content, namely, the trigonometric position coding based on the sample position number and the band number, the trigonometric position coding based on the sample position number and the band value, the trigonometric position coding based on the sample content and the band number, and the trigonometric position coding based on the sample content and the band value; the content sorting is to sort the content from small to large;

[0023] The trigonometric position coding based on the sample position number and the band number is an application extension of the trigonometric position coding in chemometrics, and its position PE is:

[0024]

[0025] Among them, 2i represents the even-numbered band number, and 2i+1 represents the odd-numbered band number, where the band numbers are 1, 2, 3, ..., d band ;d bandis the number of bands; pos is the position number of the sample, pos = 1, 2, 3, ..., d sample ;d sample is the number of samples; sin is the sine function, cos is the cosine function;

[0026] The trigonometric position coding based on the sample position number and the band value is divided into two types; the first type is an improved version of the trigonometric position coding, and its position PE is:

[0027]

[0028] Among them, 2i represents the even-numbered band number, and 2i+1 represents the odd-numbered band number, where the band numbers are 1, 2, 3, ..., d band ;d band is the number of bands; pos is the position number of the sample, pos = 1, 2, 3, ..., d sample ;d sample is the number of samples; band max is the maximum value of the band value, band(2i) is the band value when the band number is an even number, and band(2i+1) is the band value when the band number is an odd number;

[0029] Method 2 takes into account the fact that the spectral resolution is sometimes not fixed, and more realistically represents the positional relationship between different bands. Its position PE is:

[0030]

[0031] Where I represents the band number, I = 1, 2, 3, ..., d band ;d band is the number of bands; band(I) represents the band value of band number I; 2j represents that the band value is an even number, and 2j+1 represents that the band value is an odd number; pos represents the position number of the sample, pos=1,2,3,…,d sample ;d sample is the number of samples; band max is the maximum value of the band; the above method 2 is limited to the case where the band value is an integer;

[0032] The trigonometric position encoding based on sample content and band number, its position PE is:

[0033]

[0034] Among them, Y pos is the content of the sample with position number pos;

[0035] The trigonometric position encoding based on sample content and band value is divided into two types; the first type is an improved version of the trigonometric position encoding, and its position PE is:

[0036]

[0037] Method 2 takes into account the fact that the spectral resolution is sometimes not fixed, and more realistically represents the positional relationship between different bands. Its position PE is:

[0038]

[0039] The above method 2 is limited to the case where the band value is an integer.

[0040] Furthermore, in step 2, the rotary position encoding method is specifically:

[0041] First, the trigonometric position encoding based on the spectral matrix and the content vector is calculated considering the content, and then the position matrix and the spectral matrix are fused by equation (13) or equation (14);

[0042]

[0043] Among them, RotaryX represents the fusion matrix based on the position matrix and the spectral matrix; d sample is the number of samples, d band is the number of bands; A n The dimension is d sample ×1 column vector and represents the nth band, n=1,2,3,...,d band ; Indicates the element-by-element multiplication of the matrix; 2i represents the even-numbered band number, 2i+1 represents the odd-numbered band number, where the band numbers are 1, 2, 3, ..., d band ; PE(2i) represents the position corresponding to the even number of the band number, and PE(2i+1) represents the position corresponding to the odd number of the band number, which is obtained by trigonometric position coding based on the spectral matrix and the content vector taking into account the content;

[0044] The rotational position encoding method of the second method based on the trigonometric function position encoding of the spectral matrix and the content vector considering the content is not applicable to formula (13), and its rotational position encoding method is formula (14);

[0045]

[0046] Among them, 2j indicates that the band value is an even number, and 2j+1 indicates that the band value is an odd number; PE(2j) indicates the position corresponding to the band value being an even number, and PE(2j+1) indicates the position corresponding to the band value being an odd number, which is obtained by a trigonometric position encoding method based on the spectral matrix and the content vector taking into account the content.

[0047] Furthermore, in step 3, the soil quantitative model based on the random vector function chain neural network is constructed by taking the feature-processed new angle as input:

[0048] Step B1: Set the model's operating environment and parameters;

[0049] Step B2: Processing the new type of argument by feature processing method;

[0050] Step B3: Use 10-fold cross validation to divide the new radiation angle and soil content after feature processing into training set and test set;

[0051] Step B4: perform maximum and minimum normalization on the new angles and soil contents after feature processing in the training set and the test set respectively;

[0052] Step B5: Use the normalized training set and test set to train and test the random vector function chain neural network. After 10 training processes with 10-fold cross validation, calculate the mean of the root mean square error RMSE of the training set and the coefficient of determination R of the training set. 2 The mean of the root mean square error RMSE of the test set and the coefficient of determination R of the test set are calculated after 10 tests of the 10-fold cross validation process. 2 The mean of , respectively, is used to obtain the completed model for training and testing.

[0053] Furthermore, the deep random vector function chain neural network in step 4 is a deep structure of a random vector function chain neural network, the input weights and biases between the input layer and the hidden layer are randomly taken and kept fixed, the weights and biases between different hidden layers are randomly taken and kept fixed, the input features are concatenated with the output features of all hidden layers, the output weights are solved by the Moore-Penrose generalized inverse, and the number of neurons in different hidden layers is the same.

[0054] Furthermore, in step 4, the trigonometric function position encoding based on the hidden layer number and the neuron number is specifically:

[0055] Drawing on the spectral matrix composed of samples and bands, a matrix composed of hidden layers and neurons is constructed to realize the position association between different neurons in different hidden layers. Since the number of hidden layers and neurons is an integer value, the trigonometric function position encoding based on the hidden layer number and the neuron number is adopted, and its position PE is:

[0056]

[0057] Among them, 2m represents an even-numbered neuron number, and 2m+1 represents an odd-numbered neuron number, where the neuron numbers are 1, 2, 3, ..., d neuron ;d neuron is the number of neurons; L is the position number of the hidden layer, L = 1, 2, 3, ..., d layer ;d layer is the number of hidden layers; sin is the sine function, and cos is the cosine function.

[0058] Furthermore, in step 4, the soil quantitative model constructed by improving the deep random vector function chain neural network using trigonometric position coding based on hidden layer number and neuron number is specifically:

[0059] Step C1: Set the model's operating environment and parameters;

[0060] Step C2: processing input variables by a feature processing method; the feature processing method adopts partial least squares regression belonging to feature extraction; the input variables are the spectral matrix of step 2, the fusion matrix based on the spectral matrix and the position matrix of step 2, the angle based on the band and the reflectivity or absorptivity of step 3, and the new angle of step 3;

[0061] Step C3: Use 10-fold cross validation to divide the input variables and soil content after feature processing into training set and test set;

[0062] Step C4: perform maximum and minimum normalization on the input variables and soil contents after feature processing in the training set and the test set respectively;

[0063] Step C5: Use the normalized training set and test set to train and test the deep random vector function chain neural network. After 10 training processes with 10-fold cross validation, calculate the mean of the root mean square error RMSE of the training set and the coefficient of determination R of the training set. 2 The mean of the root mean square error RMSE of the test set and the coefficient of determination R of the test set are calculated after 10 tests of the 10-fold cross validation process. 2 The mean of , respectively, is used to obtain the completed model for training and testing.

[0064] The beneficial effects of adopting the above technical scheme are: the soil quantitative modeling method based on position coding, spectrum and neural network provided by the present invention proposes trigonometric position coding based on spectral matrix and content vector, applies absolute position coding to spectroscopy, obtains four position coding methods based on the combination of sample position number or sample content, band number or band value, the position relationship of different bands is obtained based on spectral continuity and the position relationship of different samples is obtained based on content sorting; the fusion method of position matrix and spectral matrix includes element-by-element addition, element-by-element multiplication and rotation position coding method; the present invention constructs a new type of angle based on absolute position coding and reflectivity or absorbance as the input of random vector function chain neural network model; the present invention realizes the position coding of hidden layer and neuron by using trigonometric position coding based on hidden layer number and neuron number; the present invention significantly improves the model performance by utilizing the continuity and position relationship of the spectrum. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] Figure 1 A flow chart of a soil quantitative modeling method based on position coding, spectrum and neural network provided in an embodiment of the present invention;

[0066] Figure 2 The spectrum matrix of the Chinese soil spectrum library provided by the embodiment of the present invention; wherein, Figure (2a) is an unsorted spectrum matrix based on content; Figure (2b) is a spectrum matrix sorted from small to large based on content;

[0067] Figure 3 The present invention provides a position matrix of four position coding methods based on trigonometric position coding of spectral matrix and content vector which are applied to the Chinese soil spectral library considering content. Among them, Figure (3a) is a position matrix of trigonometric position coding based on sample position number and band number; Figure (3b) is a position matrix of trigonometric position coding based on sample position number and band value and method one; Figure (3c) is a position matrix of trigonometric position coding based on sample position number and band value and method two; Figure (3d) is a position matrix of trigonometric position coding based on sample content and band number; Figure (3e) is a position matrix of trigonometric position coding based on sample content and band value and method one; Figure (3f) is a position matrix of trigonometric position coding based on sample content and band value and method two. DETAILED DESCRIPTION

[0068] The specific implementation of the present invention is further described in detail below in conjunction with the accompanying drawings and examples. The following examples are used to illustrate the present invention, but are not intended to limit the scope of the present invention.

[0069] The present invention adopts trigonometric position coding (Sinusoidal position coding) based on spectral matrix and content vector taking into account the content to obtain the position matrix through the spectral matrix, and uses element-by-element addition, element-by-element multiplication, and rotation position coding to obtain the fusion matrix of the two, which is used as input to construct a soil quantitative model; a new type of radiation angle based on the position matrix and reflectivity or absorptivity is used as input to construct a soil quantitative model; the model is a random vector function chain neural network; trigonometric position coding (Sinusoidal position coding) based on hidden layer sequence number and neuron sequence number is used to improve the deep random vector function chain neural network and construct a soil quantitative model. The present invention realizes the application of absolute position coding in the spectrum, constructs a new type of radiation angle, and realizes the position coding of the hidden layer and neurons of the deep random vector function chain neural network. Figure 1 As shown, the method of this embodiment is described as follows.

[0070] Step 1: obtain soil samples through field collection, and obtain a soil data set through spectral measurement and content test; the soil data set includes several soil samples, and each soil sample includes spectral data and content data.

[0071] This embodiment uses the Chinese Soil Spectral Library (CSSL) as the soil dataset; CSSL contains 1581 soil samples, and the soil organic matter content is obtained by potassium dichromate volumetric method-external heating method, and the spectral data is obtained by FieldSpec Pro FR spectrometer; the processed spectrum ranges from 400nm to 2450nm, the spectral resolution is 1nm, and the number of bands is 2051.

[0072] Step 2: Based on the soil data set, the position matrix is ​​obtained through the spectral matrix by using the trigonometric position coding based on the spectral matrix and the content vector (Sinusoidal position coding) that takes into account the content. The fusion matrix based on the spectral matrix and the position matrix is ​​obtained by element-by-element addition, element-by-element multiplication, and rotation position coding. The fusion matrix after feature processing is used as input to construct a soil quantitative model based on the random vector functional link network (RVFL). The evaluation indicators are the root mean squared error (RMSE) and the coefficient of determination (R 2 ).

[0073] The spectrum matrix has a single sample in each row, a single band in each column, the number of rows is the number of samples, the number of columns is the number of bands, and the elements are the spectrum data;

[0074] The position matrix has a single sample in each row, a single band in each column, the number of rows is the number of samples, the number of columns is the number of bands, and the elements are position data;

[0075] The feature processing method adopts partial least squares regression (PLSR) belonging to feature extraction;

[0076] In the random vector function chain neural network, the input weights and biases between the input layer and the hidden layer are randomly valued and kept fixed, the output weights from the hidden layer to the output layer are solved by the Moore-Penrose generalized inverse, and there is a direct link between the input layer and the output layer.

[0077] The trigonometric position coding (Sinusoidal position coding) based on the spectral matrix and the content vector considering the content obtains four position coding methods based on the combination of the sample position number or the sample content, the band number or the band value through the ordered relationship of the band itself and the ordered relationship of the sample sorted based on the content, namely, trigonometric position coding (Sinusoidal position coding) based on the sample position number and the band number, trigonometric position coding (Sinusoidal position coding) based on the sample position number and the band value, trigonometric position coding (Sinusoidal position coding) based on the sample content and the band number, and trigonometric position coding (Sinusoidal position coding) based on the sample content and the band value. The content sorting is to sort the content from small to large.

[0078] The trigonometric position coding (Sinusoidal position coding) based on the sample position number and the band number is an application extension of the trigonometric position coding (Sinusoidal position coding) in chemometrics, and its position PE is:

[0079]

[0080] Among them, 2i represents the even-numbered band number, and 2i+1 represents the odd-numbered band number, where the band numbers are 1, 2, 3, ..., d band ;d band is the number of bands; pos is the position number of the sample, pos = 1, 2, 3, ..., d sample ;d sample is the number of samples; sin is the sine function, and cos is the cosine function.

[0081] The trigonometric position coding (Sinusoidal position coding) based on the sample position number and the band value is divided into two types; the first type is an improved version of the trigonometric position coding (Sinusoidal position coding), and its position PE is:

[0082]

[0083] Among them, 2i represents the even-numbered band number, and 2i+1 represents the odd-numbered band number, where the band numbers are 1, 2, 3, ..., d band ;d band is the number of bands; pos is the position number of the sample, pos = 1, 2, 3, ..., d sample ;d sample is the number of samples; band max is the maximum value of the band value, band(2i) is the band value when the band number is an even number, and band(2i+1) is the band value when the band number is an odd number.

[0084] Method 2 takes into account the fact that the spectral resolution is sometimes not fixed, and more realistically represents the positional relationship between different bands. Its position PE is:

[0085]

[0086] Where I represents the band number, I = 1, 2, 3, ..., d band ;d band is the number of bands; band(I) represents the band value of band number I; 2j represents that the band value is an even number, and 2j+1 represents that the band value is an odd number; pos represents the position number of the sample, pos=1,2,3,…,d sample ;d sample is the number of samples; band max is the maximum value of the band; the above method 2 is limited to the case where the band value is an integer.

[0087] The trigonometric position coding (Sinusoidal position coding) based on sample content and band number is specifically: the difference between the contents of different samples is not the same, and the position relationship between different contents is more realistically shown as follows, using an improved version of trigonometric position coding (Sinusoidal position coding); the contents have the same value, which leads to the position coding method introducing the content having the same value; its position PE is:

[0088]

[0089] Among them, Y pos is the content of the sample at position number pos.

[0090] The trigonometric position coding (Sinusoidal position coding) based on sample content and band value is similar to the trigonometric position coding (Sinusoidal position coding) based on sample position sequence number and band value, and is divided into two types, specifically:

[0091] Method 1 is an improved version of the trigonometric position encoding (Sinusoidal position encoding), and its position PE is:

[0092]

[0093] Method 2 takes into account the fact that the spectral resolution is sometimes not fixed, and more realistically represents the positional relationship between different bands. Its position PE is:

[0094]

[0095] The above method 2 is limited to the case where the band value is an integer.

[0096] The rotary position encoding method is specifically:

[0097] The rotational position coding method is a variant of the multiplicative position coding. First, the trigonometric position coding (Sinusoidal position coding) based on the spectral matrix and the content vector is calculated, and then the position matrix and the spectral matrix are fused through equation (13) or (14).

[0098]

[0099] Among them, RotaryX represents the fusion matrix based on the position matrix and the spectral matrix; d sample is the number of samples, d band is the number of bands; A n The dimension is d sample ×1 column vector and represents the nth band, n=1,2,3,...,d band ; Indicates the element-by-element multiplication of the matrix; 2i represents the even-numbered band number, 2i+1 represents the odd-numbered band number, where the band numbers are 1, 2, 3, ..., d band ; PE(2i) represents the position corresponding to the even number of the band number, and PE(2i+1) represents the position corresponding to the odd number of the band number, which is obtained by the trigonometric position coding (Sinusoidal position coding) based on the spectral matrix and the content vector taking into account the content.

[0100] The second method of the rotational position coding method based on the trigonometric position coding of the spectral matrix and the content vector (Sinusoidal position coding) considering the content is not applicable to formula (13), and its rotational position coding method is formula (14);

[0101]

[0102] Among them, 2j indicates that the band value is an even number, and 2j+1 indicates that the band value is an odd number; PE(2j) indicates the position corresponding to the band value being an even number, and PE(2j+1) indicates the position corresponding to the band value being an odd number, which is obtained by a trigonometric position coding (Sinusoidal position coding) method based on the spectral matrix and the content vector taking into account the content.

[0103] The soil quantitative model based on random vector function chain neural network is constructed by taking the feature-processed fusion matrix as input as follows:

[0104] Step A1: Set the model's operating environment and parameters;

[0105] As for the operating environment, the software of this embodiment uses PyCharm, the operating system uses Windows 10, and the running processor uses Intel(R) Core(TM) i5-8400 CPU@2.80GHz 2.81GHz.

[0106] The parameters of the random vector function chain neural network are set as follows: the input weight adopts a random value with a uniform distribution and a range of [-1, 1), the bias adopts a random value with a uniform distribution and a range of [0, 1), the activation function adopts the sigmoid function, the model adds ridge regression to prevent overfitting, and the inverse of the regularization parameter adopts a random value with a uniform distribution and a range of [0, 1), and the number of hidden layer nodes is selected as 150 based on experience.

[0107] Step A2: Processing the fusion matrix based on the spectrum matrix and the position matrix by a feature processing method; the feature processing method adopts partial least squares regression (PLSR) belonging to feature extraction.

[0108] Step A3: Use 10-fold cross validation to divide the feature-processed fusion matrix and soil content into training set and test set.

[0109] Step A4: perform maximum and minimum normalization on the fusion matrix and soil content after feature processing in the training set and the test set respectively;

[0110] In this embodiment, after maximum and minimum normalization, the fusion matrix and soil content after feature processing are both within the range of [-1, 1].

[0111] Step A5: Use the normalized training set and test set to train and test the random vector function chain neural network. After 10 training processes with 10-fold cross validation, calculate the mean of the root mean square error RMSE of the training set and the coefficient of determination R of the training set. 2 The mean of the root mean square error RMSE of the test set and the coefficient of determination R of the test set are calculated after 10 tests of the 10-fold cross validation process. 2 The mean of , respectively, is used to obtain the completed model for training and testing.

[0112] In this embodiment, the number of input variables based on PLSR is selected as 500 according to manual experience;

[0113] In this embodiment, the spectrum matrix is ​​as follows: Figure 2 As shown, the position matrices of the four position encoding methods based on the trigonometric position encoding of the spectral matrix and the content vector (Sinusoidal position encoding) are as follows: Figure 3 shown.

[0114] In this embodiment, the model results are shown in Table 1, which shows the performance of the soil quantitative model based on the random vector function chain neural network constructed with the feature-processed fusion matrix as input, and the results are expressed as the mean ± overall standard deviation of 10-fold cross validation. The random vector function chain neural network model with the spectral matrix processed by PLSR as input is used as a comparison model. Except for the different input variables, the other settings are the same as the soil quantitative model based on the random vector function chain neural network constructed with the feature-processed fusion matrix as input.

[0115] Table 1 Model results of step 2

[0116]

[0117]

[0118] In Table 1, addition refers to the element-by-element addition of the position matrix and the spectral matrix; multiplication refers to the element-by-element multiplication of the position matrix and the spectral matrix; RoPE refers to the rotational position encoding method.

[0119] Compared with the comparison model, this method significantly improves the model performance.

[0120] For the element-by-element addition method, the sample position number has a better effect than the sample content. When used in combination with the sample content, the band value has a better effect than the band number. When used in combination with the sample position number, the band number has a better effect than the band value.

[0121] For the element-by-element multiplication method and RoPE, the band value works better than the band number, but the performance is worse than the element-by-element addition method.

[0122] The performance of models based on RoPE is generally worse than that of models based on element-wise multiplication methods.

[0123] The optimal model is the trigonometric position coding (Sinusoidal position coding) based on the sample position number and the band number using the element-by-element addition method.

[0124] Step 3: The position matrix obtained by the spectral matrix is ​​obtained by using the sinusoidal position coding based on the spectral matrix and the content vector, so as to obtain a new type of angle based on absolute position and reflectance or absorptivity. The soil quantitative model based on the random vector functional link network (RVFL) is constructed with the new angle processed by features as input. The evaluation indicators are the root mean squared error (RMSE) and the coefficient of determination (R 2 ).

[0125] The content-considered trigonometric position encoding (Sinusoidal position encoding) based on the spectral matrix and the content vector has been described in detail in step 2.

[0126] The spectrum matrix has a single sample in each row, a single band in each column, the number of rows is the number of samples, the number of columns is the number of bands, and the elements are the spectrum data;

[0127] The position matrix has a single sample in each row, a single band in each column, the number of rows is the number of samples, the number of columns is the number of bands, and the elements are position data;

[0128] The feature processing method adopts partial least squares regression (PLSR) which belongs to feature extraction.

[0129] In the random vector function chain neural network, the input weights and biases between the input layer and the hidden layer are randomly valued and kept fixed, the output weights from the hidden layer to the output layer are solved by the Moore-Penrose generalized inverse, and there is a direct link between the input layer and the output layer.

[0130] The soil quantitative model based on random vector function chain neural network is constructed by taking the feature-processed new angle as input as follows:

[0131] Step B1: Set the model's operating environment and parameters;

[0132] For the operating environment, the software of this embodiment uses PyCharm, the operating system uses Windows 10, and the processor used is Intel(R) Core(TM) i5-8400 CPU@2.80GHz 2.81GHz;

[0133] The parameters of the random vector function chain neural network are set as follows: the input weight uses a random value with a uniform distribution and a range of [-1, 1), the bias uses a random value with a uniform distribution and a range of [0, 1), the activation function uses the sigmoid function, the model adds ridge regression to prevent overfitting, and the inverse of the regularization parameter uses a random value with a uniform distribution and a range of [0, 1), and the number of hidden layer nodes is selected as 150 based on experience;

[0134] Step B2: Processing the new type of angle by a feature processing method; the feature processing method adopts partial least squares regression (PLSR) belonging to feature extraction;

[0135] Step B3: Use 10-fold cross validation to divide the new radiation angle and soil content after feature processing into training set and test set;

[0136] Step B4: perform maximum and minimum normalization on the new angles and soil contents after feature processing in the training set and the test set respectively;

[0137] In this embodiment, after maximum and minimum normalization, the new type of angle and soil content after feature processing are within the range [-1,1];

[0138] Step B5: Use the normalized training set and test set to train and test the random vector function chain neural network. After 10 training processes with 10-fold cross validation, calculate the mean of the root mean square error RMSE of the training set and the coefficient of determination R of the training set. 2 The mean of the root mean square error RMSE of the test set and the coefficient of determination R of the test set are calculated after 10 tests of the 10-fold cross validation process. 2 The mean of , respectively, is used to obtain the completed model for training and testing.

[0139] The number of input variables based on PLSR in this embodiment is selected as 500 according to manual experience. The model results are shown in Table 2. The performance of the soil quantitative model based on the random vector function chain neural network is constructed with the new type of radiation angle processed by the feature as input. The results are expressed as the mean ± overall standard deviation of 10-fold cross validation. The random vector function chain neural network model with the spectral matrix processed by PLSR as input is used as a comparison model. Except for the different input variables, the other settings are the same as the soil quantitative model based on the random vector function chain neural network constructed with the fusion matrix processed by the feature as input; the random vector function chain neural network model with the radiation angle based on band and reflectance processed by PLSR as input is used as a comparison model. Except for the different input variables, the other settings are the same as the soil quantitative model based on the random vector function chain neural network constructed with the fusion matrix processed by the feature as input.

[0140] Table 2 Model results of step 3

[0141]

[0142]

[0143] In Table 2, ordered means that the ordered relationship between samples is constructed by sorting the content, that is, from small to large; unordered means that the ordered relationship between samples is not constructed by sorting the content.

[0144] Compared with the comparison model, in addition to the trigonometric position coding (Sinusoidal position coding) based on sample content and band value, the method of this embodiment significantly improves the model performance, which shows that adding appropriate position information is beneficial to improving the performance of the model with the angle as input.

[0145] Step 4: Sinusoidal position coding based on hidden layer number and neuron number is used to improve the deep random vector functional link network (dRVFL) and build a soil quantitative model. The input variables can be the spectral matrix of step 2, the fusion matrix based on spectral matrix and position matrix of step 2, the angle based on band and reflectance or absorptivity of step 3, and the new angle of step 3. The evaluation indicators are root mean squared error (RMSE) and coefficient of determination (R 2 ).

[0146] The deep random vector function chain neural network is a deep structure of a random vector function chain neural network. The input weights and biases between the input layer and the hidden layer are randomly taken and kept fixed, the weights and biases between different hidden layers are randomly taken and kept fixed, the input features are spliced ​​with the output features of all hidden layers, the output weights are solved by the Moore-Penrose generalized inverse, and the number of neurons in different hidden layers is the same.

[0147] The trigonometric position coding (Sinusoidal position coding) based on the hidden layer number and the neuron number is specifically:

[0148] Drawing on the spectral matrix composed of samples and bands, a matrix composed of hidden layers and neurons is constructed to realize the position association between different neurons in different hidden layers. Since the number of hidden layers and neurons is an integer value, the trigonometric position coding (Sinusoidal position coding) based on the hidden layer number and neuron number is adopted, and its position PE is:

[0149]

[0150] Among them, 2m represents an even-numbered neuron number, and 2m+1 represents an odd-numbered neuron number, where the neuron numbers are 1, 2, 3, ..., d neuron ;d neuron is the number of neurons; L is the position number of the hidden layer, L = 1, 2, 3, ..., d layer ;d layer is the number of hidden layers; sin is the sine function, and cos is the cosine function.

[0151] The soil quantitative model constructed by improving the deep random vector function chain neural network (dRVFL based on position coding) by using the trigonometric position coding (Sinusoidal position coding) based on the hidden layer number and the neuron number is specifically as follows:

[0152] Step C1: Set the model's operating environment and parameters;

[0153] For the operating environment, the software of this embodiment uses PyCharm, the operating system uses Windows 10, and the processor used is Intel(R) Core(TM) i5-8400 CPU@2.80GHz 2.81GHz;

[0154] The parameters of the deep random vector function chain neural network are set as follows: the input weights between the input layer and the first hidden layer, the weights between different hidden layers use uniformly distributed random values ​​in the interval [-1, 1), the biases of different hidden layers use uniformly distributed random values ​​in the interval [0, 1), the activation function uses the sigmoid function, the model adds ridge regression to prevent overfitting, and the inverse of the regularization parameter uses uniformly distributed random values ​​in the interval [0, 1), the number of hidden layer nodes is selected as 100 based on experience, and the number of hidden layers is 10;

[0155] Step C2: processing input variables by a feature processing method; the feature processing method adopts partial least squares regression (PLSR) belonging to feature extraction; the input variables are the spectral matrix (reflectance or absorptivity) of step 2, the fusion matrix based on the spectral matrix and the position matrix of step 2, the angle based on the band and the reflectance or absorptivity of step 3, and the new angle of step 3;

[0156] Step C3: Use 10-fold cross validation to divide the input variables and soil content after feature processing into training set and test set;

[0157] Step C4: perform maximum and minimum normalization on the input variables and soil contents after feature processing in the training set and the test set respectively;

[0158] In this embodiment, after maximum and minimum normalization, the input variables and soil contents after feature processing are within the range [-1,1];

[0159] Step C5: Use the normalized training set and test set to train and test the deep random vector function chain neural network. After 10 training processes with 10-fold cross validation, calculate the mean of the root mean square error RMSE of the training set and the coefficient of determination R of the training set. 2 The mean of the root mean square error RMSE of the test set and the coefficient of determination R of the test set are calculated after 10 tests of the 10-fold cross validation process. 2 The mean of , respectively, is used to obtain the completed model for training and testing.

[0160] In this embodiment, the number of input variables based on PLSR is selected as 500 according to manual experience; the element-by-element addition of the hidden layer output feature and the position is selected as the new hidden layer output feature; the model results are shown in Table 3, and the performance of the soil quantitative model constructed by improving the deep random vector function chain neural network by using trigonometric position coding (Sinusoidal position coding) based on the hidden layer number and the neuron number is shown in Table 3. The results are expressed as the mean ± overall standard deviation of 10-fold cross validation.

[0161] A related model based on dRVFL, namely the Ensemble deep random vector functional link network (edRVFL), is added. When adding a hidden layer, the random vector function chain neural network method, namely the Moore-Penrose generalized inverse, is used to solve the output weights between a hidden layer and the output layer and obtain the output of the output layer. Then, an improved deep ensemble random vector function chain neural network (edRVFL based on position coding) using trigonometric position coding (Sinusoidal position coding) based on the hidden layer number and the neuron number is obtained.

[0162] Due to the random values ​​of weights and biases, the model performance of deep random vector function chain neural network is similar to that of random vector function chain neural network;

[0163] The fusion matrix or new radiation angle based on the spectral matrix and the position matrix can further improve the performance in the deep random vector function chain neural network with deep structure;

[0164] Position encoding based on hidden layers and neurons can improve the performance of deep random vector function chain neural network models;

[0165] The band-and-reflectance-based argumen- tation is more helpful in improving the model performance than the spectral matrix (reflectance);

[0166] The deep integrated random vector function chain neural network is an improvement of the deep random vector function chain neural network. The position encoding based on hidden layers and neurons is also conducive to improving its performance.

[0167] Table 3 Model results of step 4

[0168]

[0169]

[0170] In Table 3, ① is the trigonometric position coding (Sinusoidal position coding) based on the sample position number and the band number, which adopts the element-by-element addition of the spectral matrix (reflectance) and the position matrix; ② is the trigonometric position coding (Sinusoidal position coding) based on the sample position number and the band number, which adopts order; order means that the ordered relationship between samples is constructed by sorting the content, that is, from small to large.

[0171] Step 5: Select the optimal soil quantitative model from the soil quantitative models obtained in steps 2, 3 and 4; the optimal soil quantitative model is the one with the smallest root mean square error RMSE of the test set and the coefficient of determination R of the test set. 2 The largest quantitative soil model.

[0172] It can be seen from Tables 1, 2 and 3 that the optimal models all meet the following conditions: the model is edRVFL based on position encoding, the model input is the new type of radiation;

[0173] The optimal model inputs the new type of angle and outputs the content of the soil sample; the accuracy of the optimal model is that the root mean square error RMSE of the test set is 0.077 and the determination coefficient R of the test set is 2 is 0.999.

[0174] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope defined by the claims of the present invention.

Claims

1. A soil quantitative modeling method based on position coding, spectrum and neural network, characterized by: The following steps are involved: Step 1: obtain soil samples through field collection, and obtain a soil data set through spectral measurement and content test; the soil data set includes several soil samples, and each soil sample includes spectral data and content data; Step 2: Based on the soil data set, the trigonometric position coding based on the spectral matrix and the content vector is used to obtain the position matrix through the spectral matrix. The fusion matrix based on the spectral matrix and the position matrix is ​​obtained by element-by-element addition, element-by-element multiplication, and rotation position coding. The soil quantitative model based on the random vector function chain neural network is constructed with the feature-processed fusion matrix as input. The evaluation indicators are the root mean square error RMSE and the determination coefficient R 2 ; Step 3: The position matrix obtained by the spectral matrix is ​​encoded by trigonometric function based on the spectral matrix and the content vector, so as to obtain a new type of angle based on absolute position and reflectance or absorptivity. The soil quantitative model based on random vector function chain neural network is constructed with the new angle processed by features as input. The evaluation indicators are root mean square error RMSE and determination coefficient R 2 ; Step 4: Improve the deep random vector function chain neural network with trigonometric position coding based on hidden layer number and neuron number and construct a soil quantitative model. The input variables can be the spectral matrix of step 2, the fusion matrix based on spectral matrix and position matrix of step 2, the angle based on band and reflectance or absorptivity of step 3, and the new angle of step 3. The evaluation indicators are root mean square error RMSE and determination coefficient R 2 ; Step 5: Select the optimal soil quantitative model from the several soil quantitative models obtained in step 2, step 3 and step 4; the optimal soil quantitative model is the one with the smallest root mean square error RMSE of the test set and the coefficient of determination R of the test set. 2 The largest quantitative soil model.

2. The soil quantitative modeling method based on position coding, spectrum and neural network according to claim 1 is characterized in that: In step 2 and step 3, the spectrum matrix has a single sample in each row, a single band in each column, the number of rows is the number of samples, the number of columns is the number of bands, and the elements are the spectrum data; The position matrix has a single sample in each row, a single band in each column, the number of rows is the number of samples, the number of columns is the number of bands, and the elements are position data; The feature processing method adopts partial least squares regression belonging to feature extraction; In the random vector function chain neural network, the input weights and biases between the input layer and the hidden layer are randomly valued and kept fixed, the output weights from the hidden layer to the output layer are solved by the Moore-Penrose generalized inverse, and there is a direct link between the input layer and the output layer.

3. The soil quantitative modeling method based on position coding, spectrum and neural network according to claim 2 is characterized in that: In step 2, the soil quantitative model based on random vector function chain neural network is constructed by taking the feature-processed fusion matrix as input as follows: Step A1: Set the model's operating environment and parameters; Step A2: Processing the fusion matrix based on the spectrum matrix and the position matrix by a feature processing method; Step A3: Use 10-fold cross validation to divide the feature-processed fusion matrix and soil content into training set and test set; Step A4: perform maximum and minimum normalization on the fusion matrix and soil content after feature processing in the training set and the test set respectively; Step A5: Use the normalized training set and test set to train and test the random vector function chain neural network. After 10 training processes with 10-fold cross validation, calculate the mean of the root mean square error RMSE of the training set and the coefficient of determination R of the training set. 2 The mean of the root mean square error RMSE of the test set and the coefficient of determination R of the test set are calculated after 10 tests of the 10-fold cross validation process. 2 The mean of , and the models completed by training and testing are obtained respectively.

4. The soil quantitative modeling method based on position coding, spectrum and neural network according to claim 3 is characterized in that: In the step 2, the trigonometric position coding based on the spectral matrix and the content vector considering the content obtains four position coding methods based on the combination of the sample position number or the sample content, the band number or the band value through the ordered relationship of the band itself and the ordered relationship of the sample sorted based on the content, namely, the trigonometric position coding based on the sample position number and the band number, the trigonometric position coding based on the sample position number and the band value, the trigonometric position coding based on the sample content and the band number, and the trigonometric position coding based on the sample content and the band value; the content sorting is to sort the content from small to large; The trigonometric position coding based on the sample position number and the band number is an application extension of the trigonometric position coding in chemometrics, and its position PE is: Among them, 2i represents the even-numbered band number, and 2i+1 represents the odd-numbered band number, where the band numbers are 1, 2, 3, ..., d band ;d band is the number of bands; pos is the position number of the sample, pos = 1, 2, 3, ..., d sample ;d sample is the number of samples; sin is the sine function, cos is the cosine function; The trigonometric position coding based on the sample position number and the band value is divided into two types; the first type is an improved version of the trigonometric position coding, and its position PE is: Among them, 2i represents the even-numbered band number, and 2i+1 represents the odd-numbered band number, where the band numbers are 1, 2, 3, ..., d band ;d band is the number of bands; pos is the position number of the sample, pos = 1, 2, 3, ..., d sample ;d sample is the number of samples; band max is the maximum value of the band value, band(2i) is the band value when the band number is an even number, and band(2i+1) is the band value when the band number is an odd number; Method 2 takes into account the fact that the spectral resolution is sometimes not fixed, and more realistically represents the positional relationship between different bands. Its position PE is: Where I represents the band number, I = 1, 2, 3, ..., d band ;d band is the number of bands; band(I) represents the band value of band number I; 2j represents that the band value is an even number, and 2j+1 represents that the band value is an odd number; pos represents the position number of the sample, pos=1,2,3,…,d sample ;d sample is the number of samples; band max is the maximum value of the band; the above method 2 is limited to the case where the band value is an integer; The trigonometric position encoding based on sample content and band number, its position PE is: Among them, Y pos is the content of the sample at position number pos; The trigonometric position encoding based on sample content and band value is divided into two types; the first type is an improved version of the trigonometric position encoding, and its position PE is: Method 2 takes into account the fact that the spectral resolution is sometimes not fixed, and more realistically represents the positional relationship between different bands. Its position PE is: The above method 2 is limited to the case where the band value is an integer.

5. The soil quantitative modeling method based on position coding, spectrum and neural network according to claim 4 is characterized in that: In step 2, the rotary position encoding method is specifically: First, the trigonometric position encoding based on the spectral matrix and the content vector is calculated considering the content, and then the position matrix and the spectral matrix are fused by equation (13) or equation (14); Among them, RotaryX represents the fusion matrix based on the position matrix and the spectral matrix; d sample is the number of samples, d band is the number of bands; A n The dimension is d sample ×1 column vector and represents the nth band, n=1,2,3,...,d band ; Indicates the element-by-element multiplication of the matrix; 2i represents the even-numbered band number, 2i+1 represents the odd-numbered band number, where the band numbers are 1, 2, 3, ..., d band ; PE(2i) represents the position corresponding to the even number of the band number, and PE(2i+1) represents the position corresponding to the odd number of the band number, which is obtained by trigonometric position coding based on the spectral matrix and the content vector taking into account the content; The rotational position encoding method of the second method based on the trigonometric function position encoding of the spectral matrix and the content vector considering the content is not applicable to formula (13), and its rotational position encoding method is formula (14); Among them, 2j indicates that the band value is an even number, and 2j+1 indicates that the band value is an odd number; PE(2j) indicates the position corresponding to the band value being an even number, and PE(2j+1) indicates the position corresponding to the band value being an odd number, which is obtained by a trigonometric position encoding method based on the spectral matrix and the content vector taking into account the content.

6. The soil quantitative modeling method based on position coding, spectrum and neural network according to claim 2 is characterized in that: In step 3, the soil quantitative model based on random vector function chain neural network is constructed by taking the feature-processed new angle as input: Step B1: Set the model's operating environment and parameters; Step B2: Processing the new type of argument by feature processing method; Step B3: Use 10-fold cross validation to divide the new radiation angle and soil content after feature processing into training set and test set; Step B4: perform maximum and minimum normalization on the new angles and soil contents after feature processing in the training set and the test set respectively; Step B5: Use the normalized training set and test set to train and test the random vector function chain neural network. After 10 training processes with 10-fold cross validation, calculate the mean of the root mean square error RMSE of the training set and the coefficient of determination R of the training set. 2 The mean of the root mean square error RMSE of the test set and the coefficient of determination R of the test set are calculated after 10 tests of the 10-fold cross validation process. 2 The mean of , and the models completed by training and testing are obtained respectively.

7. The soil quantitative modeling method based on position coding, spectrum and neural network according to claim 2 is characterized in that: The deep random vector function chain neural network in step 4 is a deep structure of a random vector function chain neural network, in which the input weights and biases between the input layer and the hidden layer are randomly taken and kept fixed, the weights and biases between different hidden layers are randomly taken and kept fixed, the input features are concatenated with the output features of all hidden layers, the output weights are solved by the Moore-Penrose generalized inverse, and the number of neurons in different hidden layers is the same.

8. The soil quantitative modeling method based on position coding, spectrum and neural network according to claim 7 is characterized in that: In step 4, the trigonometric function position encoding based on the hidden layer number and the neuron number is specifically: Drawing on the spectral matrix composed of samples and bands, a matrix composed of hidden layers and neurons is constructed to realize the position association between different neurons in different hidden layers. Since the number of hidden layers and neurons is an integer value, the trigonometric function position encoding based on the hidden layer number and the neuron number is adopted, and its position PE is: Among them, 2m represents an even-numbered neuron number, and 2m+1 represents an odd-numbered neuron number, where the neuron numbers are 1, 2, 3, ..., d neuron ;d neuron is the number of neurons; L is the position number of the hidden layer, L = 1, 2, 3, ..., d layer ;d layer is the number of hidden layers; sin is the sine function, and cos is the cosine function.

9. The soil quantitative modeling method based on position coding, spectrum and neural network according to claim 8, characterized in that: In step 4, the soil quantitative model constructed by improving the deep random vector function chain neural network using trigonometric function position coding based on hidden layer number and neuron number is specifically: Step C1: Set the model's operating environment and parameters; Step C2: processing input variables by a feature processing method; the feature processing method adopts partial least squares regression belonging to feature extraction; the input variables are the spectral matrix of step 2, the fusion matrix based on the spectral matrix and the position matrix of step 2, the angle based on the band and the reflectivity or absorptivity of step 3, and the new angle of step 3; Step C3: Use 10-fold cross validation to divide the input variables and soil content after feature processing into training set and test set; Step C4: perform maximum and minimum normalization on the input variables and soil contents after feature processing in the training set and the test set respectively; Step C5: Use the normalized training set and test set to train and test the deep random vector function chain neural network. After 10 training processes with 10-fold cross validation, calculate the mean of the root mean square error RMSE of the training set and the coefficient of determination R of the training set. 2 The mean of the root mean square error RMSE of the test set and the coefficient of determination R of the test set are calculated after 10 tests of the 10-fold cross validation process. 2 The mean of , and the models completed by training and testing are obtained respectively.