Spectroscopy and Spectral Analysis, Volume. 45, Issue 7, 2017(2025)

Prediction of Soil Total Nitrogen Based on NIR Spectroscopy and BiGRU Model With Attention Mechanism

JU Wei-liang1, YANG Wei1,2, SONG Ya-mei1, LIU Nan1, LI Hao1, and LI Min-zan1,2、*
Author Affiliations
  • 1Key Lab of Smart Agriculture System Integration, Ministry of Education, China Agricultural University, Beijing 100083, China
  • 2Key Lab of Agricultural Information Acquisition Technology, Ministry of Agriculture and Rural Affairs, China Agricultural University, Beijing 100083, China
  • show less

    Soil total nitrogen (STN) content is a key indicator for evaluating soil fertility, and its accurate measurement is of great significance for improving crop yield and quality. Predicting soil total nitrogen content using near-infrared spectroscopy has been proven to be an effective solution. However, due to the high dimensionality and complex time series characteristics of soil spectral data, traditional models often struggle to capture critical information, affecting prediction accuracy. Hence, based on near-infrared spectra (900~1 700 nm) of 600 soil samples, the method for predicting soil totalnitrogen (STN) content was investigated, and a Bidirectional Gated Recurrent Unit based on an Attention Mechanism (BiGRU-Attention) model was proposed. First, the spectral data quality was optimized using SG filtering and SNV preprocessing methods. Then, using the CARS feature selection algorithm, the wavelengths for modeling were reduced from 198 to 30, thereby removing redundant information and decreasing the complexity of the modeling process. The BiGRU-Attention model effectively manages the flow of information using update and reset gates and enables the model to disregard the unimportant spectral data and retain the key information, which impacts the prediction accuracy. By leveraging the dual temporal sequence processing advantages of bidirectional GRU, the model can simultaneously handle forward and backward inputs of spectral sequences, thereby enhancing its ability to focus on edge data and comprehensively capture the dependencies present in soil spectral data. Additionally, the model employs an attention layer to compute the importance of each segment using the QKV matrix and dynamically determines which features should be emphasized based on the sequential interdependencies. This process calculates attention weight matrices to assign weights to each input data point, generating a more relevant context matrix that improves the model's predictive accuracy. Experimental results show that the BiGRU-Attention model can better understand the correlation between bands and perform better in prediction than other models, with the spectral data achieving an R2 of 0.87 and an RMSE of 0.20 g·kg-1 on the test dataset after feature selection. This study provides technical support for rapid soil nutrient detection and offers a method and reference for establishing high-accuracy STN predictionmodels.

    Tools

    Get Citation

    Copy Citation Text

    JU Wei-liang, YANG Wei, SONG Ya-mei, LIU Nan, LI Hao, LI Min-zan. Prediction of Soil Total Nitrogen Based on NIR Spectroscopy and BiGRU Model With Attention Mechanism[J]. Spectroscopy and Spectral Analysis, 2025, 45(7): 2017

    Download Citation

    EndNote(RIS)BibTexPlain Text
    Save article for my favorites
    Paper Information

    Received: Sep. 23, 2024

    Accepted: Jul. 24, 2025

    Published Online: Jul. 24, 2025

    The Author Email: LI Min-zan (limz@cau.edu.cn)

    DOI:10.3964/j.issn.1000-0593(2025)07-2017-09

    Topics