Related Experiment Video
Updated: May 5, 2026

Use of Principal Components for Scaling Up Topographic Models to Map Soil Redistribution and Soil Organic Carbon
Published on: October 16, 2018
GAF-ResNet-MHSA: A novel transfer learning method for soil nutrient prediction in small sample datasets
Hao Liang1, Kangyuan Zhong2, Yue Song3
1College of Mathematics and Computer Science, Zhejiang A&F University, Hangzhou, 311300, China; College of Engineering, China Agricultural University, Beijing, 100083, China; Institute of Modern Agriculture and Health Care Industry, Wencheng, 325300, China.
Abstract:
Near Infrared Spectroscopy (NIR) is an effective technique for the quantitative estimation of soil nutrient content. However, models developed using spectral data from specific regions often suffer from low prediction accuracy and overfitting due to small sample sizes. This paper introduces a novel approach that combines the Gramian Angular Field (GAF) and a multi-head attention mechanism (MHSA) within a ResNet34 framework (GAF-ResNet-MHSA) for transfer learning in soil nutrient analysis. Soil samples from four distinct regions in Zhejiang Province were collected, and their near-infrared (NIR) spectral data along with corresponding pH and available phosphorus (SAP) content were synchronously obtained. After transforming the spectral data into two-dimensional images in GAF format, the modified ResNet34 model was trained and fine-tuned. Experimental results demonstrate that models built on small samples from the Hangzhou area in Zhejiang Province showed limited predictive accuracy, with R2, RMSEp, and RPD values for pH and SAP being 0.7575, 0.4221, 2.0305, and 0.7393, 32.5245 mg/kg, 1.9586, respectively. By applying the GAF-ResNet-MHSA method and incorporating some target domain samples for fine-tuning, significant improvements in prediction accuracy were observed: R2 and RPD for the pH model increased to 0.8962 and 3.1043, and RMSEp decreased to 0.2731, while for the SAP model, R2 and RPD increased to 0.8110 and 2.3002, and RMSEp decreased to 26.7910 mg/kg. The GAF-ResNet-MHSA transfer learning approach effectively addresses the issue of low accuracy in small-sample soil spectral models, achieving efficient nutrient prediction. This study demonstrates the innovative potential and practical applicability of our method in spectral transfer learning.

