Pumpkin sugar degree efficient detection method and system for enhancing multitask deep attention network collaborative near infrared spectrum

By enhancing the multitasking deep attention network collaborative near-infrared spectroscopy method, the subjectivity problem of traditional sensory evaluation methods is solved, and the rapid and accurate detection of pumpkin soluble sugar content and quality breeding support are achieved.

CN120385642APending Publication Date: 2025-07-29INST OF VEGETABLES GUANGDONG PROV ACAD OF AGRI SCI
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510477568.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-16
Publication Date
2025-07-29

AI Technical Summary

Technical Problem

Traditional sensory evaluation methods have problems with strong subjectivity and high professionalism in the evaluation of pumpkin fruit quality, and it is difficult to achieve convenient, scientific and objective evaluation of pumpkin fruit quality.

Method used

The method of collaborative near-infrared spectral of enhanced multi-task deep attention network is adopted. By obtaining the near-infrared spectral data of pumpkin fruits, standard normal variable correction, multivariate scattering correction and wavelet transform denoising treatment are carried out, and a sugar prediction model is constructed in combination with the sparse self-attention mechanism to achieve rapid detection of soluble sugar content in pumpkin.

Benefits of technology

It realizes rapid and accurate detection of the soluble sugar content of pumpkin, generates a thermal map of the sugar spatial distribution, provides intuitive visual information for pumpkin quality breeding, and improves detection efficiency and application value.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120385642A_ABST
    Figure CN120385642A_ABST
Patent Text Reader

Abstract

The invention discloses an efficient pumpkin sugar degree detection method and system for enhancing multitask deep attention network collaborative near infrared spectrum. The method comprises the following steps: acquiring near infrared spectrum data of pumpkin fruits to be detected; preprocessing the near infrared spectrum data of the pumpkin fruits to be detected to obtain preprocessed data; combining a multi-task neural network model with a sparse self-attention mechanism to construct an initial sugar degree prediction model, and training the initial sugar degree prediction model by using the preprocessed data to obtain a sugar degree prediction model; and acquiring near infrared spectrum data of target pumpkin fruits, and inputting the near infrared spectrum data into the sugar degree prediction model to obtain a prediction result. The method realizes efficient detection of the soluble sugar content of the pumpkin fruit, has the advantages of simple operation, rapid detection, accurate result and the like, provides a quantitative basis and an innovative technical scheme for prediction of the soluble sugar content of the pumpkin and quality grading of the pumpkin, and also provides a powerful technical support for breeding improvement of the sweetness quality of the pumpkin.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical fields of vegetable quality detection, artificial intelligence, and machine learning, and particularly relates to a method and system for efficiently detecting the sugar content of pumpkins by enhancing a multi-task deep attention network to collaborate with near-infrared spectroscopy. Background Art

[0002] With the development of China's economy, the demand in the consumer market has shifted from pursuing quantity to pursuing quality, and the demand for special and high-quality agricultural products is increasing day by day. At the same time, the focus of scientific research and breeding has correspondingly shifted from increasing yield to improving quality and nutrition. Pumpkins are important crops that can be used as both vegetables and grains, rich in nutrients, and China is one of the countries with the highest pumpkin yields in the world. People mostly use traditional sensory evaluation methods to evaluate the quality of pumpkin fruits. Although traditional sensory evaluation methods are classic, they are highly professional and are easily affected by various factors such as the differences in the preferences of evaluators, physical conditions, and the environment, resulting in strong subjectivity of the results. Therefore, it is very necessary to develop a convenient, scientific, objective, and effective method for evaluating the quality of pumpkin fruits. Summary of the Invention

[0003] To solve the above technical problems, the present invention proposes a method and system for efficiently detecting the sugar content of pumpkins by enhancing a multi-task deep attention network to collaborate with near-infrared spectroscopy, realizing the rapid detection of soluble sugars in pumpkin fruits, with a simple, fast, and accurate operation process, providing a new technical means for the quantitative evaluation of soluble sugars in pumpkin fruits, and at the same time, providing technical support for the quality breeding improvement of pumpkins.

[0004] On the one hand, to achieve the above object, the present invention provides a method for efficiently detecting the sugar content of pumpkins by enhancing a multi-task deep attention network to collaborate with near-infrared spectroscopy, including:

[0005] Obtaining near-infrared spectral data of the pumpkin fruit to be measured;

[0006] Successively performing standard normal variate correction, multiplicative scatter correction, and denoising processing based on wavelet transform on the near-infrared spectral data of the pumpkin fruit to be measured to obtain processed data;

[0007] Constructing an initial sugar content prediction model by combining a multi-task neural network model with a sparse self-attention mechanism, and training the initial sugar content prediction model with the processed data to obtain a sugar content prediction model;

[0008] Obtaining near-infrared spectral data of the target pumpkin fruit and inputting it into the sugar content prediction model to obtain a prediction result.

[0009] Optionally, before obtaining the near-infrared spectral data of the pumpkin fruit to be measured, it is necessary to select pumpkin varieties with rich sugar content polymorphism; for the collected pumpkin samples of different varieties, peel and remove the pulp, and grind them into powder samples after freeze-drying.

[0010] Optionally, constructing an initial sugar content prediction model by combining a multi-task neural network model with a sparse self-attention mechanism includes: adding an adaptive convolution module to the shared layer of the multi-task deep neural network model, and the adaptive convolution module dynamically adjusts the convolution kernel size and stride according to the spectral data features. Let the input spectral data be X, and the output of the l-th adaptive convolution module, with the convolution kernel being K l , and the stride being s l , then: Y l = f(X * K l + b l ), where f is the activation function and b l is the bias. The task-specific layer uses an attention-weighted long short-term memory network, and the attention mechanism calculates the attention weight α t , and sums the weighted hidden states to obtain the task-specific output y task ;

[0011] The attention weight is:

[0012] The attention score is: e t = v T tanh(W a h t + b a );

[0013] The task output is:

[0014] where v, W a , b a are the attention mechanism parameters, and h t is the hidden state of the RNN / LSTM at time step t.

[0015] Optionally, in the sparse self-attention mechanism, window-based calculation is adopted and an adaptive threshold adjustment strategy is introduced. The window-based calculation:

[0016]

[0017] where Q is the query vector, K is the key vector, V is the value vector, d k is the key vector dimension, and window is the window range.

[0018] Optionally, the calculation of the adaptive threshold adjustment includes: the mean of the attention scores within the current window is μ, the standard deviation is σ, the threshold τ = μ + ασ, where α is the adjustment coefficient. A sliding window of a fixed size is used to extract local features from the spectral data. After each window slide, the mean and standard deviation of the attention scores within the current window are calculated, and the threshold benchmark is dynamically adjusted in combination with the spectral data complexity. When the attention score is less than τ, the corresponding feature weight is dynamically weakened to optimize the feature selection process.

[0019] Optionally, in the construction process of the initial sugar content prediction model, the initial sugar content prediction model adopts a joint loss optimization strategy, where the losses of multiple tasks are weighted and summed to obtain the total loss, realizing the collaborative optimization of multiple tasks. The formula for the joint loss optimization strategy is: where K is the number of tasks, L k is the loss function of the k-th task, λ k is the dynamically adjusted weight, ‖W‖ is the Frobenius norm constraint β is the corresponding adjustment coefficient, where σ k is the uncertainty coefficient of the k-th task, calculated through a sliding window, and T is the temperature parameter.

[0020] On the other hand, to achieve the above object, the present invention also provides an efficient pumpkin sugar content detection system for enhancing multi-task deep attention network collaboration with near-infrared spectroscopy, including:

[0021] A data acquisition module, a data preprocessing module, a model construction and training module, and a prediction module;

[0022] The data acquisition module is used to acquire the near-infrared spectral data of the pumpkin fruit to be measured;

[0023] The data preprocessing module is used to preprocess the near-infrared spectral data of the pumpkin fruit to be measured to obtain the preprocessed data;

[0024] The model construction and training module is used to construct an initial sugar content prediction model by combining a multi-task neural network model with a sparse self-attention mechanism, and train the initial sugar content prediction model with the preprocessed data to obtain a sugar content prediction model;

[0025] The prediction module is used to acquire the near-infrared spectral data of the target pumpkin fruit and input it into the sugar content prediction model to obtain a prediction result.

[0026] Technical effects of the present invention: The present invention discloses a method and system for efficiently detecting the sugar content of pumpkins by enhancing multi-task deep attention network collaborative near-infrared spectroscopy. The full-band optical characteristics of pumpkin fruits are rapidly collected by a near-infrared spectrometer, and the spectral data is adaptively analyzed by combining an enhanced multi-task deep attention network, realizing the synchronous prediction of core indicators such as soluble sugars (glucose, fructose, and sucrose) in pumpkins. The model uses a sparse self-attention mechanism to dynamically screen key wavelengths, and cooperates with the collaborative architecture of the shared layer and the task-specific layer, strengthening the correlation feature extraction between multi-tasks while reducing the computational complexity, enabling the model to accurately capture the sugar content distribution law from complex spectral signals. This method can not only quickly predict the soluble sugar content of pumpkins, but also generate a heat map of the sugar content spatial distribution, providing intuitive and visual metabolic information for breeding screening, significantly improving the detection efficiency and application value, and providing a new technical means for high-quality pumpkin breeding. Description of the Drawings

[0027] The drawings forming a part of this application are used to provide a further understanding of this application. The schematic embodiments of this application and their descriptions are used to explain this application and do not constitute an improper limitation of this application. In the drawings:

[0028] Figure 1 It is a schematic flowchart of the method and system for efficiently detecting the sugar content of pumpkins by enhancing multi-task deep attention network collaborative near-infrared spectroscopy according to an embodiment of the present invention;

[0029] Figure 2 It is a schematic structural diagram of the system for efficiently detecting the sugar content of pumpkins by enhancing multi-task deep attention network collaborative near-infrared spectroscopy according to an embodiment of the present invention. Detailed Embodiments

[0030] It should be noted that, without conflict, the embodiments in this application and the features in the embodiments can be combined with each other. The following will refer to the drawings and combine the embodiments to detail this application.

[0031] It should be noted that the flowchart steps shown in the drawings can be executed by a computer system (for example, through a set of computer-executable instructions). Although the flowchart shows a logical order, in some cases, the actual execution order of these steps may be different from that shown in the drawings or described in the text.

[0032] As Figure 1 shown, the present embodiment provides a method for efficiently detecting the sugar content of pumpkins by enhancing multi-task deep attention network collaborative near-infrared spectroscopy, including:

[0033] Obtain the near-infrared spectral data of the pumpkin fruit to be measured;

[0034] Preprocess the near-infrared spectral data of the pumpkin fruit to be measured to obtain the preprocessed data;

[0035] Construct an initial sugar content prediction model by combining a multi-task neural network model with a sparse self-attention mechanism, and train the initial sugar content prediction model with the preprocessed data to obtain a sugar content prediction model.

[0036] Obtain the near-infrared spectroscopy data of the target pumpkin fruit, and input it into the sugar content prediction model to obtain a prediction result.

[0037] Furthermore, before obtaining the near-infrared spectroscopy data of the pumpkin fruit to be measured, it is necessary to select pumpkin varieties with rich sugar content polymorphism. For the collected pumpkin samples of different varieties, peel and remove the pulp, and grind them into powder samples after freeze-drying.

[0038] Specifically, collecting the near-infrared spectroscopy data of the pumpkin fruit to be measured and preprocessing the spectrum includes: selecting pumpkin varieties with rich sugar content polymorphism. For the collected pumpkin samples of different varieties, peel and remove the pulp, and grind them into powder samples after freeze-drying. Use a PerkinElmer FT-NIR Fourier transform near-infrared spectrometer to obtain the near-infrared spectroscopy data of the pumpkin samples. Perform preprocessing on the original near-infrared spectrum, such as standard normal variate correction, multiplicative scatter correction, and wavelet denoising.

[0039] Perform standard normal variate correction, multiplicative scatter correction, and denoising processing based on wavelet transform on the original spectrum in sequence. Decompose the spectrum into different frequency components by wavelet transform, and perform threshold processing on the high-frequency coefficients; let w ij be the coefficient after wavelet transform,

[0040] where λ is the threshold, and reconstruct the denoised spectrum by inverse wavelet transform, representing the updated wavelet coefficient.

[0041] Use a high-performance liquid chromatography - refractive index detector (HPLC-RI) system to quantitatively analyze the soluble sugar content of the pumpkin fruit samples. The specific experimental steps are as follows: Use chromatographic grade acetonitrile - aqueous solution (5:5, V / V) as the extraction solution, centrifuge at 12,000 r / min for 15 minutes at 4°C, and take the supernatant for detection.

[0042] Furthermore, constructing the initial sugar content prediction model by combining the multi-task neural network model with the sparse self-attention mechanism includes:

[0043] Add an adaptive convolution module to the shared layer of the multi-task deep neural network model, and this module dynamically adjusts the convolution kernel size and stride according to the spectral data characteristics. The task-specific layer adopts an attention-weighted recurrent neural network structure, such as long short-term memory network, bidirectional long short-term memory neural network, residual long short-term memory neural network, etc.

[0044] Based on the multi-task deep neural network model, a sparse self-attention mechanism is introduced to adaptively select key features and complete the construction of the initial sugar content prediction model.

[0045] Specifically, an efficient detection of pumpkin sugar content based on an enhanced multi-task deep attention network collaborating with near-infrared spectroscopy is established, and the model training is carried out through the backpropagation algorithm, including: The model combines the multi-task learning framework with the sparse self-attention mechanism. By sharing the underlying feature extraction layer, the model can simultaneously process multiple related tasks, such as predicting the content of multiple components in spectral data. At the same time, the sparse self-attention mechanism is introduced to enable the model to adaptively focus on key features and improve the modeling ability for complex data. This fusion not only gives full play to the advantages of multi-task learning but also overcomes the limitations of traditional attention mechanisms in terms of computational complexity and feature selection.

[0046] As an optional implementation manner in this embodiment, constructing the initial sugar content prediction model by combining the multi-task neural network model with the sparse self-attention mechanism includes: The multi-task deep neural network model adds an adaptive convolution module in the shared layer. The adaptive convolution module dynamically adjusts the convolution kernel size and stride according to the spectral data features. Let the input spectral data be X, and the output of the l-th layer adaptive convolution module, with the convolution kernel being K l , and the stride being s l , then: Y l =f(X*K l +b l ), where f is the activation function, and b l is the bias. The task-specific layer uses an attention-weighted long short-term memory network, and the attention mechanism calculates the attention weight α t , and sums the weighted hidden states to obtain the task-specific output y task ;

[0047] The attention weight is:

[0048] The attention score is: e t =v T tanh(W a h t +b a );

[0049] The task output is:

[0050] where v, W a , b a are the attention mechanism parameters, and h t is the hidden state of the RNN / LSTM at time step t.

[0051] As an alternative implementation in this embodiment, an efficient detection of pumpkin sugar content based on an enhanced multi-task deep attention network collaborating with near-infrared spectroscopy is established, including: a multi-task learning framework and a sparse self-attention mechanism. The multi-task learning framework is used to simultaneously process multiple related tasks, and the sparse self-attention mechanism is used to adaptively focus on key features, improving the model's ability to model complex data; the attention mechanism calculates the attention weight α t , and performs a weighted sum of the hidden states to obtain the task-specific output y task ;

[0052] Attention weight:

[0053] Attention score: e t = v T tanh(W a h t + b a );

[0054] Task output:

[0055] Among them, v, W a , b a are attention mechanism parameters, and h t is the hidden state of the RNN / LSTM at time step t.

[0056] In the sparse self-attention mechanism, a window-based calculation method is adopted. By setting the local window size, only the attention scores within the window are calculated, thereby achieving sparsity. This method not only reduces the computational complexity but also enables the model to more effectively capture the relationships between local features, while avoiding redundant calculations between features of the global attention mechanism, improving the model's computational efficiency and feature extraction ability.

[0057] The sparse self-attention mechanism adopts a window-based calculation method. By setting the local window size L, the attention scores within the window are calculated to achieve sparsity, reduce the computational complexity, and improve the model's computational efficiency and feature extraction ability; window-based calculation is adopted, and an adaptive threshold adjustment strategy is introduced:

[0058] Window-based calculation:

[0059] Among them, Q is the query vector, K is the key vector, V is the value vector, d k is the dimension of the key vector, and window is the window range.

[0060] The calculation of adaptive threshold adjustment is as follows: the mean of the attention scores within the current window is μ, the standard deviation is σ, and the threshold τ = μ + ασ, where α is the adjustment coefficient, which is dynamically adjusted according to the complexity of the spectral data. When the attention score is less than τ, the corresponding feature weight is reduced.

[0061] In the model, a shared layer and task-specific layers are designed. The shared layer is used to extract general features of the input data, which can be shared by all tasks, reducing the redundancy of feature extraction and improving the generalization ability of the model. The task-specific layers are designed according to the specific requirements of each task, and can further process and handle the features extracted by the shared layer, enabling the model to better adapt to the prediction requirements of different tasks and achieve accurate prediction of multiple tasks. Specifically, the multi-task deep neural network model includes a shared layer and task-specific layers. The shared layer is used to extract general features of the input data, and the task-specific layers are designed according to the specific requirements of each task to further process and handle the features extracted by the shared layer to achieve accurate prediction of multiple tasks. The calculation formula of the shared layer is: H [l+1] = ReLU[H [l] ·W [l] + b [l] ;

[0062] where, H [l] is the output of the l-th layer, W [l] is the weight matrix of the l-th layer, b [l] is the bias vector of the l-th layer, and ReLU is the activation function.

[0063] During the model training process, a random small-sample training method is adopted. Each time, a certain number (such as 50) of training samples are randomly selected for training. This method can increase the adaptability of the model to different data distributions, improve the generalization ability of the model, and at the same time reduce the risk of overfitting, making the model have better stability and reliability in practical applications. Specifically, a random small-sample training method is adopted, and each time a certain number of training samples are randomly selected for training to increase the adaptability of the model to different data distributions, improve the generalization ability of the model, and reduce the risk of overfitting. The steps of the random small-sample training method are:

[0064] Randomly select N samples (N is the number of small samples) from the training set, and use the selected samples to train the model and update the model parameters.

[0065] The model adopts a joint loss optimization strategy, which weights and sums the losses of multiple tasks to obtain the total loss. By optimizing the total loss, the model can take into account the prediction performance of multiple tasks simultaneously and achieve collaborative optimization of multiple tasks. This strategy can improve the overall performance of the model and enable the model to achieve good prediction results on multiple tasks. Specifically, the joint loss optimization strategy is adopted to weight and sum the losses of multiple tasks to obtain the total loss. The formula for the joint loss optimization strategy is as follows:

[0066] where K is the number of tasks, L k is the loss function of the k-th task, and λ k is the dynamically adjusted weight. ‖W‖ is the Frobenius norm constraint β is the corresponding adjustment coefficient. where σ k represents the uncertainty coefficient of the k-th task, which is calculated through a sliding window; T is the temperature parameter that scales the influence of the energy value. The larger the value, the flatter the distribution. The model realizes feature selection through a sparse self-attention mechanism. When calculating the attention scores, the model can automatically identify and focus on important features, and assign smaller weights or ignore unimportant features. This method does not require manual intervention and can adaptively perform feature selection according to the characteristics of the data, improving the accuracy and efficiency of feature selection. At the same time, it reduces the feature dimension and the computational burden of the model. Specifically, through the sparse self-attention mechanism to achieve feature selection, the model can automatically identify and focus on important features, assign smaller weights or ignore unimportant features, improve the accuracy and efficiency of feature selection, and reduce the feature dimension. The formula for feature selection is as follows: α j is the attention weight of the j-th feature, and N is the number of features.

[0067] As Figure 2 shown, in this embodiment, a high-efficiency pumpkin sugar content detection system for enhancing multi-task deep attention network collaborative near-infrared spectroscopy is also provided, including:

[0068] a data acquisition module, a data preprocessing module, a model construction and training module, and a prediction module;

[0069] The data acquisition module is used to acquire the near-infrared spectral data of the pumpkin fruit to be measured;

[0070] The data preprocessing module is used to preprocess the near-infrared spectral data of the pumpkin fruit to be measured to obtain the preprocessed data;

[0071] The model construction and training module is used to construct an initial sugar content prediction model by combining a multi-task neural network model with a sparse self-attention mechanism, and train the initial sugar content prediction model with the preprocessed data to obtain a sugar content prediction model;

[0072] The prediction module is used to obtain the near-infrared spectral data of the target pumpkin fruit and input it into the sugar content prediction model to obtain a prediction result.

[0073] A specific application example of the present invention is as follows:

[0074] Collecting the near-infrared spectral data of the pumpkin fruit to be measured and preprocessing the spectrum includes: selecting pumpkin varieties with rich sugar content polymorphism. For the collected pumpkin samples of different varieties, peel and remove the pulp, and grind them into powder samples after freeze-drying. Use a PerkinElmer FT-NIR Fourier transform near-infrared spectrometer to obtain the near-infrared spectral data of the pumpkin samples. Respectively preprocess the original near-infrared spectra by standard normal variate correction, multiplicative scatter correction, and wavelet denoising.

[0075] Quantitatively analyze the soluble sugar content of the pumpkin fruit samples using a high performance liquid chromatography-refractive index detector (HPLC-RI) system. The specific experimental steps are as follows: Use chromatographic grade acetonitrile-aqueous solution (5:5, V / V) as the extraction solution, centrifuge at 12,000 r / min for 15 minutes at 4°C, and take the supernatant for detection.

[0076] Establish an efficient detection of pumpkin sugar content based on an enhanced multi-task deep attention network combined with near-infrared spectroscopy, and train the model using the backpropagation algorithm.

[0077] This network utilizes an enhanced multi-task deep attention network architecture to efficiently detect pumpkin sugar content through collaborative analysis of near-infrared spectral data. The input layer receives preprocessed near-infrared spectral features, which are then subjected to step-by-step dimensionality reduction using a convolutional neural network and LSTM. Reinforced unit (ReLU) activation is then used for nonlinear feature extraction, effectively capturing sugar-sensitive wavelengths in the spectrum. A random dropout layer (with a dropout probability of 0.2) is then introduced to mitigate overfitting and improve the model's robustness to individual sample differences. The core module employs a sparse self-attention layer with a window size of 2. This layer dynamically assigns spectral channel weights through local feature correlation calculations (Softmax normalization), reducing the computational complexity of traditional global attention while enhancing the ability to identify characteristic sugar peaks (such as 1170nm and 1450nm). The network's terminal employs three independent branches, sharing the 32-dimensional features output by the self-attention layer. Each branch performs task-specific feature transformations through a 16-dimensional fully connected layer (ReLU activation), ultimately outputting predicted values for soluble sugar (glucose, fructose, and sucrose) content, thereby achieving multi-task joint optimization. This structure effectively takes into account the high-dimensional characteristics of spectral data and the needs of multi-index prediction through the collaboration of hierarchical feature extraction and attention mechanism, reducing parameter redundancy by 60% compared with traditional single-task models.

[0078] The collected pumpkin near-infrared spectral data were preprocessed with standard normal variable correction, multivariate scattering correction, and wavelet denoising to eliminate instrument noise and sample scattering effects, and normalize the original spectral data to a uniform dimensional range. The preprocessed spectral data is used as the network input feature and divided into batch sample sequences through a sliding window to retain the local continuity characteristics of the spectrum. At each iteration, a fixed number of samples (such as 50) are randomly selected from the training set to form a small batch data. By dynamically adjusting the sample distribution, the model's adaptability to pumpkin variety differences and changes in the growth environment is enhanced. This strategy utilizes the high-frequency update characteristics of small sample sets to force the network to learn a more generalized spectrum-sugar content mapping relationship, avoiding the risk of overfitting caused by the solidification of sample distribution in traditional full-scale training.

[0079] The model adopts a joint loss optimization strategy to perform a weighted summation of the losses of multiple tasks to obtain the total loss. By optimizing the total loss, the model can take into account the prediction performance of multiple tasks at the same time and achieve collaborative optimization of multiple tasks. This strategy can improve the overall performance of the model and enable the model to achieve better prediction results on multiple tasks. Specifically, the joint loss optimization strategy is adopted to perform a weighted summation of the losses of multiple tasks to obtain the total loss. By optimizing the total loss, the model can take into account the prediction performance of multiple tasks at the same time and achieve collaborative optimization of multiple tasks; the joint loss optimization strategy is adopted to perform a weighted summation of the losses of multiple tasks, and the formula for the joint loss optimization strategy is: Among them, K is the number of tasks, L k is the loss function of the kth task, λk For dynamically adjusting weights; ‖W‖ is the Frobenius norm constraint β is the corresponding adjustment coefficient. Among them, σ k represents the uncertainty coefficient of the k-th task, calculated through a sliding window. T is the temperature parameter, scaling the influence of the energy value. The larger the value, the flatter the distribution.

[0080] Calculate the gradient of the total loss with respect to the network parameters through the backpropagation algorithm, and use the stochastic gradient descent method (fixed learning rate) to iteratively update the weights and biases of modules such as the fully connected layer and the self-attention layer. Among them, the parameters of the shared layer are jointly adjusted by the gradients of all tasks, while the task-specific layer only receives the gradient signals of the corresponding task, thus achieving a balance between feature sharing and specific prediction in multi-task learning. The gradient calculation covers the entire network architecture, including the spectral feature extraction layer (fully connected layer), the sparse self-attention layer, and the task branch layer, and finally realizes the multi-task high-precision prediction of the pumpkin sugar content (glucose, fructose, sucrose).

[0081] Finally, compare the proposed method, the enhanced multi-task deep attention network, with the partial least squares method (PLS). The results in Table 1 show the following rules: The proposed method performs significantly better than the PLS method in the prediction sets of fructose and glucose. Among them, the RMSEp of fructose prediction drops from 13.50 of PLS to 9.80, a decrease of 27.4%; the RMSEp of glucose prediction drops from 15.00 to 12.50, a decrease of 16.7%. In terms of the Rp value, EM_Net maintains its advantages in both fructose (0.85 vs 0.82) and glucose (0.83 vs 0.80), indicating that multi-task joint learning effectively improves the generalization prediction accuracy of complex sugar components.

[0082] In the sucrose prediction task, PLS and EM_Net show different characteristics: PLS achieves a lower RMSE in the prediction set (13.00 vs 15.00), but EM_Net is more advantageous in terms of the Rp value (0.84 vs 0.81) and the calibration set stability (Rc = 0.84 vs 0.83), which may reflect that deep learning methods require more training data support in the non-linear modeling process.

[0083] Table 1

[0084]

[0085] The present invention discloses a method and system for efficiently detecting the sugar content of pumpkins by enhancing multi-task deep attention network collaborative near-infrared spectroscopy. The full-band optical characteristics of the internal components of pumpkin fruits are rapidly collected by a near-infrared spectrometer, and the spectral data is adaptively analyzed in combination with the enhanced multi-task deep attention network, realizing the synchronous prediction of core indicators such as soluble sugars (glucose, fructose, and sucrose) in pumpkins. The model uses a sparse self-attention mechanism to dynamically screen key wavelengths, and cooperates with the collaborative architecture of the shared layer and the task-specific layer, strengthening the correlation feature extraction between multi-tasks while reducing the computational complexity, enabling the model to accurately capture the sugar content distribution law from complex spectral signals. This method can not only quickly predict the soluble sugar content of pumpkins, but also generate a heat map of the sugar content spatial distribution, providing intuitive and visual metabolic information for breeding screening, significantly improving the detection efficiency and the application value of the results, and providing a new technical means for high-quality pumpkin breeding.

[0086] The above is only a preferred specific embodiment of the invention patent of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by those skilled in the art within the technical scope disclosed in the present application should be covered by the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. An efficient detection method for pumpkin sugar content by enhancing multi-task deep attention network collaborative near-infrared spectroscopy, characterized in that Including: Obtaining the near-infrared spectral data of the pumpkin fruit to be measured; Successively performing standard normal variate correction, multiplicative scatter correction, and denoising processing based on wavelet transform on the near-infrared spectral data of the pumpkin fruit to be measured to obtain the processed data; Constructing an initial sugar content prediction model by combining a multi-task neural network model with a sparse self-attention mechanism, and training the initial sugar content prediction model with the processed data to obtain a sugar content prediction model; Obtaining the near-infrared spectral data of the target pumpkin fruit, and inputting it into the sugar content prediction model to obtain a prediction result.

2. The efficient pumpkin sugar content detection method for enhancing multi-task deep attention network collaborative near-infrared spectroscopy according to claim 1, characterized in that, Before obtaining the near-infrared spectral data of the pumpkin fruit to be measured, it is necessary to select pumpkin varieties with rich sugar content polymorphism; for the collected pumpkin samples of different varieties, peel and remove the pulp, and grind them into powder samples after freeze-drying.

3. The high-efficiency pumpkin sugar content detection method for enhancing multi-task deep attention network collaborative near-infrared spectroscopy according to claim 1, characterized in that Constructing an initial sugar content prediction model by combining a multi-task neural network model with a sparse self-attention mechanism includes: adding an adaptive convolution module to the shared layer of the multi-task deep neural network model. The adaptive convolution module dynamically adjusts the convolution kernel size and stride according to the spectral data features. Let the input spectral data be X, and the output of the l-th adaptive convolution module, with the convolution kernel being K l , and the stride being s l , then: Y l = f(X * K l + b l ), where f is the activation function, and b l is the bias. The task-specific layer uses an attention-weighted long short-term memory network. The attention mechanism calculates the attention weight α t , and sums the weighted hidden states to obtain the task-specific output y task ; The attention weight is: The attention score is: e t = v T tanh(W a h t + b a ); The task output is: Among them, v, W a , b a are attention mechanism parameters, and h t is the hidden state of the RNN / LSTM at time step t.

4. The efficient pumpkin sugar content detection method for enhancing multi-task deep attention network collaborative near-infrared spectroscopy according to claim 3, characterized in that In the sparse self-attention mechanism, window-based calculation is adopted and an adaptive threshold adjustment strategy is introduced. The window-based calculation: Among them, Q is the query vector, K is the key vector, V is the value vector, and d k is the key vector dimension, and window is the window range.

5. The high-efficiency pumpkin sugar content detection method for enhancing multi-task deep attention network collaborative near-infrared spectroscopy according to claim 4, characterized in that The calculation of the adaptive threshold adjustment includes: the mean of the attention scores within the current window is μ, the standard deviation is σ, the threshold τ = μ + ασ, where α is an adjustment coefficient. A sliding window of a fixed size is used to extract local features from the spectral data. After each window slide, the mean and standard deviation of the attention scores within the current window are calculated, and the threshold benchmark is dynamically adjusted in combination with the complexity of the spectral data; when the attention score is less than τ, the corresponding feature weight is dynamically weakened to optimize the feature selection process.

6. The efficient pumpkin sugar content detection method for enhancing multi-task deep attention network collaborative near-infrared spectroscopy according to claim 1, characterized in that In the construction process of the initial sugar content prediction model, the initial sugar content prediction model adopts a joint loss optimization strategy to perform weighted summation on the losses of multiple tasks to obtain the total loss and achieve collaborative optimization of multiple tasks; the formula of the joint loss optimization strategy is: where K is the number of tasks, L k is the loss function of the k-th task, λ k is the dynamically adjusted weight, and ‖W‖ is the Frobenius norm constraint β is the corresponding adjustment coefficient, where σ k is the uncertainty coefficient of the k-th task, calculated through a sliding window, and T is the temperature parameter.

7. An efficient pumpkin sugar content detection system for enhancing multi-task deep attention network collaborative near-infrared spectroscopy according to any one of claims 1-6, characterized in that, Including: A data acquisition module, a data preprocessing module, a model construction and training module, and a prediction module; The data acquisition module is used to obtain the near-infrared spectral data of the pumpkin fruit to be measured; The data preprocessing module is used to preprocess the near-infrared spectral data of the pumpkin fruit to be measured to obtain the preprocessed data; The model construction and training module is used to construct an initial sugar content prediction model by combining a multi-task neural network model with a sparse self-attention mechanism, and train the initial sugar content prediction model with the preprocessed data to obtain a sugar content prediction model; The prediction module is used to obtain the near-infrared spectral data of the target pumpkin fruit, input it into the sugar content prediction model to obtain the prediction result of the soluble sugar of the pumpkin fruit, and the soluble sugar of the pumpkin fruit includes glucose, fructose, and sucrose.

Citation Information

Patent Citations

  • Method for detecting sugar content of pumpkins by utilizing near infrared spectroscopy

    CN112816435A

  • American ginseng quality evaluation method based on multi-task deep learning, computer readable storage medium and computer program product

    CN119622520A

  • Method and system for rapidly detecting protein content and water content in plant-based product based on near infrared spectrum and deep learning

    CN119643500A

  • Food additive detection method and system based on Fourier transform infrared spectroscopy

    CN119757266A

  • Deep learning-based method for updating spectral analysis model for fruit

    WO2023077569A1