A method and system for cross variety fruit soluble solids content prediction
The Label Distribution Aware Domain Adversarial Network (LDA-DANN) addresses the discrepancy between spectral and label distributions in cross-variety fruit spectral models, achieving efficient feature transfer and label correction even with limited target domain samples, thus improving the model's generalization ability and prediction accuracy.
Patent Information
- Application Number
- CN202611528652.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-30
- Publication Date
- 2026-11-03
AI Technical Summary
Traditional near-infrared spectroscopy models based on a single fruit variety suffer from decreased predictive performance when transferred to other varieties due to differences in spectral and label distributions, especially when the number of samples in the target domain is limited, resulting in insufficient generalization ability.
Label Distribution Aware Domain Adversarial Network (LDA-DANN) is employed. By constructing a feature extractor, regression predictor, conditional domain discriminator, and label distribution density ratio estimation network, and combining dual-channel convolutional neural network and autoencoder features, feature transfer and label distribution correction across fruit varieties are achieved. A joint loss function is used to optimize training to mitigate the differences between spectral and label distributions.
Under the condition of limited target domain samples, the generalization ability and prediction stability of the model are improved, effectively alleviating the performance degradation problem of cross-variety fruit spectral models, and maintaining high prediction accuracy and stability.
Smart Images

Figure CN123030937A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the fields of near-infrared spectroscopy analysis, deep learning and transfer learning technology, and specifically relates to a method and system for predicting the soluble solids content of cross-variety fruits. Background Technology
[0002] Near-infrared spectroscopy has been widely used in recent years for detecting fruit sugar content, moisture content, and internal quality due to its advantages such as being non-destructive, rapid, and low-cost. Traditional spectral regression models based on a single fruit variety are usually only applicable to that specific variety. When the model is transferred to other fruit varieties, the differences in tissue structure, water content, and physicochemical composition among different fruits can easily lead to significant shifts in spectral distribution, resulting in a decline in the model's predictive performance.
[0003] Furthermore, different fruit varieties exhibit not only differences in feature distribution but also in label distribution. For instance, the range and distribution of soluble solids content vary among different fruits, making traditional transfer learning methods prone to negative transfer when aligning feature spaces. Especially when the number of samples in the target domain is limited, the model struggles to fully learn the distribution features of the target domain, resulting in insufficient generalization ability.
[0004] Existing Domain Adversarial Neural Networks (DANNs) primarily achieve feature distribution alignment between the source and target domains through adversarial learning. However, they typically assume that the source and target domains have the same or similar label distributions, an assumption that is often difficult to satisfy in cross-variety fruit regression tasks. Therefore, how to further constrain label distribution consistency while achieving feature space alignment has become a key issue in cross-variety fruit spectral modeling. Summary of the Invention
[0005] To address the problem of insufficient model generalization ability caused by differences in spectral and label distributions among different fruit varieties in existing technologies, this invention provides a method and system for predicting soluble solids content across fruit varieties. The aim is to effectively alleviate the model performance degradation caused by differences in spectral and label distributions among different fruit varieties, and to improve the model's generalization ability and prediction stability under limited target domain samples.
[0006] To achieve the above objectives, the present invention provides the following solution: A method for predicting the soluble solids content of cross-variety fruits, the method comprising: Near-infrared spectral data and SSC content of different fruit varieties were obtained, and the near-infrared spectral data were preprocessed. Feature representations are constructed based on preprocessed near-infrared spectral data; Based on the feature representation and the SSC content, source domain samples and target domain samples are constructed; A label distribution-aware domain adversarial network is constructed, and the label distribution-aware domain adversarial network is optimized and trained based on the source domain samples, the target domain samples, and the joint loss function; The optimized label distribution-aware adversarial network is used to complete feature transfer and label distribution correction between the source and target domains, and the soluble solids content prediction results of the target fruit sample are obtained through a regression predictor.
[0007] Preferably, the feature representation includes: original spectral features, spectral autoencoder features, two-dimensional spectral image features, two-dimensional image autoencoder features, and fused features; The spectral autoencoder features include: spectral latent features extracted based on the autoencoder; The two-dimensional spectral image features include: GADF image features and GASF image features; The fusion features include: the fusion features of the original spectral features and the two-dimensional spectral image features, and the fusion features of the spectral autoencoder features and the two-dimensional image autoencoder features.
[0008] Preferably, the label distribution-aware adversarial network includes: a feature extractor, a regression predictor, a conditional domain discriminator, and a label distribution density ratio estimation network; The feature extractor adopts a dual-channel convolutional neural network structure, which jointly models the original spectral features or spectral autoencoder features with the two-dimensional image autoencoder features through the dual-channel convolutional neural network to obtain domain-shared features; The regression predictor is used to obtain SSC prediction values based on the domain-shared features; A conditional domain discriminator is constructed using predicted labels as conditional information, and a conditional domain adversarial loss is output. Adversarial training between the feature extractor and the conditional domain discriminator is achieved through a gradient inversion layer. The label distribution density ratio estimation network is used to characterize the label distribution offset between the source domain and the target domain.
[0009] Preferably, the feature extractor employs a dual-channel convolutional neural network structure, specifically including: Two identical and parameter-independent one-dimensional convolutional neural network branches are used to process different spectral features. Each branch consists of four stacked substructures. Each substructure contains sequentially connected one-dimensional convolutional layers, batch normalization layers, and ReLU activation function layers. The number of input and output channels of the convolutional layers in each substructure are adjusted accordingly, and the convolutional kernel size is 3 and the stride is 3. The high-dimensional feature vectors output by the branches of two one-dimensional convolutional neural networks are concatenated along the feature dimension to form a joint feature representation.
[0010] Preferably, the method by which the label distribution density ratio estimation network is used to characterize the label distribution shift between the source domain and the target domain includes: The label distribution density ratio is estimated by using the label distribution density ratio estimation network to learn the logarithmic form of the label distribution density ratio, and the label distribution density ratio between the source domain and the target domain is obtained through exponential mapping; Based on the label distribution density ratio, the initial weights of the source domain samples are obtained; The initial weights are pruned and normalized to obtain the final source domain sample weights, which are used to adjust the weighted source domain regression loss.
[0011] Preferably, the joint loss function includes weighted regression loss, conditional domain adversarial loss, and label distribution alignment loss; The weighted regression loss includes: constructing a weighted mean squared error loss in the source domain based on the source domain sample weights as a weighted source domain regression loss; introducing a weakly supervised regression constraint in the target domain as a weakly supervised target regression loss; and weightedly fusing the weighted source domain regression loss and the weakly supervised target regression loss to obtain the weighted regression loss.
[0012] The present invention also provides a cross-variety fruit soluble solids content prediction system, the system being used to implement the aforementioned method, the system comprising: a data acquisition and processing module, a feature construction module, a sample construction module, a network construction and training module, and a target prediction module; The data acquisition and processing module is used to acquire near-infrared spectral data and SSC content of different fruit varieties, and to preprocess the near-infrared spectral data. The feature construction module is used to construct feature representations based on the preprocessed near-infrared spectral data; The sample construction module is used to construct source domain samples and target domain samples based on the feature representation and the SSC content; The network construction and training module is used to construct a label distribution-aware domain adversarial network and optimize and train the label distribution-aware domain adversarial network based on the source domain samples, the target domain samples, and the joint loss function. The target prediction module is used to complete feature transfer and label distribution correction between the source and target domains using an optimized and trained label distribution-aware adversarial network, and obtain the soluble solids content prediction result of the target fruit sample through a regression predictor.
[0013] Preferably, the feature representation includes: original spectral features, spectral autoencoder features, two-dimensional spectral image features, two-dimensional image autoencoder features, and fused features; The spectral autoencoder features include: spectral latent features extracted based on the autoencoder; The two-dimensional spectral image features include: GADF image features and GASF image features; The fusion features include: the fusion features of the original spectral features and the two-dimensional spectral image features, and the fusion features of the spectral autoencoder features and the two-dimensional image autoencoder features.
[0014] Preferably, the label distribution-aware adversarial network includes: a feature extractor, a regression predictor, a conditional domain discriminator, and a label distribution density ratio estimation network; The feature extractor adopts a dual-channel convolutional neural network structure, which jointly models the original spectral features or spectral autoencoder features with the two-dimensional image autoencoder features through the dual-channel convolutional neural network to obtain domain-shared features; The regression predictor is used to obtain SSC prediction values based on the domain-shared features; A conditional domain discriminator is constructed using predicted labels as conditional information, and a conditional domain adversarial loss is output. Adversarial training between the feature extractor and the conditional domain discriminator is achieved through a gradient inversion layer. The label distribution density ratio estimation network is used to characterize the label distribution offset between the source domain and the target domain.
[0015] Compared with the prior art, the beneficial effects of the present invention are as follows: This invention, by introducing a label distribution awareness mechanism, can simultaneously alleviate the problems of feature distribution shift and label distribution shift, avoiding the negative transfer phenomenon in traditional domain adversarial learning. A density ratio weighting strategy makes the source domain training closer to the label distribution of the target domain, improving the model's generalization ability under small sample conditions. Combining GADF / GASF two-dimensional spectral representation with a deep feature fusion strategy effectively enhances the ability to express spectral structural information. Using the latent representation output by the autoencoder as AE features removes redundancy and noise while preserving inter-band discrimination information of the one-dimensional spectrum and the local texture and global structural patterns of the two-dimensional spectral image, effectively capturing complex nonlinear relationships in the signal. The overall scheme achieves cross-domain transfer modeling between different fruit varieties, maintaining high prediction accuracy and stability even with limited sample size in the target domain. Attached Figure Description
[0016] To more clearly illustrate the technical solution of the present invention, the drawings used in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a schematic diagram of the technical route of an embodiment of the present invention; Figure 2 This is a schematic diagram of the label distribution perceptual domain adversarial network structure according to an embodiment of the present invention; Figure 3 This is a schematic diagram of the grape GAF two-dimensional spectral image generation process according to an embodiment of the present invention; Figure 4 This is a schematic diagram of the process for generating two-dimensional spectral images of citrus fruits using the GAF method according to an embodiment of the present invention; Figure 5 This is a schematic diagram of the process for generating a two-dimensional spectral image of yellow peach using the GAF method according to an embodiment of the present invention; Figure 6 This is a schematic diagram of a custom DCCNN structure according to an embodiment of the present invention; Figure 7 This is a graph showing the differences in spectral distribution of different fruits according to an embodiment of the present invention; Figure 8 This is a scatter plot of the true and predicted values of the source domain (red) and target domain (blue) of the LDA-DANN model based on the GADF-AE features in an embodiment of the present invention. Figure 9 This is a scatter plot of the true and predicted values of the source domain (red) and target domain (blue) of the LDA-DANN model based on the GADF-AE feature validation set in an embodiment of the present invention. Figure 10 This is a scatter plot of the true and predicted values of the source domain (red) and target domain (blue) of the LDA-DANN model based on GADF-AE features in a grape test set according to an embodiment of the present invention. Figure 11 This is a scatter plot of the true and predicted values of the source domain (red) and target domain (blue) of the LDA-DANN model based on the GADF-AE features of the yellow peach training set in an embodiment of the present invention. Figure 12 This is a scatter plot of the true and predicted values of the source domain (red) and target domain (blue) of the LDA-DANN model based on GADF-AE features for a yellow peach validation set according to an embodiment of the present invention. Figure 13 This is a scatter plot of the true and predicted values of the source domain (red) and target domain (blue) of the LDA-DANN model based on GADF-AE features for the yellow peach test set in an embodiment of the present invention. Detailed Implementation
[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0019] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0020] Example 1 This invention provides a method for predicting the soluble solids content of fruits across different varieties, comprising: Near-infrared spectral data and SSC content of different fruit varieties were obtained, and the near-infrared spectral data were preprocessed. Feature representations are constructed based on preprocessed near-infrared spectral data; Based on the feature representation and the SSC content, source domain samples and target domain samples are constructed; A label distribution-aware domain adversarial network is constructed, and the label distribution-aware domain adversarial network is optimized and trained based on the source domain samples, the target domain samples, and the joint loss function; The optimized label distribution-aware adversarial network is used to complete feature transfer and label distribution correction between the source and target domains, and the soluble solids content prediction results of the target fruit sample are obtained through a regression predictor.
[0021] like Figures 1-2 As shown, the specific implementation process of the present invention is as follows: This invention can be applied to various fruit varieties. In this embodiment, near-infrared spectral data in the wavelength range of 900 nm to 1700 nm were collected from three fruit varieties, and the effective wavelength range of 942 nm to 1670 nm was retained for modeling and analysis. Soluble solids content (SSC) was determined using a digital Brix refractometer (ATAGO PAL-1 digital Brix refractometer). All samples were stored in a constant temperature environment (approximately 25°C) before measurement to reduce quality variations.
[0022] Furthermore, in this embodiment, the feature representation includes: original spectral features, spectral autoencoder features, two-dimensional spectral image features, two-dimensional image autoencoder features, and fused features; Autoencoder features include spectral autoencoder features and two-dimensional image autoencoder features; the latent representation of the encoder output is directly used as the AE feature to obtain a compact and information-rich low-dimensional representation. This representation removes redundancy and noise while preserving the inter-band discrimination information of the one-dimensional spectrum and the local texture and global structural patterns of the two-dimensional spectral image, thereby effectively capturing complex nonlinear relationships in the signal.
[0023] Two-dimensional spectral image features include: GADF (Gramian Angular Difference Field) image features and GASF (Gramian Angular Summation Field) image features; the process of generating two-dimensional spectral image features includes: normalizing the input spectral sequence; mapping the normalized spectral sequence to polar coordinate space; constructing a Gram matrix based on the polar coordinate representation; and generating GADF and GASF images based on the Gram matrix.
[0024] The fusion features include: fusion features of the original spectral features and two-dimensional spectral image features, and fusion features of spectral autoencoder features and two-dimensional image autoencoder features. To overcome the limitations of traditional one-dimensional spectral representation methods while retaining the advantages of spectral acquisition, this invention generates fusion features by mapping the spectral sequence to a two-dimensional matrix and introducing spatial structure and other feature information, thus explicitly expressing the correlation between wavelengths.
[0025] Furthermore, in this embodiment, a Label Distribution Aware Domain-Adversarial Neural Network (LDA-DANN) is introduced. By jointly modeling feature distribution alignment and label distribution correction, effective transfer to cross-variety spectral regression tasks is achieved. It consists of four core modules: a feature extractor... Regression predictor Conditional domain discriminator and label distribution density ratio estimation network .
[0026] The feature extractor adopts a dual-channel convolutional neural network structure, which jointly models the original spectral features or spectral autoencoder features with the two-dimensional image autoencoder features to obtain domain-shared features.
[0027] The regression predictor obtains the SSC prediction value based on domain-shared features.
[0028] A conditional domain discriminator is constructed using predicted labels as conditional information, and the conditional domain adversarial loss is output. The domain label of the source domain samples is set to 0, and that of the target domain samples is set to 1. Adversarial training between the feature extractor and the conditional domain discriminator is achieved through a gradient reversal layer, enabling the feature extractor to learn domain-inseparable feature representations.
[0029] Label distribution density ratio estimation networks are used to characterize the label distribution offset between the source domain and the target domain, making the source domain training closer to the label distribution of the target domain.
[0030] This invention achieves the alignment of the source and target domains in the feature space through conditional adversarial learning, and estimates the label distribution offset between the source and target domains through a label distribution density ratio estimation network.
[0031] Furthermore, in this embodiment, as Figure 6 As shown, the feature extractor employs a dual-channel convolutional neural network (DCCNN) structure, specifically including: Two structurally identical and parameter-independent one-dimensional convolutional neural network branches are used to process different spectral features (raw spectral features / spectral autoencoder features, and two-dimensional image autoencoder features), respectively. Each branch consists of four sets of stacked substructures. Each substructure contains sequentially connected one-dimensional convolutional layers (Conv1d), batch normalization layers (BatchNorm), and ReLU activation function layers (Rectified Linear Unit Layer, ReLU). The number of input and output channels of the convolutional layers in each substructure are adjusted accordingly, and the kernel size is 3 and the stride is 3. The high-dimensional feature vectors output by the branches of two one-dimensional convolutional neural networks are concatenated along the feature dimension to form a joint feature representation.
[0032] Furthermore, in this embodiment, the method by which the label distribution density ratio estimation network characterizes the label distribution offset between the source domain and the target domain includes: The label distribution density ratio estimation network learns the logarithmic form of the label distribution density ratio, and obtains the label distribution density ratio between the source domain and the target domain through exponential mapping; The initial weights of the source domain samples are obtained based on the label distribution density ratio. The initial weights are pruned and normalized to obtain the final source domain sample weights. These source domain sample weights are used to adjust the weighted source domain regression loss, making the source domain training more closely resemble the label distribution of the target domain.
[0033] Furthermore, in this embodiment, the joint loss function includes weighted regression loss, conditional domain adversarial loss, and label distribution alignment loss; The weighted regression loss includes: constructing a weighted mean squared error loss in the source domain based on the sample weights in the source domain as the weighted source domain regression loss; introducing a weakly supervised regression constraint in the target domain as the weakly supervised target regression loss; and weightedly fusing the weighted source domain regression loss and the weakly supervised target regression loss to obtain the weighted regression loss.
[0034] In summary, this invention discloses a method for predicting the soluble solids content of cross-varietal fruits based on label distribution-aware adversarial learning. The method includes: acquiring and preprocessing near-infrared spectral data of different fruit varieties; constructing original spectral features, spectral autoencoder features, two-dimensional spectral image features, two-dimensional image autoencoder features, and fused features; inputting source domain samples and target domain samples into a label distribution-aware adversarial network for training; modeling the label distribution offset between the source and target domains using a label distribution density ratio estimation network; achieving feature space alignment by combining conditional adversarial learning; and finally outputting the predicted soluble solids content of the target fruit sample. This invention effectively alleviates the model performance degradation problem caused by differences in spectral and label distributions among different fruit varieties, improving the model's generalization ability and prediction stability under the condition of limited target domain samples.
[0035] Example 2 like Figures 1-13 As shown, this embodiment illustrates the specific implementation process of the method described in the foregoing embodiments using specific data: 1. Sample preparation.
[0036] The experimental subjects in this embodiment were yellow peaches (variety: Jinxiu), citrus fruits (variety: Hongmeiren), and grapes (variety: Xiahei) from an orchard in a certain area. A total of 602 yellow peach samples, 490 Hongmeiren samples, and 1350 Xiahei samples were collected, and no mechanical damage was found in the fruits. All samples were stored in a constant temperature environment (approximately 25°C) before measurement to reduce quality differences.
[0037] 2. Collect one-dimensional near-infrared spectral data of the sample.
[0038] This embodiment utilizes a portable near-infrared spectrometer (DLP NIRScan Nano) for spectral acquisition. This portable spectrometer acquires reflectance spectra in the wavelength range of 900-1700 nm. During acquisition, the contact probe of the portable near-infrared spectrometer is kept in close contact with the sample surface to ensure consistency of measurement conditions and stability of the signal-to-noise ratio. Different sampling strategies are adopted for different fruit morphologies and size characteristics: when collecting near-infrared spectra of citrus and yellow peach samples, four sampling positions are randomly selected along the equatorial direction, spaced approximately 90 degrees apart; when collecting grape samples, two sampling positions are randomly selected along the equatorial direction, spaced approximately 180 degrees apart.
[0039] Figure 7The average spectral curves and standard deviations of grapes, yellow peaches, and citrus fruits in the 900–1700 nm wavelength range are presented, encompassing a total of 208 bands. Overall, the spectral morphology of the three fruits shows high consistency, with distinct peaks at approximately 1100 nm and 1280 nm, and significant absorption troughs in the 1350–1450 nm range. While the overall spectral morphology of the three varieties is similar, stable differences in reflectance still exist among them. This indicates systematic differences in tissue structure, peel characteristics, and internal composition among the three fruits. Particularly in the 950–1150 nm and 1500–1650 nm wavelength ranges, the spectral curves show significant differences. This result suggests that models built based on single-variety data are easily affected by distribution shifts in cross-variety applications, often resulting in a significant decrease in predictive performance.
[0040] 3. SSC determination.
[0041] In this embodiment, a digital Brix refractometer (ATAGO PAL-1) was used for measurement. For citrus and yellow peach samples, each fruit was cut into three equal parts, and juice was extracted from each part. The obtained juice was filtered through a 60-mesh screen, and the SSC value was measured using the digital refractometer. The average of the three measurements was taken as the SSC content of the sample. For grape samples, three fruits with similar color, size, and ripeness were selected as a group. Each group was measured three times, and the average of the measurements was taken as the SSC content of the group. To avoid cross-contamination affecting the measurement results, the juicer, refractometer, and beakers used in the experiment were thoroughly cleaned and dried before each measurement. The statistical analysis results of the SSC content of the three fruits are shown in Table 1.
[0042] In this embodiment, the core purpose of determining the SSC content is to provide accurate and reliable chemical reference values for the subsequent construction of an SSC prediction model. The determination results not only establish the correlation between spectral signals and internal quality, but also provide a crucial benchmark for subsequent statistical analysis and objective evaluation of the model's prediction accuracy.
[0043] Table 1. Statistical analysis results of SSC for different fruits 4. Preprocess the near-infrared spectral data.
[0044] The acquired near-infrared spectral data underwent noise removal at the beginning and end of bands and Standard Normal Variation (SNV) processing. Subsequently, the following feature representations were constructed: Original spectral features: Preprocessed raw absorbance or reflectance data acquired by the spectrometer were directly used as the original spectral features. The aim was to retain the most complete and original spectral information, serving as the baseline for all subsequent feature extraction methods. Spectral latent features extracted based on an autoencoder (one-dimensional spectral autoencoder features, or simply spectral autoencoder features): An autoencoder was trained to compress and reconstruct the original spectral features. The aim was to achieve nonlinear dimensionality reduction and denoising of the spectral data, compressing the high-dimensional spectrum into a compact, low-dimensional latent representation while retaining the most crucial nonlinear variation information for subsequent regression analysis. The predictor provides more refined and robust input; 2D spectral image features based on GADF and GASF are constructed: one-dimensional spectral data is encoded into a 2D image through GADF and GASF transformations, aiming to capture the implicit local correlations and global structural relationships between spectral wavelengths; 2D image autoencoder features: the 2D image generated by the above GADF and GASF is further input into the 2D image autoencoder to extract the low-dimensional latent features of its encoding layer. The purpose is to perform secondary feature compression on the spectral image in the 2D image space, remove redundant texture information in the image, further reduce the feature dimensionality, and improve the discriminative power and generalization ability of the features. To achieve complementarity and enhancement of multi-view, multi-scale information, the original spectral features are fused with 2D spectral image features, and the spectral autoencoder features are fused with 2D image autoencoder features. By fusing, the limitations of single feature representation in information expression are compensated for, so that the final fused features contain both the fine numerical changes of the spectrum and the spatial relationships of wavelengths, while also possessing low-dimensional compactness and noise resistance, thereby significantly improving the prediction accuracy and robustness of the model.
[0045] Figures 3-5This paper presents the preprocessed one-dimensional spectral curves of three different fruits and their corresponding GADF and GASF two-dimensional spectral images. After GADF and GASF mapping, the two-dimensional images exhibit significant differences in texture distribution, energy concentration regions, and symmetry patterns. These differences reflect the essential differences in chemical composition and internal structure among the different fruits, and also demonstrate that the two-dimensional encoding method can effectively mine and amplify the implicit nonlinear relationships and inter-band correlations in the original spectra. However, the original one-dimensional spectra and their generated two-dimensional spectral images are usually characterized by high dimensionality and rich redundant information. Directly inputting this high-dimensional data into a convolutional neural network not only incurs high computational costs but may also introduce noise, reducing the model's generalization ability. This embodiment directly uses the spectral latent representation output by the autoencoder as AE features (spectral autoencoder features) to obtain a compact and information-rich low-dimensional representation. While removing redundancy and noise, it retains the inter-band discrimination information of the one-dimensional spectrum and the local texture and global structural patterns of the two-dimensional spectral image, thereby effectively capturing the complex nonlinear relationships in the signal.
[0046] 5. Construct a label distribution perceptual domain adversarial network (LDA-DANN) to achieve cross-variety transfer.
[0047] After constructing the spectral features, different forms of feature representation are used as input features for the label distribution perceptual domain adversarial network to achieve cross-variety transfer. Specifically, for each fruit sample, its raw near-infrared spectral data is first preprocessed to obtain raw spectral features; then, spectral latent features are extracted through a spectral autoencoder; simultaneously, the preprocessed spectral sequence is transformed using GADF and GASF to obtain two-dimensional spectral image features, and further extracted using a two-dimensional image autoencoder to obtain two-dimensional image autoencoder features; the raw spectral features are fused with the two-dimensional spectral image features, and the spectral autoencoder features are fused with the two-dimensional image autoencoder features to obtain fused features.
[0048] In the transfer learning phase, the data of Red Beauty tangerines is used as the source domain, and the data of grapes and yellow peaches are used as the target domain. The data in the source and target domains include feature representations extracted from near-infrared spectral data and their corresponding SSC content. The label distribution-aware adversarial network in this embodiment includes a feature extractor. Regression predictor Conditional domain discriminator and label distribution density ratio estimation network .
[0049] (1) Construction of source and target domain samples Transfer learning samples are constructed based on different feature representation methods. The sample formats are as follows: in, Represents the source domain sample set, Represents the target domain sample set. and These represent the number of samples in the source domain and the target domain, respectively. This represents the feature representation extracted from near-infrared spectral data. Indicates the SSC content of the corresponding sample, subscript and These represent the index variables of the source and target domain samples, respectively. Represents the source domain. Indicates the target domain. Indicates the first Feature representations corresponding to each source domain sample Indicates the first SSC content corresponding to each source domain sample Indicates the first Feature representations corresponding to each target domain sample Indicates the first The SSC content corresponding to each target domain sample.
[0050] Taking the source domain as an example, for feature representation When using the original spectral features: in, Indicates the first The first sample Spectral response values at each wavelength.
[0051] When using spectral autoencoder features: in, This represents the encoding process of a spectral autoencoder. Indicates the first The spectral response value of each sample.
[0052] When using two-dimensional image autoencoder features: in, This indicates the GADF or GASF conversion process. This represents the process of a two-dimensional image autoencoder.
[0053] When using fusion features, features from different modalities are concatenated: A joint feature representation is formed. Among them, Indicates the first The one-dimensional spectral features of each sample can be either the original near-infrared spectral features or the spectral latent features extracted by a spectral autoencoder. Indicates the first The two-dimensional spectral image features corresponding to each sample are the latent image features obtained by converting the preprocessed near-infrared spectrum through GADF or GASF and extracting them through a two-dimensional image autoencoder.
[0054] The same applies to the target domain.
[0055] (2) Feature extraction and network input process The above different types of features represent the input label distribution in a feature extractor within a receptive adversarial network. Specifically, when the input is a single feature, a convolutional neural network structure is used; when the input is a fused feature, a dual-channel convolutional neural network structure is used: the first branch is used to extract the original spectral features or spectral autoencoder features, and the second branch is used to extract the two-dimensional image autoencoder features.
[0056] The two branches extract high-dimensional feature representations through convolution operations and then concatenate the features: in, This represents the extracted domain-shared features.
[0057] Subsequently: Through regression predictor Obtain SSC predicted values (predicted labels) .
[0058] Simultaneously, the domain-shared features and SSC predictions are input into the conditional domain discriminator: in, This represents the domain category probability output by the domain discriminator, used to determine whether an input sample comes from the source or target domain. Predicted label. As a conditional constraint information-assisted domain discriminator, it enables more accurate cross-domain feature alignment.
[0059] (3) Estimation of label distribution density ratio and sample weighting Because the SSC distribution varies among different fruit varieties, simply aligning the feature space may lead to negative transfer. Therefore, this embodiment introduces a label distribution density ratio estimation network. It is used to characterize the label distribution offset between the source domain and the target domain.
[0060] Let the probability densities of the source and target domain labels be respectively and The label distribution density ratio is defined as: Since probability density is difficult to estimate directly, the label distribution density ratio is used to estimate the network to learn its logarithmic form: The label distribution density ratio is obtained through exponential mapping: For the The initial weights of the source domain samples are expressed as follows: To reduce the instability caused by abnormal label values, the initial weights are pruned: in, This represents the preset minimum weight threshold; This indicates the preset maximum weight threshold.
[0061] Further adjustments to the weights after cropping Normalize: in, For the final source domain sample weights, This is the index variable for the source domain samples.
[0062] This weight is used to adjust the weighted source domain regression loss, so that the source domain training process pays more attention to the sample region that is consistent with the target domain SSC distribution.
[0063] (4) Weighted regression loss Based on the above label distribution weights (i.e., source domain sample weights) A weighted mean squared error loss is constructed in the source domain as the weighted source domain regression loss. : in, This represents the predicted SSC value from the source domain.
[0064] To further improve the model's adaptability to SSC prediction in the target domain, a weakly supervised regression constraint in the target domain is introduced as the weakly supervised target regression loss. : in, Indicates the sample weights in the target domain. This represents the predicted SSC value for the target domain.
[0065] Final weighted regression loss for: in, This represents the regression constraint weights for the target domain.
[0066] (5) Conditional domain adversarial loss To reduce the differences in spectral feature distribution among different fruit varieties, a conditional domain discriminator based on predicted label conditional information is constructed, and the output conditional domain is used to combat loss.
[0067] The source domain samples are labeled with 0, the target domain samples are labeled with 1, and the conditional domain adversarial loss is applied. Defined as: in, This represents the probability that a sample belongs to either the source domain or the target domain, given the features and predicted labels. and These represent the features obtained from the source and target domains by the feature extractor, respectively.
[0068] By using a gradient inversion layer (GRL), the feature extractor learns domain-invariant features that cannot be distinguished by the conditional domain discriminator, thus enabling adversarial training between the feature extractor and the conditional domain discriminator.
[0069] (6) Label distribution alignment loss To further constrain the consistency of SSC label distribution between the source and target domains, a binary classification method is used to train the label distribution density ratio estimation network.
[0070] Its loss function (label distribution alignment loss) Defined as: in, This represents the Sigmoid function. Denotes the mathematical expectation of the source domain. Represent the mathematical expectation of the target domain. Indicates the SSC content of the source domain. This indicates the SSC content of the target domain.
[0071] This loss prompts the label distribution density ratio estimate network to learn the SSC distribution difference between the source and target domains, thereby achieving label space distribution alignment.
[0072] (7) Overall optimization objectives Based on the above loss functions, the overall optimization objective of LDA-DANN is defined as: in, Indicates the feature extractor parameters. Indicates the parameters of the regression predictor. The label distribution density ratio is used to estimate network parameters. Indicates the parameters of the conditional domain discriminator. and These represent the weights of the conditional domain adversarial loss and the label distribution alignment loss, respectively.
[0073] Through the above joint optimization process, the Label Distribution Aware Domain Adversarial Network (LDA-DANN) can simultaneously achieve feature space distribution alignment and label space distribution correction, enabling the SSC prediction model based on near-infrared spectroscopy to adapt to the differences in spectral response and sugar content distribution among different fruit varieties, thereby improving the transferability of the SSC prediction model among different fruit varieties.
[0074] The Label Distribution Aware Domain Adversarial Network (LDA-DANN) builds upon the traditional domain adversarial learning framework by introducing label distribution information to explicitly regulate the alignment process. By constructing a mini-maximum adversarial optimization objective, it achieves collaborative alignment of feature and label distributions between the source and target domains while maintaining regression accuracy. Specifically, an adversarial relationship is formed between the conditional discriminator and the feature extractor, while the label distribution alignment loss further constrains the consistency of cross-domain features in the prediction space. This effectively mitigates the performance degradation caused by the dual shifts in feature and label distributions during small-sample cross-variety migration.
[0075] The performance metrics of LDA-DANN in the fruit soluble solids content detection task, including the accuracy and correlation coefficients on the training set, validation set and test set, are shown in Tables 2 and 3.
[0076] Table 2 Results of Grape Label Distribution Perceptual Domain Adversarial Network (LDA-DANN) Table 3. Results of the Perceptual Domain Adversarial Network (LDA-DANN) for Yellow Peach Label Distribution In Tables 2 and 3, Spe: original spectrum; Spe-AE: original spectrum AE feature; Img-AE: image AE feature; Spe +Img-AE: original spectrum and image AE fusion feature; Spe-AE+ Img-AE: original spectrum AE and image AE fusion feature; r c : Correlation coefficient of the training set; r v : Correlation coefficient of the validation set; r p : Correlation coefficient of the test set, source: source domain; target: target domain.
[0077] As shown in Tables 2 and 3, LDA-DANN can achieve cross-variety transfer in both grapes and yellow peaches, but the transfer effect is influenced by both crop type and feature representation method. Autoencoded spectral features exhibit better stability on both datasets.
[0078] 6. Use a scatter plot of the actual and predicted values to visualize and analyze the regression results.
[0079] Scatter plots can effectively supplement and cross-validate correlation coefficients and error indices from the perspective of geometric structure and distribution characteristics, providing more interpretive and convincing intuitive evidence for comparing model performance differences under different feature representation methods and fusion strategies. Figures 8-13 Scatter plots of the true and predicted values of the LDA-DANN model built based on GADF-AE features for grape and yellow peach datasets are presented. The results show that using GADF-AE as a feature representation can effectively improve the model's ability to characterize spectral nonlinear structure information, making the prediction results highly concentrated near the ideal fitting line, and exhibiting good stability and generalization performance under different datasets and model frameworks.
[0080] Experimental results show that this invention can effectively improve the model's prediction stability and generalization ability in cross-variety fruit migration tasks, with a target domain correlation coefficient exceeding 0.8. Combining spectral autoencoder features and spectral-image fusion features further enhances the model's discriminative and generalization abilities. The method of this invention introduces a label distribution awareness mechanism into a domain adversarial learning framework, achieving synergistic optimization of feature distribution alignment and label structure constraints. In cross-variety scenarios with significant differences between the source and target domains and high annotation costs, this method exhibits stronger transfer potential, especially when combined with spectral autoencoder features, effectively narrowing the performance gap between domains. Compared to traditional fine-tuning strategies, the method of this invention has stronger adaptability in handling significant distribution shifts. Compared to DANN methods that only focus on feature distribution alignment, by introducing label distribution awareness constraints, it effectively alleviates the negative transfer problem caused by inconsistent label distributions, improving the discriminative ability in regression tasks to a certain extent.
[0081] Example 3 Based on the same inventive concept, the present invention also provides a cross-variety fruit soluble solids content prediction system for implementing the method described in the foregoing embodiments. The system includes: a data acquisition and processing module, a feature construction module, a sample construction module, a network construction and training module, and a target prediction module. The data acquisition and processing module is used to acquire near-infrared spectral data and SSC content of different fruit varieties, and to preprocess the near-infrared spectral data. The feature construction module is used to construct feature representations based on the preprocessed near-infrared spectral data; The sample construction module is used to construct source domain samples and target domain samples based on the feature representation and the SSC content; The network construction and training module is used to construct a label distribution-aware domain adversarial network and optimize and train the label distribution-aware domain adversarial network based on the source domain samples, the target domain samples, and the joint loss function. The target prediction module is used to complete feature transfer and label distribution correction between the source and target domains using an optimized and trained label distribution-aware adversarial network, and obtain the soluble solids content prediction result of the target fruit sample through a regression predictor.
[0082] Furthermore, in this embodiment, the feature representation includes: original spectral features, spectral autoencoder features, two-dimensional spectral image features, two-dimensional image autoencoder features, and fused features; The spectral autoencoder features include: spectral latent features extracted based on the autoencoder; The two-dimensional spectral image features include: GADF image features and GASF image features; The fusion features include: the fusion features of the original spectral features and the two-dimensional spectral image features, and the fusion features of the spectral autoencoder features and the two-dimensional image autoencoder features.
[0083] Furthermore, in this embodiment, the label distribution-aware adversarial network includes: a feature extractor, a regression predictor, a conditional domain discriminator, and a label distribution density ratio estimation network; The feature extractor adopts a dual-channel convolutional neural network structure, which jointly models the original spectral features or spectral autoencoder features with the two-dimensional image autoencoder features through the dual-channel convolutional neural network to obtain domain-shared features; The regression predictor is used to obtain SSC prediction values based on the domain-shared features; A conditional domain discriminator is constructed using predicted labels as conditional information, and a conditional domain adversarial loss is output. Adversarial training between the feature extractor and the conditional domain discriminator is achieved through a gradient inversion layer. The label distribution density ratio estimation network is used to characterize the label distribution offset between the source domain and the target domain.
[0084] Furthermore, in this embodiment, the feature extractor adopts a dual-channel convolutional neural network structure, specifically including: Two identical and parameter-independent one-dimensional convolutional neural network branches are used to process different spectral features. Each branch consists of four stacked substructures. Each substructure contains sequentially connected one-dimensional convolutional layers, batch normalization layers, and ReLU activation function layers. The number of input and output channels of the convolutional layers in each substructure are adjusted accordingly, and the convolutional kernel size is 3 and the stride is 3. The high-dimensional feature vectors output by the branches of two one-dimensional convolutional neural networks are concatenated along the feature dimension to form a joint feature representation.
[0085] Furthermore, in this embodiment, the method by which the label distribution density ratio estimation network characterizes the label distribution offset between the source domain and the target domain includes: The label distribution density ratio is estimated by using the label distribution density ratio estimation network to learn the logarithmic form of the label distribution density ratio, and the label distribution density ratio between the source domain and the target domain is obtained through exponential mapping; Based on the label distribution density ratio, the initial weights of the source domain samples are obtained; The initial weights are pruned and normalized to obtain the final source domain sample weights, which are used to adjust the weighted source domain regression loss.
[0086] Furthermore, in this embodiment, the joint loss function includes weighted regression loss, conditional domain adversarial loss, and label distribution alignment loss; The weighted regression loss includes: constructing a weighted mean squared error loss in the source domain based on the source domain sample weights as a weighted source domain regression loss; introducing a weakly supervised regression constraint in the target domain as a weakly supervised target regression loss; and weightedly fusing the weighted source domain regression loss and the weakly supervised target regression loss to obtain the weighted regression loss.
[0087] The embodiments described above are merely preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Various modifications and improvements made to the technical solutions of the present invention by those skilled in the art without departing from the spirit of the present invention should fall within the protection scope defined by the claims of the present invention.
Claims
1. A method for predicting the soluble solids content of cross-variety fruits, characterized in that, The method includes: Near-infrared spectral data and SSC content of different fruit varieties were obtained, and the near-infrared spectral data were preprocessed. Feature representations are constructed based on preprocessed near-infrared spectral data; Based on the feature representation and the SSC content, source domain samples and target domain samples are constructed; A label distribution-aware domain adversarial network is constructed, and the label distribution-aware domain adversarial network is optimized and trained based on the source domain samples, the target domain samples, and the joint loss function; The optimized label distribution-aware adversarial network is used to complete feature transfer and label distribution correction between the source and target domains, and the soluble solids content prediction results of the target fruit sample are obtained through a regression predictor.
2. The method for predicting soluble solids content in cross-variety fruits according to claim 1, characterized in that, The feature representation includes: original spectral features, spectral autoencoder features, two-dimensional spectral image features, two-dimensional image autoencoder features, and fused features; The spectral autoencoder features include: spectral latent features extracted based on the autoencoder; The two-dimensional spectral image features include: GADF image features and GASF image features; The fusion features include: the fusion features of the original spectral features and the two-dimensional spectral image features, and the fusion features of the spectral autoencoder features and the two-dimensional image autoencoder features.
3. The method for predicting soluble solids content in cross-variety fruits according to claim 2, characterized in that, The label distribution-aware adversarial network includes: a feature extractor, a regression predictor, a conditional domain discriminator, and a label distribution density ratio estimation network; The feature extractor adopts a dual-channel convolutional neural network structure, which jointly models the original spectral features or spectral autoencoder features with the two-dimensional image autoencoder features through the dual-channel convolutional neural network to obtain domain-shared features; The regression predictor is used to obtain SSC prediction values based on the domain-shared features; A conditional domain discriminator is constructed using predicted labels as conditional information, and a conditional domain adversarial loss is output. Adversarial training between the feature extractor and the conditional domain discriminator is achieved through a gradient inversion layer. The label distribution density ratio estimation network is used to characterize the label distribution offset between the source domain and the target domain.
4. The method for predicting soluble solids content in cross-variety fruits according to claim 3, characterized in that, The feature extractor employs a dual-channel convolutional neural network structure, specifically including: Two identical and parameter-independent one-dimensional convolutional neural network branches are used to process different spectral features. Each branch consists of four stacked substructures. Each substructure contains sequentially connected one-dimensional convolutional layers, batch normalization layers, and ReLU activation function layers. The number of input and output channels of the convolutional layers in each substructure are adjusted accordingly, and the convolutional kernel size is 3 and the stride is 3. The high-dimensional feature vectors output by the branches of two one-dimensional convolutional neural networks are concatenated along the feature dimension to form a joint feature representation.
5. The method for predicting soluble solids content in cross-variety fruits according to claim 3, characterized in that, The label distribution density ratio estimation network used to characterize the label distribution shift between the source and target domains includes the following methods: The label distribution density ratio is estimated by using the label distribution density ratio estimation network to learn the logarithmic form of the label distribution density ratio, and the label distribution density ratio between the source domain and the target domain is obtained through exponential mapping; Based on the label distribution density ratio, the initial weights of the source domain samples are obtained; The initial weights are pruned and normalized to obtain the final source domain sample weights, which are used to adjust the weighted source domain regression loss.
6. The method for predicting soluble solids content in cross-variety fruits according to claim 5, characterized in that, The joint loss function includes weighted regression loss, conditional domain adversarial loss, and label distribution alignment loss; The weighted regression loss includes: constructing a weighted mean squared error loss in the source domain based on the source domain sample weights as the weighted source domain regression loss; Simultaneously, a weakly supervised regression constraint in the target domain is introduced as the weakly supervised target regression loss; the weighted source domain regression loss and the weakly supervised target regression loss are weighted and fused to obtain the weighted regression loss.
7. A system for predicting the soluble solids content of cross-variety fruits, the system being used to implement the method for predicting the soluble solids content of cross-variety fruits according to any one of claims 1-6, characterized in that, The system includes: a data acquisition and processing module, a feature construction module, a sample construction module, a network construction and training module, and a target prediction module; The data acquisition and processing module is used to acquire near-infrared spectral data and SSC content of different fruit varieties, and to preprocess the near-infrared spectral data. The feature construction module is used to construct feature representations based on the preprocessed near-infrared spectral data; The sample construction module is used to construct source domain samples and target domain samples based on the feature representation and the SSC content; The network construction and training module is used to construct a label distribution-aware domain adversarial network and optimize and train the label distribution-aware domain adversarial network based on the source domain samples, the target domain samples, and the joint loss function. The target prediction module is used to complete feature transfer and label distribution correction between the source and target domains using an optimized and trained label distribution-aware adversarial network, and obtain the soluble solids content prediction result of the target fruit sample through a regression predictor.
8. The cross-variety fruit soluble solids content prediction system according to claim 7, characterized in that, The feature representation includes: original spectral features, spectral autoencoder features, two-dimensional spectral image features, two-dimensional image autoencoder features, and fused features; The spectral autoencoder features include: spectral latent features extracted based on the autoencoder; The two-dimensional spectral image features include: GADF image features and GASF image features; The fusion features include: the fusion features of the original spectral features and the two-dimensional spectral image features, and the fusion features of the spectral autoencoder features and the two-dimensional image autoencoder features.
9. The cross-variety fruit soluble solids content prediction system according to claim 8, characterized in that, The label distribution-aware adversarial network includes: a feature extractor, a regression predictor, a conditional domain discriminator, and a label distribution density ratio estimation network; The feature extractor adopts a dual-channel convolutional neural network structure, which jointly models the original spectral features or spectral autoencoder features with the two-dimensional image autoencoder features through the dual-channel convolutional neural network to obtain domain-shared features; The regression predictor is used to obtain SSC prediction values based on the domain-shared features; A conditional domain discriminator is constructed using predicted labels as conditional information, and a conditional domain adversarial loss is output. Adversarial training between the feature extractor and the conditional domain discriminator is achieved through a gradient inversion layer. The label distribution density ratio estimation network is used to characterize the label distribution offset between the source domain and the target domain.
