Food adulteration detection method and system based on spectral analysis
By calculating the spectral data deviation to generate an abnormal band list, using backpropagation algorithm and long-term short-term memory network, the problems of environmental interference and instrument error in spectral analysis are solved, and the efficiency and accuracy of food adulteration detection are achieved.
Patent Information
- Application Number
- CN202510454918.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-11
- Publication Date
- 2025-07-18
AI Technical Summary
The existing spectral analysis technology is affected by environmental interference and instrument errors in food adulteration detection, resulting in data fluctuations and abnormal points not being effectively processed, and the multi-level information cannot be fully utilized, resulting in the tiny adulterating components being ignored and the detection efficiency and accuracy are insufficient.
By calculating the deviations of different bands in the spectral data, a list of abnormal bands is generated, data points are corrected using the backpropagation algorithm, spectral data correction sets are generated, multi-scale feature maps are extracted, important bands are screened, and adulterated components are judged using long and short-term memory networks.
Quickly identify abnormal bands, reduce noise interference, improve data quality, ensure consideration of details of each scale, accurately distinguish adulterated components, and improve detection accuracy and efficiency.
Smart Images

Figure CN120334151A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of spectral analysis, and particularly to a method and system for detecting food adulteration based on spectral analysis. Background Art
[0002] The technical field of spectral analysis aims to analyze the composition, structure, and physicochemical properties of substances by measuring the absorption, emission, reflection, or scattering characteristics of substances for light of different wavelengths, providing a non-destructive, fast, and highly accurate method to help scientists and engineers identify and quantitatively analyze the chemical composition and physical properties of samples in various applications.
[0003] The purpose of the method for detecting food adulteration based on spectral analysis is to ensure the authenticity and safety of food, prevent consumers from being harmed by adulterated or inferior food, identify the components different from normal food by analyzing the spectral characteristics of food, detect whether there are adulterated components, help discover adulteration behaviors that are difficult to detect by traditional sensory detection, and improve the detection efficiency and accuracy.
[0004] Due to the shortcomings of the existing technology in the processing and analysis of data, spectral data is affected by environmental interference and instrument errors, resulting in data fluctuations and the appearance of abnormal points. The abnormal points have not been effectively processed, affecting the analysis results, and the multi-level information of spectral data cannot be fully utilized, resulting in the neglect of tiny adulterated components. It is impossible to automatically screen out the bands with important information according to the real needs of the data, resulting in redundant bands occupying computing resources and reducing the detection efficiency. Moreover, the changes in relevant bands have not been accurately captured, resulting in the failure to detect adulteration behaviors in a timely manner and affecting the results and reliability of food safety detection. Summary of the Invention
[0005] The purpose of the present invention is to solve the shortcomings existing in the prior art, and to propose a method and system for detecting food adulteration based on spectral analysis.
[0006] To achieve the above purpose, the present invention adopts the following technical solutions: A method for detecting food adulteration based on spectral analysis, comprising the following steps:
[0007] Step 1: Obtain the absorbance values of different bands in the spectral data through a sensor, calculate the deviation between each spectral point and the adjacent band, compare the differences in wavelength data points, determine whether it exceeds a set threshold, and if it exceeds, mark it as abnormal to generate a list of abnormal bands;
[0008] Step 2: According to the list of abnormal bands, adopt the backpropagation algorithm, calculate the correction amount of the abnormal value by processing the wavelength differences between each abnormal point and the adjacent point one by one, use the gradient adjustment mechanism to correct the values of the data points, update the spectral data, and generate a corrected set of spectral data;
[0009] Step 3: Based on the spectral data correction set, input spectral information for hierarchical processing, extract spectral features at different scales layer by layer, analyze the correlation between local bands and global bands, generate feature maps for each layer, and obtain multi-scale feature maps;
[0010] Step 4: According to the multi-scale feature maps, screen the band data, sort based on the correlation and importance between bands, eliminate redundant bands, extract the changing information, and reduce the dimension by merging similar bands to generate a refined spectral feature set;
[0011] Step 5: Based on the refined spectral feature set, calculate the distribution difference of each band, and use a long short-term memory network for threshold judgment. Distinguish adulterated substances from normal components according to the results and output the results to obtain the adulterated component determination result.
[0012] As a further solution of the present invention, the specific steps for generating the abnormal band list are as follows:
[0013] Collect spectral data through a sensor, extract the absorbance value of each spectral point, calculate the numerical difference between each spectral point and the adjacent band, perform difference quantization and compare it with a preset wavelength difference threshold to generate band difference data;
[0014] Based on the band difference data, compare the absorbance value of each band with the adjacent band value. If the difference exceeds the set threshold, it is marked as abnormal to generate abnormal band marking data;
[0015] According to the abnormal band marking data, collect and organize all the data points marked as abnormal to generate an abnormal band list.
[0016] As a further solution of the present invention, the specific steps for generating the spectral data correction set are as follows:
[0017] Based on the abnormal band list, for each data point marked as abnormal, calculate the difference between the data point and the adjacent band, compare the band differences and calculate the deviation amount. Reverse the error to each layer of the network through the backpropagation algorithm, and calculate the correction amount for each band, gradually correcting the deviation value to generate correction amount data;
[0018] Based on the correction amount data, adjust each abnormal data point, and gradually update the absorbance value of the corresponding band using the correction amount to generate a spectral data correction set;
[0019] According to the spectral data correction set, organize and summarize all the updated data to generate a complete corrected data set to obtain the spectral data correction set.
[0020] As a further solution of the present invention, the backpropagation algorithm follows the formula:
[0021]
[0022] Where: E represents the loss function, w i represents the network weight of the i-th layer, y i represents the output of the i-th layer, t i represents the target value or true value of the i-th layer, α represents the learning rate, λ j represents the wavelength adjustment factor, β i represents the correction intensity coefficient.
[0023] As a further solution of the present invention, the specific steps for generating the multi-scale feature map are as follows:
[0024] Based on the spectral data correction set, perform hierarchical processing on the data of each band, perform information transfer in sequence according to the relationship between the local band and the global band, analyze the changes of local features and global features layer by layer, extract the features of each layer, and generate a hierarchical feature map;
[0025] Based on the hierarchical feature map, analyze the correlation between each band, calculate the correlation between the features of each layer and the global features, extract the more important local and global features, and generate band correlation data;
[0026] Based on the band correlation data, select the bands with obvious changes, eliminate redundant information, and merge the bands with high correlation to obtain a multi-scale feature map.
[0027] As a further solution of the present invention, the specific steps for generating the refined spectral feature set are as follows:
[0028] Based on the multi-scale feature map, select the band data with strong change amplitude, use correlation calculation to screen out important bands, eliminate redundant bands, and generate selected band data;
[0029] Based on the selected band data, analyze the differences between the bands, merge the bands with similar changes, and reduce the number of bands through the merging operation to generate refined spectral feature data;
[0030] Based on the refined spectral feature data, perform dimensionality reduction operation on the bands, and generate a refined spectral feature set by merging the bands with similar change trends.
[0031] As a further solution of the present invention, for screening out important bands by using correlation calculation, first calculate the Pearson correlation coefficient between each band, evaluate the information redundancy between the bands, and perform screening and elimination at the same time;
[0032] The dimensionality reduction operation on the wavelength band adopts principal component analysis. By performing eigenvalue decomposition on the covariance matrix of the spectral data, the directions of variances in the data are screened, the variation information in the data is retained, and by screening the principal components, the high-dimensional spectral data is mapped into a lower-dimensional space, reducing the computational complexity and removing noise, so as to obtain concise features that can effectively express the important information in the data.
[0033] As a further solution of the present invention, the specific steps for generating the determination result of the adulterated component are as follows:
[0034] Based on the refined spectral feature set, calculate the mean, standard deviation and statistical features of the spectral data of each wavelength band, evaluate the distribution range of each wavelength band, perform the difference calculation of the data of each wavelength band, and generate the wavelength band distribution data;
[0035] Based on the wavelength band distribution data, use a long short-term memory network to process the time series features between different wavelength bands, gradually capture the dependence relationship between the features of each layer and the global features, and optimize the feature extraction process through a recursive structure to generate the difference determination data;
[0036] According to the difference determination data, analyze the distribution differences of each wavelength band, distinguish the wavelength bands different from the normal food components, judge the adulterated components and output the detection results, and generate the determination result of the adulterated components.
[0037] As a further solution of the present invention, the long short-term memory network is in accordance with the formula:
[0038] h t =σ(α1·W x x t +α2·U x h t-1 +α3·b x +α4·λ t )
[0039] Where: h t represents the hidden state at the current time step, x t represents the input data at the current time step, W x represents the weight matrix of the current input feature spectral data, U x represents the weight matrix between the hidden state of the previous time step and the current state, b x represents the bias term, λ t represents the change factor of the time step, α1 represents the weight coefficient of the input feature, α2 represents the weight coefficient of the hidden state of the previous moment, α3 represents the adjustment coefficient of the bias term, α4 represents the adaptive adjustment coefficient of the time step, and σ represents the activation function.
[0040] A food adulteration detection system based on spectral analysis, which is used to execute the above-mentioned food adulteration detection method based on spectral analysis. The system includes:
[0041] Spectral data acquisition module: Obtain the absorbance values of different bands in the spectral data through sensors, calculate the deviation between each spectral point and the adjacent band, compare the differences in wavelength data points, determine whether the set threshold is exceeded, and if exceeded, mark it as abnormal to generate a list of abnormal bands;
[0042] Spectral data correction and calibration module: Based on the list of abnormal bands, adopt the backpropagation algorithm to process each data point marked as abnormal one by one, calculate the difference between the data point and the adjacent band, calculate the deviation amount, and correct the value of the data point through error feedback by the backpropagation algorithm to update the spectral data and generate a spectral data calibration set;
[0043] Feature extraction module: Based on the spectral data calibration set, extract spectral features of different scales layer by layer, analyze the correlation between local bands and global bands, generate a feature map for each layer, and obtain a multi-scale feature map;
[0044] Adulteration determination and classification module: Based on the multi-scale feature map, select the band data with large changes, perform correlation calculation to screen out important bands, eliminate redundant bands, perform dimensionality reduction operations by merging similar bands, and adopt a long short-term memory network to calculate the band distribution difference and perform threshold judgment to distinguish adulterated substances from normal components, output the detection result, and generate an adulterated component determination result.
[0045] Compared with the prior art, the advantages and positive effects of the present invention are as follows:
[0046] 1. In the present invention, by calculating the deviation of different bands in the spectral data and comparing the differences between wavelength data points, abnormal bands can be quickly identified, reducing the data inaccuracy caused by environmental noise or equipment errors;
[0047] 2. In the present invention, by adjusting the wavelength difference of each abnormal point through the backpropagation algorithm, the adjustment mechanism corrects the data points to ensure the accuracy and consistency of the data, eliminates noise interference, and improves the quality of spectral data;
[0048] 3. In the present invention, through the generation of multi-scale feature maps, effective spectral features are extracted at different scales, and the correlation between local bands and global bands is analyzed to ensure that details at each scale are fully considered;
[0049] 4. In the present invention, the long short-term memory network is used to determine the difference in band distribution, accurately distinguish adulterated components from normal components in the long-term relationship between time series and bands, improve the accuracy and efficiency of adulteration detection, and enhance the reliability and efficiency of detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 is a schematic diagram of the working process of the present invention;
[0051] Figure 2 is a detailed flowchart of S1 of the present invention;
[0052] Figure 3 is a detailed flowchart of S2 of the present invention;
[0053] Figure 4 is a detailed flowchart of S3 of the present invention;
[0054] Figure 5 is a detailed flowchart of S4 of the present invention;
[0055] Figure 6 is a detailed flowchart of S5 of the present invention;
[0056] Figure 7 is a system flowchart of the present invention. DETAILED DESCRIPTION OF THE INVENTION
[0057] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only for explaining the present invention and are not intended to limit the present invention.
[0058] Please refer to Figure 1 , the present invention provides a technical solution: a method for detecting food adulteration based on spectral analysis, comprising the following steps:
[0059] S1: Obtain the absorbance values of different bands in the spectral data through a sensor, calculate the deviation between each spectral point and the adjacent band, compare the differences in wavelength data points, determine whether the set threshold is exceeded, and if exceeded, mark it as abnormal to generate a list of abnormal bands;
[0060] S2: According to the list of abnormal bands, adopt the backpropagation algorithm, calculate the correction amount of the abnormal value by processing the wavelength differences between each abnormal point and the adjacent point one by one, correct the value of the data point using the gradient adjustment mechanism, update the spectral data, and generate a corrected set of spectral data;
[0061] S3: Based on the corrected set of spectral data, input the spectral information for hierarchical processing, extract spectral features of different scales layer by layer, analyze the correlation between local bands and global bands, generate a feature map for each layer, and obtain a multi-scale feature map;
[0062] S4: Based on the multi-scale feature maps, filter the band data, sort them according to the correlation and importance between bands, remove redundant bands, extract the changing information, and reduce the dimension by merging similar bands to generate a refined spectral feature set;
[0063] S5: Based on the refined spectral feature set, calculate the distribution difference of each band, and use a long short-term memory network for threshold judgment. Distinguish the adulterated substances from the normal components according to the results and output the results to obtain the determination result of the adulterated components.
[0064] Please refer to Figure 2 , and the specific steps to generate the list of abnormal bands are as follows:
[0065] S101: Collect spectral data through a sensor, extract the absorbance value of each spectral point, calculate the numerical difference between each spectral point and the adjacent band, perform difference quantization and compare it with a preset wavelength difference threshold to generate band difference data;
[0066] S102: Based on the band difference data, compare the absorbance value of each band with the value of the adjacent band. If the difference exceeds the set threshold, mark it as abnormal to generate abnormal band marking data;
[0067] S103: According to the abnormal band marking data, collect and organize all the data points marked as abnormal to generate a list of abnormal bands;
[0068] S101: Collect spectral data through a sensor, calculate the absorbance value of each spectral point using an absorbance calculation function, calculate the wavelength difference of each spectral point, calculate the numerical difference between each spectral point and the adjacent band using a difference calculation formula, calculate the numerical difference between adjacent bands using an absolute difference function, and use a threshold judgment function to compare with a preset wavelength difference threshold. If the difference exceeds the set threshold, it is determined as a difference band and band difference data is generated;
[0069] S102: Based on the band difference data, use a band comparison algorithm to compare the absorbance value of each band with the value of the adjacent band, compare the absorbance difference between the current band and the adjacent band using a difference calculation formula. If the difference value exceeds the set threshold, use an abnormal marking function to mark the band as an abnormal band and generate abnormal band marking data;
[0070] S103: According to the abnormal band marking data, use a data screening algorithm to screen all the data points marked as abnormal bands, and collect and organize the data points through a marking matching function to generate a list of abnormal bands.
[0071] Please refer to Figure 3, the specific steps for generating the spectral data correction set are as follows:
[0072] S201: Based on the abnormal band list, for each data point marked as abnormal, calculate the difference between the data point and the adjacent bands, compare the band differences and calculate the deviation amount, reverse-transmit the error to each layer of the network through the backpropagation algorithm, and calculate the correction amount for each band, gradually correcting the deviation value to generate correction amount data;
[0073] S202: Based on the correction amount data, adjust each abnormal data point, and gradually update the absorbance value of the corresponding band using the correction amount to generate the spectral data correction set;
[0074] S203: According to the spectral data correction set, organize and summarize all the updated data to generate a complete corrected data set, and obtain the spectral data correction set;
[0075] S201: Based on the abnormal band list, for each data point marked as abnormal, use the band difference calculation function to calculate the difference between the data point and the adjacent bands, use the deviation amount calculation formula to compare the band differences and calculate the deviation amount, based on the backpropagation algorithm, transmit the error to each layer of the network through the reverse transmission function, and use the gradient descent method to calculate the correction amount for each band, where the learning rate parameter is set to 0.01, the number of iterations is 1000 times, the loss function uses the mean square error function, and gradually correct the deviation value through the correction amount adjustment function to generate correction amount data;
[0076] S202: Based on the correction amount data, adjust each abnormal data point, gradually update the absorbance value of the corresponding band using the correction amount update formula, and gradually adjust the absorbance value of each band through the absorbance adjustment function. During the update process, use the correction amount gradual update function to accumulate the updated absorbance values to generate the spectral data correction set;
[0077] S203: According to the spectral data correction set, use the data organization algorithm to organize all the updated data, summarize all the corrected data points through the data summarization function, sort the corrected data by wavelength value using the sorting function, the sorting rule is from small to large, use the duplicate data removal algorithm to remove duplicate data points, and use the data merging function to merge the corrected data points with the original data set, and the merging method is to merge by wavelength matching to obtain the spectral data correction set.
[0078] The backpropagation algorithm, according to the formula:
[0079]
[0080] where: E represents the loss function, w i represents the network weight of the i-th layer, y iDenotes the output of the $i$-th layer, $t$ i Denotes the target value or true value of the $i$-th layer, $\alpha$ denotes the learning rate, $\lambda$ j Denotes the wavelength adjustment factor, $\beta$ i Denotes the correction intensity coefficient;
[0081] Execution process: First, the output value $y$ of each band in the spectral data i and the corresponding true value $t$ i are used to calculate the error, which represents the difference between the network prediction and the true value. Then the learning rate $\alpha$ controls the step size of each weight update, determining how the network adjusts the weights to minimize the error. Next, the wavelength adjustment factor $\lambda$ j dynamically adjusts the contribution of each band to the error feedback according to the characteristics of different bands in the spectral data, ensuring that the band information related to the actual wavelength change is properly processed. Finally, the correction intensity coefficient $\beta$ i determines the contribution degree of each layer in the error correction process. By controlling the correction intensity of each layer's features, it optimizes the final output data, accurately distinguishes normal foods from adulterated ingredients, and gradually adjusts the weights of each layer in the network through the backpropagation algorithm to optimize the correction effect of the spectral data and improve the accuracy of food adulteration detection.
[0082] Please refer to Figure 4 , and the specific steps to generate the multi-scale feature map are as follows:
[0083] S301: Based on the spectral data calibration set, perform hierarchical processing on the data of each band, sequentially perform information transfer according to the relationship between the local band and the global band, layer by layer analyze the changes of local features and global features, extract the features of each layer, and generate a hierarchical feature map;
[0084] S302: Based on the hierarchical feature map, analyze the correlation between each band, calculate the correlation between the features of each layer and the global features, extract the relatively important local and global features, and generate band correlation data;
[0085] S303: Based on the band correlation data, select the bands with obvious changes, remove redundant information, merge the bands with high correlation, and obtain the multi-scale feature map;
[0086] S301: Based on the spectral data calibration set, perform hierarchical processing on the data of each band. Use the local band analysis function to sequentially perform information transfer according to the relationship between the local band and the global band, calculate the relationship between the local band and the global band through the global band relationship calculation formula, use the hierarchical feature extraction algorithm to layer by layer analyze the changes of local features and global features, extract the local features and global features of each layer, set the convolution kernel size to 3x3, the stride to 1, the pooling size to 2x2, and use the ReLU activation function when extracting the features of each layer to generate a hierarchical feature map;
[0087] S302: Based on the hierarchical feature map, use the band correlation analysis algorithm to analyze the correlation between each band, calculate the correlation between each layer of features and the global features, calculate the correlation degree between the local features and the global features of each layer through the correlation calculation function, use the correlation coefficient formula to calculate the correlation between features, adopt the importance scoring function to extract relatively important local and global features, set the correlation threshold to 0.8, and the features with high correlation are regarded as important features to generate band correlation data;
[0088] S303: Based on the band correlation data, select the bands with obvious changes, adopt the feature selection algorithm to eliminate redundant information, use the redundant information detection function to calculate the redundancy of all bands, set the redundancy threshold to 0.5, and eliminate the bands with high redundancy. Adopt the correlation merging function to merge the bands with high correlation, use the K-means clustering algorithm, set the value of K to 5, and the number of iterations to 100 to cluster the merged bands, and finally obtain the multi-scale feature map.
[0089] Please refer to Figure 5 , and the specific steps to generate the refined spectral feature set are as follows:
[0090] S401: Based on the multi-scale feature map, select the band data with strong change amplitude, use the correlation calculation to screen out the important bands, eliminate the redundant bands, and generate the selected band data;
[0091] S402: Based on the selected band data, analyze the differences between the bands, merge the bands with similar changes, reduce the number of bands through the merging operation, and generate the refined spectral feature data;
[0092] S403: Based on the refined spectral feature data, perform dimensionality reduction operations on the bands, and generate the refined spectral feature set by merging the bands with similar change trends;
[0093] S401: Based on the multi-scale feature map, select the band data with strong change amplitude, use the correlation calculation function to calculate the correlation between each band and its adjacent bands, use the correlation coefficient formula to calculate the correlation between bands, set the correlation threshold to 0.8, and the bands with high correlation are regarded as important bands, and use the redundancy calculation function to eliminate the redundant bands, and the elimination condition is that the redundancy is greater than 0.5, and generate the selected band data;
[0094] S402: Based on the selected band data, analyze the differences between the bands. Use a difference calculation function to calculate the differences between the bands, and use a difference quantization algorithm to compare the differences of each band. Select the bands with smaller differences for merging, and use a merging operation function to merge the bands with similar changes. The merging condition is that the difference in the change amplitude between the bands is less than the set threshold, and the threshold is set to 0.1. Reduce the number of bands through the merging operation to generate refined spectral feature data;
[0095] S403: Based on the refined spectral feature data, perform a dimensionality reduction operation on the bands. Use the principal component analysis algorithm, set the number of principal components to 5, and use the covariance matrix to perform dimensionality reduction analysis on the correlation between the bands. Screen and retain the main features through the variance contribution rate, and merge the bands with similar change trends to generate a refined spectral feature set.
[0096] Use correlation calculation to screen out important bands. First, calculate the Pearson correlation coefficient between each band, evaluate the information redundancy between the bands, and perform screening and elimination at the same time;
[0097] Perform a dimensionality reduction operation on the bands using principal component analysis. By performing eigenvalue decomposition on the covariance matrix of the spectral data, screen the direction of variance in the data, retain the variation information in the data, and map the high-dimensional spectral data to a lower-dimensional space by screening the principal components, reducing the computational complexity and removing noise, to obtain concise features that can effectively express the important information in the data.
[0098] Please refer to Figure 6 , and the specific steps to generate the adulterated component determination result are as follows:
[0099] S501: Based on the refined spectral feature set, calculate the mean, standard deviation, and statistical features of the spectral data of each band, evaluate the distribution range of each band, perform differential calculation of the data of each band, and generate band distribution data;
[0100] S502: Based on the band distribution data, use a long short-term memory network to process the time series features between different bands, gradually capture the dependency relationship between the features of each layer and the global features, and optimize the feature extraction process through a recursive structure to generate difference determination data;
[0101] S503: According to the difference determination data, analyze the distribution differences of each band, distinguish the bands that are different from the normal food components, judge the adulterated components, and output the detection results to generate the adulterated component determination result;
[0102] S501: Based on the reduced spectral feature set, calculate the mean of the spectral data for each band using the mean calculation function, calculate the standard deviation of each band using the standard deviation calculation formula, calculate the statistical features of each band through the statistical feature calculation algorithm, evaluate the distribution range of each band, perform differential calculation on the data of each band using the differential calculation algorithm, calculate the difference value between each band and other bands using the difference metric function, and generate band distribution data;
[0103] S502: Based on the band distribution data, use the long short-term memory network to process the time series features between different bands, train using the LSTM model, set the input sequence length to 50, the number of hidden layer units to 100, the learning rate to 0.001, use the Adam optimizer during training, gradually capture the dependency relationship between the features of each layer and the global features, and optimize the feature extraction process through the recursive structure optimization function to generate difference determination data;
[0104] S503: According to the difference determination data, analyze the distribution differences of each band, analyze the distribution characteristics of each band using the distribution analysis function, use the threshold determination algorithm to distinguish the bands different from the normal food ingredients, further analyze the detected abnormal bands using the anomaly detection algorithm, judge the adulterated ingredients and output the detection results, and generate the adulterated ingredient determination results.
[0105] The long short-term memory network, according to the formula:
[0106] h t =σ(α1·W x x t +α2·U x h t-1 +α3·b x +α4·λ t )
[0107] Where: h t represents the hidden state at the current time step, x t represents the input data at the current time step, W x represents the weight matrix of the current input feature spectral data, U x represents the weight matrix between the hidden state of the previous time step and the current state, b x represents the bias term, λ t represents the change factor of the time step, α1 represents the weight coefficient of the input feature, α2 represents the weight coefficient of the hidden state at the previous moment, α3 represents the adjustment coefficient of the bias term, α4 represents the adaptive adjustment coefficient of the time step, and σ represents the activation function;
[0108] Execution process: First, x t represents the spectral input data at the current time step, is passed to the current layer, and through Wx The matrix is weighted with the input data to determine the contribution of the current input to the hidden state, h t-1 is the hidden state of the previous time step, representing the characteristics of the previous spectral data. After being weighted by the U x matrix, it is combined with the current hidden state to reflect the influence of the information at the previous moment on the current state. Then, b x is the bias term. The output of each time step is adjusted by the adjustment coefficient of α3, enabling the model to adaptively adjust the bias to optimize the training process. To dynamically adjust the contribution of spectral data at each time step, λ t is introduced and optimized by the adaptive adjustment coefficient of α4. Through calculation by the activation function σ, the hidden state h at the current time step is obtained t , reflecting the comprehensive characteristics of the input data and historical information.
[0109] A food adulteration detection system based on spectral analysis. The food adulteration detection system based on spectral analysis is used to execute the above-mentioned food adulteration detection method based on spectral analysis. The system includes:
[0110] Spectral data acquisition module: Obtain the absorbance values of different bands in the spectral data through sensors, calculate the deviation between each spectral point and the adjacent bands, compare the differences in wavelength data points, determine whether they exceed the set threshold, and if so, mark them as abnormal to generate a list of abnormal bands;
[0111] Spectral data correction and calibration module: Based on the list of abnormal bands, adopt the backpropagation algorithm to process each data point marked as abnormal one by one, calculate the difference between the data point and the adjacent bands, and calculate the deviation amount. The value of the data point is corrected through error feedback by the backpropagation algorithm to update the spectral data and generate a spectral data calibration set;
[0112] Feature extraction module: Based on the spectral data calibration set, extract spectral features of different scales layer by layer, analyze the correlation between local bands and global bands, generate feature maps for each layer, and obtain multi-scale feature maps;
[0113] Adulteration determination and classification module: Based on the multi-scale feature maps, select the band data with large variations, perform correlation calculation to screen out important bands, remove redundant bands, perform dimensionality reduction operations by merging similar bands, and adopt a long short-term memory network to calculate the band distribution differences and perform threshold judgment to distinguish adulterated substances from normal components, output the detection results, and generate adulterated component determination results.
[0114] The above are only the preferred embodiments of the present invention, and do not limit the present invention in other forms. Any person skilled in the relevant art may use the technical content disclosed above to make changes or modifications into equivalent embodiments with equivalent changes and apply them to other fields. However, as long as it does not depart from the technical solution content of the present invention, any simple modification, equivalent change, and modification made to the above embodiments based on the technical essence of the present invention still fall within the protection scope of the technical solution of the present invention.
Claims
1. A food adulteration detection method based on spectral analysis, characterized in that, It includes the following steps: Step 1: Obtain the absorbance values of different bands in the spectral data through a sensor, calculate the deviation between each spectral point and the adjacent band, compare the differences in wavelength data points, determine whether they exceed the set threshold. If they exceed, mark them as abnormal and generate a list of abnormal bands; Step 2: According to the list of abnormal bands, adopt the backpropagation algorithm. By processing the wavelength differences between each abnormal point and its adjacent points one by one, calculate the correction amount of the abnormal value, use the gradient adjustment mechanism to correct the value of the data point, update the spectral data, and generate a spectral data correction set; Step 3: Based on the spectral data correction set, input the spectral information for hierarchical processing, extract spectral features of different scales layer by layer, analyze the correlation between local bands and global bands, generate a feature map for each layer, and obtain a multi-scale feature map; Step 4: According to the multi-scale feature map, screen the band data, sort based on the correlation and importance between bands, eliminate redundant bands, extract the changing information, and reduce the dimension by merging similar bands to generate a refined spectral feature set; Step 5: Based on the refined spectral feature set, calculate the distribution difference of each band, and use a long short-term memory network for threshold judgment. Distinguish the adulterated substances from the normal components according to the results and output the results to obtain the determination result of the adulterated components.
2. The food adulteration detection method based on spectral analysis according to claim 1, wherein The specific steps for generating the list of abnormal bands are as follows: Collect spectral data through a sensor, extract the absorbance value of each spectral point, calculate the numerical difference between each spectral point and the adjacent band, perform difference quantization and compare it with the preset wavelength difference threshold to generate band difference data; Based on the band difference data, compare the absorbance value of each band with the adjacent band value. If the difference exceeds the set threshold, mark it as abnormal to generate abnormal band marking data; According to the abnormal band marking data, collect and organize all the data points marked as abnormal to generate a list of abnormal bands.
3. The food adulteration detection method based on spectral analysis according to claim 1, wherein The specific steps for generating the spectral data correction set are as follows: Based on the list of abnormal bands, for each data point marked as abnormal, calculate the difference between the data point and the adjacent band, compare the band differences and calculate the deviation amount. Use the backpropagation algorithm to reverse the error to each layer of the network and calculate the correction amount of each band, gradually correct the deviation value to generate correction amount data; Based on the correction amount data, adjust each abnormal data point, and gradually update the absorbance value of the corresponding band using the correction amount to generate a spectral data correction set; According to the spectral data correction set, organize and summarize all the updated data to generate a complete corrected data set to obtain the spectral data correction set.
4. The food adulteration detection method based on spectral analysis according to claim 1, characterized in that The backpropagation algorithm follows the formula: Among them: E represents the loss function, w i represents the network weight of the i-th layer, y i represents the output of the i-th layer, t i represents the target value or true value of the i-th layer, α represents the learning rate, λ j represents the wavelength adjustment factor, β i represents the correction intensity coefficient.
5. The food adulteration detection method based on spectral analysis according to claim 1, wherein The specific steps for generating the multi-scale feature map are as follows: Based on the spectral data correction set, perform hierarchical processing on the data of each band, sequentially perform information transmission according to the relationship between local bands and global bands, analyze the changes of local features and global features layer by layer, extract the features of each layer, and generate a hierarchical feature map; Based on the hierarchical feature map, analyze the correlation between each band, calculate the correlation between the features of each layer and the global features, extract the more important local and global features to generate band correlation data; Based on the band - associated data, select the bands with obvious changes, eliminate redundant information, and merge the bands with high correlation to obtain a multi - scale feature map.
6. The food adulteration detection method based on spectral analysis according to claim 1, wherein The specific steps for generating the refined spectral feature set are as follows: Based on the multi - scale feature map, select the band data with strong change amplitude, use correlation calculation to screen out important bands, eliminate redundant bands, and generate the selected band data; Based on the selected band data, analyze the differences between bands, merge the bands with similar changes, reduce the number of bands through the merging operation, and generate refined spectral feature data; Based on the refined spectral feature data, perform a dimensionality reduction operation on the bands, merge the bands with similar change trends, and generate a refined spectral feature set.
7. The food adulteration detection method based on spectral analysis according to claim 6, characterized in that When using correlation calculation to screen out important bands, first calculate the Pearson correlation coefficient between each band, evaluate the information redundancy between bands, and perform screening and elimination simultaneously; When performing the dimensionality reduction operation on the bands, use principal component analysis. By performing eigenvalue decomposition on the covariance matrix of the spectral data, screen the directions of variance in the data, retain the variation information in the data, and map the high - dimensional spectral data to a lower - dimensional space by screening the principal components, reducing the computational complexity and removing noise, to obtain features that are concise and can effectively express the important information in the data.
8. The food adulteration detection method based on spectral analysis according to claim 1, wherein The specific steps for generating the adulterated component determination result are as follows: Based on the refined spectral feature set, calculate the mean, standard deviation, and statistical features of the spectral data for each band, evaluate the distribution range of each band, perform the difference calculation of the data for each band, and generate band distribution data; Based on the band distribution data, use a long short - term memory network to process the time - series features between different bands, gradually capture the dependence relationship between the features of each layer and the global features, optimize the feature extraction process through the recursive structure, and generate difference determination data; According to the difference determination data, analyze the distribution differences of each band, distinguish the bands that are different from the normal food components, judge the adulterated components, and output the detection result to generate the adulterated component determination result.
9. The method for detecting food adulteration based on spectral analysis according to claim 1, wherein The long short - term memory network, according to the formula: h t = σ(α1·W x x t + α2·U x h t-1 + α3·b x + α4·λ t ) where: h t represents the hidden state at the current time step, x t represents the input data at the current time step, W x represents the weight matrix of the current input feature spectral data, U x represents the weight matrix between the hidden state of the previous time step and the current state, b x represents the bias term, λ t represents the change factor of the time step, α1 represents the weight coefficient of the input feature, α2 represents the weight coefficient of the hidden state at the previous moment, α3 represents the adjustment coefficient of the bias term, α4 represents the adaptive adjustment coefficient of the time step, and σ represents the activation function.
10. A food adulteration detection system based on spectral analysis, characterized in that, According to the food adulteration detection method based on spectral analysis according to any one of claims 1 - 9, the system includes: Spectral data acquisition module: Obtain the absorbance values of different bands in the spectral data through sensors, calculate the deviation between each spectral point and the adjacent bands, compare the differences in wavelength data points, judge whether it exceeds the set threshold, if it exceeds, mark it as abnormal, and generate a list of abnormal bands; Spectral data correction and calibration module: Based on the list of abnormal bands, use the backpropagation algorithm to process each data point marked as abnormal one by one, calculate the difference between the data point and the adjacent bands, calculate the deviation amount, and correct the value of the data point through error feedback using the backpropagation algorithm, update the spectral data, and generate a spectral data calibration set; Feature extraction module: Based on the spectral data calibration set, extract spectral features of different scales layer by layer, analyze the association between local bands and global bands, generate the feature map of each layer, and obtain a multi - scale feature map; Adulteration determination and classification module: Based on the multi-scale feature maps, select the band data with large variations, perform correlation calculations to screen out important bands, eliminate redundant bands, perform dimensionality reduction operations by merging similar bands, and use a long short-term memory network to calculate the band distribution differences and perform threshold judgments to distinguish adulterated substances from normal components, output the detection results, and generate the determination results of adulterated components.