A Novel 2D‐CNN Model Integrating 2D‐Transformed NIR Spectra and Attention Mechanism With Transfer Learning: A Case in SSC Prediction of Pears
Zhangwei Fan, Anyi Zhao, Jianyi Zhang, Xiaping FuABSTRACT
Near‐infrared (NIR) spectroscopy technology has been widely used in agriculture, food, pharmaceuticals, petrochemical, and other fields due to its advantages of high efficiency and nondestructiveness. However, it still faces challenges such as data distribution shifts caused by factors like different spectrometers and spectral acquisition environments. In this study, we propose a GASp2DCNN model that integrates the Gramian Angular Summation Field (GASF) and the adaptive star block (ASB) to address the performance degradation of models when spectrometers or environments change. Firstly, the spectrum is transformed to two‐dimensional data after piecewise aggregation approximation (PAA), polar coordinate transformation, and GASF to capture correlation features with 2D convolution. Then, an ASB module integrating star operation and channel attention mechanism is designed to enhance the model's ability to capture spectral local correlations. Finally, a feature‐vector based transfer learning (FBTL) method is proposed, which dynamically weights the feature vectors of the source and target domains through an attention mechanism to enhance cross‐domain adaptation. The results on a pear dataset indicate that the GASp2DCNN improves R 2 by 5.2% to 24.4% compared to machine learning models (PLSR, SVR) and 1D‐CNN models. In transfer learning experiments, the proposed FBTL method improved R 2 by 4% to 12% compared to global fine‐tuning and head‐freezing fine‐tuning methods and outperformed domain‐adversarial neural networks (DANN) and maximum classifier discrepancy (MCD) by 4% to 9% across all transfer scenarios. Stable transfer effects are achieved when the target domain sample size reaches 40% of the total, reducing reliance on target samples. This also provides an interpretable and highly robust solution for fruit quality detection.