Near-infrared detection method for soil organic matter and total nitrogen content by comparing neural network
By comparing neural network and near-infrared spectroscopy technology, the soil spectral information is obtained by shaking treatment and multiple scans, the problem of limited samples in soil organic matter and total nitrogen content detection is solved, and efficient and accurate soil organic matter and total nitrogen content is achieved. Test.
Patent Information
- Application Number
- CN202411098242.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2044-08-12
AI Technical Summary
In the prior art, near-infrared detection methods for soil organic matter and total nitrogen content have problems with limited samples, resulting in low detection efficiency and high cost.
By combining contrast neural network with near-infrared spectroscopy technology, the similar and heterogeneous spectral information is obtained by shaking the soil samples and multiple scans. A pair of convolutional neural networks with weight sharing and contrast loss functions are used to extract and train features to generate effective spectral characteristic information to characterize soil organic matter and total nitrogen content.
Effective excavation of soil near-infrared spectral information under limited sample conditions improves the accuracy and efficiency of detection, reduces detection costs, and achieves rapid and efficient measurement of soil organic matter and total nitrogen content.
Smart Images

Figure CN119044108A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of soil detection, and in particular to a near-infrared detection method for soil organic matter and total nitrogen content using a comparative neural network. Background Art
[0002] Traditional soil organic matter and total nitrogen detection methods are mainly based on chemical detection methods, but they face risks such as long detection cycle, complex operation, large human interference, and environmental pollution. In the face of the problems of traditional detection methods, soil nutrient detection technology based on spectroscopy technology has the characteristics of fast detection speed, non-destructive, non-contact, and environmentally friendly.
[0003] However, the complex structure and rich nutrients of the soil affect the near-infrared spectrum. At the same time, the expensive detection fees, high labor costs, and corresponding time expenditures mean that only a limited number of soil samples are available for near-infrared spectral data modeling.
[0004] It can be seen from this that the near-infrared detection method of soil organic matter and total nitrogen content in the relevant technology has the technical problem of a limited number of soil samples available for near-infrared spectral data modeling. Summary of the invention
[0005] The present invention provides a near-infrared detection method for soil organic matter and total nitrogen content based on a comparative neural network, so as to solve the defect that the near-infrared detection method for soil organic matter and total nitrogen content in the prior art has a limited number of soil samples available for near-infrared spectral data modeling, and realizes the effective mining of soil near-infrared spectral information under limited sample conditions.
[0006] The present invention provides a near-infrared detection method for soil organic matter and total nitrogen content using a comparative neural network, comprising the following steps. Sampling and pre-processing the soil in the detection plot to obtain a soil sample; filling the soil sample with a preset detection mold to obtain a plurality of soil samples to be detected, wherein the plurality of soil samples to be detected are respectively filled in a plurality of the preset detection molds; performing a first near-infrared spectrum scan on the soil sample to be detected in the same preset detection mold to obtain near-infrared spectrum information of the same type of soil; performing a second near-infrared spectrum scan on the soil sample to be detected in different preset detection molds to obtain near-infrared spectrum information of heterogeneous soil; pairing and extracting the near-infrared spectrum information of the same type of soil with the near-infrared spectrum information of the heterogeneous soil to obtain an original spectrum pair of soil spectrum information; inputting the original spectrum pair of soil spectrum information into a preset comparative neural network for network parameter training to obtain a trained comparative neural network, and outputting effective spectrum feature information through the trained comparative neural network, wherein the effective spectrum feature information is used to characterize the spectrum feature information of the organic matter and total nitrogen content of the soil sample.
[0007] According to a near-infrared detection method for soil organic matter and total nitrogen content using a comparative neural network provided by the present invention, a first near-infrared spectral scan is performed on the soil sample to be detected in the same preset detection mold to obtain near-infrared spectral information of the same type of soil, including: shaking the soil sample to be detected in the same preset detection mold for multiple times; after each shaking treatment, performing a first near-infrared spectral scan on the soil sample to be detected in the preset detection mold to obtain near-infrared spectral information of the same type of soil.
[0008] According to a near-infrared detection method for soil organic matter and total nitrogen content using a comparative neural network provided by the present invention, the near-infrared spectral information of the same type of soil is paired with the near-infrared spectral information of the different type of soil to obtain an original spectral pair of soil spectral information, including: pairing the near-infrared spectral information of the same type of soil with the near-infrared spectral information of the different type of soil to obtain a spectral data pair; adding labels to the spectral data pair to obtain an original spectral pair of soil spectral information, wherein when two spectral data in the spectral data pair are the same, the label of the original spectral pair of soil spectral information is 1, and when the two spectral data in the spectral data pair are different, the label of the original spectral pair of soil spectral information is 0.
[0009] According to a near-infrared detection method for soil organic matter and total nitrogen content using a comparative neural network provided by the present invention, the preset comparative neural network is a pair of convolutional neural networks with shared weights.
[0010] According to a near-infrared detection method for soil organic matter and total nitrogen content using a comparative neural network provided by the present invention, the original spectral pair of soil spectral information is input into a preset comparative neural network for network parameter training to obtain a trained comparative neural network, and effective spectral feature information is output through the trained comparative neural network, including: based on the preset comparative neural network, using a preset energy function as a comparative loss function, measuring the original spectral pair of soil spectral information to bring similar spectral features closer and different spectral features farther apart, to obtain a trained comparative neural network, and outputting effective spectral feature information through the trained comparative neural network.
[0011] According to a near-infrared detection method for soil organic matter and total nitrogen content using a comparative neural network provided by the present invention, after the trained comparative neural network outputs effective spectral feature information, the method further includes: constructing a soil organic matter total nitrogen content prediction model based on the effective spectral feature information, wherein the soil organic matter total nitrogen content prediction model is used to output soil indicators, and the soil indicators are used to represent soil attribute information.
[0012] The present invention also provides a near-infrared detection device for soil organic matter and total nitrogen content by contrast neural network, comprising the following modules: a sampling module, used for sampling and pre-processing the soil in the detection plot to obtain a soil sample; a filling module, used for filling the soil sample through a preset detection mold to obtain a plurality of soil samples to be detected, wherein the plurality of soil samples to be detected are respectively filled in a plurality of the preset detection molds; a first scanning module, used for performing a first near-infrared spectrum scan on the soil samples to be detected in the same preset detection mold to obtain near-infrared spectrum information of the same type of soil; a second scanning module, used for performing a first near-infrared spectrum scan on the soil samples to be detected in the same preset detection mold to obtain near-infrared spectrum information of the same type of soil; and a second scanning module, used for performing a first near-infrared spectrum scan on the soil samples to be detected in the same preset detection mold to obtain near-infrared spectrum information of the same type of soil. The soil sample to be tested in the detection mold is subjected to a second near-infrared spectral scan to obtain near-infrared spectral information of the heterogeneous soil; a pairing module is used to perform pairing extraction based on the near-infrared spectral information of the homogeneous soil and the near-infrared spectral information of the heterogeneous soil to obtain an original spectral pair of soil spectral information; an output module is used to input the original spectral pair of soil spectral information into a preset comparison neural network for network parameter training to obtain a trained comparison neural network, and output effective spectral feature information through the trained comparison neural network, wherein the effective spectral feature information is used to characterize the spectral feature information of the organic matter and total nitrogen content of the soil sample.
[0013] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a near-infrared detection method for soil organic matter and total nitrogen content using a comparative neural network as described in any one of the above-mentioned methods is implemented.
[0014] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a near-infrared detection method for soil organic matter and total nitrogen content using a comparative neural network as described in any of the above.
[0015] The present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements the near-infrared detection method for soil organic matter and total nitrogen content using any of the above-mentioned comparative neural networks.
[0016] The present invention provides a near-infrared detection method for soil organic matter and total nitrogen content using a comparative neural network. The method comprises the following steps: sampling and pre-processing the soil in a detection plot to obtain soil samples; filling the soil samples with a preset detection mold to obtain a plurality of soil samples to be detected; performing near-infrared spectral scanning on the soil samples to be detected in the same preset detection mold to obtain near-infrared spectral information of the same type of soil; performing near-infrared spectral scanning on the soil samples to be detected in different preset detection molds to obtain near-infrared spectral information of different types of soil; performing pairing extraction based on the near-infrared spectral information of the same type of soil and the near-infrared spectral information of the different types of soil to obtain original spectral pairs of soil spectral information, thereby performing feature mining of spectral data by combining soil spectral data pairs to form a larger number of data pairs from small sample data; based on the original spectral pairs of soil spectral information, effective spectral feature information output by a trained comparative neural network is used to characterize the spectral feature information of the organic matter and total nitrogen content of the soil sample, thereby solving the technical problem that the near-infrared detection method for soil organic matter and total nitrogen content in the related art has a limited number of soil samples available for near-infrared spectral data modeling. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced one by one below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 It is a schematic flow chart of the near-infrared detection method for soil organic matter and total nitrogen content using a comparative neural network provided by the present invention.
[0019] Figure 2 It is a schematic diagram of the soil spectral data acquisition process provided by the present invention.
[0020] Figure 3 It is a schematic diagram of comparative feature extraction of the soil organic matter and total nitrogen content detection method based on comparative neural network provided by the present invention.
[0021] Figure 4 It is a prediction flow chart of the soil organic matter and total nitrogen content detection method based on comparative neural network provided by the present invention.
[0022] Figure 5 It is a workflow diagram of the soil organic matter and total nitrogen content detection method based on comparative neural network provided by the present invention.
[0023] Figure 6 It is a structural schematic diagram of a near-infrared detection device for soil organic matter and total nitrogen content using a comparative neural network provided by the present invention.
[0024] Figure 7 It is a schematic diagram of the physical structure of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0026] Soil organic matter and total nitrogen represent the total amount of soil organic matter and nitrogen, marking the long-term nutrient supply capacity of the soil, so they are often selected as indicators of soil fertility and the basis for the division of nutrient levels. Traditional soil organic matter and total nitrogen detection methods are mainly based on chemical detection methods, but they face risks such as long detection cycles, complex operations, large human interference, and environmental pollution. In the face of the problems of traditional detection methods, soil nutrient detection technology based on spectroscopy technology has the characteristics of fast detection speed, non-destructive, non-contact, and environmentally friendly, which makes it have good application prospects in soil nutrient detection tasks. Among them, near-infrared spectroscopy can be applied to the detection tasks of soil organic matter and total nitrogen.
[0027] Near infrared spectroscopy is one of the important components of spectral analysis. It can reflect the combined frequency and double frequency information of groups such as CH and NH, so it can be selected as the detection spectrum of soil organic matter and total nitrogen content. However, the complex structure and rich nutrients of the soil affect the near infrared spectrum, which leads to serious peak overlap and wide effective information band, which in turn causes data fluctuations in the near infrared spectrum. At the same time, the expensive detection fee, high labor cost, and corresponding time expenditure make only a limited number of soil samples available for near infrared spectral data modeling. Therefore, how to efficiently use limited soil samples for near infrared spectral data collection is an urgent problem to be solved.
[0028] In order to solve the above problems, the present invention proposes a near-infrared detection method for soil organic matter and total nitrogen content based on contrast neural network. The spectral information of the same soil sample is obtained by shaking the mold containing the soil sample, and the spectral information of different soil samples is obtained by scanning the spectra of different soil samples. A pair of weight-sharing one-dimensional convolution operations are introduced to extract features from the near-infrared spectrum, and the contrast loss function is used to screen and obtain the spectral feature information that can characterize the soil organic matter and total nitrogen content, and the soil organic matter and total nitrogen content are predicted based on the corresponding spectral feature information.
[0029] refer to Figure 1 , Figure 1 : is a schematic diagram of the process of the near infrared detection method of soil organic matter and total nitrogen content using a comparative neural network provided by the present invention, such as Figure 1 As shown, the method includes the following: Step 101, sampling and pre-processing the soil in the detection plot to obtain a soil sample.
[0030] In an embodiment of the present invention, the soil sample in the plot to be detected is sampled, air-dried, impurity-removed, ground, and the like are subjected to operations such as sampling to obtain a soil sample that can be used for near-infrared spectrum collection (ie, the soil sample mentioned above).
[0031] Step 102, filling the soil sample into a preset detection mold to obtain a plurality of soil samples to be detected, wherein the plurality of soil samples to be detected are respectively filled into a plurality of preset detection molds.
[0032] In an embodiment of the present invention, a soil sample that can be used for near-infrared spectrum collection is loaded into a preset soil detection mold.
[0033] Step 103, performing a first near-infrared spectrum scan on the soil sample to be tested in the same preset testing mold to obtain near-infrared spectrum information of the same type of soil.
[0034] In the embodiment of the present invention, the same preset detection mold is shaken, and the near-infrared spectrum is scanned once each time it is shaken to obtain the near-infrared spectrum information of the same type of soil.
[0035] Step 104, performing a second near-infrared spectrum scan on the soil samples to be tested in different preset test molds to obtain near-infrared spectrum information of the heterogeneous soils.
[0036] In the embodiment of the present invention, near infrared spectroscopy scanning is performed on soils in different molds to obtain near infrared spectral information of heterogeneous soils.
[0037] Step 105, pairing and extracting the near infrared spectrum information of the same type of soil and the near infrared spectrum information of the different type of soil to obtain an original spectrum pair of soil spectrum information.
[0038] refer to Figure 2 , Figure 2 It is a schematic diagram of the soil spectral data acquisition process provided by the present invention.
[0039] like Figure 2As shown, soil samples (including different types of soil) are loaded into a plurality of preset detection molds to obtain soil samples 1 to n; near-infrared spectral scanning is performed on the soil samples to be detected in the same preset detection mold to obtain near-infrared spectral information of the same type of soil; near-infrared spectral scanning is performed on the soil samples to be detected in different preset detection molds to obtain near-infrared spectral information of heterogeneous soils; and a pairing module is used to extract the near-infrared spectral information of the same type of soil and the near-infrared spectral information of the heterogeneous soil to obtain an original spectral pair of soil spectral information (including spectrum and label), wherein the label is used to indicate different types (0) or the same type (1).
[0040] In the embodiment of the present invention, paired spectral information is extracted from the same type and different type of soil spectral information, and corresponding labels are added to obtain original spectral pairs of soil spectral information.
[0041] Step 106, inputting the original spectrum pair of soil spectral information into a preset comparative neural network for network parameter training to obtain a trained comparative neural network, and outputting effective spectral feature information through the trained comparative neural network, wherein the effective spectral feature information is used to characterize the spectral feature information of organic matter and total nitrogen content of the soil sample.
[0042] In an embodiment of the present invention, the same / different soil spectral pairs (i.e., the above-mentioned original spectral pairs of soil spectral information) are sent to a preset comparative neural network, and the comparative loss function is used to obtain spectral feature information (effective spectral feature information) that can reflect the current soil state.
[0043] Here, a pair of weight-sharing convolutional neural networks are used to extract spectral feature information of similar / heterogeneous soil spectral information pairs to obtain the spectral feature distribution in the latent space; then, a contrast loss function is selected to measure the soil spectral features, so that similar spectral features are close and heterogeneous spectral features are far apart; finally, the trained contrast neural network output can more effectively distinguish the effective features of the spectrum.
[0044] In an embodiment of the present invention, when used, the soil sample to be tested is first subjected to spectral data scanning to obtain original spectral information, and then the original spectrum is copied and labeled as the same category to construct original data input that meets the comparison network, and the pre-trained model is used to obtain effective spectral information of soil total nitrogen and organic matter, based on which soil organic matter and total nitrogen are predicted.
[0045] Subsequently, the effective spectral information was used to construct a soil organic matter / total nitrogen content prediction model to output the corresponding indicators.
[0046] Through the above steps of the embodiment of the present invention, the soil in the detection plot is sampled and pre-processed to obtain soil samples; the soil samples are filled through a preset detection mold to obtain multiple soil samples to be detected, wherein the multiple soil samples to be detected are respectively filled in multiple preset detection molds; the first near-infrared spectrum scan is performed on the soil samples to be detected in the same preset detection mold to obtain the near-infrared spectrum information of the same type of soil; the second near-infrared spectrum scan is performed on the soil samples to be detected in different preset detection molds to obtain the near-infrared spectrum information of heterogeneous soils; based on the near-infrared spectrum information of the same type of soil and the near-infrared spectrum information of the heterogeneous soil, the original spectrum pair of soil spectrum information is obtained; the original spectrum pair of soil spectrum information is input into the pre-trained comparison neural network to obtain the effective spectrum feature information output by the pre-trained comparison neural network, wherein the effective spectrum feature information is used to characterize the spectrum feature information of the organic matter and total nitrogen content of the soil sample. In addition, the technical problem that the near-infrared detection method of soil organic matter and total nitrogen content in the related technology is that there is a limited number of soil samples available for near-infrared spectrum data modeling is solved.
[0047] According to a near-infrared detection method for soil organic matter and total nitrogen content using a comparative neural network provided by the present invention, a first near-infrared spectrum scan is performed on a soil sample to be detected in a same preset detection mold to obtain near-infrared spectrum information of the same type of soil, including: The soil sample to be tested in the same preset testing mold is shaken multiple times; After each shaking process, a first near-infrared spectrum scan is performed on the soil sample to be tested in the preset testing mold to obtain near-infrared spectrum information of the same type of soil.
[0048] In an embodiment of the present invention, based on the phenomenon of uneven distribution of organic matter and total nitrogen in the soil, soil samples loaded in the same mold are shaken and the near-infrared spectrum is scanned once each time the shaking is performed to obtain similar soil spectrum data.
[0049] According to a near-infrared detection method for soil organic matter and total nitrogen content using a comparative neural network provided by the present invention, the near-infrared spectral information of the same type of soil is paired with the near-infrared spectral information of the different type of soil to obtain the original spectral pair of soil spectral information, including: Pair the near infrared spectrum information of the same type of soil with the near infrared spectrum information of the different type of soil to obtain a spectrum data pair; Labels are added to the spectral data pair to obtain an original spectral pair of soil spectral information, wherein when the two spectral data in the spectral data pair are the same, the label of the original spectral pair of soil spectral information is 1, and when the two spectral data in the spectral data pair are different, the label of the original spectral pair of soil spectral information is 0.
[0050] In the embodiment of the present invention, the process of obtaining the original spectral pair (spectral data pair) of soil spectral information is as follows: first, the original soil sample that has been pre-treated is loaded into the detection mold; then, the soil sample in the same mold is shaken, and the spectrum is scanned once each time it is shaken to obtain the spectral information of the same type of soil sample; secondly, different soil samples are replaced for scanning to obtain the spectral information of different types of soil samples; finally, the spectral data pairing is extracted using the method shown in formula (1).
[0051] (1)
[0052] in, Labels representing spectral data pairs, , Respectively represent the numbers The spectrum obtained by scanning the soil sample 1 ( ), Spectrum 2 ( ).
[0053] It should be noted that, usually, the number of heterogeneous sample pairs is much larger than the number of homogeneous sample pairs, and they often need to be multiplied by a correction factor to limit the number.
[0054] According to a near-infrared detection method for soil organic matter and total nitrogen content using a comparative neural network provided by the present invention, the preset comparative neural network is a pair of weight-shared convolutional neural networks.
[0055] According to a near-infrared detection method for soil organic matter and total nitrogen content using a comparative neural network provided by the present invention, the original spectrum of soil spectral information is input into the comparative neural network for model training to obtain effective spectral feature information output by the pre-trained comparative neural network, including: Based on the pre-trained contrast neural network, the preset energy function is used as the contrast loss function to measure the original spectral pairs of soil spectral information so that similar spectral features are close and heterogeneous spectral features are far away, and the effective spectral feature information output by the pre-trained contrast neural network is obtained.
[0056] refer to Figure 3 , Figure 3 It is a schematic diagram of comparative feature extraction of the soil organic matter and total nitrogen content detection method based on comparative neural network provided by the present invention.
[0057] In the embodiment of the present invention, the key point is the comparison and measurement of the same type / different type spectral data pairs. For this purpose, the present invention proposes the following Figure 3 The comparative feature extraction methods shown.
[0058] Among them, it includes soil sample spectral data pairs, spectra (including spectra 11 / 12), and contrast neural networks (including a pair of weight-sharing neural networks) respectively including multiple convolutional layers, multiple pooling layers and flat layers, fully connected layers, and network layers. The network layers output latent space variables (including feature 1, feature 2, feature 3, and feature 4). The energy function shown in formula (2) is selected as the metric function (i.e., contrast loss function) to measure the soil spectral features, so that the target variable is close and the heterogeneous spectral features are far away.
[0059] In the embodiment of the present invention, firstly, a pair of weight-sharing convolutional neural networks is used to extract spectral feature information of similar / different soil spectral information pairs to obtain the spectral feature distribution in the latent space; then, an energy function as shown in formula (2) is selected as a metric function (i.e., a contrast loss function) to measure the soil spectral features, so that similar spectral features are close and different spectral features are far away; finally, effective features that can more effectively distinguish spectra are obtained.
[0060] (2)
[0061] in, represents the distance metric, which is defined as two eigenvectors and The square of the Euclidean distance between and is from the original data (soil samples) and The eigenvector (soil spectral characteristics) obtained after transformation.
[0062] refer to Figure 4 , Figure 4 It is a prediction flow chart of the soil organic matter and total nitrogen content detection method based on comparative neural network, which includes first scanning the spectral data of the soil sample to be detected to obtain the original spectral information, and copying the original spectrum and labeling it as the same category as the data input of the weight-sharing feature mining network (pre-trained), obtaining the effective spectral information output by the feature mining network, and using the preset random forest, extreme learning machine and other modules as prediction models to predict soil organic matter and total nitrogen.
[0063] According to a near-infrared detection method for soil organic matter and total nitrogen content using a comparative neural network provided by the present invention, the original spectrum of soil spectral information is input into a preset comparative neural network for network parameter training to obtain a trained comparative neural network, and effective spectral feature information is output through the trained comparative neural network, including: Based on the preset contrast neural network, the preset energy function is used as the contrast loss function to measure the original spectral pairs of soil spectral information so that similar spectral features are close and heterogeneous spectral features are far apart, so as to obtain the trained contrast neural network, and output the effective spectral feature information through the trained contrast neural network.
[0064] In the embodiment of the present invention, the spectrum pairs of the same / different soils are sent to the contrast neural network, and the contrast loss function is used to obtain the spectral feature information that can reflect the current soil state. Finally, the soil organic matter / total nitrogen content prediction model is constructed using the effective spectral information to output the corresponding index.
[0065] refer to Figure 5 , Figure 5 It is a workflow diagram of the soil organic matter and total nitrogen content detection method based on comparative neural network provided by the present invention.
[0066] The embodiment of the present invention mainly solves the problem of soil near-infrared spectral feature data mining under limited sample conditions. Through the embodiment of the present invention, the spectral information of the same soil sample is obtained by shaking the mold containing the soil sample, and the spectral information of different soil samples is obtained by scanning the spectra of different soil samples. A pair of weight-sharing one-dimensional convolution operations are introduced to extract features from the near-infrared spectrum, and the contrast loss function is used to screen and obtain spectral feature information that can characterize the soil organic matter and total nitrogen content, and the soil organic matter and total nitrogen content are predicted based on the corresponding spectral feature information. The specific process is as follows: Figure 4 shown.
[0067] The specific steps are as follows: First, the soil samples in the test area are sampled, air-dried, impurities removed, and ground to obtain soil samples that can be used for near-infrared spectrum collection, and then loaded into the test mold.
[0068] Secondly, the same mold was shaken and the near-infrared spectrum was scanned each time it was shaken to obtain the near-infrared spectrum information of the same type of soil; Replace the soil in different molds and perform near-infrared spectral scanning to obtain near-infrared spectral information of heterogeneous (different types) soils.
[0069] Again, paired spectral information is extracted from the same and different soil spectral information, and corresponding labels are added to obtain the original data pairs of soil spectral information (with labels). Then, the same / different soil spectral pairs are input into the contrast neural network, and the contrast loss function is used to obtain the spectral feature information that can reflect the current soil state.
[0070] Finally, the effective spectral information was used to construct a soil organic matter / total nitrogen content prediction model to output the corresponding indicators (soil property information).
[0071] The purpose of the present invention is to provide a near-infrared detection method for soil organic matter and total nitrogen content based on a contrast neural network, which can make full use of limited soil spectral information to mine effective soil features. The present invention solves the problem of effective mining of soil near-infrared spectral information under limited sample conditions. The invention will provide fast, efficient and accurate measurement for soil organic matter and total nitrogen detection in actual field application scenarios.
[0072] According to the method for detecting soil organic matter and total nitrogen content based on comparative neural network provided by the present invention, based on the phenomenon of uneven distribution of organic matter and total nitrogen in soil, soil samples filled in the same mold are shaken to obtain similar soil spectral data; by combining soil spectral data pairs (number is , The feature mining of spectral data (the amount of soil sample data) can be carried out to form a larger number of data pairs from small sample data; the soil spectral feature information is mined by contrasting neural networks, and the energy function is used to measure the contrast loss, which can make the spectral features of the same type closer and the spectral features of different types farther apart.
[0073] The near-infrared detection device for soil organic matter and total nitrogen content of the comparative neural network provided by the present invention is described below. The near-infrared detection device for soil organic matter and total nitrogen content of the comparative neural network described below and the near-infrared detection method for soil organic matter and total nitrogen content of the comparative neural network described above can be referenced to each other.
[0074] refer to Figure 6 , Figure 6 It is a structural schematic diagram of the near-infrared detection device for soil organic matter and total nitrogen content based on a comparative neural network provided by the present invention, which includes a sampling module 601, a filling module 602, a first scanning module 603, a second scanning module 604, a pairing module 605 and an output module 606.
[0075] The sampling module 601 is used to sample and pre-process the soil in the detection plot to obtain a soil sample; A filling module 602 is used to fill the soil sample through a preset detection mold to obtain a plurality of soil samples to be detected, wherein the plurality of soil samples to be detected are respectively filled in a plurality of preset detection molds; The first scanning module 603 is used to perform a first near-infrared spectrum scan on the soil sample to be tested in the same preset detection mold to obtain near-infrared spectrum information of the same type of soil; The second scanning module 604 is used to perform a second near-infrared spectrum scan on the soil samples to be tested in different preset testing molds to obtain near-infrared spectrum information of heterogeneous soils; A pairing module 605 is used to perform pairing extraction based on the near infrared spectrum information of the same type of soil and the near infrared spectrum information of the different type of soil to obtain an original spectrum pair of soil spectrum information; The output module 606 is used to input the original spectrum of soil spectral information into a preset comparative neural network for network parameter training to obtain a trained comparative neural network, and output effective spectral feature information through the trained comparative neural network, wherein the effective spectral feature information is used to characterize the spectral feature information of the organic matter and total nitrogen content of the soil sample.
[0076] Specifically, the near-infrared detection device for soil organic matter and total nitrogen content of the above-mentioned comparative neural network provided by the present invention can implement all the method steps implemented by the above-mentioned near-infrared detection method embodiment of soil organic matter and total nitrogen content of the comparative neural network, and can achieve the same technical effect. The parts and beneficial effects of this embodiment that are the same as those of the method embodiment will not be described in detail here.
[0077] Figure 7 is a schematic diagram of the physical structure of the electronic device provided by the present invention, such as Figure 7 As shown, the electronic device may include: a processor (processor) 710 , a communication interface (Communications Interface) 720 , a memory (memory) 730 and a communication bus 740 , wherein the processor 710 , the communication interface 720 , and the memory 730 communicate with each other through the communication bus 740 . The processor 710 can call the logic instructions in the memory 730 to execute the near-infrared detection method of soil organic matter and total nitrogen content of the comparative neural network, which method includes: sampling and preprocessing the soil in the detection plot to obtain soil samples; filling the soil samples through a preset detection mold to obtain multiple soil samples to be detected, wherein the multiple soil samples to be detected are respectively filled in multiple preset detection molds; performing a first near-infrared spectral scan on the soil samples to be detected in the same preset detection mold to obtain near-infrared spectral information of the same type of soil; performing a second near-infrared spectral scan on the soil samples to be detected in different preset detection molds to obtain near-infrared spectral information of heterogeneous soils; pairing and extracting the near-infrared spectral information of the same type of soil with the near-infrared spectral information of the heterogeneous soil to obtain an original spectral pair of soil spectral information; inputting the original spectral pair of soil spectral information into the pre-trained comparative neural network to obtain effective spectral feature information output by the pre-trained comparative neural network, wherein the effective spectral feature information is used to characterize the spectral feature information of the organic matter and total nitrogen content of the soil sample.
[0078] In addition, the logic instructions in the above-mentioned memory 730 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0079] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the near-infrared detection method of soil organic matter and total nitrogen content provided by the comparative neural network of the above-mentioned methods, the method including: sampling and preprocessing the soil in the detection plot to obtain a soil sample; filling the soil sample through a preset detection mold to obtain a plurality of soil samples to be detected, wherein the plurality of soil samples to be detected are respectively filled in a plurality of preset detection molds; performing a first near-infrared spectral scan on the soil samples to be detected in the same preset detection mold to obtain near-infrared spectral information of the same type of soil; performing a second near-infrared spectral scan on the soil samples to be detected in different preset detection molds to obtain near-infrared spectral information of heterogeneous soils; pairing and extracting the near-infrared spectral information of the same type of soil with the near-infrared spectral information of the heterogeneous soil to obtain an original spectral pair of soil spectral information; inputting the original spectral pair of soil spectral information into a pre-trained comparative neural network to obtain effective spectral feature information output by the pre-trained comparative neural network, wherein the effective spectral feature information is used to characterize the spectral feature information of the organic matter and total nitrogen content of the soil sample.
[0080] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the near-infrared detection method for soil organic matter and total nitrogen content of the comparative neural network provided by the above-mentioned methods, the method comprising: sampling and preprocessing the soil in the detection plot to obtain a soil sample; filling the soil sample through a preset detection mold to obtain a plurality of soil samples to be detected, wherein the plurality of soil samples to be detected are respectively filled in a plurality of preset detection molds; performing a first near-infrared spectral scan on the soil samples to be detected in the same preset detection mold to obtain near-infrared spectral information of the same type of soil; performing a second near-infrared spectral scan on the soil samples to be detected in different preset detection molds to obtain near-infrared spectral information of heterogeneous soils; pairing and extracting the near-infrared spectral information of the same type of soil with the near-infrared spectral information of the heterogeneous soil to obtain an original spectral pair of soil spectral information; inputting the original spectral pair of soil spectral information into a pre-trained comparative neural network to obtain effective spectral feature information output by the pre-trained comparative neural network, wherein the effective spectral feature information is used to characterize the spectral feature information of the organic matter and total nitrogen content of the soil sample.
[0081] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0082] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0083] 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 aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A near infrared detection method for soil organic matter and total nitrogen content using a contrasting neural network, characterized in that: include: Sampling and pre-treating the soil in the testing plot to obtain a soil sample; The soil sample is filled into a preset detection mold to obtain a plurality of soil samples to be detected, wherein the plurality of soil samples to be detected are respectively filled into a plurality of the preset detection molds; Performing a first near-infrared spectrum scan on the soil sample to be tested in the same preset detection mold to obtain near-infrared spectrum information of the same type of soil; Performing a second near-infrared spectrum scan on the soil samples to be tested in different preset detection molds to obtain near-infrared spectrum information of heterogeneous soils; Based on the near infrared spectrum information of the same type of soil and the near infrared spectrum information of the different type of soil, an original spectrum pair of soil spectrum information is obtained; The original spectrum of the soil spectral information is input into a preset comparative neural network for network parameter training to obtain a trained comparative neural network, and effective spectral feature information is output through the trained comparative neural network, wherein the effective spectral feature information is used to characterize the spectral feature information of the organic matter and total nitrogen content of the soil sample.
2. The near-infrared detection method of soil organic matter and total nitrogen content by contrast neural network according to claim 1 is characterized in that: The first near-infrared spectrum scanning is performed on the soil sample to be tested in the same preset detection mold to obtain near-infrared spectrum information of the same type of soil, including: Shaking the soil sample to be tested in the same preset testing mold for multiple times; After each shaking process, a first near-infrared spectrum scan is performed on the soil sample to be tested in the preset testing mold to obtain near-infrared spectrum information of the same type of soil.
3. The near infrared detection method of soil organic matter and total nitrogen content by contrast neural network according to claim 1 is characterized in that: The method of pairing and extracting the near infrared spectrum information of the same type of soil with the near infrared spectrum information of the different type of soil to obtain an original spectrum pair of soil spectrum information includes: Pairing the near infrared spectrum information of the same type of soil with the near infrared spectrum information of the different type of soil to obtain a spectrum data pair; A label is added to the spectral data pair to obtain an original spectral pair of soil spectral information, wherein when two spectral data in the spectral data pair are the same, the label of the original spectral pair of soil spectral information is 1, and when the two spectral data in the spectral data pair are different, the label of the original spectral pair of soil spectral information is 0.
4. The near-infrared detection method of soil organic matter and total nitrogen content by contrast neural network according to claim 1 is characterized in that: The preset contrast neural network is a pair of weight-shared convolutional neural networks.
5. The near-infrared detection method of soil organic matter and total nitrogen content by contrast neural network according to claim 4 is characterized in that: The inputting of the original spectrum of the soil spectrum information into a preset comparative neural network for network parameter training to obtain a trained comparative neural network, and outputting effective spectrum feature information through the trained comparative neural network, comprises: Based on a preset contrast neural network, a preset energy function is used as a contrast loss function to measure the original spectral pair of the soil spectral information so that similar spectral features are close and heterogeneous spectral features are far apart, thereby obtaining a trained contrast neural network, and outputting effective spectral feature information through the trained contrast neural network.
6. The near infrared detection method of soil organic matter and total nitrogen content by contrast neural network according to claim 1, characterized in that: After the trained contrast neural network outputs effective spectral feature information, the method further includes: A soil organic matter total nitrogen content prediction model is constructed based on the effective spectral feature information, wherein the soil organic matter total nitrogen content prediction model is used to output soil indicators, and the soil indicators are used to represent soil attribute information.
7. A near-infrared detection device for soil organic matter and total nitrogen content using a contrasting neural network, characterized in that: include: The sampling module is used to sample and pre-treat the soil in the detection plot to obtain soil samples; A filling module, used for filling the soil sample through a preset detection mold to obtain a plurality of soil samples to be detected, wherein the plurality of soil samples to be detected are respectively filled in a plurality of the preset detection molds; A first scanning module is used to perform a first near-infrared spectrum scan on the soil sample to be detected in the same preset detection mold to obtain near-infrared spectrum information of the same type of soil; A second scanning module is used to perform a second near-infrared spectrum scan on the soil samples to be detected in different preset detection molds to obtain near-infrared spectrum information of heterogeneous soils; A pairing module is used to perform pairing extraction based on the near-infrared spectrum information of the same type of soil and the near-infrared spectrum information of the different type of soil to obtain an original spectrum pair of soil spectrum information; The output module is used to input the original spectrum of the soil spectral information into a preset comparative neural network for network parameter training to obtain a trained comparative neural network, and output effective spectral feature information through the trained comparative neural network, wherein the effective spectral feature information is used to characterize the spectral feature information of the organic matter and total nitrogen content of the soil sample.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the near-infrared detection method for soil organic matter and total nitrogen content based on the comparative neural network as described in any one of claims 1 to 6 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the near-infrared detection method for soil organic matter and total nitrogen content using a comparative neural network as described in any one of claims 1 to 6 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the near-infrared detection method for soil organic matter and total nitrogen content using a comparative neural network as described in any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Method for identifying white spirits
CN102023137A
Method for eliminating influence on infrared spectrum detection of soil total nitrogen content from moisture
CN103134770A
Soil total nitrogen real-time detection method based on soil visible-near infrared spectrum library
CN103884661A
Soil total nitrogen content detection method and device, electronic equipment and storage medium
CN113203689A
Spatial prediction and evaluation method of soil organic matter content based on partition algorithm
GB202305398D0
Cited By
Soil spectrum detection method and device based on reversible calculation
CN119555624A
Soil Spectral Detection Method and Device Based on Reversible Computing
CN119555624B
Vehicle-mounted soil nutrient detection method and device based on soil spectral data classification
CN119555633A
Vehicle-mounted soil nutrient detection system and method based on comparative learning
CN120908134A
Soil total nitrogen content detection method and device, electronic equipment and storage medium
CN121027036A
