Comparative study on near infrared detection method of soil organic matter and total nitrogen content using artificial neural network
By comparing near-infrared detection methods for soil organic matter and total nitrogen content using neural networks, and utilizing spectral scanning and feature extraction of similar and dissimilar soil samples, the problem of limited sample quantity was solved, achieving efficient and accurate detection of soil organic matter and total nitrogen content.
Patent Information
- Application Number
- CN202411098242.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2044-08-12
AI Technical Summary
Traditional near-infrared methods for detecting soil organic matter and total nitrogen content have limitations due to the limited number of samples, resulting in high detection costs and time consumption. Furthermore, the detection results are easily affected by the complex structure and nutrients of the soil, making it difficult to effectively utilize limited samples for spectral data modeling.
By employing a contrastive neural network approach, near-infrared spectral scanning of similar and dissimilar soil samples is performed. Combined with a weighted one-dimensional convolution operation and a contrastive loss function, effective spectral feature information is extracted to construct a prediction model for soil organic matter and total nitrogen content.
Under limited sample conditions, rapid and accurate detection of soil organic matter and total nitrogen content was achieved, improving detection efficiency and accuracy while reducing labor and time costs.
Smart Images

Figure CN119044108B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of soil detection, and particularly relates to a soil organic matter and total nitrogen content near-infrared detection method based on a contrast neural network. BACKGROUND
[0002] Traditional soil organic matter and total nitrogen detection methods are mainly chemical detection methods, but they have problems such as long detection period, complex operation, large human interference, and environmental pollution risks. 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 environmental friendliness.
[0003] However, the complex structure and rich nutrients of soil affect the near-infrared spectrum, and the high cost of detection, high labor cost, and corresponding time consumption make only a limited number of soil samples available for near-infrared spectrum data modeling.
[0004] Therefore, the soil organic matter and total nitrogen content near-infrared detection method in the related art has the technical problem that the number of soil samples available for near-infrared spectrum data modeling is limited. SUMMARY
[0005] The present application provides a soil organic matter and total nitrogen content near-infrared detection method based on a contrast neural network, which solves the defect that the number of soil samples available for near-infrared spectrum data modeling is limited in the prior art soil organic matter and total nitrogen content near-infrared detection method, and effectively mines soil near-infrared spectrum information under limited sample conditions.
[0006] The present application provides a soil organic matter and total nitrogen content near-infrared detection method based on a contrast neural network, comprising the following steps. Soil in a detection plot is sampled and pretreated to obtain soil samples; the soil samples are filled by a preset detection mold to obtain a plurality of to-be-detected soil samples, wherein the plurality of to-be-detected soil samples are filled in a plurality of preset detection molds; the to-be-detected soil samples in the same preset detection mold are subjected to first near-infrared spectrum scanning to obtain homogenous soil near-infrared spectrum information; the to-be-detected soil samples in different preset detection molds are subjected to second near-infrared spectrum scanning to obtain heterogeneous soil near-infrared spectrum information; the homogenous soil near-infrared spectrum information and the heterogeneous soil near-infrared spectrum information are paired and extracted to obtain a soil spectrum information original spectrum pair; the soil spectrum information original spectrum pair is input into a preset contrast neural network for network parameter training to obtain a trained contrast neural network, and effective spectrum feature information is output by the trained contrast neural network, wherein the effective spectrum feature information is used to represent the spectrum feature information of the organic matter and total nitrogen content of the soil samples.
[0007] The application provides a soil organic matter and total nitrogen content near-infrared detection method based on a contrastive neural network, and the method comprises the following steps: performing first near-infrared spectrum scanning on the same soil sample in a preset detection mold, obtaining the same soil near-infrared spectrum information, and performing multiple shaking treatments on the same soil sample in the preset detection mold; and performing first near-infrared spectrum scanning on the soil sample in the preset detection mold after each shaking treatment, and obtaining the same soil near-infrared spectrum information.
[0008] The application provides a soil organic matter and total nitrogen content near-infrared detection method based on a contrastive neural network, and the method comprises the following steps: performing first near-infrared spectrum scanning on the same soil sample in a preset detection mold, obtaining the same soil near-infrared spectrum information, and performing multiple shaking treatments on the same soil sample in the preset detection mold; and performing first near-infrared spectrum scanning on the soil sample in the preset detection mold after each shaking treatment, and obtaining the same soil near-infrared spectrum information.
[0009] The application provides a soil organic matter and total nitrogen content near-infrared detection method based on a contrastive neural network, and the method comprises the following steps: performing first near-infrared spectrum scanning on the same soil sample in a preset detection mold, obtaining the same soil near-infrared spectrum information, and performing multiple shaking treatments on the same soil sample in the preset detection mold; and performing first near-infrared spectrum scanning on the soil sample in the preset detection mold after each shaking treatment, and obtaining the same soil near-infrared spectrum information.
[0010] The application provides a soil organic matter and total nitrogen content near-infrared detection method based on a contrastive neural network, and the method comprises the following steps: performing first near-infrared spectrum scanning on the same soil sample in a preset detection mold, obtaining the same soil near-infrared spectrum information, and performing multiple shaking treatments on the same soil sample in the preset detection mold; and performing first near-infrared spectrum scanning on the soil sample in the preset detection mold after each shaking treatment, and obtaining the same soil near-infrared spectrum information.
[0011] The application provides a soil organic matter and total nitrogen content near-infrared detection method based on a contrastive neural network, and the method comprises the following steps: performing first near-infrared spectrum scanning on the same soil sample in a preset detection mold, obtaining the same soil near-infrared spectrum information, and performing multiple shaking treatments on the same soil sample in the preset detection mold; and performing first near-infrared spectrum scanning on the soil sample in the preset detection mold after each shaking treatment, and obtaining the same soil near-infrared spectrum information. The application provides a soil organic matter and total nitrogen content near-infrared detection method based on a contrastive neural network, and the method comprises the following steps: performing first near-infrared spectrum scanning on the same soil sample in a preset detection mold, obtaining the same soil near-infrared spectrum information, and performing multiple shaking treatments on the same soil sample in the preset detection mold; and performing first near-infrared spectrum scanning on the soil sample in the preset detection mold after each shaking treatment, and obtaining the same soil near-infrared spectrum information.
[0012] The application further provides a soil organic matter and total nitrogen content near-infrared detection device for a contrast neural network, comprising the following modules: a sampling module for sampling and pretreating soil in a detection plot to obtain soil samples; a loading module for loading the soil samples through a preset detection mold to obtain a plurality of to-be-detected soil samples, wherein the plurality of to-be-detected soil samples are loaded in a plurality of preset detection molds; a first scanning module for performing first near-infrared spectrum scanning on the to-be-detected soil samples in the same preset detection mold to obtain homogenous soil near-infrared spectrum information; a second scanning module for performing second near-infrared spectrum scanning on the to-be-detected soil samples in different preset detection molds to obtain heterogeneous soil near-infrared spectrum information; a pairing module for pairing and extracting based on the homogenous soil near-infrared spectrum information and the heterogeneous soil near-infrared spectrum information to obtain a soil spectrum information original spectrum pair; and an output module for inputting the soil spectrum information original spectrum pair into a preset contrast neural network for network parameter training to obtain a trained contrast neural network, and outputting effective spectrum feature information through the trained contrast neural network, wherein the effective spectrum feature information is used to represent spectrum feature information of organic matter and total nitrogen content of the soil samples.
[0013] The application further provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the soil organic matter and total nitrogen content near-infrared detection method of the contrast neural network according to any one of the above when executing the program.
[0014] The application further provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program is executable on a processor to implement the soil organic matter and total nitrogen content near-infrared detection method of the contrast neural network according to any one of the above.
[0015] The application further provides a computer program product comprising a computer program, wherein the computer program is executable on a processor to implement the soil organic matter and total nitrogen content near-infrared detection method of the contrast neural network according to any one of the above.
[0016] The application provides a soil organic matter and total nitrogen content near-infrared detection method based on a comparative neural network. BRIEF DESCRIPTION OF DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description one by one. Obviously, the drawings in the following description are some embodiments of the application, and for those skilled in the art, other drawings can also be obtained from these drawings without creative labor.
[0018] Figure 1 FIG. 1 is a flowchart of the soil organic matter and total nitrogen content near-infrared detection method based on the comparative neural network provided by the application.
[0019] Figure 2 FIG. 2 is a schematic diagram of the soil spectrum data pair acquisition process provided by the application.
[0020] Figure 3 FIG. 3 is a comparative feature extraction schematic diagram of the soil organic matter and total nitrogen content detection method based on the comparative neural network provided by the application.
[0021] Figure 4 FIG. 4 is a prediction flowchart of the soil organic matter and total nitrogen content detection method based on the comparative neural network provided by the application.
[0022] Figure 5 FIG. 5 is a work flowchart of the soil organic matter and total nitrogen content detection method based on the comparative neural network provided by the application.
[0023] Figure 6 FIG. 6 is a structural schematic diagram of the soil organic matter and total nitrogen content near-infrared detection device based on the comparative neural network provided by the application.
[0024] Figure 7 Fig. 1 is a schematic diagram of the physical structure of an electronic device according to the present application. DETAILED DESCRIPTION
[0025] In order to make the objectives, technical solutions and advantages of the present application clearer, the technical solutions in the present application will be described clearly and completely below with reference to the drawings in the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.
[0026] Soil organic matter and total nitrogen represent the total amount of soil organic matter and nitrogen, and indicate the long-term nutrient supply capacity of the soil, so they are often selected as the measurement index of soil fertility and the basis for dividing nutrient grades. The traditional detection methods of soil organic matter and total nitrogen are mainly chemical detection methods, but they face the problems of long detection period, complex operation, large human interference, and environmental pollution risks. 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 environmental friendliness, 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 methods, which can reflect the combination frequency and double frequency information of C-H, N-H groups, 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 soil affect the near-infrared spectrum, and there are characteristics such as serious spectral peak overlap and wide effective information band, which in turn causes the near-infrared spectrum to fluctuate. At the same time, the high detection cost, high labor cost, and corresponding time consumption make only a limited number of soil samples available for near-infrared spectroscopy data modeling. Therefore, how to efficiently use limited soil samples for near-infrared spectroscopy data acquisition is a problem that needs to be solved at present.
[0028] In order to solve the above problems, the present application provides a kind of near infrared detection method for soil organic matter and total nitrogen content based on contrast neural network. Among them, the same kind of soil sample spectrum information is obtained by shaking the mold containing soil sample, different soil sample spectrum scanning obtains different kind of soil sample spectrum information, a pair of weight shared one-dimensional convolution operation is introduced to extract features of near-infrared spectrum, and contrast loss function is used to filter and obtain spectral feature information that can represent soil organic matter and total nitrogen content, and soil organic matter and total nitrogen content are predicted according to the corresponding spectral feature information.
[0029] REFERENCE Figure 1 ,Figure 1 is a process schematic diagram of the soil organic matter and total nitrogen content near-infrared detection method of the comparative neural network provided by the present application, as shown in Figure 1 , the method comprises the following:
[0030] Step 101, sampling and pretreating the soil in the detection plot to obtain soil samples.
[0031] In the embodiment of the present application, the soil samples in the detection plot are sampled, air-dried, decontaminated, ground and the like to obtain soil samples that can be used for near-infrared spectrum acquisition (i.e. the soil samples mentioned above).
[0032] Step 102, filling the soil samples by using a preset detection mold to obtain a plurality of detection soil samples, wherein the plurality of detection soil samples are filled in a plurality of preset detection molds.
[0033] In the embodiment of the present application, the soil samples that can be used for near-infrared spectrum acquisition are filled into the preset detection mold of the soil.
[0034] Step 103, performing first near-infrared spectrum scanning on the detection soil samples in the same preset detection mold to obtain the near-infrared spectrum information of the same soil.
[0035] In the embodiment of the present application, the same preset detection mold is shaken, and the near-infrared spectrum is scanned once for each shaking to obtain the near-infrared spectrum information of the same soil.
[0036] Step 104, performing second near-infrared spectrum scanning on the detection soil samples in different preset detection molds to obtain the near-infrared spectrum information of different soils.
[0037] In the embodiment of the present application, the near-infrared spectrum scanning is performed on the soil in different molds to obtain the near-infrared spectrum information of different soils.
[0038] Step 105, pairing and extracting based on the near-infrared spectrum information of the same soil and the near-infrared spectrum information of different soils to obtain a pair of original soil spectrum information spectra.
[0039] Reference Figure 2 , Figure 2 is a process schematic diagram of the soil spectrum data pair acquisition provided by the present application.
[0040] As Figure 2As shown, the soil samples (including different types of soil) are filled into a plurality of preset detection molds to obtain soil sample 1 to soil sample n; the near-infrared spectrum scanning 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 near-infrared spectrum scanning is performed on the soil samples to be detected in different preset detection molds to obtain the near-infrared spectrum information of different types of soil; and the pairing module is used to pair and extract the same type of soil near-infrared spectrum information and the different type of soil near-infrared spectrum information based on the same type of soil near-infrared spectrum information and the different type of soil near-infrared spectrum information to obtain a soil spectrum information original spectrum pair (including spectrum and label), wherein the label is used to represent different types (0) or the same type (1).
[0041] In the embodiment of the present application, paired spectrum information is extracted from the same type and different type of soil spectrum information, and corresponding labels are added to obtain a soil spectrum information original spectrum pair.
[0042] In step 106, the soil spectrum information original spectrum pair is input into a preset contrast neural network for network parameter training to obtain a trained contrast neural network, and effective spectrum feature information is output by the trained contrast neural network, wherein the effective spectrum feature information is used to represent the spectrum feature information of the organic matter and total nitrogen content of the soil sample.
[0043] In the embodiment of the present application, the same type / different type of soil spectrum pair (i.e. the soil spectrum information original spectrum pair described above) is input into a preset contrast neural network, and a contrast loss function is used to obtain spectrum feature information (effective spectrum feature information) that can reflect the current soil state.
[0044] Here, a pair of convolutional neural networks with weight sharing are used to extract spectrum feature information from the same type / different type of soil spectrum information pair to obtain spectrum feature distribution in the latent space; then, a contrast loss function is selected to measure the soil spectrum feature, so that the same type of spectrum feature is close and the different type of spectrum feature is far away; finally, the trained contrast neural network outputs effective features that can more effectively distinguish the spectrum.
[0045] In the embodiment of the present application, when in use, the soil sample to be detected is first scanned for spectrum data to obtain original spectrum information, the original spectrum is then copied and labeled as the same type to construct original data input that meets the contrast network, a pre-trained model is used to obtain effective spectrum information of soil total nitrogen and organic matter, and the soil organic matter and total nitrogen are predicted accordingly.
[0046] Subsequently, the effective spectrum information is used to construct a soil organic matter / total nitrogen content prediction model to output corresponding indexes.
[0047] Through the above steps of the embodiment of the present application, the soil in the test plot is sampled and pretreated to obtain soil samples; the soil samples are filled in the preset detection molds to obtain a plurality of to-be-tested soil samples, wherein the plurality of to-be-tested soil samples are filled in a plurality of preset detection molds; the to-be-tested soil samples in the same preset detection mold are subjected to first near-infrared spectrum scanning to obtain homogenous soil near-infrared spectrum information; the to-be-tested soil samples in different preset detection molds are subjected to second near-infrared spectrum scanning to obtain heterogeneous soil near-infrared spectrum information; the homogenous soil near-infrared spectrum information and the heterogeneous soil near-infrared spectrum information are paired and extracted to obtain a soil spectrum information original spectrum pair; and the soil spectrum information original spectrum pair is input into the pre-trained contrast neural network to obtain effective spectrum feature information output by the pre-trained contrast neural network, wherein the effective spectrum feature information is used to represent the spectrum feature information of the organic matter and total nitrogen content of the soil sample. Thus, the technical problem that the number of soil samples available for near-infrared spectrum data modeling is limited in the related art soil organic matter and total nitrogen content near-infrared detection method is solved.
[0048] According to the soil organic matter and total nitrogen content near-infrared detection method of the contrast neural network provided by the present application, the to-be-tested soil samples in the same preset detection mold are subjected to first near-infrared spectrum scanning to obtain homogenous soil near-infrared spectrum information, which includes:
[0049] The to-be-tested soil samples in the same preset detection mold are subjected to multiple shaking treatments.
[0050] After each shaking treatment, the to-be-tested soil samples in the preset detection mold are subjected to first near-infrared spectrum scanning to obtain homogenous soil near-infrared spectrum information.
[0051] In the embodiment of the present application, according to the phenomenon that the organic matter and total nitrogen are unevenly distributed in the soil, the soil samples filled in the same mold are shaken, and the near-infrared spectrum is scanned once for each shaking to obtain homogenous soil spectrum data.
[0052] According to the soil organic matter and total nitrogen content near-infrared detection method of the contrast neural network provided by the present application, the homogenous soil near-infrared spectrum information and the heterogeneous soil near-infrared spectrum information are paired and extracted to obtain a soil spectrum information original spectrum pair, which includes:
[0053] The homogenous soil near-infrared spectrum information and the heterogeneous soil near-infrared spectrum information are paired to obtain a spectrum data pair.
[0054] The spectrum data pair is labeled to obtain a soil spectrum information original spectrum pair, wherein when the two spectrum data in the spectrum data pair are the same, the label of the soil spectrum information original spectrum pair is 1, and when the two spectrum data in the spectrum data pair are different, the label of the soil spectrum information original spectrum pair is 0.
[0055] In the embodiment of the present application, the soil spectrum information original spectrum pair (spectrum data pair) acquisition process is as follows: first, the pretreated original soil sample is loaded into a detection mold; then, the soil sample in the same mold is shaken and scanned once for each shaking to obtain the spectrum information of the same soil sample; second, different soil samples are replaced for scanning to obtain the spectrum information of different soil samples; finally, the spectrum data is paired and extracted by using the method shown in formula (1).
[0056] (1)
[0057] wherein, represents the label of the spectrum data pair, , represent spectrum 1 (S1) and spectrum 2 (S2) scanned from the soil samples numbered 1 and 2 respectively. .
[0058] It should be noted that in general, the number of different sample pairs is much larger than the number of same sample pairs, and a correction coefficient is often multiplied to limit the number.
[0059] According to the soil organic matter and total nitrogen content near-infrared detection method of the comparative neural network provided by the present application, the preset comparative neural network is a pair of convolutional neural networks with shared weights.
[0060] According to the soil organic matter and total nitrogen content near-infrared detection method of the comparative neural network provided by the present application, the soil spectrum information original spectrum pair is input into the comparative neural network for model training to obtain the effective spectrum feature information output by the pre-trained comparative neural network, including:
[0061] Based on the pre-trained comparative neural network, the preset energy function is used as a contrast loss function to measure the soil spectrum information original spectrum pair, so that the same spectrum features are close and the different spectrum features are far apart, to obtain the effective spectrum feature information output by the pre-trained comparative neural network.
[0062] Reference Figure 3 , Figure 3 is a comparative feature extraction schematic diagram of the soil organic matter and total nitrogen content detection method based on the comparative neural network provided by the present application.
[0063] In the embodiments of the present application, the key point is the comparison and measurement of the same / different spectrum data pairs, and the present application proposes a contrast feature extraction method as shown in Figure 3
[0064] Wherein, the soil sample spectrum data pairs are included, the spectrum (including spectrum 11 / 12), the contrast neural network (including a pair of neural networks with weight sharing) includes a plurality of convolution layers, a plurality of pooling layers, and a flat layer, a full connection layer, a network layer, and a latent space variable (including feature 1, feature 2, feature 3, and feature 4) is output through the network layer, the energy function as shown in formula (2) is selected as the measurement function (i.e. contrast loss function) for feature measurement of soil spectrum features, so that the target variable is close to, and the different spectrum features are far away.
[0065] In the embodiments of the present application, first, the same / different soil spectrum information pairs are extracted by a pair of convolutional neural networks with weight sharing to obtain the spectrum feature distribution in the latent space; then, the energy function as shown in formula (2) is selected as the measurement function (i.e. contrast loss function) for measurement of soil spectrum features, so that the same spectrum features are close to, and the different spectrum features are far away; finally, the effective features that can more effectively distinguish the spectrum are obtained.
[0066] (2)
[0067] Wherein, represents the distance measurement, which is defined as the square of the Euclidean distance of two feature vectors and Here, and are the feature vectors (soil spectrum features) obtained after transformation from the original data (soil samples) and .
[0068] Reference Figure 4 , Figure 4 is a prediction flowchart of the soil organic matter and total nitrogen content detection method based on the contrast neural network, wherein, the soil sample to be detected is first scanned to obtain the original spectrum information, and the original spectrum is copied and labeled as the same class to be used as the data input of the weight-sharing feature mining network (pre-trained), and the effective spectrum information output by the feature mining network is obtained, and the preset random forest, extreme learning machine and other modules are used as the prediction model, and the soil organic matter and total nitrogen are predicted accordingly.
[0069] The application provides a soil organic matter and total nitrogen content near-infrared detection method based on a contrastive neural network.
[0070] Based on the preset contrastive neural network, the preset energy function is used as a contrastive loss function to measure the soil spectrum information original spectrum pair, so that similar spectrum features are close to each other and different spectrum features are far away from each other, the trained contrastive neural network is obtained, and the effective spectrum feature information is output through the trained contrastive neural network.
[0071] In the embodiment of the application, the similar / different soil spectrum pairs are input into the contrastive neural network, and the contrastive loss function is used to obtain spectrum feature information that can reflect the current soil state. Finally, the effective spectrum information is used to construct a soil organic matter / total nitrogen content prediction model to output corresponding indexes.
[0072] Reference Figure 5 , Figure 5 is a soil organic matter and total nitrogen content detection method based on a contrastive neural network provided by the application.
[0073] The embodiment of the application mainly solves the soil near-infrared spectrum feature data mining problem in the limited sample case. Through the embodiment of the application, the similar soil sample spectrum information is obtained by shaking the mold filled with the soil sample, the different soil sample spectrum information is obtained by scanning the near-infrared spectrum, a pair of weight-shared one-dimensional convolution operations are introduced to extract the near-infrared spectrum features, the contrastive loss function is used to screen and obtain the spectrum feature information capable of representing the soil organic matter and total nitrogen content, and the soil organic matter and total nitrogen content are predicted according to the corresponding spectrum feature information. The specific process is shown in Figure 4
[0074] The specific steps are as follows: first, the soil samples in the detection plot are sampled, air-dried, cleaned, ground and the like to obtain soil sample samples that can be used for near-infrared spectrum collection, and the soil sample samples are filled into detection molds.
[0075] Secondly, the same mold is shaken, and the near-infrared spectrum is scanned once each time the mold is shaken to obtain the similar soil near-infrared spectrum information.
[0076] The near-infrared spectrum of the soil in different molds is scanned to obtain the different (different types) soil near-infrared spectrum information.
[0077] Again, the paired spectral information is extracted from the homologous and heterogeneous soil spectral information, and the corresponding labels are added to obtain the original data pair of soil spectral information (with labels). Then, the homologous / heterogeneous soil spectrum pair is 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.
[0078] Finally, the effective spectral information is used to construct a soil organic matter / total nitrogen content prediction model to output the corresponding index (soil property information).
[0079] The purpose of the present application is to provide a near-infrared detection method for soil organic matter and total nitrogen content based on a contrast neural network, which can fully utilize limited soil spectral information to mine soil effective features. The present application solves the effective mining of soil near-infrared spectral information under the condition of limited samples. The present application provides a fast, efficient and accurate measurement for soil organic matter and total nitrogen detection in actual application scenarios.
[0080] The present application provides a soil organic matter and total nitrogen content detection method based on a contrast neural network. According to the uneven distribution of organic matter and total nitrogen in soil, the soil samples filled in the same mold are shaken to obtain homologous soil spectral data. The spectral data pairs (the number of , is the amount of soil sample data) are combined for spectral data feature mining, and a larger number of data pairs can be composed from small sample data. The contrast neural network is used for soil spectral feature information mining, and the energy function is used for contrast loss measurement, so that the homologous spectral features are close and the heterogeneous spectral features are far away.
[0081] The contrast neural network soil organic matter and total nitrogen content near-infrared detection device provided by the present application is described below. The contrast neural network soil organic matter and total nitrogen content near-infrared detection device described below can be correspondingly referred to the contrast neural network soil organic matter and total nitrogen content near-infrared detection method described above.
[0082] Reference Figure 6 , Figure 6 is a structural schematic diagram of the contrast neural network soil organic matter and total nitrogen content near-infrared detection device provided by the present application, 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.
[0083] The sampling module 601 is used for sampling and pretreating the soil in the detection plot to obtain soil samples.
[0084] The filling module 602 is configured to fill the soil samples in the preset detection molds to obtain a plurality of to-be-detected soil samples, wherein the plurality of to-be-detected soil samples are filled in the plurality of preset detection molds respectively;
[0085] The first scanning module 603 is configured to perform first near-infrared spectrum scanning on the to-be-detected soil samples in the same preset detection mold to obtain homogenous soil near-infrared spectrum information.
[0086] The second scanning module 604 is configured to perform second near-infrared spectrum scanning on the to-be-detected soil samples in different preset detection molds to obtain heterogeneous soil near-infrared spectrum information.
[0087] The pairing module 605 is configured to pair and extract the homogenous soil near-infrared spectrum information and the heterogeneous soil near-infrared spectrum information to obtain a soil spectrum information original spectrum pair.
[0088] The output module 606 is configured to input the soil spectrum information original spectrum pair into the preset comparative neural network to perform network parameter training, obtain a trained comparative neural network, and output effective spectrum feature information through the trained comparative neural network, wherein the effective spectrum feature information is used to represent the spectrum feature information of the organic matter and total nitrogen content of the soil sample.
[0089] Specifically, the soil organic matter and total nitrogen content near-infrared detection device of the above comparative neural network provided by the present application can realize all the method steps realized by the soil organic matter and total nitrogen content near-infrared detection method embodiment of the above comparative neural network, and can achieve the same technical effects. The same parts and beneficial effects in this embodiment as in the method embodiment will not be described in detail.
[0090] Figure 7 is the entity structure schematic diagram of the electronic equipment provided by the present application, like Figure 7As shown, the electronic device can include a processor 710, a communications interface 720, a memory 730, and a communications bus 740, wherein the processor 710, the communications interface 720, and the memory 730 complete mutual communication through the communications bus 740. The processor 710 can invoke a logical instruction in the memory 730 to execute a soil organic matter and total nitrogen content near-infrared detection method of a comparative neural network, the method comprising: sampling and pretreating soil in a detection plot to obtain soil samples; filling the soil samples through a preset detection mold to obtain a plurality of to-be-detected soil samples, wherein the plurality of to-be-detected soil samples are filled in a plurality of preset detection molds; performing first near-infrared spectrum scanning on the to-be-detected soil samples in the same preset detection mold to obtain homogenous soil near-infrared spectrum information; performing second near-infrared spectrum scanning on the to-be-detected soil samples in different preset detection molds to obtain heterogeneous soil near-infrared spectrum information; pairing and extracting based on the homogenous soil near-infrared spectrum information and the heterogeneous soil near-infrared spectrum information to obtain a soil spectrum information original spectrum pair; and inputting the soil spectrum information original spectrum pair into a pre-trained comparative neural network to obtain effective spectrum feature information output by the pre-trained comparative neural network, wherein the effective spectrum feature information is used to represent the spectrum feature information of the organic matter and total nitrogen content of the soil sample.
[0091] In addition, the logical instructions in the memory 730 described above can be implemented in the form of a software function unit and sold or used as an independent product, and can be stored in a computer-readable storage medium. Based on such understanding, the technical solutions of the present application or parts of the present application that essentially contribute to the prior art or parts of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.
[0092] In another aspect, the present application also provides a computer program product, which comprises a computer program, the computer program being stored in a non-transitory computer-readable storage medium and executable by a processor to enable a computer to perform the soil organic matter and total nitrogen content near-infrared detection method of the comparative neural network provided by the above method, the method comprising: sampling and pretreating the soil in a detection plot to obtain soil samples; filling the soil samples by using a preset detection mold to obtain a plurality of to-be-detected soil samples, wherein the plurality of to-be-detected soil samples are filled in a plurality of preset detection molds; performing first near-infrared spectrum scanning on the to-be-detected soil samples in the same preset detection mold to obtain homogenous soil near-infrared spectrum information; performing second near-infrared spectrum scanning on the to-be-detected soil samples in different preset detection molds to obtain heterogeneous soil near-infrared spectrum information; pairing and extracting based on the homogenous soil near-infrared spectrum information and the heterogeneous soil near-infrared spectrum information to obtain a soil spectrum information original spectrum pair; inputting the soil spectrum information original spectrum pair into a pre-trained comparative neural network to obtain effective spectrum feature information output by the pre-trained comparative neural network, wherein the effective spectrum feature information is used to represent the spectrum feature information of the organic matter and total nitrogen content of the soil sample.
[0093] In yet another aspect, the present application also provides a non-transitory computer-readable storage medium having a computer program stored thereon, the computer program being executable by a processor to implement the soil organic matter and total nitrogen content near-infrared detection method of the comparative neural network provided by the above method, the method comprising: sampling and pretreating the soil in a detection plot to obtain soil samples; filling the soil samples by using a preset detection mold to obtain a plurality of to-be-detected soil samples, wherein the plurality of to-be-detected soil samples are filled in a plurality of preset detection molds; performing first near-infrared spectrum scanning on the to-be-detected soil samples in the same preset detection mold to obtain homogenous soil near-infrared spectrum information; performing second near-infrared spectrum scanning on the to-be-detected soil samples in different preset detection molds to obtain heterogeneous soil near-infrared spectrum information; pairing and extracting based on the homogenous soil near-infrared spectrum information and the heterogeneous soil near-infrared spectrum information to obtain a soil spectrum information original spectrum pair; inputting the soil spectrum information original spectrum pair into a pre-trained comparative neural network to obtain effective spectrum feature information output by the pre-trained comparative neural network, wherein the effective spectrum feature information is used to represent the spectrum feature information of the organic matter and total nitrogen content of the soil sample.
[0094] The device embodiments described above are merely illustrative, wherein the units described as separate components can or can not be physically separate, and the components displayed as units can or can not be physical units, i.e., can be located in one place, or can be distributed to multiple network units. Part or all of the modules can be selected to achieve the purposes of the embodiments according to actual needs. Those skilled in the art can understand and implement without creative labor.
[0095] Through the description of the above embodiments, those skilled in the art can clearly understand that the embodiments can be realized by means of software and the necessary general hardware platform, and of course can also be realized by hardware. Based on such understanding, the above technical solutions can be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the methods described in each embodiment or some parts of the embodiments.
[0096] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for part of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for detecting soil organic matter and total nitrogen content by near-infrared spectroscopy using a contrastive neural network, characterized in that, The method comprises the following steps: sampling and pretreating soil in a test plot to obtain soil samples; filling the soil samples into preset test molds to obtain a plurality of soil samples to be tested, wherein the plurality of soil samples to be tested are filled into a plurality of preset test molds; performing first near-infrared spectrum scanning on the soil samples in the same test mold to obtain homogenous soil near-infrared spectrum information; performing second near-infrared spectrum scanning on the soil samples in different test molds to obtain heterogeneous soil near-infrared spectrum information; pairing and extracting the homogenous soil near-infrared spectrum information and the heterogeneous soil near-infrared spectrum information to obtain a pair of soil spectrum information original spectra; inputting the pair of soil spectrum information original spectra into a preset contrast neural network for network parameter training to obtain a trained contrast neural network, and outputting effective spectrum feature information through the trained contrast neural network, wherein the effective spectrum feature information is used to represent spectrum feature information of organic matter and total nitrogen content of the soil samples; the step of performing first near-infrared spectrum scanning on the soil samples in the same test mold to obtain homogenous soil near-infrared spectrum information comprises the following steps: performing multiple shaking treatments on the soil samples in the same test mold; performing first near-infrared spectrum scanning on the soil samples in the test mold after each shaking treatment to obtain homogenous soil near-infrared spectrum information; the step of pairing and extracting the homogenous soil near-infrared spectrum information and the heterogeneous soil near-infrared spectrum information to obtain a pair of soil spectrum information original spectra comprises the following steps: pairing the homogenous soil near-infrared spectrum information and the heterogeneous soil near-infrared spectrum information to obtain a pair of spectrum data; adding labels to the pair of spectrum data to obtain a pair of soil spectrum information original spectra, wherein when the two spectrum data in the pair of spectrum data are the same, the label of the pair of soil spectrum information original spectra is 1, and when the two spectrum data in the pair of spectrum data are different, the label of the pair of soil spectrum information original spectra is 0.
2. The method of claim 1, wherein the soil organic matter and total nitrogen content near-infrared detection method of the contrast neural network is characterized in that, The preset contrast neural network is a pair of convolutional neural networks sharing weights.
3. The method of claim 2, wherein the soil organic matter and total nitrogen content near-infrared detection method is a comparative neural network. The step of inputting the pair of soil spectrum information original spectra into a preset contrast neural network for network parameter training to obtain a trained contrast neural network, and outputting effective spectrum feature information through the trained contrast neural network comprises the following steps: based on the preset contrast neural network, using a preset energy function as a contrast loss function to measure the pair of soil spectrum information original spectra so that homogenous spectrum features are close to each other and heterogeneous spectrum features are far away from each other, to obtain a trained contrast neural network, and output effective spectrum feature information through the trained contrast neural network.
4. The method of claim 1, wherein the soil organic matter and total nitrogen content near-infrared detection method is a comparative neural network. After the step of outputting effective spectrum feature information through the trained contrast neural network, the method further comprises the following steps: 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 indexes, and the soil indexes are used to represent soil attribute information.
5. A soil organic matter and total nitrogen content near-infrared detection device for a contrast neural network, characterized in that, Comprise: A sampling module is configured to sample and pretreat soil in a detection plot to obtain soil samples; A loading module is configured to load the soil samples into a plurality of preset detection molds to obtain a plurality of to-be-detected soil samples, wherein the plurality of to-be-detected soil samples are loaded into the plurality of preset detection molds respectively; A first scanning module is configured to perform first near-infrared spectrum scanning on the to-be-detected soil samples in the same preset detection mold to obtain homogenous soil near-infrared spectrum information; A second scanning module is configured to perform second near-infrared spectrum scanning on the to-be-detected soil samples in different preset detection molds to obtain heterogeneous soil near-infrared spectrum information; A pairing module is configured to pair and extract the homogenous soil near-infrared spectrum information and the heterogeneous soil near-infrared spectrum information to obtain a soil spectrum information original spectrum pair; An output module is configured to input the soil spectrum information original spectrum pair into a preset contrast neural network for network parameter training to obtain a trained contrast neural network, and output effective spectral feature information through the trained contrast neural network, wherein the effective spectral feature information is used to represent spectral feature information of organic matter and total nitrogen content of the soil samples; The first near-infrared spectrum scanning on the to-be-detected soil samples in the same preset detection mold to obtain homogenous soil near-infrared spectrum information comprises: Performing multiple shaking processes on the to-be-detected soil samples in the same preset detection mold; After each shaking process, performing first near-infrared spectrum scanning on the to-be-detected soil samples in the preset detection mold to obtain homogenous soil near-infrared spectrum information; The pairing and extracting the homogenous soil near-infrared spectrum information and the heterogeneous soil near-infrared spectrum information to obtain a soil spectrum information original spectrum pair comprises: Pairing the homogenous soil near-infrared spectrum information and the heterogeneous soil near-infrared spectrum information to obtain a spectrum data pair; Adding labels to the spectrum data pair to obtain a soil spectrum information original spectrum pair, wherein when two spectrum data in the spectrum data pair are the same, the label of the soil spectrum information original spectrum pair is 1, and when the two spectrum data in the spectrum data pair are different, the label of the soil spectrum information original spectrum pair is 0.
6. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the computer program to implement the soil organic matter and total nitrogen content near-infrared detection method of the contrast neural network according to any one of claims 1 to 4.
7. A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the soil organic matter and total nitrogen content near-infrared detection method of the contrast neural network according to any one of claims 1 to 4.
8. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the soil organic matter and total nitrogen content near-infrared detection method of the contrast neural network according to any one of claims 1 to 4.