A fusion multi-target grey wolf optimization method for freshness multi-task detection of aquatic products

By combining the multi-objective gray wolf optimization algorithm with data augmentation and multi-task learning, the problems of subjectivity and low efficiency in aquatic product freshness detection are solved. It achieves simultaneous prediction and efficient detection of multiple freshness indicators, has strong adaptability, and is applicable to fields such as aquatic product processing, cold chain logistics, and market supervision.

CN121051364BActive Publication Date: 2026-02-10HEFEI UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510944376.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-09
Publication Date
2026-02-10
Estimated Expiration
2045-07-09

AI Technical Summary

Technical Problem

Existing methods for detecting the freshness of aquatic products are subjective, destructive, and inefficient, making it difficult to meet the needs of large-scale industrial applications. Furthermore, existing infrared spectroscopy modeling methods are not adaptable to small sample scenarios, lack multi-task collaborative prediction capabilities, and have imperfect hyperparameter optimization mechanisms.

Method used

The multi-objective gray wolf optimization algorithm (MOGWO) is adopted, which combines data augmentation, CNN-LSTM-SE feature extraction and multi-task learning. The data augmentation module expands the sample size, CNN and LSTM extract spectral features in parallel, SE attention mechanism filters features, and multiple freshness indicators are predicted simultaneously through the multi-task learning framework. The MOGWO algorithm optimizes hyperparameters in stages.

Benefits of technology

It improves the accuracy, robustness, and adaptability of aquatic product freshness detection, enables simultaneous prediction of multiple freshness indicators, reduces data collection costs, improves detection efficiency and model stability, and is suitable for small sample and weak supervision conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121051364B_ABST
    Figure CN121051364B_ABST
Patent Text Reader

Abstract

The application discloses a kind of fusion multi-objective grey wolf optimization aquatic product freshness multi-task detection method, including data foundation construction, enhancement, CNN-LSTM-SE feature extraction, multi-task model formation, super parameter optimization, model training and evaluation deployment etc. steps.This method expands sample scale by data enhancement, extracts features using CNN and LSTM in parallel combined with SE attention mechanism, constructs multi-task learning framework to realize multi-index synchronous prediction, and optimizes super parameters in stages using MOGWO algorithm.The beneficial effects are to improve small sample robustness, feature extraction accuracy, multi-task detection efficiency and model generalization ability, and modular design facilitates popularization and application.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of intelligent detection of aquatic product quality, and particularly relates to an aquatic product freshness multi-task detection method fusing multi-target grey wolf optimization. BACKGROUND

[0002] With the development of aquatic product cold chain logistics and food intelligent detection technology, it has become a core requirement to quickly and accurately evaluate the freshness of aquatic products to ensure the safety of aquatic product circulation and consumer experience. In the whole chain of aquatic products from capture, processing to sales, freshness detection is a key link to control quality, but the existing detection methods have significant technical bottlenecks and cannot meet the needs of industrial scale application.

[0003] Traditional aquatic product freshness detection methods mainly include sensory evaluation, physicochemical index determination and microbial detection. Sensory evaluation relies on manual visual and olfactory judgment, which has the problems of non-uniform evaluation standard and poor repeatability; physicochemical index detection needs to use professional instruments to quantitatively analyze volatile basic nitrogen and biological amine, which has a complicated operation process and needs to destroy the sample; microbial detection needs to obtain the total number of colonies by culture counting, which has a long detection period and cannot realize real-time monitoring. The subjectivity, destructiveness and inefficiency of these methods seriously limit their application in aquatic product processing, circulation and consumption.

[0004] Infrared spectroscopy technology is widely used in aquatic product quality evaluation field due to its non-destructive, efficient and online detection characteristics. The modeling methods based on infrared spectroscopy mainly include traditional machine learning and deep learning: traditional methods such as support vector regression and partial least squares regression have limited modeling ability for high-dimensional spectral data, and are highly dependent on feature preprocessing, which makes it difficult to capture the complex nonlinear relationship in the spectrum; deep learning methods such as convolutional neural network and long short-term memory network have automatic feature extraction capability, but they are prone to overfitting under small sample conditions, and most of the models use single-task structure, which cannot predict multiple freshness indicators at the same time, making it difficult to meet the needs of multi-dimensional quality evaluation. In addition, the hyperparameter setting of existing models mostly depends on human experience or grid search, which has high computational cost, low optimization efficiency and difficulty in realizing multi-index global optimization, etc., resulting in limited prediction accuracy and generalization performance of the model.

[0005] In current research, the freshness detection model based on infrared spectroscopy has insufficient adaptability in small sample scenarios, lacks multi-task collaborative prediction capability, and the hyperparameter optimization mechanism is imperfect, making it difficult to realize efficient deployment in actual detection scenarios. Therefore, it is urgent to build an infrared modeling method that integrates small sample enhancement, deep feature extraction, multi-task learning and intelligent hyperparameter optimization to break through the limitations of existing technology and improve the accuracy, robustness and adaptability of aquatic product freshness detection. SUMMARY

[0006] The application aims to provide a water product freshness multi-task detection method fusing multi-objective grey wolf optimization, which fuses a multi-objective grey wolf optimization algorithm, solves small sample overfitting, multi-index prediction capability deficiency and hyperparameter optimization inefficiency through data enhancement, CNN-LSTM-SE feature extraction, multi-task learning and hyperparameter optimization, and improves detection accuracy, robustness and adaptability.

[0007] To achieve the above-mentioned purpose, the application adopts the following technical means:

[0008] A water product freshness multi-task detection method fusing multi-objective grey wolf optimization comprises the following steps:

[0009] Step 1: data base construction

[0010] m water product samples covering different freshness grades are selected to establish a sample set T, infrared spectrum data and n freshness indexes are measured, and the sample set T is divided into a training set, a validation set and a test set according to a proportion;

[0011] Step 2: data enhancement supports feature extraction

[0012] Based on the training set and the validation set spectrum data divided in step 1, the sample size is expanded through a data enhancement module operation;

[0013] Step 3: CNN-LSTM-SE feature extraction module construction

[0014] For the data enhanced in step 2, the local spatial features and time sequence dependent information of the spectrum are extracted in parallel by using CNN and LSTM, and then the features are weighted and filtered through an SE attention mechanism to form a feature extraction module;

[0015] Step 4: multi-task model formation

[0016] After the output of the feature extraction module in step 3 is spliced, it is input into a multi-task learning framework, common features are extracted through a shared fully connected network, multiple task-specific branches are connected, a regression head is arranged at the end of each branch to output the prediction value of the corresponding freshness index, and a CNN-LSTM-SE multi-task model capable of synchronously predicting multiple freshness indexes is formed;

[0017] Step 5: hyperparameter optimization improves model performance

[0018] For the CNN-LSTM-SE multi-task model formed in step 4, the MOGWO algorithm is used to optimize its hyperparameters in stages, the optimal parameter configuration is obtained through defining hyperparameter groups and optimization strategies, initializing grey wolf populations and parameters, calculating fitness functions, updating grey wolf positions, updating archives and wolf social ranks, boundary processing, checking termination conditions and grouping optimization operations;

[0019] Step 6: Optimal parameter-driven model training

[0020] The optimal hyperparameters of step 5 are imported into the CNN-LSTM-SE multi-task model, retrained based on the training set of step 1, and the final freshness prediction model is generated;

[0021] Step 7: Model evaluation and deployment preparation

[0022] The prediction performance of the freshness prediction model generated in step 6 is evaluated using the test set of step 1, and the model parameters and structure are saved after verification, completing the full-process closed loop from data processing to model deployment.

[0023] In a further aspect of the present application, in step 1, the division ratio of the training set, the validation set and the test set is 3:1:1.

[0024] In a further aspect of the present application, in step 2, the enhancement operations performed by the data enhancement module on the original spectral data include disturbance, noise addition, stretching and amplitude transformation.

[0025] In a further aspect of the present application, in step 3, the CNN is composed of 1-4 layers of one-dimensional convolution structure, and after each layer of convolution, batch normalization and ReLU activation function are sequentially connected;

[0026] The LSTM is composed of 1-3 layers of LSTM neural network structure stacked in sequence;

[0027] The SE is composed of a channel attention mechanism structure, including two stages of Squeeze and Excitation.

[0028] In a further aspect of the present application, in step 3, the feature extraction module adds Dropout and L2 regularization.

[0029] In a further aspect of the present application, in step 4, the shared fully connected network contains one or more layers; the task-specific branch contains one or more fully connected layers; and the freshness indicators include but are not limited to total number of colonies, volatile salt-based nitrogen, and biological amine content.

[0030] In a further aspect of the present application, in step 4, each sub-task of the multi-task learning framework uses an independent mean square error loss function to form a joint loss structure:

[0031]

[0032] wherein, L t represents the prediction error of the tth index, the task weight a t ∈[0.1,0.9], and needs to satisfy the normalization constraint The hyperparameter a t participates in the joint optimization of MOGWO.

[0033] The further scheme of the present application is that in step 5, the definition of the hyperparameter group and the optimization strategy is specifically:

[0034] In order to reduce the dimension of a single search, reduce the number of hyperparameters optimized each time, and improve the search efficiency of MOGWO, all hyperparameters are divided into three groups according to their functional attributes, and a phased grouping optimization strategy is adopted:

[0035] Group 1 is the hyperparameter related to the CNN-LSTM-SE architecture, group 2 is the training related hyperparameter, and group 3 is the task weight hyperparameter in multi-task learning;

[0036] Phased optimization: phase 1 optimizes group 1, fixes group 2 and group 3; phase 2 optimizes group 2, fixes the optimal solution of group 1 and group 3; phase 3 optimizes group 3, fixes the optimal solution of group 1 and group 2; Each group is independently optimized based on the fixed parameters of other groups, and finally iteratively fused to form the overall optimal configuration;

[0037] The initialized grey wolf population and parameters are specifically:

[0038] In order to realize automatic configuration of the hyperparameters of the model built by MOGWO, the population size N, search space dimension D', and maximum iteration number g max are set, and the convergence precision is set. Initialize the iteration counter g=0 and enter the iterative optimization;

[0039] Define the position vector of the current group of grey wolves as X i =(x i,1 ,x i,2 ,…,x i,D′ ), where i=1,2,…,N, randomly initialize the position of each grey wolf within the search space boundary [X′ l ,X′ u ] of the current group, and the hyperparameters of the non-optimized group are fixed as the predefined value or the optimal value of the previous stage;

[0040] For special hyperparameters, special processing is performed: for discrete hyperparameters, round up to the nearest allowed value; the convolution kernel size is mapped to the nearest odd number; the task weight a t ∈[0.1,0.9], and

[0041] The calculation of the fitness function is specifically:

[0042] Define the objective function to evaluate the fitness of each grey wolf: use the joint loss L total on the training set to train the CNN-LSTM-SE multi-task model; calculate the current grey wolf individual Xi The corresponding fitness function F(X i ) = (f1(X i ), f2(X i ), …, f k (X i ), where f1(X i ), f2(X i ), …, f k (X i ) is the gray wolf X i The average evaluation index of n tasks on the validation set; since the dimensions of each component are different, f1(X i ), f2(X i ), …, f k (X i ) are respectively processed by Min-Max normalization;

[0043] In the initial population, based on the joint action of non-dominated level and crowding distance, three solutions are randomly selected as α, β and δ, and the non-dominated solution is stored in the archive A;

[0044] Updating the gray wolf position is specifically:

[0045] At each iteration, the position of the current gray wolf group is updated according to the hunting behavior of α, β and δ; for each gray wolf i, its position is updated using the following formula:

[0046] D α = |C1·X α (g) - X i (g) |, X i,α (g+1) = X α (g) - A1·D α

[0047] D β = |C2·X β (g) - X i (g) |, X i,β (g+1) = X β (g) - A2·D β

[0048] D δ = |C3·X δ (g) - X i (g) |, X i,δ (g+1) = X δ (g) - A3·D δ

[0049]

[0050] Where A k= 2ar1-a, C k = 2r2, r1, t2 e [0, 1];

[0051] After updating the position, the new fitness vector F(X i ) = (f1(X i ), f2(X i ), …, f k (X i ) of each wolf is recalculated, and Min-Max normalization processing is performed on f1(X i ), f2(X i ), …, f k (X i ), respectively;

[0052] The updating of the archive and the social rank of the wolf pack is as follows:

[0053] The current population and the archive A are non-dominantly sorted, and new non-dominant solutions are added to the archive A. If the size of the archive a exceeds the predefined limit, the solution with the lowest crowding distance is removed to maintain diversity, and then three solutions are randomly selected from the archive A according to the non-dominant level and the crowding distance, and a, β and δ are updated;

[0054] The boundary processing is as follows:

[0055] Check whether the updated position X i (g+1) of the current group is within the space boundary [X′ l , X′ u ]. If it is out of the boundary, adjust it as follows: if x i,j (g+1) < X′ l,j , then x i,j (g+1) = X′ l,j ; if x i,j (g+1) > X′ u,j , then x i,j (g+1) = X′ u,j , where j = 1, 2, …, D′;

[0056] The termination condition check is as follows:

[0057] Check whether the termination condition is met: the iteration counter g ≥ g max or the fitness of the solution set of the archive A changes by less than the convergence precision If the termination condition is not met, increase the iteration counter by 1, i.e. g = g + 1, and return to step 3 to continue the iteration of the current stage;

[0058] If the termination condition is met, perform the grouping optimization operation according to the current stage;

[0059] The group optimization is specifically:

[0060] Stage 1 is completed: the non-dominated solution set of group 1 is output Each solution contains the optimized hyperparameters of group 1 and the normalized fitness vector, and the optimal solution is selected by weighted summation of the fitness vector, and the hyperparameters of group 1 are fixed;

[0061] Stage 2: initialize the grey wolf population and parameters of stage 2, repeatedly execute the calculation of the fitness function, update the grey wolf position, update the archive and wolf social rank, boundary processing, termination condition check, output the non-dominated solution set of group 2 Each solution contains the optimal hyperparameters of group 1, the optimized hyperparameters of group 2 and the normalized fitness vector, and the optimal solution is selected by weighted summation of the fitness vector, and the hyperparameters of group 2 are fixed;

[0062] Stage 3: initialize the grey wolf population and parameters of stage 3, repeatedly execute the calculation of the fitness function, update the grey wolf position, update the archive and wolf social rank, boundary processing, termination condition check, output the non-dominated solution set of group 3, form the Pareto solution set Each solution contains the optimal hyperparameters of group 1, group 2, the optimized hyperparameters of group 3 and the normalized fitness vector, and the optimal solution is selected from the Pareto solution set by weighted summation of the fitness vector, and the final global optimal hyperparameter configuration is obtained;

[0063] If higher precision is required, stages 1, 2 and 3 can be alternately optimized one or twice each time, and the optimal solution of the previous stage is used to update the fixed hyperparameters.

[0064] Further schemes of the application are that the detection method is realized through the following system, the system comprises a data enhancement module, a feature extraction module, a multi-task learning module and a multi-objective optimization module, and each module cooperates to realize the process closed loop of the detection method;

[0065] The data enhancement module receives the original infrared spectrum data, performs various enhancement operations on it, effectively expands the sample size to Q times of the original, and enhances the robustness of the model under small sample conditions by improving the data diversity;

[0066] The feature extraction module: the enhanced sample data output by the data enhancement module is sent into two independent channels of CNN and LSTM in parallel, CNN extracts local spatial features of the spectrum, and LSTM captures sequence dependent information, independent SE attention mechanism modules are arranged at the output ends of CNN and LSTM respectively, the channel dimensions of the two types of features are weighted and selected, and the key information most relevant to each target task is focused;

[0067] Multi-task learning module: receives the output of the double-channel SE attention mechanism in the feature extraction module, fuses the output to obtain comprehensive features, and then inputs the comprehensive features into the constructed multi-task learning framework; the framework compresses the comprehensive features through a shared fully connected network, extracts general features suitable for all tasks, connects multiple task-specific branches, finally outputs prediction values with a regression head corresponding to a freshness indicator of aquatic products, and realizes the synchronous output of multiple freshness indicators of aquatic products;

[0068] Multi-objective optimization module: the MOGWO algorithm is used to guide the search on the multi-objective evaluation function; this module realizes the stage grouping optimization of key hyperparameters affecting the performance of the model, and the optimization range covers the convolution kernel size, the number of convolution kernels of the CNN module, the number of hidden neurons of the LSTM module, the learning rate, the batch size, the number of iterations in the training process, the L2 regularization coefficient, the Dropout rate, and the task loss weight related to multi-task learning.

[0069] The beneficial effects of the present application are:

[0070] 1. Data enhancement improves robustness: the data enhancement module effectively expands the sample size by implementing various enhancement operations on the original infrared spectrum data, significantly improves the training stability and generalization ability of the model under small sample conditions, overcomes the dependence of traditional methods on large-scale data, reduces the data acquisition cost and difficulty, and can better adapt to the situation that sample acquisition is limited in actual detection scenarios.

[0071] 2. Efficient feature extraction guarantees accuracy: the feature extraction module adopts a parallel structure of CNN and LSTM, combines a double-channel SE attention mechanism, comprehensively captures spectral features from two dimensions of space and time, and performs weighted screening on the channel dimension, greatly improving the model's ability to capture and express complex infrared spectrum features, providing a solid foundation for accurate prediction of multiple freshness indicators of aquatic products, and significantly improving the prediction accuracy compared with traditional methods.

[0072] 3. Multi-task learning improves detection efficiency: the multi-task learning module realizes the synchronous modeling and collaborative prediction of multiple freshness indicators of aquatic products, avoids the loss of useful information when each indicator is learned independently, and improves the modeling efficiency and comprehensive evaluation ability of the detection method. In practical applications, multiple key freshness indicators can be detected at one time, and the detection efficiency is greatly improved compared with single indicator prediction methods, which can provide comprehensive data support for aquatic product quality evaluation more quickly.

[0073] 4. Intelligent optimization enhances model performance: The multi-objective optimization module based on the MOGWO algorithm can automatically adjust the model hyperparameters and achieve overall balanced optimization between multiple performance evaluation indicators. This mechanism effectively avoids the subjectivity and inefficiency of traditional manual parameter adjustment, significantly improves the stability and generalization ability of the model performance, and enables the model to maintain good detection results under different aquatic product categories and different detection environments, reducing the performance fluctuation risk caused by improper parameter settings.

[0074] 5. Modular design facilitates application and promotion: The system adopts a modular closed-loop architecture design of "data augmentation-feature extraction and fusion dual-channel attention mechanism-multi-task learning-hyperparameter stage-based grouping optimization", and each module has clear division of labor and close cooperation. This design not only facilitates the development, maintenance and upgrade of the system, but also makes it suitable for complex aquatic product detection scenarios such as small sample and weak supervision, has good universality and expandability, has broad application and promotion prospects in aquatic product processing, cold chain logistics, market supervision and other fields, and can provide strong support for the intelligent development of aquatic product quality detection. BRIEF DESCRIPTION OF DRAWINGS

[0075] Figure 1 The method flowchart of the present application;

[0076] Figure 2 The framework diagram of feature extraction and multi-task learning of the present application. DETAILED DESCRIPTION

[0077] The technical solutions of the present application will be described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.

[0078] A water product freshness multi-task detection method fusing multi-objective grey wolf optimization, comprising the following steps:

[0079] Step 1: Data base construction

[0080] Select m aquatic product samples covering different freshness grades to establish a sample set T, and measure the infrared spectrum data and n freshness indicators of the m samples. The spectrum of each sample contains a characteristics, and n outputs corresponding to the n freshness indicators of the sample;

[0081] Randomly divide the m sample data into 0.6m, 0.2m and 0.2m data sets to form a training set, a validation set and a test set respectively; if 0.6m, 0.2m and 0.2m are not integer multiples, then round up.

[0082] Step 2: Data augmentation supports feature extraction

[0083] Based on the training set and the verification set spectrum data divided in step 1, the sample scale is expanded by the data augmentation module operation;

[0084] The enhancement operation of the data augmentation module on the original spectrum data includes disturbance, noise addition, stretching and amplitude transformation, which effectively expands the sample scale of the training set and the verification set to Q times (the enhanced spectrum data still uses the freshness index of the original sample).

[0085] Step 3: CNN-LSTM-SE feature extraction module construction

[0086] For the data enhanced in step 2, the local spatial features and time sequence dependent information of the spectrum are extracted by using CNN and LSTM in parallel. This parallel design can avoid the interference of one side to the other side in the serial structure, and improve the integrity of feature extraction. Independent double-channel SE attention mechanisms are set at the output ends of CNN and LSTM, respectively. The features are weighted and filtered by the SE attention mechanism, focusing on the key information most relevant to each target task, improving the effectiveness of subsequent multi-task modeling, and forming a feature extraction module.

[0087] Among them, the CNN is composed of 1-4 layers of one-dimensional convolution structure, and batch normalization and ReLU activation function are sequentially connected after each convolution; the LSTM is composed of 1-3 layers of LSTM neural network structure stacked in sequence; the SE is composed of channel attention mechanism structure, including Squeeze and Excitation two stages, used to control the compression dimension and reconstruction ability of feature channels, so as to adjust the channel selectivity and representation ability; the outputs of CNN and LSTM are respectively sent to independent SE attention mechanism modules, and the compression ratio p∈[4,32] is set, and the weighted feature representation of two channels is output.

[0088] The structure parameters (convolution kernel size, convolution kernel number) of the convolution layer and the number of hidden neurons are selected according to the structural characteristics of the CNN and LSTM architecture as the hyperparameters of the application;

[0089] In order to avoid the overfitting phenomenon of the model, Dropout and L2 regularization are added to the feature extraction module. In addition, the learning rate, batch size, iteration number, Dropout rate and L2 regularization coefficient together constitute the hyperparameters of the application.

[0090] Step 4: Multi-task model formation

[0091] The output of the step 3 feature extraction module is spliced and input into a multi-task learning framework, a general feature is extracted through a shared fully connected network, a plurality of task-specific branches are connected, a regression head is arranged at the end of each branch to output a predicted value of a corresponding freshness indicator, and a CNN-LSTM-SE multi-task model capable of synchronously predicting a plurality of freshness indicators is formed;

[0092] The shared fully connected network comprises one or more layers, the task-specific branch comprises one or more fully connected layers, and the freshness indicator includes but is not limited to total number of colonies, volatile salt-based nitrogen, and biological amine content.

[0093] Each sub-task of the multi-task learning framework adopts an independent mean square error loss function to form a joint loss structure.

[0094]

[0095] L t represents the prediction error of the t-th indicator, the task weight a t ∈ [0.1, 0.9], and needs to satisfy the normalization constraint The hyperparameter a t is jointly optimized by the MOGWO.

[0096] Step 5: Hyperparameter optimization to improve model performance

[0097] The CNN-LSTM-SE multi-task model formed in step 4 is optimized in stages by using the MOGWO algorithm, and the optimal parameter configuration is obtained by defining hyperparameter grouping and optimization strategy, initializing grey wolf population and parameters, calculating fitness function, updating grey wolf position, updating archive and wolf social rank, boundary processing, checking termination condition and grouping optimization operation, wherein each operation is specifically as follows:

[0098] Define hyperparameter grouping and optimization strategy:

[0099] In order to reduce the dimension of single search, reduce the number of hyperparameters optimized each time, and improve the search efficiency of MOGWO, all hyperparameters are divided into three groups according to their functional attributes, and a phased grouping optimization strategy is adopted:

[0100] Group 1 is the hyperparameter related to the CNN-LSTM-SE architecture, including the size of the convolution kernel, the number of convolution kernels, the number of hidden neurons, etc., which is used to control the expression ability and complexity of the model;

[0101] Group 2 is the training-related hyperparameter, including learning rate, batch size, iteration number, Dropout rate, L2 regularization coefficient, etc., which is used to adjust the model learning process;

[0102] Group 3 is the task weight hyperparameter in multi-task learning, including at , where t∈[1,n], is used to optimize the error balance between tasks;

[0103] Phased optimization: Phase 1 optimizes group 1, while fixing groups 2 and 3; Phase 2 optimizes group 2, while fixing the optimal solution of group 1 and group 3; Phase 3 optimizes group 3, while fixing the optimal solutions of group 1 and group 2; Each group is independently optimized based on the fixed parameters of the other groups, and finally iteratively merged to form the overall optimal configuration;

[0104] Initialize the gray wolf population and parameters:

[0105] To automate the configuration of hyperparameters of the constructed model using MOGWO, the population size N, search space dimension D′, and maximum number of iterations g are initialized. max Set convergence precision Initialize the iteration counter g = 0, and enter the iterative optimization phase;

[0106] Define the position vector of the current group of gray wolves as X. i =(x i,1 ,x i,2 ,…,x i,D′ ), where i = 1, 2, ..., N, and the search space boundary [X′] of the current group. l ,X′ u The position of each gray wolf is randomly initialized within the group, and the hyperparameters of the non-optimized group are fixed to predefined values ​​or the optimal values ​​of the previous stage.

[0107] Special hyperparameters are handled differently: discrete hyperparameters (such as kernel size, number of kernels, number of LSTM hidden units, batch size) are rounded up to the nearest allowable value; specifically, kernel size is mapped to the nearest odd number, and the number of kernels and the number of LSTM hidden neurons are mapped to the nearest power of 2; task weight a t ∈[0.1,0.9], and In addition, GradNorm is used to compute an initial a in stage 3. t To balance the training difficulty between tasks, the remaining N-1 gray wolves are still randomly generated and normalized.

[0108] Calculate the fitness function:

[0109] Define an objective function (fitness function) to evaluate the fitness of each gray wolf: use the joint loss L on the training set. total Train the CNN-LSTM-SE multi-task model; compute the current gray wolf individual X on the validation set. i The corresponding fitness function F(X) i )=(f1(X i ),f2(X i ),…,fk (X i ), wherein f1(X i ), f2(X i ),…, f k (X i ) is the grey wolf X i The average evaluation index of n tasks on the validation set, such as the coefficient of determination, the root mean square error, the absolute error, and the convergence time (when the directions are inconsistent in multi-objective optimization, some components take negative values to be unified to the maximum direction); since the dimensions of each component are different, f1(X i ), f2(X i ),…, f k (X i ) are respectively subjected to Min-Max normalization processing;

[0110] In the initial population, based on the joint action of non-dominated level and crowding distance, three solutions are randomly selected as alpha, beta and delta, and the non-dominated solution is stored in the archive A;

[0111] Update the grey wolf position:

[0112] At each iteration, the position of the current grey wolf group is updated according to the hunting behavior of alpha, beta and delta; for each grey wolf i, its position is updated using the following formula:

[0113] D α = |C1·X α (g) - X i (g)|, X i,α (g+1) = X α (g) - A1·D α

[0114] D β = |C2·X β (g) - X i (g)|, X i,β (g+1) = X β (g) - A2·D β

[0115] D δ = |C3·X δ (g) - X i (g)|, X i,δ (g+1) = X δ (g) - A3·D δ

[0116]

[0117] wherein, A k = 2ar1-a, C k= 2r2, r1, r2 e [0, 1];

[0118] After updating the position, the new fitness vector F(X i ) of each wolf is recalculated i , f2(X i ), …, f k (X i ), and Min-Max normalization is performed on f1(X i ), f2(X i ), …, f k (X i ) respectively for subsequent non-dominated sorting and archive A update;

[0119] Update the archive and wolf pack social rank:

[0120] Non-dominated sorting is performed on the current population and archive A, and new non-dominated solutions are added to the archive A. If the size of the archive A exceeds the predefined limit, the solution with the lowest crowding distance is removed to maintain diversity. Then, three solutions are randomly selected from the archive A according to the non-dominated rank and crowding distance, and α, β and δ are updated;

[0121] Boundary processing:

[0122] Check whether the updated position X i (g+1) of the current group is within the space boundary [X' l , X' u ]. If it exceeds the boundary, adjust it as follows: if x i,j (g+1) < X' l,j , then x i,j (g+1) = X' l,j ; if x i,j (g+1) > X' u,j , then x i,j (g+1) = X' u,j , where j = 1, 2, …, D';

[0123] Termination condition check:

[0124] Check whether the termination condition is met: the iteration counter g ≥ g max or the fitness change of the archive A solution set is less than the convergence precision If the termination condition is not met, increase the iteration counter by 1, i.e. g = g + 1, and return to step 3 to continue the current stage iteration;

[0125] If the termination condition is met, perform grouping optimization according to the current stage;

[0126] Grouping optimization:

[0127] Stage 1 (optimization group 1): output the non-dominated solution set of group 1 (stored in archive A) Each solution contains the optimized hyperparameters of group 1 and the normalized fitness vector, and the optimal solution is selected by weighted summation of the fitness vector, fixing the hyperparameters of group 1;

[0128] Stage 2 (optimization group 2): initialize the gray wolf population and parameters of stage 2, repeatedly execute the calculation of the fitness function, update the gray wolf position, update the archive and wolf social rank, boundary processing, termination condition check, output the non-dominated solution set of group 2 (stored in archive A) Each solution contains the optimal hyperparameters of group 1, the optimized hyperparameters of group 2 and the normalized fitness vector, and the optimal solution is selected by weighted summation of the fitness vector, fixing the hyperparameters of group 2;

[0129] Stage 3 (optimization group 3): initialize the gray wolf population and parameters of stage 3, repeatedly execute the calculation of the fitness function, update the gray wolf position, update the archive and wolf social rank, boundary processing, termination condition check, output the non-dominated solution set of group 3, form the Pareto solution set Each solution contains the optimal hyperparameters of group 1, group 2, the optimized hyperparameters of group 3 and the normalized fitness vector, and the optimal solution is selected from the Pareto solution set by weighted summation of the fitness vector, and the final global optimal hyperparameter configuration is obtained;

[0130] If higher precision is required, stages 1, 2 and 3 can be alternately optimized one or twice, and the optimal solution of the previous stage is used to update the fixed hyperparameters each time.

[0131] Step 6: optimal parameter driving model training

[0132] The optimal hyperparameters of step 5 are imported into the CNN-LSTM-SE multi-task model, and the training set of step 1 is used to retrain the model to generate the final freshness prediction model;

[0133] Step 7: model evaluation and deployment preparation

[0134] The test set of step 1 is used to evaluate the prediction performance of the freshness prediction model generated in step 6, and the model parameters and structure are saved after verification, completing the whole process closed loop from data processing to model deployment.

[0135] A system for a multi-objective gray wolf optimization integrated water product freshness multi-task detection method includes a data enhancement module, a feature extraction module, a multi-task learning module and a multi-objective optimization module, which work together to realize the process closed loop of the detection method;

[0136] ​Data augmentation module: receives the original infrared spectrum data, performs various enhancement operations on it, effectively expands the sample size to Q times the original, and enhances the robustness of the model under small sample conditions by improving data diversity;

[0137] Feature extraction module: the enhanced sample data output by the data augmentation module is sent into two independent channels of CNN and LSTM in parallel, CNN extracts local spatial features of the spectrum, and LSTM captures sequence dependent information. Independent SE attention mechanism modules are set at the output ends of CNN and LSTM to weight and filter the channel dimensions of the two types of features, focusing on the key information most relevant to each target task.

[0138] Multi-task learning module: receives the output of the double-channel SE attention mechanism in the feature extraction module, fuses the comprehensive features obtained by splicing, and then inputs them into the constructed multi-task learning framework. The framework compresses the comprehensive features through a shared fully connected network, extracts general features suitable for all tasks, connects multiple task-specific branches, and finally outputs prediction values with a regression head corresponding to a water product freshness indicator, achieving simultaneous output of multiple freshness indicators of water products.

[0139] Multi-objective optimization module: uses the MOGWO algorithm to guide the search on the multi-objective evaluation function. This module realizes the phased grouping optimization of key hyperparameters that affect the performance of the model, including the size and number of convolution kernels in the CNN module, the number of hidden neurons in the LSTM module, the learning rate, batch size, and iteration number in the training process, the L2 regularization coefficient, the Dropout rate, and the task loss weight related to multi-task learning.

[0140] Embodiment 1

[0141] As shown in Figure 1 , a water product freshness multi-task detection method fusing multi-objective grey wolf optimization includes the following steps:

[0142] Step 1, obtain the original infrared spectrum data and water product freshness indicator data:

[0143] Select 135 Chinese mitten crab samples, which cover different freshness levels from fresh to postmortem (fresh, moribund, postmortem 1, 6, 12, 18, 24, 36, and 48 hours, with 15 samples in each group), to establish a sample set T. Measure the infrared spectrum data and freshness indicators of the 135 samples. Each sample's spectrum contains 3112 features, and there are 6 outputs corresponding to the 6 freshness indicators (total number of colonies, volatile nitrogen, putrescine, cadaverine, histamine, and tryptamine) of the sample. Then divide the 135 sample data into a training set, a validation set, and a test set, with 81 samples in the training set, 27 samples in the validation set, and 27 samples in the test set.

[0144] Step 2, enhancement of original data:

[0145] The 81 and 27 infrared spectrum data in the training set and the validation set are input into a data enhancement module, random perturbations of ±0.4% amplitude are added to the original data, Gaussian noise with a mean of 0 and a standard deviation of 0.01 is introduced, and the spectrum is linearly stretched by a random ratio of ±1%; the spectrum is randomly scaled in

[0146] [0.96, 1.04] range, the enhanced data is expanded to 10 times the original sample size (enhanced spectrum data, still using the freshness index of the original sample).

[0147] Step 3, construct a CNN-LSTM-SE hybrid feature extraction module:

[0148] The enhanced sample data is sent into two independent channels of CNN and LSTM in parallel, the local spatial features of the spectrum are extracted by CNN, and at the same time, considering the influence of time on the freshness of aquatic products, LSTM is used to capture sequence dependent information, and the potential key information in the data is captured from different dimensions. This module adopts a parallel design, which can avoid interference between the two in a serial structure and improve the integrity of feature extraction; independent double-channel SE attention mechanisms are set at the output ends of CNN and LSTM for weighting and filtering the channel dimensions of the two types of features, focusing on the key information most relevant to each target task, and improving the effectiveness of subsequent multi-task modeling;

[0149] As shown in Figure 2 The constructed CNN consists of 2 layers of one-dimensional convolution structure, and after each layer of convolution, batch normalization and ReLU activation function are sequentially connected; the constructed LSTM consists of 2 layers of LSTM neural network structure stacked in sequence; the constructed SE consists of a channel attention mechanism structure, including Squeeze and Excitation two stages, for controlling the compression dimension and reconstruction ability of the feature channel, thereby adjusting the channel selectivity and representation ability; the outputs of CNN and LSTM are respectively sent to independent SE attention mechanism modules, and the compression ratio p=16 is set, and the weighted feature representation of two channels is output;

[0150] The structure parameters (convolution kernel size, convolution kernel number) of the convolution layer and the number of hidden neurons are selected according to the structure characteristics of the CNN and LSTM architecture as the hyperparameters of the application;

[0151] In order to avoid overfitting of the model, Dropout and L2 regularization are added to the constructed CNN-LSTM-SE architecture; in addition, the learning rate, batch size, iteration number, Dropout rate, and L2 regularization coefficient together constitute the hyperparameters of the application.

[0152] Step 4, multi-task learning network structure design:

[0153] The output of the dual-channel SE attention mechanism is spliced and fused to obtain comprehensive features, which are input into the constructed multi-task learning framework to realize the synchronous output of multiple freshness indicators of aquatic products, meet the multi-dimensional demand of quality evaluation, and avoid the loss of useful information caused by independent learning of each indicator, thereby reducing the generalization ability of the model. The multi-task learning framework includes a shared fully connected network to represent and compress the comprehensive features, extract general features suitable for all tasks, then connect 6 task-specific branches, each branch has 2 fully connected layers, and finally output the predicted value with a regression head, corresponding to total bacterial count, volatile base nitrogen, putrescine, cadaverine, histamine and tryptamine respectively. Each sub-task uses an independent mean square error loss function to form a joint loss structure:

[0154]

[0155] Wherein, L t represents the prediction error of the tth index, the task weight a t ∈[0.1,0.9], and needs to satisfy the normalization constraint Where n=6; the hyperparameter a t is involved in the MOGWO joint optimization.

[0156] Step 5, using MOGWO algorithm to optimize the hyperparameters of CNN-LSTM-SE model:

[0157] (1) Define hyperparameter groups and optimization strategy

[0158] In order to reduce the dimension of single search, reduce the number of hyperparameters optimized each time, and improve the search efficiency of MOGWO, all hyperparameters are divided into three groups according to their functional attributes, and a phased grouping optimization strategy is adopted:

[0159] Group 1 is the hyperparameters related to the CNN-LSTM-SE architecture, including the size of the convolution kernel, the number of convolution kernels, the number of hidden neurons, etc., which are used to control the expression ability and complexity of the model;

[0160] Group 2 is the training-related hyperparameters, including learning rate, batch size, iteration number, Dropout rate, L2 regularization coefficient, etc., which are used to adjust the model learning process;

[0161] Group 3 is the hyperparameters of the task weight in multi-task learning, including a1, a2, a3, a4, a5, a6, which are used to optimize the error balance between tasks;

[0162] Stage optimization: stage 1 optimizes group 1 (fix group 2 and group 3), stage 2 optimizes group 2 (fix group 1 optimal solution and group 3), stage 3 optimizes group 3 (fix group 1 and group 2 optimal solution), each group is independently optimized based on the fixed parameters of other groups, and finally the whole optimal configuration is formed by iteration fusion.

[0163] (2) Initialize the gray wolf population and parameters:

[0164] Stage 1: Set the population size N of stage 1 to 40, the search space dimension D' to 6, the maximum number of iterations to 200, and the convergence precision Initialize iteration counter f = 0, and prepare to enter iterative optimization;

[0165] Randomly generate 40 position vectors of gray wolves as X i =(x i,1 ,x i,2 ,…,x i,6 ), where i = 1, 2, …, 40. Randomly initialize the position of each gray wolf within the search space boundary [X' l ,X' u ] of the current group. The hyperparameters of the non-optimized group are fixed as the predefined value or the optimal value of the previous stage; The search space boundary is set as:

[0166] Group 1 optimizes 6 model architecture related hyperparameters, and the search space boundary [X' l ,X' u ] is set as follows:

[0167] [X' l ,X' u ] = [(3, 3, 8, 8, 16, 16), (7, 7, 128, 128, 128, 128)], respectively corresponding to:

[0168] Convolution kernel size: range [3, 7], mapped to {3, 5, 7};

[0169] Number of convolution kernels: range [8, 128], mapped to {8, 16, 32, 64, 128};

[0170] Number of LSTM hidden layer units: range [16, 128], mapped to {16, 32, 64, 128};

[0171] Fixed value of non-optimized group hyperparameters:

[0172] Group 2 (training hyperparameters): learning rate 0.02, batch size 64, number of iterations 300, Dropout rate 0.2, L2 regularization coefficient 0.0005;

[0173] Group 3 (task weight hyperparameters): a1 = a2 = a3 = a4 = a5 = a6 = 1 / 6.

[0174] (3) Calculate the fitness function:

[0175] Define the objective function (fitness function) to evaluate the fitness of each grey wolf. Use the joint loss L total Train the CNN-LSTM-SE model; calculate the current grey wolf individual X i on the validation set i The corresponding fitness function (F(X i ) = (f1(X i ), f2(X i ), f3(X i )), where f1(X i ), f2(X i ), f3(X i ) are the grey wolf X 2 The average determination coefficient (R i ), the average root mean square error (RMSE) and the average convergence time of the n tasks on the validation set (where f2(X i ), f3(X i ) take negative values to unify the maximization direction); due to the different dimensions of each component, Min-Max normalization is performed on f1(X i ), f2(X i ), f3(X α );

[0176] In the initial population, based on the joint action of non-dominated rank and crowding distance, randomly select three solutions as α, β and δ, and store the non-dominated solutions in the archive A.

[0177] (4) Update the position of the grey wolf:

[0178] At each iteration, update the position of the current grey wolf group according to the hunting behavior of α, β and δ, and for each grey wolf i, update its position using the following formula:

[0179] D α = |C1·X i (g) - X i,α (g)|, X α (g+1) = X α

[0180] D β = |C2·X β (g) - X i (g)|, X i,β (g+1) = X β (g) - A2·Dβ

[0181] D δ = |C3·X δ (g) - X i (g) |, X i,δ (g+1) = X δ (g) - A3·D δ

[0182]

[0183] wherein, A k = 2ar1-a, C k = 2r2, r1, r2 ∈ [0, 1];

[0184] After updating the position, the new fitness vector of each wolf is recalculated (F(X i ) = (f1(X i ), f2(X i ), f3(X i )), and Min-Max normalization is performed on f1(X i ), f2(X i ), and f3(X i ) respectively for subsequent non-dominated sorting and archive A update.

[0185] (5) Update the archive and the social rank of the wolf pack:

[0186] The current population and the archive A are non-dominantly sorted, and new non-dominated solutions are added to the archive A. The maximum size of the archive A is controlled to be 200, and the solution with the lowest crowding distance is removed to maintain diversity. Then, three solutions are randomly selected from the archive A according to the non-dominated rank and the crowding distance, and α, β, and δ are updated.

[0187] (6) Boundary processing:

[0188] Check whether the updated position X i (g+1) of the current group is within the space boundary [X' l , X' u ]. If it is out of the boundary, adjust it as follows: if x i,j (g+1) < X' l,j , then x i,j (g+1) = X' l,j ; if x i,j (g+1) > X' u,j , then x i,j (g+1) = X' u,j , where j = 1, 2, …, 6.

[0189] (7) Termination condition check:

[0190] Check if the termination condition is met: iteration counter g ≥ g max or the fitness change of the archive A solution set is less than the convergence precision If the termination condition is not met, increase the iteration counter by 1, i.e. g = g + 1, and return to step (3) to continue the current stage iteration;

[0191] If the termination condition is met, perform the grouping optimization operation according to the current stage.

[0192] (8) Grouping optimization

[0193] Stage 1 complete: output the non-dominated solution set of group 1 (stored in archive A) Each solution contains the optimized hyperparameters of group 1 and the normalized fitness vector, and the weighted sum of the fitness vector (weight coefficients are 0.6, 0.3, 0.1) is calculated to select the solution with the highest comprehensive score from the solution set as the optimal solution, fixing the hyperparameters of group 1;

[0194] Stage 2: initialize the grey wolf population and parameters of stage 2, set the population size N of stage 2 to 30, the search space dimension D' to 5, the maximum number of iterations to 150, and the convergence precision Initialize the iteration counter g = 0 and prepare for iterative optimization;

[0195] Randomly generate 30 position vectors for grey wolves Y i = (y i,1 , y i,2 , …, y i,5 ), where i = 1, 2, …, 30. Randomly initialize the position of each grey wolf within the search space boundary [Y' l , Y' u ]. The hyperparameters of the non-optimized group are fixed as the pre-defined value or the optimal value of the previous stage. The search space boundary is set as follows:

[0196] Group 2 optimizes 5 model training related hyperparameters, and the search space boundary [Y' l , Y' u ] is set as follows:

[0197] [Y' l , Y' u ] = [(0.005, 16, 100, 0.1, 0.0001), (0.05, 256, 500, 0.4, 0.005)], corresponding to:

[0198] Learning rate: range [0.005, 0.05];

[0199] Batch size: range [16, 256], rounded up to the nearest allowed value;

[0200] Number of iterations: range [100, 500], rounded up to the nearest allowed value;

[0201] Dropout rate: range [0.1, 0.4];

[0202] L2 regularization coefficient: range [0.0001, 0.005];

[0203] Fixed values of non-optimized group hyperparameters:

[0204] Group 1: optimal hyperparameters obtained in the fixed phase 1;

[0205] Group 3: a1 = a2 = a3 = a4 = a5 = a6 = 1 / 6.

[0206] After initializing the grey wolf population and parameters, steps (3) to (7) are executed, and the non-dominated solution set of group 2 is output Each solution contains the optimal hyperparameters of group 1, the optimized hyperparameters of group 2, and the normalized fitness vector. The fitness vectors are weighted and summed (weight coefficients are 0.6, 0.3, 0.1), and the solution with the highest comprehensive score is selected from the solution set as the optimal solution, and the hyperparameters of group 2 are fixed;

[0207] Phase 3: Initialize the grey wolf population and parameters of phase 3, set the population size N of phase 3 to 40, the search space dimension D' to 6, the maximum number of iterations to 200, and the convergence accuracy Initialize the iteration counter g = 0 and prepare for iterative optimization;

[0208] Randomly generate 40 position vectors of grey wolves as Z i = (z i,1 ,z i,2 ,…,z i,6 ), where i = 1, 2, …, 40. Randomly initialize the position of each grey wolf within the search space boundary [Z' l ,Z' u ]. The hyperparameters of the non-optimized group are fixed as the optimal values of the previous phase; initialize the iteration counter g = 0 and prepare for iterative optimization; set the search space boundary:

[0209] Group 3 optimizes 6 model architecture related hyperparameters, and the search space boundary [Z' l ,Z' u ] is set as follows:

[0210] [Z' l ,Z' u] = [(0.1, 0.1, 0.1, 0.1, 0.1, 0.1), (0.9, 0.9, 0.9, 0.9, 0.9, 0.9)], respectively corresponding to:

[0211] Task weights a1-a6: range [0.1, 0.9], and First, calculate an initial a by GradNorm t to balance the training difficulty between tasks, and the remaining 39 wolves are randomly generated and normalized;

[0212] Fixed values of non-optimized group hyperparameters:

[0213] Group 1 and group 2: fixed optimal hyperparameters obtained in stage 1 and stage 2;

[0214] After initializing the gray wolf population and parameters, steps (3)-(7) are executed, and the non-dominated solution set of group 3 is output, forming the Pareto solution set Each solution contains the optimal hyperparameters of group 1, group 2, optimized hyperparameters of group 3, and normalized fitness vectors. The weighted sum of the fitness vectors is calculated (weight coefficients are 0.6, 0.3, and 0.1, respectively), and the solution with the highest comprehensive score is selected from the Pareto solution set as the optimal solution, and the final global optimal hyperparameters are obtained;

[0215] Repeat optimization stages 1, 2, and 3 twice, and update the fixed hyperparameters using the highest solution of the weighted sum of the fitness vectors of the previous stage.

[0216] Step 6, model training and generation based on optimal hyperparameter configuration:

[0217] The output combined hyperparameters are input into the CNN-LSTM-SE multi-task learning model together with other fixed parameters, and the complete training is performed based on the training set data. By backpropagation, the internal parameters of the model (such as convolution kernel weights, LSTM weights, and fully connected layer weights) are learned, and the trained aquatic product freshness prediction model is generated. The hyperparameter optimization results are shown in Table 1:

[0218]

[0219]

[0220] Table 1 Hyperparameter optimization results based on MOGWO algorithm

[0221] a1-a6: task weight coefficients of total bacterial count, volatile salt-based nitrogen, putrescine, cadaverine, histamine, and tryptamine.

[0222] Step 7, model performance evaluation and saving:

[0223] The trained model is evaluated for performance using test set samples, and the prediction results of total bacterial count, volatile base nitrogen and biogenic amine content. After verifying the performance of the model, the final trained complete model parameters and network structure are saved for actual detection deployment.

[0224]

[0225] Table 2 CNN-LSTM-SE multi-task prediction results based on the MOGWO algorithm

[0226] As can be seen from Table 2, the CNN-LSTM-SE model based on the MOGWO algorithm can realize the simultaneous prediction of multiple freshness indicators of Eriocheir sinensis. In the prediction of total bacterial count, volatile base nitrogen, putrescine, cadaverine, histamine and tryptamine, a high determination coefficient (R2> 0.89) and a low root mean square error (RMSE<2) are obtained, indicating that the method presented in the present application has effective multi-index synchronous modeling and generalization ability under small sample conditions.

[0227] To verify the effectiveness of the technical solution proposed in the present application, five different comparative methods are constructed as comparative examples, which correspond to the typical methods in the prior art respectively. All methods are compared on the same data set, and the specific conditions are as follows:

[0228] Comparative Example 1: same as Example 1, except that:

[0229] In step 3, only the CNN network structure is used to extract local spatial features from the enhanced sample data, without considering the time series dependence relationship and without introducing the SE attention mechanism; in step 4, a single-task prediction network is constructed, which only outputs a single freshness indicator; in step 5, all hyperparameters are manually set, without using an optimization algorithm to adjust them;

[0230] Comparative Example 2: same as Example 1, except that:

[0231] In step 3, only the LSTM network structure is used to extract time series features from the enhanced sample data, without considering the influence of local spatial features and without introducing the SE attention mechanism; in step 4, a single-task prediction network is constructed, which only outputs a single freshness indicator; in step 5, all hyperparameters are manually set, without using an optimization algorithm to adjust them;

[0232] Comparative Example 3: same as Example 1, except that:

[0233] In step 3, the CNN and LSTM are connected in series to extract features, that is, the local spatial features are extracted by the CNN, and then the output is sent to the LSTM network to capture sequence information, without parallel fusion and without introducing the SE attention mechanism; in step 4, a single-task prediction network is constructed, and only a single freshness index is output; in step 5, all hyperparameters are set by artificial experience, and an optimization algorithm is not used for adjustment.

[0234] Comparative Example 4: The same as Example 1, except that:

[0235] In step 4, a single-task prediction network is constructed, and only a single freshness index is output after the outputs of the dual-channel SE attention are spliced and fused, without realizing multi-task collaborative modeling; in step 5, all hyperparameters are set by artificial experience, and an optimization algorithm is not used for adjustment.

[0236] Comparative Example 5: The same as Example 1, except that:

[0237] In step 5, all hyperparameters are set by artificial experience, and the MOGWO algorithm is not used for optimization.

[0238] The prediction results of the freshness indexes of the total number of colonies, volatile salt-based nitrogen, putrescine, cadaverine, histamine, and tryptamine by the models of Example 1 and Comparative Examples 1 to 5 on the test set are shown in Table 3.

[0239]

[0240]

[0241] Table 3 Comparison of prediction results of multiple freshness indexes by the models of the example and the comparative examples

[0242] As can be seen from Table 3, the average determination coefficient R 2 of 0.93 and the RMSE is controlled at 0.66-1.89, which is significantly better than other models. Compared with the CNN, LSTM, and CNN-LSTM serial method, the R 2 is increased by 4%-30%, and the RMSE is reduced by nearly half; compared with the CNN-LSTM-SE single-task model, by introducing multi-task learning under the premise of keeping the same structure, the R 2 is further improved by 0.02-0.09, and the RMSE is significantly reduced, especially in the prediction of putrescine and tryptamine, the R 2 is improved to 0.95 and 0.92; compared with the CNN-LSTM-SE artificial parameter setting model, after the MOGWO processing, the model performance is further improved, and the problem of relying on artificial experience for traditional parameter setting is avoided.

[0243] The CNN-LSTM-SE multi-task detection method fusing the MOGWO algorithm has higher precision and robustness in the prediction of multiple freshness indexes, and is significantly better than existing mainstream models. Especially under the condition of small sample data, the method shows good generalization ability and automation advantage, verifying the practicability and popularization potential of the method as an intelligent aquatic product quality detection method.

[0244] The examples in the present application are not limited to the embodiments. Based on the above description, other different forms of changes or variations can be made by those skilled in the art, and all the embodiments do not need to be exhausted here, and the obvious changes or variations derived therefrom are still within the protection scope of the present application.

Claims

1. A multi-task method for detecting the freshness of aquatic products that integrates multi-objective gray wolf optimization, characterized in that, Includes the following steps: Step 1: Building the Data Infrastructure Select m aquatic product samples covering different freshness grades to establish a sample set T, measure infrared spectral data and n freshness indicators, and divide them into training set, validation set and test set according to the proportion; Step 2: Data Augmentation Supports Feature Extraction Based on the spectral data of the training and validation sets divided in step 1, the sample size is expanded through data augmentation module operations; Step 3: Construction of CNN-LSTM-SE Feature Extraction Module For the data enhanced in step 2, CNN and LSTM are used in parallel to extract local spatial features and temporal dependency information of the spectrum, and then the features are weighted and filtered through the SE attention mechanism to form a feature extraction module. Step 4: Multi-task model formation After concatenating the outputs of the feature extraction module in step 3, the model is input into the multi-task learning framework. Common features are extracted through a shared fully connected network, and multiple task-specific branches are connected. At the end of each branch, a regression head is set to output the predicted value of the corresponding freshness index, forming a CNN-LSTM-SE multi-task model that can simultaneously predict multiple freshness indices. Step 5: Optimize hyperparameters to improve model performance For the CNN-LSTM-SE multi-task model formed in step 4, the MOGWO algorithm is used to optimize its hyperparameters in stages. The optimal parameter configuration is obtained by defining hyperparameter grouping and optimization strategies, initializing the gray wolf population and parameters, calculating the fitness function, updating the gray wolf positions, updating the records and wolf pack social hierarchy, boundary handling, termination condition checking and grouping optimization operations. Step 6: Optimal Parameter-Driven Model Training The optimal hyperparameters from step 5 are imported into the CNN-LSTM-SE multi-task model, and the model is retrained based on the training set from step 1 to generate the final freshness prediction model. Step 7: Model Evaluation and Deployment Preparation The predictive performance of the freshness prediction model generated in step 6 is evaluated using the test set from step 1. After verification, the model parameters and structure are saved, completing the closed loop from data processing to model deployment.

2. The multi-task method for detecting the freshness of aquatic products by incorporating multi-objective gray wolf optimization as described in claim 1, characterized in that, In step 1, the ratio of the training set, validation set, and test set is 3:1:

1.

3. The multi-task method for detecting the freshness of aquatic products by incorporating multi-objective gray wolf optimization as described in claim 1, characterized in that, In step 2, the data enhancement module performs enhancement operations on the original spectral data, including perturbation, noise addition, stretching, and amplitude transformation.

4. The multi-task method for detecting the freshness of aquatic products by incorporating multi-objective gray wolf optimization as described in claim 1, characterized in that, In step 3, the CNN consists of 1 to 4 layers of one-dimensional convolutional structure, with batch normalization and ReLU activation function sequentially following each convolutional layer. LSTM is composed of 1 to 3 layers of LSTM neural network structure stacked sequentially; SE is composed of a channel attention mechanism structure, which includes two stages: Squeeze and Excitation.

5. The multi-task method for detecting the freshness of aquatic products by incorporating multi-objective gray wolf optimization as described in claim 4, characterized in that, In step 3, Dropout and L2 regularization are added to the feature extraction module.

6. The multi-task method for detecting the freshness of aquatic products by incorporating multi-objective gray wolf optimization as described in claim 1, characterized in that, In step 4, the shared fully connected network includes one or more layers; the task-specific branch includes one or more fully connected layers; and the freshness indicators include, but are not limited to, total bacterial count, volatile basic nitrogen, and biogenic amine content.

7. The multi-task method for detecting the freshness of aquatic products by incorporating multi-objective gray wolf optimization as described in claim 1, characterized in that, In step 4, each subtask of the multi-task learning framework employs an independent mean squared error loss function, forming a joint loss structure: Among them, L t The prediction error of the t-th indicator is represented by the task weight a. t ∈[0.1,0.9], and must satisfy the normalization constraint. hyperparameter a t Participate in MOGWO joint optimization.

8. The multi-task method for detecting the freshness of aquatic products by incorporating multi-objective gray wolf optimization as described in claim 1, characterized in that, In step 5, the definition of hyperparameter grouping and optimization strategy is as follows: To reduce the dimensionality of a single search, decrease the number of hyperparameters optimized each time, and improve MOGWO's search efficiency, all hyperparameters are divided into three groups based on their functional attributes, and a staged grouping optimization strategy is adopted: Group 1 consists of hyperparameters related to the CNN-LSTM-SE architecture, Group 2 consists of training-related hyperparameters, and Group 3 consists of task weight hyperparameters in multi-task learning. Phased optimization: Phase 1 optimizes group 1, while fixing groups 2 and 3; Phase 2 optimizes group 2, while fixing the optimal solution of group 1 and group 3; Phase 3 optimizes group 3, while fixing the optimal solutions of group 1 and group 2; Each group is independently optimized based on the fixed parameters of the other groups, and finally iteratively merged to form the overall optimal configuration; The specific steps for initializing the gray wolf population and parameters are as follows: To automate the configuration of hyperparameters of the constructed model using MOGWO, the population size N, search space dimension D′, and maximum number of iterations g are initialized. max Set convergence precision Initialize the iteration counter g = 0, and enter the iterative optimization phase; Define the position vector of the current group of gray wolves as X. i =(x i,1 ,x i,2 ,…,x i,D′ ), where i = 1, 2, ..., N, and the search space boundary [X′] of the current group. l ,X′ u The position of each gray wolf is randomly initialized within the group, and the hyperparameters of the non-optimized group are fixed to predefined values ​​or the optimal values ​​of the previous stage. Special hyperparameters require special handling: discrete hyperparameters are rounded up to the nearest allowable value; the kernel size is mapped to the nearest odd number; and the task weights 'a' are adjusted accordingly. t ∈[0.1,0.9], and The fitness function is calculated as follows: Define an objective function to evaluate the fitness of each gray wolf: use the joint loss L on the training set. total Train the CNN-LSTM-SE multi-task model; compute the current gray wolf individual X on the validation set. i The corresponding fitness function F(X) i )=(f1(X i ),f2(X i ),…,f k (X i ), where f1(X i ),f2(X i ),…,f k (X i ) for Gray Wolf X i The average evaluation index for n tasks on the validation set; due to the different dimensions of each component, for f1(X) i ),f2(X i ),…,f k (X i Min-Max normalization was performed separately for each. In the initial population, based on the combined effect of non-dominated hierarchy and crowding distance, three solutions are randomly selected as α, β and δ, and the non-dominated solutions are stored in file A. The specific location of the Grey Wolves has been updated as follows: At each iteration, the position of the current gray wolf group is updated based on the hunting behaviors inspired by α, β, and δ; for each gray wolf i, its position is updated using the following formula: D α =|C1·X α (g)-X i (g)|,X i,α (g+1)=X α (g)-A1·D α D β =|C2·X β (g)-X i (g)|,X i,β (g+1)=X β (g)-A2·D β D δ =|C3·X δ (g)-X i (g)|,X i,δ (g+1)=X δ (g)-A3·D δ Among them, A k =2ar1-a,C k =2r2, r1, r2∈[0,1]; After updating the position, recalculate the new fitness vector F(X) for each gray wolf. i )=(f1(X i ),f2(X i ),…,f k (X i ), and for f1(X i ),f2(X i ),…,f k (X i Min-Max normalization was performed separately for each. The updated archives and wolf pack social hierarchy are as follows: Perform non-dominated sorting on the current population and file A, add new non-dominated solutions to file A, and if the size of file A exceeds the predefined limit, remove the solution with the lowest crowding distance to maintain diversity. Then, randomly select three solutions from file A according to the non-dominated level and crowding distance, and update α, β and δ. Boundary handling specifically includes: Check the updated position X of the current group i Is (g+1) at the spatial boundary [X']? l ,X' u If x exceeds the boundary, adjust as follows: i,j (g+1) <X' l,j Then x i,j (g+1)=X' l,j If x i,j (g+1)>X′ u,j Then x i,j (g+1)=X' u,j , where j = 1, 2, ..., D′; The termination condition check is as follows: Check if the termination condition is met: iteration counter g ≥ g max Or the fitness change of the solution set of file A is less than the convergence accuracy. If the termination condition is not met, the iteration counter is incremented by 1, i.e., g = g + 1, and the process returns to step 3 to continue the current stage of iteration. If the termination condition is met, perform group optimization operations based on the current stage. The specific grouping optimization is as follows: Phase 1 complete: Output the non-dominated solution set of group 1 Each solution contains the optimized hyperparameters of group 1 and the normalized fitness vector. The optimal solution is selected by weighted summation of the fitness vectors, while fixing the hyperparameters of group 1. Phase 2: Initialize the gray wolf population and parameters for Phase 2, repeatedly perform the following steps: calculate the fitness function, update gray wolf positions, update records and wolf pack social hierarchy, handle boundary conditions, check termination conditions, and output the non-dominated solution set for Group 2. Each solution contains the optimal hyperparameters of group 1, the optimized hyperparameters of group 2, and the normalized fitness vector. The optimal solution is selected by weighted summation of the fitness vectors, while the hyperparameters of group 2 are fixed. Phase 3: Initialize the gray wolf population and parameters for Phase 3, repeatedly perform the following steps: calculate the fitness function, update gray wolf positions, update records and wolf pack social hierarchy, handle boundaries, check termination conditions, and output the non-dominated solution set of Group 3, forming the Pareto solution set. Each solution contains the optimal hyperparameters for group 1 and group 2, the optimized hyperparameters for group 3, and a normalized fitness vector. The Pareto solution set is obtained by weighted summation of the fitness vectors. Select the optimal solution to obtain the final globally optimal hyperparameter configuration; For higher accuracy, stages 1, 2, and 3 can be optimized alternately, either once or twice, with the optimal solution from the previous stage used to update the fixed hyperparameters each time.

9. The multi-task method for detecting the freshness of aquatic products by incorporating multi-objective gray wolf optimization as described in claim 1, characterized in that, The detection method is implemented through the following system, which includes a data augmentation module, a feature extraction module, a multi-task learning module, and a multi-objective optimization module. The modules work together to achieve a closed-loop process for the detection method. Data augmentation module: Receives raw infrared spectral data and performs various augmentation operations on it, effectively expanding the sample size to Q times the original size. By increasing data diversity, it enhances the robustness of the model under small sample conditions. Feature extraction module: The augmented sample data output by the data augmentation module is fed into two independent channels, CNN and LSTM, in parallel. CNN extracts local spatial features of the spectrum, and LSTM captures sequence dependency information. Independent SE attention mechanism modules are set at the output of CNN and LSTM respectively to perform weighted filtering on the channel dimensions of the two types of features and focus on the key information most relevant to each target task. Multi-task learning module: Receives the output of the dual-channel SE attention mechanism in the feature extraction module, concatenates and fuses them to obtain comprehensive features, and then inputs them into the constructed multi-task learning framework; this framework compresses the comprehensive features through a shared fully connected network, extracts general features applicable to all tasks, connects multiple task-specific branches, and finally outputs a predicted value with a regression head, corresponding to a freshness index of aquatic products, realizing the synchronous output of multiple freshness indicators of aquatic products; Multi-objective optimization module: The MOGWO algorithm is used to guide the search on the multi-objective evaluation function. This module realizes the staged group optimization of key hyperparameters that affect model performance. The optimization scope covers the kernel size and number of kernels of the CNN module, the number of hidden neurons of the LSTM module, the learning rate, batch size, number of iterations, L2 regularization coefficient, Dropout rate, and task loss weights related to multi-task learning.

Citation Information

Patent Citations

  • Intelligent aquatic product freshness identification method based on improved YOLOv8 model

    CN118486049A

  • Automatic control method and system based on microbiological detection

    CN118932011A