A soil heavy metal hyperspectral inversion method based on a CNN-TabM model

By combining a one-dimensional convolutional neural network and the TabM model, local features of soil spectra are extracted and fused, which solves the problem of insufficient local spectral feature perception capability in existing technologies and improves the accuracy of hyperspectral inversion of heavy metals in soil.

CN122365366APending Publication Date: 2026-07-10KUNMING UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610496265.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-04-15
Publication Date
2026-07-10

AI Technical Summary

Technical Problem

Existing methods for retrieval of heavy metals in soil have difficulty fully exploring the nonlinear local details in soil hyperspectral data. Traditional machine learning models and tabular deep learning models such as TabM have limited ability to perceive local spectral features and cannot simultaneously possess the sensitivity to local spectral details and the ability to model the correlation of global features.

Method used

A CNN-TabM model-based approach is adopted, which extracts local spectral features of soil spectra through a one-dimensional convolutional neural network, fuses these features with feature bands, and inputs them into the TabM model for global feature interaction and integrated prediction, thereby enhancing the model's sensitivity to local spectral morphology and its ability to model global features.

Benefits of technology

It improves the accuracy and stability of soil heavy metal hyperspectral inversion, and enhances the inversion accuracy of heavy metal elements such as copper, lead, and zinc, outperforming traditional models and the single TabM model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122365366A_ABST
    Figure CN122365366A_ABST
Patent Text Reader

Abstract

This invention discloses a hyperspectral inversion method for soil heavy metals based on a CNN-TabM model, belonging to the field of quantitative inversion of soil heavy metal content via hyperspectral remote sensing. The method includes: collecting soil samples and measuring hyperspectral data and heavy metal content; sequentially performing noise band removal, SG smoothing, and fractional derivative transform on the hyperspectral data, and using the CARS algorithm to select feature bands; inputting the selected bands into the CNN-TabM model, which uses a one-dimensional convolutional neural network to extract local spectral features, and after feature fusion, inputting the results into the TabM model for global feature interaction and ensemble prediction, outputting the heavy metal content inversion result. This invention achieves complementary advantages of local spectral detail perception and global feature modeling by coupling convolutional neural networks and tabular deep learning models, significantly improving the accuracy of soil heavy metal inversion and providing effective technical support for soil environmental monitoring.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of quantitative inversion of soil heavy metal content by hyperspectral remote sensing, and particularly relates to a method for hyperspectral inversion of soil heavy metals based on the CNN-TabM model. Background Technology

[0002] Heavy metal pollution in soil poses a serious threat to ecosystems and public health. Heavy metals such as copper, lead, and zinc, due to their high toxicity, recalcitrant nature, and bioaccumulation, can cause long-term potential harm to the ecological environment and human health through the food chain accumulation effect. Therefore, achieving rapid, accurate, and large-scale monitoring of heavy metal elements in soil is a primary prerequisite for conducting pollution risk assessments, implementing precise remediation, and making sustainable management decisions. Hyperspectral remote sensing technology, with its high spectral resolution and rich information content, can capture subtle spectral characteristics related to soil physicochemical properties and has become an important tool for quantitative inversion of soil heavy metal content. Existing inversion methods mainly include partial least squares regression based on statistical analysis, random forests and support vector machines based on machine learning, and tabular deep learning models (such as TabNet and TabM) that have emerged in recent years. Among them, the TabM model, through a parameter-efficient ensemble mechanism, simulates the effect of multi-model ensembles with almost no increase in computational cost, demonstrating good generalization performance in structured tabular data processing.

[0003] However, existing methods still have significant limitations when processing soil hyperspectral data. Soil hyperspectral data exhibits strong continuity and high dimensionality, and the local spectral morphology formed by adjacent bands (such as the depth, width, and symmetry of absorption valleys) is crucial information for identifying soil mineral components and heavy metal carriers. Traditional machine learning models and tabular deep learning models such as TabM primarily model based on global features, exhibiting limited ability to perceive these local spectral features and failing to fully extract nonlinear local details from the spectral data. While convolutional neural networks possess advantages in local feature extraction, their efficiency in modeling global feature interactions is insufficient when used alone. Therefore, how to enable inversion models to possess both sensitivity to local spectral details and the ability to model global feature correlations has become a key issue in improving the accuracy of soil heavy metal hyperspectral inversion. Summary of the Invention

[0004] To address the aforementioned technical problems, this invention provides a method for hyperspectral inversion of heavy metals in soil based on the CNN-TabM model, comprising: Soil samples were obtained, and the hyperspectral data and heavy metal content of the soil samples were determined. Based on the hyperspectral data, noise bands are removed, and the noise-removed hyperspectral data is smoothed to obtain the original spectral data. Based on the original spectral data, a fractional derivative transformation is performed to obtain the transformed spectral data; Based on the transformed spectral data, a feature selection algorithm is used to filter out the characteristic bands related to the heavy metal content; The heavy metal content is used as the dependent variable, and the selected characteristic bands are used as independent variables. The results are input into the CNN-TabM inversion model to output the inversion results of the heavy metal content. The CNN-TabM inversion model extracts local spectral features of the feature bands through a one-dimensional convolutional neural network, fuses the local spectral features with the feature bands, and inputs the fused features into the TabM model for global feature interaction and integrated prediction.

[0005] Optionally, soil samples are acquired, and hyperspectral data and heavy metal content of the soil samples are determined, including: Soil samples were collected and then air-dried, ground, and sieved to obtain processed soil powder. The hyperspectral data of the treated soil powder were measured using a ground object spectrometer, and the heavy metal content was determined using a handheld fluorescence spectrometer.

[0006] Optionally, based on the hyperspectral data, noise bands are removed, including: Obtain the spectral range measured by the ground object spectrometer, and remove the edge intervals within the spectral range as the noise band.

[0007] Optionally, the noise-removed hyperspectral data is smoothed to obtain the original spectral data, including: The Savitzky-Golay convolutional smoothing algorithm is used to smooth the noise-removed hyperspectral data to obtain the original spectral data.

[0008] Optionally, the one-dimensional convolutional neural network extracts local spectral features of the feature band, including: The characteristic bands are constructed into an input matrix, and channel dimensions are added to the input matrix to obtain three-dimensional input data; The three-dimensional input data is fed into a two-layer one-dimensional convolutional network, where convolution, batch normalization, activation function, and regularization are performed sequentially. The processed three-dimensional output tensor is then flattened into two-dimensional data to obtain the local spectral features.

[0009] Optionally, feature fusion of the local spectral features and the feature band includes: The characteristic bands are spliced ​​and fused with the local spectral features to obtain enhanced feature data.

[0010] Optionally, the fused features are input into the TabM model for global feature interaction and ensemble prediction, including: The enhanced feature data is input into the integrated view module and expanded into a three-dimensional tensor through tensor product; The three-dimensional tensor is input into a TabM module consisting of multiple stacked integrated feedforward networks. The prediction results of multiple integrated members are generated through a batch integration layer, and the average value of the prediction results of all integrated members is used as the final inversion result.

[0011] Optionally, based on the transformed spectral data, a feature selection algorithm is used to filter out characteristic bands related to the heavy metal content, including: A competitive adaptive reweighting algorithm is used to iteratively filter the transformed spectral data multiple times, and the bands that appear a preset threshold number of times are taken as the feature bands.

[0012] On the other hand, the present invention also provides an electronic device including a memory, a processor, and a computing program stored in the memory and executable on the processor, wherein the processor implements the method when executing the computing program.

[0013] On the other hand, the present invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method.

[0014] Compared with the prior art, the present invention has the following advantages and technical effects: This invention couples a one-dimensional convolutional neural network (CNN) with a TabM model. The CNN extracts local dependencies and abstract features between adjacent spectral bands, effectively enhancing the model's sensitivity to local spectral morphology such as absorption valley depth and width. A feature fusion strategy combines the local features extracted by convolution with the original spectral features, enhancing the completeness of the input features. The fused features are then input into the TabM model for efficient global feature interaction and integrated prediction, achieving a complementary advantage between local perception and global modeling. Experimental results show that this invention outperforms traditional models and the single TabM model in the inversion of three heavy metals: copper, lead, and zinc. It provides a new technical means for hyperspectral inversion of heavy metals in soil, effectively improving the accuracy and stability of the inversion results. Attached Figure Description

[0015] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings: Figure 1 This is a schematic diagram of the method flow according to an embodiment of the present invention; Figure 2 This is a diagram of the fractional differential transform according to an embodiment of the present invention; Figure 3 This is a band distribution diagram after feature selection in an embodiment of the present invention; Figure 4 This is a schematic diagram of the innovative CNN-TabM model structure according to an embodiment of the present invention; Figure 5 This is a 1:1 scatter plot comparing the Cu models of various embodiments of the present invention. Figure 6 This is a 1:1 scatter plot comparing the Pb modeling of each model in the embodiments of the present invention; Figure 7 This is a 1:1 scatter plot comparing the Zn modeling of various models in the embodiments of the present invention. Detailed Implementation

[0016] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.

[0017] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.

[0018] Example 1 like Figure 1 As shown, this embodiment provides a method for hyperspectral inversion of soil heavy metals based on the CNN-TabM model, including: Soil samples were obtained, and the hyperspectral data and heavy metal content of the soil samples were determined. Based on the hyperspectral data, noise bands are removed, and the noise-removed hyperspectral data is smoothed to obtain the original spectral data. Based on the original spectral data, a fractional derivative transformation is performed to obtain the transformed spectral data; Based on the transformed spectral data, a feature selection algorithm is used to filter out the characteristic bands related to the heavy metal content; The heavy metal content is used as the dependent variable, and the selected characteristic bands are used as independent variables. The results are input into the CNN-TabM inversion model to output the inversion results of the heavy metal content. The CNN-TabM inversion model extracts local spectral features of the feature bands through a one-dimensional convolutional neural network, fuses the local spectral features with the feature bands, and inputs the fused features into the TabM model for global feature interaction and integrated prediction.

[0019] Specifically, it includes: Step 1: Field soil sample collection, indoor soil spectral reflectance data and determination of copper, lead and zinc heavy metal content; Step 2: Remove bands with significant noise interference from the hyperspectral reflectance data; Step 3: Perform SG convolution smoothing on the bands after removing noise interference, and use the smoothed data as the original spectrum; Step 4: Perform fractional derivative (FOD) spectral transformation on the original spectrum to highlight the spectral peak characteristics. Set the transformation step size to 0.25. Step 5: The competitive adaptive reweighted (CARS) feature selection method was used to screen the sensitive wavelengths of the hyperspectral feature bands of heavy metals copper, lead and zinc in the soil. Step 6: Use the CNN-TabM model proposed in this invention to establish hyperspectral prediction models for the content of copper, lead, and zinc, and verify their accuracy and stability. Step 1 specifically refers to: If soil samples are collected in the field, use GPS to record the latitude and longitude coordinates of the point. Collect 500-1000g of each sample. Transport the soil samples back to the laboratory and spread them out in time to air dry naturally, avoiding exposure to sunlight. After air drying, grind them through a 100-mesh nylon sieve and retain about 100g of soil powder. The processed soil powder was divided into two portions. One portion was used for indoor soil spectral reflectance data measurement (using a ground object spectrometer ASD), and the other portion was used to determine the content of heavy metal copper (using a handheld fluorescence spectrometer).

[0020] Step 2 specifically refers to: The spectral range measured by the ASD ground object spectrometer is usually 350-2500nm. However, noise interference is usually significant in the edge ranges of 350-399nm and 2451-2500nm, so spectral reflectance data in these ranges are excluded.

[0021] Step 3, which involves SG convolution smoothing of the soil spectrum, specifically includes: The Savitzky-Golay (SG) convolution smoothing algorithm was used to process the soil spectral curves. The sliding window number was set to 9, the order of the fitting polynomial was 2, and the data smoothed by SG was used as the original spectral data OR.

[0022] The transformation using fractional derivatives in Step 4 specifically involves: ; In the formula, Indicates the order of the differential. This represents the step size of the differential. This represents the upper limit of the derivative. This represents the lower limit of the differential. Represents the Gamma function. .

[0023] hypothesis function It is a one-dimensional hyperspectral signal. Representing wavelength range It can be based on the differential step size Divide the band intervals equally. For example, let... , Then the function can be derived. of The expression for the difference between the derivatives of the first and second orders is as follows: ; In the formula, Indicates the order, Represents the original spectrum; Represents the 1.0 order differential of integer order; This represents the 2.0th order derivative of integer order. The fractional derivative transformation is implemented using Python programming, with a fractional step size of 0.25.

[0024] Step 5, which utilizes CARS feature selection, specifically involves: The CARS algorithm is used to select hyperspectral feature bands. Due to the instability of the Monte Carlo algorithm, the code is iterated 50 times to select bands that appear 20 times or more. This step is implemented using MATLAB R2024B.

[0025] Step 6, which utilizes the CNN-TabM model inversion framework, specifically involves: The model first utilizes a one-dimensional convolutional network to extract multi-scale nonlinear representations from the original spectral features. Then, it combines the CNN features with the original features through a feature fusion strategy, inputting the combined features into an improved TabM ensemble architecture for prediction. The overall architecture consists of: a configurable one-dimensional CNN feature extraction module, a feature fusion module, and a parameter-efficient TabM ensemble predictor.

[0026] The feature extraction process of a CNN (Convolutional Neural Network) includes: A Convolutional Neural Network (CNN) is a feedforward neural network specifically designed to process data with a grid-like topology. It is an important deep learning technique with advantages such as weight sharing and automatic feature extraction. This method is a feedforward neural network that combines convolutional computation and deep structure, comprising an input layer, convolutional layers, activation layers, and connection layers. As the core component of a CNN, the convolutional layer automatically extracts implicit features from the data through local perception and parameter sharing mechanisms. Therefore, CNNs possess powerful feature extraction capabilities, enabling them to identify more subtle nonlinear features. Let the input tabular data be a matrix X∈R^(B×din), where B is the batch size and din is the feature dimension. The 1DCNN feature extraction process can be represented as follows: First, to adapt to one-dimensional convolution operations, channel dimensions are added to the data, X(0)=X×e∈R^(B×1×din), which is then input into a configurable two-layer one-dimensional convolutional network. Taking the first convolutional layer as an example, for the output of the c-th filter as shown in formula (1), padding is used to fill the kernel / / 2 to maintain the dimension. Then, batch normalization, ReLU activation, and Dropout regularization are performed on the convolutional output. After the second convolution and the same subsequent processing, the three-dimensional output tensor is flattened into two dimensions. Finally, a three-layer fully connected dimensionality reduction network is used to reduce the dimensionality to a fixed representation, with the output dimension set to 32. .

[0027] Convolutional layers: ; Where t represents batch (1…B), c represents channel (1…c), i represents dimension (1…din), Zi represents the three-dimensional array passed through the i-th convolutional kernel, bi represents the bias, and Wi represents the weight.

[0028] BatchNorm is calculated as follows: ; ; The ReLU activation is calculated as follows: ; The Dropout layer is computed as follows, applying a Bernoulli mask to each activation value: ; Where m[t,c,i] follows Bernoulli(1-P), P=0.3. A1[t,c,i] represents a three-dimensional array activated by ReLU.

[0029] The feature fusion process includes: In order to make comprehensive use of the original spectral features and the deep nonlinear features extracted by CNN, we use a splicing and fusion strategy to transform the original feature dimension X∈R^(B×din) into X∈R^(B×(din+32)).

[0030] ; X represents the original spectral features, and Fcnn represents the features extracted by CNN.

[0031] Ensemble TabM Deep Learning The feature-fused data X∈R^(B×(din+32)) enters the TabM predictor. The core concept of TabM is to simulate the ensemble effect of multiple sub-models within a single model through efficient parameter ensemble techniques, while maintaining a low parameter count and computational cost. Its core design is "one model, multiple predictions." Instead of independently training multiple MLPs, it shares most parameters and introduces a small number of unique parameters, allowing a single model to generate multiple predictions in parallel during forward propagation, thus simulating the behavior of an ensemble model. It is an ensemble architecture that uses an MLP as its backbone and achieves multiple predictions from a single model through an improved BatchEnsemble technique. First, after the model receives the feature vectors from the table, all features are mapped into a unified embedding vector by the feature encoding layer and then enter the EnsembleView module for integration. Based on the integration number k=32, the data is transformed into X∈R^(B×32×(din+32)), preparing for parallel processing. Subsequently, the data is input into the TabM Block module, which is an integrated feedforward network. For a traditional linear layer y=xw+b, the core of each TabM block is an improved BatchEnsemble layer. Integration members share the weight matrix w and bias b, while each individual member randomly introduces a pair of column vectors r and row vectors s. Vector r is initialized using a normal distribution in the first layer and all 1s in subsequent layers. Vector s is initialized with all 1s. After multiple blocks are stacked, this member-specific perturbation accumulates and amplifies in the deep network. Through LinearBatchsemble, the top K integrated prediction heads receive diverse feature representations, thus making different predictions. The final prediction result is the average of the outputs of all integrated members. The optimizer configuration selects the AdamW algorithm to optimize the model, and adds an early stopping mechanism and a patience value. The CNN module constructed in this paper, through its local connections and hierarchical structure, is specifically designed to mine subtle and complex nonlinear relationships and local patterns in spectral features, overcoming the shortcomings of pure MLP structures in this regard. The TabM module, through its parameter-efficient ensemble mechanism, provides robustness and strong predictive performance similar to deep ensembles with almost no increase in computational cost. The combination of the two enables the model to possess both powerful feature extraction capabilities and superior generalization performance when dealing with complex nonlinear regression tasks such as soil heavy metal inversion.

[0032] EnsembleView layer: ; Xens represents the expansion of the feature matrix into a three-dimensional tensor through tensor product fusion, and 1k represents a k-dimensional column vector with all elements being 1 (T represents transpose).

[0033] BtachEnsemble layer: ; rl,k and sl,k represent element-wise scaling factors, Wl represents the weight matrix (T represents transpose), and bl represents the bias.

[0034] Predictive head integration: ; Yk represents the predicted value for each ensemble member.

[0035] Example 2 This embodiment provides a method for hyperspectral inversion of heavy metals in soil based on the CNN-TabM model, including: Step 1: Field soil sample collection, indoor soil spectral reflectance data, and determination of heavy metals copper, lead, and zinc content: Specifically, the study area covers a total area of ​​225 square kilometers. Using 91bitmap assistant and ArcGIS software, 205 samples were planned using a 1×1 kilometer grid, avoiding vegetated areas during sampling. Easily accessible areas were selected for sampling, and samples were taken within the planned grid as much as possible. A total of 310 soil samples were collected in the field. The latitude and longitude coordinates of each point were recorded using GPS. Each sample weighed 500-1000g. The soil samples were transported back to the laboratory, spread out, and allowed to air dry. After drying, the soil was ground through a 100-mesh nylon sieve, retaining approximately 100g of soil powder. The processed soil powder was divided into two portions: one for indoor soil spectral reflectance data measurement (using an ASD ground object spectrometer), and the other for determining the copper content (using a handheld fluorescence spectrometer).

[0036] Step 2: Remove bands with significant noise interference from the hyperspectral reflectance data; Specifically, the noisy spectral ranges in the soil hyperspectral data measured in Step 1 were removed. The wavelength range of the ASD measurements was 350 nm-2500 nm, with a sampling interval of 1 nm. During the spectral acquisition process, due to instrument limitations, the 350 nm-399 nm and 2451 nm-2500 nm ranges had significant noise; therefore, the spectral data in these two ranges were removed.

[0037] Step 3: Perform SG convolution smoothing on the soil spectrum to remove noise interference bands, and use the smoothed data as the original spectrum; Specifically, the spectral data after noise removal in Step 2 were processed using the Savitzky-Golay (SG) convolution smoothing algorithm. The sliding window number was set to 9, the order of the fitting polynomial was 2, and the SG smoothed data was used as the original spectral data. The process was implemented using MATLAB R2024b.

[0038] Step 4: Perform fractional derivative transform on the original spectral data to highlight spectral features; ; In the formula, Indicates the order of the differential. This represents the step size of the differential. This represents the upper limit of the derivative. This represents the lower limit of the differential. Represents the Gamma function. .

[0039] hypothesis function It is a one-dimensional hyperspectral signal. Representing wavelength range It can be based on the differential step size Divide the band intervals equally. For example, let... , Then the function can be derived. of The expression for the difference between the derivatives of the first and second orders is as follows: ; In the formula, Indicates the order, Represents the original spectrum; Represents the 1.0 order differential of integer order; This represents the 2.0th order derivative of integer order. The fractional derivative transformation was programmed in Python with a fractional step size of 0.25. The transformation result is as follows: Figure 2 As shown.

[0040] Step 5: Select hyperspectral characteristic bands using the CARS algorithm; Specifically, the CARS algorithm was used to select hyperspectral feature bands. Due to the instability of the Monte Carlo algorithm, the code was iterated 50 times to select bands that appeared 20 times or more. This step was implemented using MATLAB R2024B. The feature selection results are as follows: Figure 3 As shown.

[0041] Step 6: Use CNN-TabM to build a hyperspectral inversion model for the content of copper, lead, and zinc; Specifically, the characteristic bands selected based on the CARS algorithm were used as independent variables, and the contents of copper, lead, and zinc were used as dependent variables. The CNN-TabM method was used to establish a hyperspectral inversion model, and the coefficient of determination (R2), root mean square error (RMSE), and percentage relative deviation (RPD) were used to verify the accuracy and stability.

[0042] like Figure 4As shown, specifically, the parameters configured for the copper inversion model are as follows: the number of convolutional layer channels (cnn_channels) is set to [16, 32], which is the number of output channels of the convolutional layer, determining the number of feature maps extracted per layer; the kernel size (kernel_sizes) is set to [3, 5] to ensure symmetrical padding; the dropout regularization ratio is set to 0.1 to discard neurons and prevent overfitting; the number of CNN training epochs is set to 100, the batch size is set to 16, and the learning rate is set to 0.004; the number of quantile intervals (n_bins) is set to 48, and the embedding dimension (d_embedding) is set to 16; the learning rate of the TabM optimizer Adamw is set to 5e. -4 To control the update step size, add L2 regularization strength (weight_decay) of 30e-4 to prevent overfitting; for training parameters, set the batch size (batch_size) to 16 and the early stopping patience value (patience) to 200. Specifically, the parameters configured for the lead inversion model are as follows: the number of convolutional layer channels (cnn_channels) is set to [16, 32], which is the number of output channels of the convolutional layer and determines the number of feature maps extracted per layer; the kernel size (kernel_sizes) is set to [3, 5] to ensure symmetrical padding; the dropout regularization ratio is set to 0.4 to discard neurons and prevent overfitting; the number of CNN training epochs is set to 100, the batch size is set to 32, and the learning rate is set to 0.002; the number of quantile intervals (n_bins) is set to 48, and the embedding dimension (d_embedding) is set to 16; the learning rate of the TabM optimizer Adamw is set to 30e. -4 To control the update step size, add L2 regularization strength (weight_decay) of 20e-4 to prevent overfitting; for training process parameters, set batch size (batch_size) to 16 and early stopping patience value (patience) to 100. Specifically, the following parameters are configured for the zinc inversion model: the number of convolutional layer channels (cnn_channels) is set to [16, 32], which is the number of output channels of the convolutional layer and determines the number of feature maps extracted per layer; the kernel size (kernel_sizes) is set to [3, 5] to ensure symmetrical padding; the dropout regularization ratio is set to 0.2 to discard neurons and prevent overfitting; the number of CNN training epochs is set to 50, the batch size is set to 16, and the learning rate is set to 0.00002; the number of quantile intervals (n_bins) is set to 48, and the embedding dimension (d_embedding) is set to 16; the learning rate of the TabM optimizer Adamw is set to 3e. -4 To control the update step size, add L2 regularization strength (weight_decay) of 10e-4 to prevent overfitting; for training process parameters, set batch size (batch_size) to 16 and early stopping patience value (patience) to 100. Research results are as follows Figure 5 , 6 As shown in Tables 7 and 1, the CNN-TabM model achieved the best prediction accuracy in the inversion of the three metals. For Cu inversion, the CNN-TabM model had a prediction accuracy of R²=0.8, with the best spectral transformation being the 0.5th derivative. Compared to the highest prediction accuracy of TabM (1.5 Order) R²=0.75, the R² was improved by 5%, and compared to the best prediction accuracy of the traditional model (PLSR, 1.5 Order, R²=0.74), the R² was improved by 6%. For Pb inversion, the CNN-TabM model had an R²=0.72, with the best spectral transformation being the 1.25th derivative. Compared to TabM (1.5 Order, R²=0.63) and the best traditional prediction model (RF, 1 Order, R²=0.69), the R² was improved by 9% and 3%, respectively. For Zn inversion, the CNN-TabM model had an R²=0.51, with the best spectral transformation being the 1.5th derivative, which was better than the basic and traditional models.

[0043] Table 1 On the other hand, this embodiment also provides an electronic device, including a memory, a processor, and a computing program stored in the memory and executable on the processor, wherein the processor implements the method when executing the computing program.

[0044] On the other hand, this embodiment also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method.

[0045] The above are merely preferred embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for hyperspectral inversion of heavy metals in soil based on a CNN-TabM model, characterized in that, include: Soil samples were obtained, and the hyperspectral data and heavy metal content of the soil samples were determined. Based on the hyperspectral data, noise bands are removed, and the noise-removed hyperspectral data is smoothed to obtain the original spectral data. Based on the original spectral data, a fractional derivative transformation is performed to obtain the transformed spectral data; Based on the transformed spectral data, a feature selection algorithm is used to filter out the characteristic bands related to the heavy metal content; The heavy metal content is used as the dependent variable, and the selected characteristic bands are used as independent variables. The results are input into the CNN-TabM inversion model to output the inversion results of the heavy metal content. The CNN-TabM inversion model extracts local spectral features of the feature bands through a one-dimensional convolutional neural network, fuses the local spectral features with the feature bands, and inputs the fused features into the TabM model for global feature interaction and integrated prediction.

2. The method according to claim 1, characterized in that, Obtain soil samples and determine the hyperspectral data and heavy metal content of the soil samples, including: Soil samples were collected and then air-dried, ground, and sieved to obtain processed soil powder. The hyperspectral data of the treated soil powder were measured using a ground object spectrometer, and the heavy metal content was determined using a handheld fluorescence spectrometer.

3. The method according to claim 1, characterized in that, Based on the hyperspectral data, noise bands are removed, including: Obtain the spectral range measured by the ground object spectrometer, and remove the edge intervals within the spectral range as the noise band.

4. The method according to claim 1, characterized in that, The noise-removed hyperspectral data is smoothed to obtain the original spectral data, including: The Savitzky-Golay convolutional smoothing algorithm is used to smooth the noise-removed hyperspectral data to obtain the original spectral data.

5. The method according to claim 1, characterized in that, The one-dimensional convolutional neural network extracts local spectral features of the feature bands, including: The characteristic bands are constructed into an input matrix, and channel dimensions are added to the input matrix to obtain three-dimensional input data; The three-dimensional input data is fed into a two-layer one-dimensional convolutional network, where convolution, batch normalization, activation function, and regularization are performed sequentially. The processed three-dimensional output tensor is then flattened into two-dimensional data to obtain the local spectral features.

6. The method according to claim 1, characterized in that, Feature fusion of the local spectral features and the feature bands includes: The characteristic bands are spliced ​​and fused with the local spectral features to obtain enhanced feature data.

7. The method according to claim 1, characterized in that, The fused features are input into the TabM model for global feature interaction and ensemble prediction, including: The enhanced feature data is input into the integrated view module and expanded into a three-dimensional tensor through tensor product; The three-dimensional tensor is input into a TabM module consisting of multiple stacked integrated feedforward networks. The prediction results of multiple integrated members are generated through a batch integration layer, and the average value of the prediction results of all integrated members is used as the final inversion result.

8. The method according to claim 1, characterized in that, Based on the transformed spectral data, a feature selection algorithm is used to filter out characteristic bands related to the heavy metal content, including: A competitive adaptive reweighting algorithm is used to iteratively filter the transformed spectral data multiple times, and the bands that appear a preset threshold number of times are taken as the feature bands.

9. An electronic device comprising a memory, a processor, and a computing program stored in the memory and executable on the processor, characterized in that, When the processor executes the computing program, it implements the method of any one of claims 1-8.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1-8.