Multi-Path Attention Fusion Transformer for Spectral Learning in Corn Quality Assessment
Abstract
1. Introduction
2. Materials and Methods
2.1. Materials
Datasets
2.2. Methods
2.2.1. Data Augmentation Strategy via Spectral Curve Interpolation
2.2.2. SpecTran Model
- Global Path: ,
- Local Path: ,
- Sequential Path: , where the output is averaged over the sequence length dimension.
2.2.3. LSTTN-Based Temporal Modeling
2.2.4. Transformer-Based Baseline Model
2.2.5. CNN-Based Baseline Model
2.2.6. MLP-Based Baseline Model
2.3. Data Preprocessing and Model Training
3. Results
3.1. Model Comparison for Corn Quality Prediction
3.2. Spectral-Level Interpretability via Perturbation-Based Feature Importance Analysis
4. Discussion
5. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
References
- Wang, W.; Li, C.; Song, Z. Applications of near-infrared spectroscopy in the agricultural products: A review. Trends Food Sci. Technol. 2020, 102, 198–210. [Google Scholar]
- Liu, Y.; Chen, X.; Zhou, Q. Review of NIR spectroscopy methods for determination of quality parameters in cereal grains. J. Cereal Sci. 2018, 81, 1–11. [Google Scholar]
- Geladi, P.; Kowalski, B.R. Partial least-squares regression: A tutorial. Anal. Chim. Acta 1986, 185, 1–17. [Google Scholar] [CrossRef]
- Eigenvector Research, Inc. Corn Dataset; Eigenvector Research, Inc.: Manson, WA, USA, 2025; Available online: https://www.eigenvector.com/data/Corn/ (accessed on 31 October 2025).
- Shenk, J.S.; Westerhaus, M.O.; Berzaghi, P. Investigation of the performance of nonlinear calibration methods. J. Near Infrared Spectrosc. 2001, 9, 257–267. [Google Scholar]
- Yan, H.; Pan, T.; Chen, J. A deep convolutional neural network for rapid determination of chemical components in tea by near-infrared spectroscopy. Spectrochim. Acta Part A Mol. Biomol. Spectrosc. 2020, 239, 118533. [Google Scholar]
- Cui, H.; Gu, F.; Qin, J.; Li, Z.; Zhang, Y.; Guo, Q.; Wang, Q. Assessment of Peanut Protein Powder Quality by Near-Infrared Spectroscopy and Generalized Regression Neural Network-Based Approach. Foods 2024, 13, 1722. [Google Scholar] [CrossRef] [PubMed]
- Liu, Y.; Wang, D.; He, Y. Limitations of convolutional neural networks for hyperspectral image classification: An empirical study. IEEE Geosci. Remote Sens. Lett. 2021, 19, 1–5. [Google Scholar]
- Schmidt, M.S.; Kehlet, B.; Hansen, P.W. Transformer-based deep learning for NIR spectroscopy: A case study on milk powder adulteration. J. Chemom. 2021, 35, e3358. [Google Scholar]
- Vaswani, A.; Shazeer, N.; Parmar, N.; Uszkoreit, J.; Jones, L.; Gomez, A.N.; Kaiser, Ł.; Polosukhin, I. Attention is all you need. Adv. Neural Inf. Process. Syst. 2017, 30. [Google Scholar] [CrossRef]
- Sun, X.; Xu, Y.; Li, H. SpectralFormer: Rethinking hyperspectral image classification with transformers. IEEE Trans. Geosci. Remote Sens. 2022, 60, 1–15. [Google Scholar]
- Li, Y.; Bai, Y.; Wang, Y.; Tian, Q. LSTTN: A Hybrid Long Short-Term Transformer Network for Multivariate Time Series Forecasting. arXiv 2021, arXiv:2106.06177. [Google Scholar]
- Loshchilov, I.; Hutter, F. Decoupled weight decay regularization. arXiv 2017, arXiv:1711.05101. [Google Scholar]
- Smith, L.N.; Topin, N. Super-convergence: Very fast training of neural networks using large learning rates. Artif. Intell. Mach. Learn. -Multi-Domain Oper. Appl. 2019, 11006, 1100612. [Google Scholar]
- Osborne, B.G.; Fearn, T. The application of near infrared spectroscopy to the analysis of animal feedstuffs: A review. J. Near Infrared Spectrosc. 1993, 1, 33–47. [Google Scholar]
- Ben-Gera, I.; Shmulevich, I.; Lapidot, M. Interpretation of important wavelengths for food quality prediction using NIR spectroscopy and machine learning. Food Chem. 2020, 309, 125688. [Google Scholar]
- Fatemi, A.; Singh, V.; Kamruzzaman, M. Identification of informative spectral ranges for predicting major chemical constituents in corn using NIR spectroscopy. Food Chem. 2022, 383, 132442. [Google Scholar] [CrossRef] [PubMed]
- Lin, L.; He, Y.; Xiao, Z.; Zhao, K.; Dong, T.; Nie, P. Rapid-Detection Sensor for Rice Grain Moisture Based on NIR Spectroscopy. Appl. Sci. 2019, 9, 1654. [Google Scholar] [CrossRef]
- Tao, R.; Xu, L.; Bai, X.; Chen, J. Principles, Applications, and Future Evolution of Agricultural Nondestructive Testing Based on Microwaves. Sensors 2025, 25, 4783. [Google Scholar] [CrossRef] [PubMed]









| Constituent | Sample Count | Min | Max | Mean | Std |
|---|---|---|---|---|---|
| Moisture (%) | 80 | 9.377 | 10.993 | 10.234 | 0.380 |
| Starch (%) | 80 | 3.088 | 3.832 | 3.498 | 0.177 |
| Oil (%) | 80 | 7.654 | 9.711 | 8.668 | 0.499 |
| Protein (%) | 80 | 62.826 | 66.472 | 64.696 | 0.821 |
| Model | Avg_R2 | Avg_RMSE | Protein_R2 | Protein_RMSE |
|---|---|---|---|---|
| MLP | 0.332 | 0.300 | 0.188 | 0.584 |
| CNN | 0.395 | 0.292 | 0.237 | 0.566 |
| LSTTN | 0.395 | 0.290 | 0.252 | 0.560 |
| Transformer | 0.442 | 0.278 | 0.294 | 0.537 |
| SpecTran | 0.483 | 0.265 | 0.368 | 0.517 |
| Model | Avg_R2 | Avg_RMSE | Protein_R2 | Protein_RMSE |
|---|---|---|---|---|
| PLS | 0.348 | 0.289 | 0.289 | 0.547 |
| Ridge | 0.378 | 0.287 | 0.281 | 0.550 |
| SVR | 0.188 | 0.337 | 0.022 | 0.641 |
| XGBoost | 0.409 | 0.279 | 0.291 | 0.540 |
| SpecTran | 0.483 | 0.265 | 0.368 | 0.517 |
| Model | Moisture_R2 | Moisture_RMSE | Moisture_MAE |
|---|---|---|---|
| PLS | 0.571 | 0.191 | 0.155 |
| Ridge | 0.585 | 0.188 | 0.154 |
| SVR | 0.462 | 0.214 | 0.172 |
| XGBoost | 0.598 | 0.185 | 0.151 |
| MLP | 0.592 | 0.186 | 0.150 |
| CNN | 0.611 | 0.182 | 0.145 |
| LSTTN | 0.618 | 0.179 | 0.143 |
| Transformer | 0.624 | 0.177 | 0.142 |
| SpecTran | 0.635 | 0.173 | 0.140 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Li, J.; Wang, H.; Zhang, H.; Jiang, T. Multi-Path Attention Fusion Transformer for Spectral Learning in Corn Quality Assessment. Foods 2025, 14, 3786. https://doi.org/10.3390/foods14213786
Li J, Wang H, Zhang H, Jiang T. Multi-Path Attention Fusion Transformer for Spectral Learning in Corn Quality Assessment. Foods. 2025; 14(21):3786. https://doi.org/10.3390/foods14213786
Chicago/Turabian StyleLi, Jialu, Haoyi Wang, Hongbo Zhang, and Tongqiang Jiang. 2025. "Multi-Path Attention Fusion Transformer for Spectral Learning in Corn Quality Assessment" Foods 14, no. 21: 3786. https://doi.org/10.3390/foods14213786
APA StyleLi, J., Wang, H., Zhang, H., & Jiang, T. (2025). Multi-Path Attention Fusion Transformer for Spectral Learning in Corn Quality Assessment. Foods, 14(21), 3786. https://doi.org/10.3390/foods14213786

