Regularized residual network-based fruit variety classification method
By improving the regularized residual network and combining multi-scale convolution and regularization strategies, the feature extraction problem in small-sample fruit variety classification is solved, achieving accurate classification and improved model robustness under small-sample conditions.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JIANGSU UNIV
- Filing Date
- 2025-12-31
- Publication Date
- 2026-04-14
AI Technical Summary
Existing technologies struggle to accurately classify fruit varieties under small sample conditions. Traditional methods rely on manually designed features and have insufficient generalization performance. Deep learning models have a high risk of overfitting and poor interpretability in spectral analysis.
An improved regularized residual network is adopted, which adapts to one-dimensional spectral characteristics through multi-scale convolutional structure and regularization strategy. Combined with data augmentation and regularization techniques, a fruit variety classification model suitable for small samples is constructed.
It improves the model's feature capture ability and interpretability, reduces the risk of overfitting, achieves accurate classification under small sample conditions, and enhances the model's robustness and adaptability.
Smart Images

Figure CN121859094A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of deep learning and pattern recognition, specifically to an improved residual network feature extraction model incorporating regularization strategies, applied to a fruit variety classification method using near-infrared spectroscopy analysis. Background Technology
[0002] Fruit variety identification is of great significance in the fields of food science and agricultural product quality control. Even the same type of fruit has multiple varieties, and these varieties differ in chemical composition, flavor, and texture. However, these differences are usually subtle, and traditional methods relying on experience or sensory evaluation are insufficient for accurate and stable identification. Near-infrared spectroscopy, due to its non-destructive, rapid, and stable advantages, has been widely used in agricultural product quality testing. However, near-infrared spectral data generally exhibits high dimensionality, band overlap, and noise interference, necessitating the use of effective pattern recognition methods for feature extraction and classification modeling.
[0003] Traditional chemometrics and machine learning methods, such as principal component analysis (PCA), partial least squares discriminant analysis (PLS-DA), and support vector machine (SVM), have achieved certain results in some spectral classification tasks. However, their performance often depends on manually designed features or linear assumptions. For tasks with limited sample size and insignificant inter-class differences, the model's discriminative ability is limited and its generalization performance is insufficient. In particular, it is prone to overfitting and poor stability under small sample conditions.
[0004] In recent years, deep learning technology, especially convolutional neural networks (CNNs), has shown potential in spectral analysis. However, directly applying them to near-infrared spectral classification still faces several key challenges: First, most CNN architectures are designed for two-dimensional data such as images, and their convolutional operations are difficult to fully adapt to the one-dimensional sequence characteristics of spectra, limiting their effective capture of local spectral structure and contextual information; Second, deep learning models typically rely on large-scale labeled samples, while the acquisition cost of spectral data for some agricultural products is high and samples are scarce, making it easy to overfit when directly training complex networks, affecting the actual deployment effect of the model; Third, the decision-making process of deep models is opaque and has poor interpretability, which is not conducive to the application and promotion in scenarios with high reliability requirements such as food quality control.
[0005] Therefore, for small sample data such as fruit variety identification, it is necessary to design a deep learning model that can adapt to one-dimensional spectral characteristics, still has strong generalization ability under small sample conditions, and also takes into account the interpretability of the model. This invention is a solution proposed based on the above background and needs. Summary of the Invention
[0006] To address the shortcomings of existing technologies, this application proposes a fruit variety classification method using regularized residual networks. This invention improves the adaptability of residual blocks in traditional residual network structures, enabling convolution operations to be better applied to one-dimensional spectral sequences. Simultaneously, by introducing multi-scale convolutional structures into the residual blocks, parallel modeling of different spectral intervals is achieved, improving the model's feature interpretability and stability. Furthermore, this invention introduces corresponding regularization strategies at the data, structure, and parameter levels, enabling deep networks to maintain good generalization ability even with a limited number of spectral samples, avoiding overfitting, and improving the robustness of the classification model. Based on the improved classification model, it can be used to accurately classify fruit quality using spectral data.
[0007] The technical solution adopted in this invention is as follows:
[0008] A method for classifying fruit varieties using regularized residual networks, comprising the following steps:
[0009] S1. Near-infrared spectrometer is used to collect spectral data of the fruit samples to be classified, and near-infrared diffuse reflectance spectral data of the fruit samples are obtained.
[0010] S2 performs noise reduction and calibration preprocessing on the dataset.
[0011] S3. Construct an improved residual network feature extraction model that combines regularization strategy, and use this feature extraction model to extract features from the processed dataset.
[0012] S4 inputs the extracted features into a traditional classifier and outputs the classification result.
[0013] Furthermore, the network structure of the improved residual network feature extraction model combined with regularization strategy mentioned above includes: a preprocessing layer, a feature extraction layer, and a global average pooling layer;
[0014] The preprocessing layer performs one-dimensional spectral preprocessing.
[0015] The feature extraction layer includes multi-scale residual blocks, residual connections, and layer stacking. Each multi-scale residual block contains three parallel one-dimensional convolutional branches with kernel sizes of 3, 7, and 15, and a convolutional stride denoted as [missing information]. The convolutional features are then subjected to batch normalization, activation functions, and secondary convolution to obtain multi-scale features, enabling parallel extraction of spectral features at different wavelength scales. Residual connections are introduced outside the main branch of the multi-scale convolution. For the input features, if the number of channels in the current residual block changes, a different approach is required. After the convolution kernels are matched for the number of channels, they are linearly summed; finally, the residual block output is the element-wise addition of the main branch output and the residual branch, and then activated by ReLU.
[0016] Global average pooling layers map the convolutional spectral features into a fixed-length depth feature vector.
[0017] Furthermore, the training method for the network structure of the improved residual network feature extraction model that incorporates regularization strategies, as described above, is as follows:
[0018] S3.1, Obtain near-infrared diffuse reflectance spectral data of different varieties of the same type of fruit.
[0019] S3.2 divides the near-infrared spectral raw data into training set, validation set and test set by stratified sampling according to a preset ratio.
[0020] S3.3, perform data augmentation on the original training set based on statistical features by introducing random mutations into the offset, multiplier variable and slope to generate an expanded training set;
[0021] S3.4 Preprocessing of the augmented dataset includes Savitzky-Golay (SG) smoothing filtering and multivariate scattering correction (MSC) to denoise and calibrate the original spectral data, respectively. During MSC correction, the average spectrum is calculated using only the training set before augmentation to avoid information leakage from the test set.
[0022] S3.5, the preprocessed training set is used to train an improved residual network feature extraction model with regularization strategy; during the training process, L2 regularization and convolutional kernel continuity regularization strategies are introduced to constrain the weight parameters of all convolutional layers in the network.
[0023] S3.6, use the validation set and test set to test and validate the trained model until the classification accuracy requirement is met.
[0024] Furthermore, the data augmentation calculation formula in S3.3 is shown below.
[0025]
[0026]
[0027]
[0028] Where x is the dataset before augmentation, x' is the dataset after augmentation, δ is the offset intensity factor, m is the multiplier variable intensity factor, τ is the slope intensity factor, and U represents a uniform distribution function. This means taking 1557 points uniformly from -1 to 1 to form a vector of length 1557 aligned with the spectral dimension.
[0029] Furthermore, in S3.5, the loss function is supplemented with... If the suppression weights are too large, constraints are applied to the differences between adjacent sampling points of the convolution kernel. The calculation formula is as follows: ;in, L2 regularization coefficient These are the adjustable parameters of the convolution kernel. The convolution kernel continuity regularization coefficients represent the number of convolution kernels. , For the adjustable parameters in the k-th convolutional kernel, is the Kth parameter in the i-th convolutional kernel.
[0030] Furthermore, L2 regularization coefficients are set separately. Set to 0.0005, the convolution kernel continuity regularization coefficient. Take 0.0001.
[0031] Furthermore, the Adam optimizer is used to iteratively update the parameters, and the optimal learning rate and regularization strength hyperparameters are automatically searched using the validation set.
[0032] Furthermore, the initial learning rate was set to 0.001, and the number of training iterations was 60.
[0033] Furthermore, preprocessing includes, but is not limited to, smoothing filtering and multivariate scattering correction.
[0034] The beneficial effects of this invention are:
[0035] (1) This invention improves the ability to capture features of key spectral bands by structurally modifying traditional residual networks, thereby enabling them to better adapt to one-dimensional near-infrared spectral sequences and enhancing the interpretability of the model through multi-scale convolutional structures.
[0036] (2) This invention introduces a variety of regularization techniques such as data augmentation, L2 regularization and continuity regularization during the training phase, so that the model can maintain good generalization ability under small sample conditions and significantly reduce the risk of overfitting.
[0037] (3) The present invention adopts a process of classification first and then spectral preprocessing to ensure the scientificity and credibility of the model evaluation results. The present invention can realize end-to-end rapid classification and can also use deep features combined with traditional classifiers to improve robustness and adaptability, thereby significantly improving the practicality and reliability of near-infrared spectroscopy for agricultural product variety identification. Attached Figure Description
[0038] Figure 1 This is a flowchart of the overall algorithm of the method of the present invention.
[0039] Figure 2 This is a schematic diagram of the improved residual network architecture combined with regularization constructed in this invention.
[0040] Figure 3 This is a schematic diagram of the multi-scale residual block structure in the improved residual network of this invention.
[0041] Figure 4 This is the original near-infrared spectrum of the mango sample.
[0042] Figure 5 This is the near-infrared spectrum of a mango sample after pretreatment.
[0043] Figure 6 This is a graph showing the change in training set accuracy over training rounds.
[0044] Figure 7 This is a graph showing how the training set loss value changes over training rounds.
[0045] Figure 8 This is the confusion matrix of the pattern binary classification results. Detailed Implementation
[0046] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the invention.
[0047] This embodiment uses mango as an example to describe the technical solution of the present invention in detail. However, the method proposed in this invention is not limited to mango and can also be used for the classification of other fruit varieties.
[0048] Combined with appendix Figures 1 to 8 This invention provides a detailed description of a fruit variety classification method using regularized residual networks. The specific steps of this method include:
[0049] S1. Near-infrared spectrometer is used to collect spectral data of mango samples to be classified, and near-infrared diffuse reflectance spectral data of fruit samples are obtained.
[0050] S2 preprocesses the enhanced dataset, specifically Savitzky-Golay (SG) smoothing filter and multivariate scattering correction (MSC) to denoise and calibrate the original spectral data, respectively.
[0051] In particular, when performing MSC correction, the average spectrum is calculated using only the training set before enhancement to avoid leakage of test set information.
[0052]
[0053] For any spectrum, perform linear regression correction.
[0054]
[0055] in , The regression coefficients are used to align the samples to the average spectrum of the training set before enhancement.
[0056] Preprocessed spectrum as follows Figure 5 As shown.
[0057] S3. Construct an improved residual network feature extraction model that incorporates a regularization strategy, and use this feature extraction model to extract features from the processed dataset.
[0058] Combined with appendix Figure 2 This invention proposes an improved residual network feature extraction model that incorporates a regularization strategy. The network structure includes: a preprocessing layer, a feature extraction layer, a global average pooling layer, and a flattening layer.
[0059] (1) The preprocessing layer performs one-dimensional spectral preprocessing, using the one-dimensional spectrum as the model input. Specifically:
[0060] First, the preprocessed spectrum is represented as:
[0061]
[0062] When inputting in batches, it is recorded as
[0063]
[0064] One-dimensional spectral preprocessing layer: through Convolutional kernels perform channel expansion on single-channel spectra; they increase the dimensionality of single-channel spectra to multi-channel feature representations, and their computational form is as follows:
[0065]
[0066] in, This represents a one-dimensional convolution with a kernel size of 1, an input channel of 1, and an output channel of 32. This is the batch normalization operation; ReLU is the activation function.
[0067] (2) The feature extraction layer includes multi-scale residual blocks, residual connections, and layer stacking.
[0068] This invention utilizes multi-scale residual blocks for core feature extraction, enabling parallel extraction of spectral features at different wavelength scales, such as... Figure 3 As shown. The specific process is as follows:
[0069] Suppose the input of a certain residual block is:
[0070]
[0071] in, L represents the number of input channels, and L represents the kernel size.
[0072] The multi-scale residual block of this invention comprises three parallel one-dimensional convolutional branches with kernel sizes of 3, 7, and 15, and a convolution stride denoted as . Used to control whether downsampling is performed:
[0073]
[0074]
[0075]
[0076] in, This represents the number of output channels.
[0077] The residual block settings for specific embodiments are shown in Table 1.
[0078] Table 1 Multi-scale residual block channel and step size settings
[0079] The convolutional features are then subjected to batch normalization, activation functions, and secondary convolution to obtain multi-scale features.
[0080] Secondly, the multi-scale features are linearly concatenated, and a layer is added after concatenation. Channel compression is applied to the convolution kernel to reduce the number of channels. 3D feature compression dimension.
[0081] In this embodiment, residual connections are introduced outside the main branch of the multi-scale convolution; for Stage2 Block1 and Stage3 Block1, a method needs to be adopted. After matching the number of channels, the convolution kernels are linearly summed; the remaining residual blocks can also be linearly summed directly. The final residual block output is the element-wise sum of the main branch output and the residual branch, followed by ReLU activation.
[0082] The global average pooling layer maps the convolved spectral features into a fixed-length depth feature vector; in this embodiment, the convolved spectral features are mapped into a 128-dimensional depth feature vector.
[0083] In this embodiment, L2 weight decay and convolutional kernel continuity regularization strategies are introduced during the training process of the above model to constrain the network parameters. Therefore, the training method of the improved residual network feature extraction model combined with regularization strategies is as follows:
[0084] S3.1, Obtain near-infrared diffuse reflectance spectral data of different varieties of the same type of fruit. The near-infrared spectral data of mangoes used in this invention are obtained from a publicly available near-infrared spectral database (dataset URL: [URL missing]). https: / / data.mendeley.com / datasets / b9d6s7hr33 / 1 This dataset contains experimental spectra of four mango varieties: Cengkir, Kent, Kweni, and Palmer, totaling 181 samples. Specifically, there are 18 Cengkir samples, 85 Kent samples, 29 Kweni samples, and 49 Palmer samples. The spectral data were acquired using a near-infrared spectrometer under standard experimental conditions, with a scanning wavelength range of 999.9–2500.2 nm and a scanning interval of 0.4 nm. Each mango sample yielded a 1557-dimensional spectrum.
[0085] Near-infrared spectrum of mango sample as follows Figure 4 As shown.
[0086] S3.2, the near-infrared spectral data is stratified and divided into training, validation, and test sets according to a preset ratio. In this embodiment, the stratified sampling is performed in a 4:2:2 ratio. The number of samples in the training set... Number of validation sets Number of test set samples .
[0087] S3.3, perform data augmentation on the original training set based on statistical features by introducing random mutations into the offset, multiplier variable, and slope to generate an expanded training set. The data augmentation calculation formula is shown below.
[0088]
[0089]
[0090]
[0091] in This means taking 1557 points uniformly from -1 to 1 to form a vector of length 1557 aligned with the spectral dimension.
[0092] The number of each category before and after data augmentation is shown in Table 2.
[0093] Table 2. Sample size before and after data augmentation
[0094]
[0095] S3.4 Preprocessing of the augmented dataset includes Savitzky-Golay (SG) smoothing filtering and multivariate scattering correction (MSC) to denoise and calibrate the original spectral data, respectively. During MSC correction, the average spectrum is calculated using only the training set before augmentation to avoid information leakage from the test set.
[0096] S3.5, the preprocessed training set is used to train an improved residual network feature extraction model with regularization strategy; during the training process, L2 regularization and convolutional kernel continuity regularization strategies are introduced to constrain the weight parameters of all convolutional layers in the network.
[0097] On the one hand, by adding to the loss function On the one hand, the suppression weights are too large, and on the other hand, the difference between adjacent sampling points of the convolution kernel is constrained. The calculation formula is as follows: .
[0098] Here, the L2 regularization coefficient is set. The convolution kernel continuity regularization coefficient is 0.0005. The value is 0.0001. Number of convolution kernels. .
[0099] S3.6, use the validation set and test set to test and validate the trained model until the classification accuracy requirement is met.
[0100] The Adam optimizer is used to iteratively update parameters, and the optimal learning rate, regularization strength, and other hyperparameters are automatically searched using the validation set.
[0101] The initial learning rate was set to 0.001, and the number of training iterations was 60. The training accuracy and loss function curves are shown below. Figure 6 and Figure 7 As shown.
[0102] S4 inputs the extracted features into a traditional classifier and outputs the classification results to classify varieties on the test set.
[0103] This embodiment employs a combination of feature extraction and a traditional classifier for output. The final output accuracy is 97.30%. The confusion matrix is as follows. Figure 8 As shown, the classification results all exceed 90%, indicating that the features extracted by the improved residual network feature extraction model combining regularization strategy of this invention have good feature interpretability and stability.
[0104] The above embodiments are only used to illustrate the design concept and features of the present invention, and their purpose is to enable those skilled in the art to understand the content of the present invention and implement it accordingly. The protection scope of the present invention is not limited to the above embodiments. Therefore, all equivalent changes or modifications made based on the principles and design ideas disclosed in the present invention are within the protection scope of the present invention.
Claims
1. A method for classifying fruit varieties using regularized residual networks, characterized by the following steps: include: S1. Near-infrared spectrometer is used to collect spectral data of the fruit samples to be classified, and near-infrared diffuse reflectance spectral data of the fruit samples are obtained. S2, performs noise reduction and calibration preprocessing on the dataset; S3. Construct an improved residual network feature extraction model that combines regularization strategy, and use this feature extraction model to extract features from the processed dataset. S4 inputs the extracted features into a traditional classifier and outputs the classification result.
2. The fruit variety classification method using a regularized residual network according to claim 1, characterized in that, The network structure of the improved residual network feature extraction model combined with regularization strategy includes: a preprocessing layer, a feature extraction layer, and a global average pooling layer; The preprocessing layer performs one-dimensional spectral preprocessing. The feature extraction layer includes multi-scale residual blocks, residual connections, and layer stacking. Each multi-scale residual block contains three parallel one-dimensional convolutional branches with kernel sizes of 3, 7, and 15, and a convolutional stride denoted as [missing information]. The convolutional features are then subjected to batch normalization, activation functions, and secondary convolution to obtain multi-scale features, enabling parallel extraction of spectral features at different wavelength scales. Residual connections are introduced outside the main branch of the multi-scale convolution. For the input features, if the number of channels in the current residual block changes, a different approach is required. After the convolution kernels are matched for the number of channels, they are linearly summed; finally, the residual block output is the element-wise addition of the main branch output and the residual branch, and then activated by ReLU. Global average pooling layers map the convolutional spectral features into a fixed-length depth feature vector.
3. The fruit variety classification method using a regularized residual network according to claim 2, characterized in that, The training method for the network structure of the improved residual network feature extraction model that incorporates regularization strategy: S3.1, Obtain near-infrared diffuse reflectance spectral data of different varieties of the same type of fruit; S3.2, the near-infrared spectral raw data is stratified and divided into training set, validation set and test set according to a preset ratio; S3.3, perform data augmentation on the original training set based on statistical features by introducing random mutations into the offset, multiplier variable and slope to generate an expanded training set; S3.4, Preprocess the enhanced dataset; S3.5, the preprocessed training set is used to train an improved residual network feature extraction model with regularization strategy; during the training process, L2 regularization and convolutional kernel continuity regularization strategies are introduced to constrain the weight parameters of all convolutional layers in the network. S3.6, use the validation set and test set to test and validate the trained model until the classification accuracy requirement is met.
4. The fruit variety classification method using a regularized residual network according to claim 3, characterized in that, The data augmentation calculation formula in S3.3 is as follows: ; ; ; Where x is the dataset before augmentation, x' is the dataset after augmentation, δ is the offset intensity factor, m is the multiplier variable intensity factor, τ is the slope intensity factor, and U represents a uniform distribution function. This means taking 1557 points uniformly from -1 to 1 to form a vector of length 1557 aligned with the spectral dimension.
5. The fruit variety classification method using a regularized residual network according to claim 3, characterized in that, In S3.5, add the following to the loss function: If the suppression weights are too large, constraints are applied to the differences between adjacent sampling points of the convolution kernel. The calculation formula is as follows: ;in, L2 regularization coefficient These are the adjustable parameters of the convolution kernel. The convolution kernel continuity regularization coefficients represent the number of convolution kernels. , For the adjustable parameters in the k-th convolutional kernel, is the Kth parameter in the i-th convolutional kernel.
6. The fruit variety classification method using a regularized residual network according to claim 5, characterized in that, Set the L2 regularization coefficients respectively Set to 0.0005, the convolution kernel continuity regularization coefficient. Take 0.0001.
7. The fruit variety classification method using a regularized residual network according to claim 3, characterized in that, The Adam optimizer is used to iteratively update parameters, and the optimal learning rate and regularization strength hyperparameters are automatically searched using the validation set.
8. The fruit variety classification method using a regularized residual network according to claim 7, characterized in that, The initial learning rate was set to 0.001, and the number of training iterations was 60.
9. The fruit variety classification method using a regularized residual network according to claim 1, characterized in that, Preprocessing includes, but is not limited to, smoothing filtering and multivariate scattering correction.