Beef producing area tracing method and device based on Raman spectrum and adaptive attention residual network
By using an Adaptive Attention Residual Network (AARNet) and a Progressive Feature Extraction Module (PAF), the problem of insufficient model generalization ability of Raman spectroscopy in beef origin tracing was solved, achieving efficient beef origin identification and capturing subtle differences, and improving classification accuracy and stability.
Patent Information
- Application Number
- CN202511176639.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-21
- Publication Date
- 2025-12-09
AI Technical Summary
Existing Raman spectroscopy technology has limited generalization ability in beef origin tracing, making it difficult to effectively capture high-dimensional nonlinear features and subtle differences in the spectrum. Furthermore, deep learning models are prone to gradient vanishing or performance degradation.
An Adaptive Attention Residual Network (AARNet) is employed, which constructs channel attention weights through global average pooling and a fully connected neural network, and combines them with a Progressive Feature Extraction (PAF) module to improve the model's ability to perceive Raman spectroscopy features and its training stability.
It achieved high accuracy and robustness in identifying beef origins, and improved the model's ability to identify subtle spectral changes and its classification performance.
Smart Images

Figure CN121093076A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of meat product analysis technology, and in particular to a method and apparatus for tracing the origin of beef based on Raman spectroscopy and adaptive attention residual networks. Background Technology
[0002] With increasing health awareness and rising living standards, consumers are increasingly demanding high-quality beef. Beef quality is related to factors such as breed, farming methods, and origin; even beef of the same breed and size can vary significantly in price due to quality differences.
[0003] Raman spectroscopy is a spectroscopic analysis method based on molecular vibrational characteristics. The molecular structure and composition of a substance can be directly reflected by the position and intensity of spectral peaks. Due to its advantages such as being non-destructive and rapid, it has shown broad application prospects in fields such as food safety testing. In recent years, many scholars at home and abroad have conducted extensive research on the application of Raman spectroscopy in meat quality analysis, origin traceability, and adulteration detection. Zhang Tonggang et al. (Zhang Tonggang, Han Bin, Li Jing. Detection of Methemoglobin and its Enzyme Activity in Fresh Beef Based on Raman Spectroscopy [J]. Food Research and Development, 2022, 43(03):158-163.) used Raman spectroscopy to construct an analytical detection model for the relative content of methemoglobin and its reductase activity on the surface of beef, and verified the effectiveness of characteristic wavelength screening in partial least squares regression (PLSR) modeling. Liu et al. (Liu Q, Dong P, Fengou LC, Nychas GJ, Fowler SM, Mao Y, Luo X, Zhang Y. Preliminary investigation into the prediction of indicators of beefspoilage using Raman and Fourier transform infrared spectroscopy[J]. MeatScience, 2023, 200: 109168.) constructed a PLSR model by combining Raman and FT-IR spectroscopy to predict beef spoilage indicators (TVC and TVB-N). Chen et al. (Chen Q, Xie Y, Yu H, Guo Y, Yao W. Non-destructive prediction of colour and water-related properties of frozen / thawed beef meat by Raman spectroscopy coupled multivariate calibration[J]. Food Chemistry, 2023, 413: 135513.) combined Raman spectroscopy with multivariate calibration methods (CARS-PLS and UVE-PLS) to predict the color and water content characteristics of frozen and thawed beef.Shoko et al. (Shoko PT, Landry JD, Blanch EW, Torley PJ. The prediction of fatty acid composition in beef muscles using Raman spectroscopy and chemometrics[J]. Journal of Food Composition and Analysis, 2025, 139: 107069.) used Raman spectroscopy combined with partial least squares regression to predict the composition of various fatty acids in beef muscle.
[0004] However, most existing research is based on traditional machine learning methods, which suffer from limited model generalization ability and insufficient extraction of high-dimensional nonlinear features in spectral analysis. Therefore, utilizing advanced modeling methods such as deep learning to fully explore the potential discriminative features in Raman spectroscopy has become an important direction for improving the application performance of Raman spectroscopy in food detection. However, common deep learning methods ignore inter-channel dependencies and fail to capture the relationships between different channels, resulting in limited feature representation capabilities and insensitivity to subtle differences. Some existing models using deep convolutional structures are prone to gradient vanishing or performance degradation during training, making it difficult for them to effectively learn high-level semantic features. Summary of the Invention
[0005] This invention provides a method and apparatus for tracing the origin of beef based on Raman spectroscopy and an adaptive attention residual network, which has high accuracy and robustness in identifying the origin of beef.
[0006] The technical solution of the present invention is as follows: A method for tracing the origin of beef based on Raman spectroscopy and an adaptive attention residual network includes the following steps: (1) Obtain beef samples and preprocess them to obtain beef slices; (2) Raman spectroscopy was performed on the beef slices to obtain the raw Raman spectral data and preprocess it; (3) Input the pre-processed Raman spectral data into the pre-trained Raman spectral classification model and output the origin of the beef sample; the Raman spectral classification model includes an input convolutional layer module, a feature extraction module, a global feature aggregation module and a classifier module connected in sequence.
[0007] In step (1), the pretreatment of the beef sample includes cutting the beef sample into thin slices of standard size of 3 cm × 4 cm and 2 mm thickness, and collecting Raman spectra.
[0008] Raman spectroscopy is a weak signal. Before modeling and analyzing Raman spectral data, it is usually necessary to perform appropriate preprocessing on the original spectrum to eliminate interference from non-chemical factors, thereby improving the signal-to-noise ratio and stability of the spectral data and enhancing the accuracy and robustness of subsequent modeling and analysis.
[0009] In step (2), the preprocessing of the raw Raman spectral data includes SG filtering smoothing and normalization.
[0010] Raman spectroscopy is characterized by high dimensionality, strong nonlinearity, and dense local information. Furthermore, the spectral differences between beef samples from different origins are relatively small, thus placing high demands on the classification performance of Raman spectroscopy classification models. These models need strong feature representation and subtle difference capture capabilities to effectively identify minute spectral variations.
[0011] Preferably, the input convolutional layer module includes a one-dimensional convolutional layer, a batch normalization layer, a ReLU activation function layer, and a max pooling layer connected in sequence.
[0012] The input convolutional layer module processes the input Raman spectral tensor through one-dimensional convolution, batch normalization, and ReLU activation to obtain a preliminary feature map. Then, the sequence length is compressed using max pooling to obtain the output features. .
[0013] Preferably, the feature extraction module includes three sets of PAF modules connected in sequence; Each PAF module consists of a one-dimensional convolutional layer, a batch normalization layer, a ReLU activation function layer, and several stacked AAR modules connected in sequence. Each AAR module consists of a one-dimensional convolutional layer, a batch normalization layer, a ReLU activation function layer, an average pooling layer, a first fully connected layer, a ReLU activation function layer, a second fully connected layer, and a Sigmoid function layer, connected in sequence.
[0014] In each layer of AAR module: (a) Input feature tensor Intermediate features are obtained after one-dimensional convolution, batch normalization, and ReLU nonlinear activation. ; (b) Perform global average pooling on the features in the spatial dimension to obtain the channel compression vector. : ; in, Indicates the channel index. For sequence length, Indicates the first Each channel is located in eigenvalues; (c) Use fully connected layers to construct non-linear relationships between channels and generate channel weight vectors. and normalized to using the Sigmoid function. : ; in, This represents the Sigmoid function. and The learned weight matrix; (d) will Adaptive adjustment and input based on channel weights Perform residual connections to obtain the output. : .
[0015] Preferably, several layers of AAR modules are stacked, and the process can be represented as follows: ; in, Indicates the first Each AAR module performs a nonlinear transformation of the input features. This represents the number of AAR modules.
[0016] The feature extraction process can be described as follows: ; in, , , These represent the first group of PAF modules, the second group of PAF modules, and the third group of PAF modules, respectively. , , They are respectively , , The output of .
[0017] Preferably, the global feature aggregation module includes an average pooling layer.
[0018] Preferably, the classifier module includes a fully connected layer.
[0019] Preferably, when training the Raman spectroscopy classification model, the cross-entropy loss function is used as the optimization objective: ; Where C represents the total number of categories. For real labels, To predict probabilities.
[0020] Preferably, the learning rate is 1×10 when training the Raman spectroscopy classification model. -4 The optimizer is Adam; the weight decay term is 2 × 10. -3 Batch size is 100; number of training rounds is 300.
[0021] This invention also provides a beef origin traceability device based on Raman spectroscopy and an adaptive attention residual network, comprising: The sample preprocessing unit acquires beef samples and preprocesses them to obtain beef slices. The Raman spectroscopy acquisition unit performs Raman spectroscopy detection on beef sample slices to obtain raw Raman spectral data and preprocess it. The classification unit inputs the pre-processed Raman spectral data into a pre-trained Raman spectral classification model and outputs the origin of the beef sample. The Raman spectral classification model includes an input convolutional layer module, a feature extraction module, a global feature aggregation module, and a classifier module connected in sequence.
[0022] Compared with the prior art, the beneficial effects of the present invention are as follows: This invention proposes an Adaptive Attention Residual Module (AAR Module), which introduces an attention mechanism on the basis of traditional residual structure. Channel attention weights are constructed through global average pooling and fully connected neural networks, and then weighted and fused with convolutional features to effectively improve the model's ability to perceive weak key features in Raman spectra. This module alleviates the gradient vanishing problem in deep networks through residual connections, ensuring training stability.
[0023] This invention designs a Progressive Feature Extraction (PAF) module, which stacks multiple adaptive attention residual modules and combines progressive downsampling operations and channel expansion to achieve layer-by-layer extraction and enhancement from low-dimensional shallow features to high-dimensional deep semantic features. This module can effectively capture local variations and fine-grained differences in spectral data, improving the model's ability to represent complex spectral information.
[0024] This invention constructs a complete Raman spectroscopy classification model structure, which includes an input convolutional layer, a feature extraction module, a global feature aggregation layer, and a classifier output structure. It supports end-to-end training and arbitrary length spectral sequence input, and can efficiently extract temporal features and category information from Raman spectra. This structure has good scalability and adaptability, and is suitable for various types of spectral classification tasks. Attached Figure Description
[0025] Figure 1 This is a schematic diagram of the structure of a Raman spectroscopy classification model; Figure 2 This is a schematic diagram of the PAF module structure; Figure 3 This is a schematic diagram of the AAR module structure. Detailed Implementation
[0026] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be noted that the embodiments described below are intended to facilitate the understanding of the present invention and do not limit it in any way.
[0027] This invention provides a method for tracing the origin of beef based on Raman spectroscopy and an adaptive attention residual network, comprising the following steps: (1) Obtain beef samples and preprocess them to obtain beef slices; (2) Raman spectroscopy was performed on the beef slices to obtain the raw Raman spectral data and preprocess it; (3) Input the pre-processed Raman spectral data into the pre-trained Raman spectral classification model and output the origin of the beef sample; the Raman spectral classification model includes an input convolutional layer module, a feature extraction module, a global feature aggregation module and a classifier module connected in sequence.
[0028] The beef samples for the training samples were selected from China, the United States, Australia, Argentina, Brazil, and Bolivia. The brisket cut was uniformly collected, and the beef samples from each origin were divided into 25 independent batches. Each batch was further cut into 10 experimental units. Each experimental unit was cut into thin slices of 3×4 cm (length×width) and 2 mm thickness. Four measurement points were selected on each sample for spectral acquisition. 1000 spectral data points were collected from each beef sample from each origin, for a total of 6000 Raman spectral data points collected from the six origins.
[0029] This invention first preprocesses the raw Raman spectral data, which includes two steps: SG filtering smoothing and normalization. (i) SG filtering smoothing (Savitzky-Golay): Using a fixed window to perform polynomial fitting on the original Raman spectral data, the spectral signal is smoothed, preserving peak characteristics while suppressing high-frequency noise.
[0030] After SG filtering and smoothing, in order to eliminate the overall intensity differences between samples caused by instrument response, the spectral data needs to be normalized.
[0031] (ii) Min-Max Normalization: Compress all spectral intensities to the 0,1 range to enhance the comparability between different sample spectra and eliminate differences between instruments.
[0032] This invention proposes a Raman spectroscopy classification model based on an adaptive attention mechanism and residual structure, such as... Figure 1As shown, it includes an input convolutional layer module, a feature extraction module, a global feature aggregation module, and a classifier module, which can fully explore the temporal patterns and subtle differences in spectral data.
[0033] Input convolutional layer module The input convolutional layer module consists of a one-dimensional convolutional layer, a batch normalization layer, a ReLU activation function layer, and a max pooling layer connected in sequence.
[0034] The input is of dimension 1 (in For batch size, The Raman spectral tensor (where is the spectral length) is first subjected to a one-dimensional convolution ( The initial feature map is obtained after convolution kernel size of 7, stride of 2, batch normalization (BN), and ReLU activation function. This process can be represented as: ; Represents the ReLU activation function. Indicates batch normalization. This represents one-dimensional convolution; Subsequently, the sequence length is compressed using max pooling to reduce computational complexity, and the output feature is denoted as... : ; in, This indicates a max pooling operation.
[0035] Feature extraction module The feature extraction module consists of three sequentially connected Progressive AttentionFeature (PAF) modules with an increasing number of channels. Each module outputs a higher-order semantic feature.
[0036] like Figure 2 As shown, each PAF module consists of a one-dimensional convolutional layer, a batch normalization layer, a ReLU activation function layer, and three stacked adaptive attention residual (AAR) modules connected in sequence.
[0037] First use a 1×1 convolutional layer to... The number of channels is adjusted, and the feature map size is reduced by stride downsampling. Next, the convolutional layer output undergoes batch normalization to ensure training stability, and a non-linear transformation is introduced using the ReLU activation function to obtain the feature tensor. The process is represented as follows: ; Next, the feature tensor It is fed into a 3-layer stacked Adaptive Attention Residual (AAR) module.
[0038] like Figure 3 As shown, each AAR module structure includes a one-dimensional convolutional layer, a batch normalization layer, a ReLU activation function layer, an average pooling layer, a first fully connected layer, a ReLU activation function layer, a second fully connected layer, and a Sigmoid function layer.
[0039] Feature tensor First, intermediate features are obtained through one-dimensional convolution, batch normalization, and ReLU nonlinear activation. ; The features are weighted using a channel attention mechanism: global average pooling is performed on the features in the spatial dimension to obtain a channel compressed vector. : ; in, Indicates the channel index. For spectral length, Indicates the sequence position index. Indicates the first Each channel is located in eigenvalues; Next, two fully connected layers are used to construct the non-linear relationship between channels, generating channel weight vectors. and normalized to using the Sigmoid function. Expressed as: ; in, This represents the Sigmoid function. and The learned weight matrix; Will Adaptive adjustment and input based on channel weights Perform residual connections to obtain the output. : ; Finally, the AAR modules are stacked, a process that can be represented as follows: ; in, Indicates the first Each AAR module performs a nonlinear transformation of the input features. This represents the number of AAR modules.
[0040] After the above steps, features are extracted using three sets of PAF modules. After each set of feature extraction is completed, the number of feature channels increases sequentially (…). This enhances the model's representational capabilities. The feature extraction process can be described as follows: ; in, , , These represent the first group of PAF modules, the second group of PAF modules, and the third group of PAF modules, respectively. , , They are respectively , , The output of .
[0041] Global feature aggregation module The global feature aggregation module includes an average pooling layer. The feature extraction module outputs features... Adaptive average pooling is used to compress sequences of arbitrary length into fixed-length feature vectors. : ; This indicates the average pooling operation.
[0042] Classifier module The classifier module includes a fully connected layer, which processes a fixed-length feature vector. Feature mapping is performed to obtain the final classification prediction result. The process is represented as follows: ; in, This indicates a fully connected layer.
[0043] Model training Use the cross-entropy loss function as the optimization objective: ; Where C represents the total number of categories. For real labels, To predict probabilities.
[0044] The entire model was implemented using PyTorch and trained on an NVIDIA RTX 3080 (10GB VRAM) device. The specific settings were as follows: Learning rate: 1×102 -4 Optimizer: Adam; Weight decay term: 2 × 10 -3 Batch size: 100; Number of training rounds: 300; Data split ratio: 70% training set, 10% validation set, and 20% test set.
[0045] Compared to common machine learning methods in existing technologies (such as Linear Discriminant Analysis (LDA), Decision Tree (DC), Support Vector Machine (SVM), and Random Forest (RF)) and deep learning models (such as AlexNet, ZFNet, LeNet, and ResNet), the Adaptive Attention Residual Network (AARNet) proposed in this invention achieves an accuracy of 97.92% in the Raman spectral classification task, with precision, recall, and F1 score of 97.94%, 97.88%, and 97.93%, respectively, as shown in Tables 1 and 2.
[0046] Table 1 Comparison of results with machine learning methods
[0047] Table 2 Comparison of results with other deep learning methods
[0048] The embodiments described above provide a detailed explanation of the technical solutions and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the present invention. Any modifications, additions, and equivalent substitutions made within the scope of the principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for tracing the origin of beef based on Raman spectroscopy and an adaptive attention residual network, characterized in that, Includes the following steps: (1) Obtain beef samples and preprocess them to obtain beef slices; (2) Raman spectroscopy was performed on the beef slices to obtain the raw Raman spectral data and preprocess it; (3) Input the preprocessed Raman spectral data into the pre-trained Raman spectral classification model to output the origin of the beef sample; The Raman spectroscopy classification model comprises an input convolutional layer module, a feature extraction module, a global feature aggregation module, and a classifier module connected in sequence.
2. The method for tracing the origin of beef based on Raman spectroscopy and adaptive attention residual network according to claim 1, characterized in that, In step (2), the preprocessing of the raw Raman spectral data includes SG filtering smoothing and normalization.
3. The method for tracing the origin of beef based on Raman spectroscopy and adaptive attention residual network according to claim 1, characterized in that, The input convolutional layer module includes a one-dimensional convolutional layer, a batch normalization layer, a ReLU activation function layer, and a max pooling layer connected in sequence.
4. The method for tracing the origin of beef based on Raman spectroscopy and adaptive attention residual network according to claim 1, characterized in that, The feature extraction module includes three sets of PAF modules connected in sequence; Each PAF module consists of a one-dimensional convolutional layer, a batch normalization layer, a ReLU activation function layer, and several stacked AAR modules connected in sequence. Each AAR module consists of a one-dimensional convolutional layer, a batch normalization layer, a ReLU activation function layer, an average pooling layer, a first fully connected layer, a ReLU activation function layer, a second fully connected layer, and a Sigmoid function layer, connected in sequence.
5. The method for tracing the origin of beef based on Raman spectroscopy and adaptive attention residual network according to claim 4, characterized in that, In each layer of AAR module: (a) Input feature tensor Intermediate features are obtained after one-dimensional convolution, batch normalization, and ReLU nonlinear activation. ; (b) Perform global average pooling on the features in the spatial dimension to obtain the channel compression vector. : in, Indicates the channel index. For sequence length, Indicates the first Each channel is located in eigenvalues; (c) Use fully connected layers to construct non-linear relationships between channels and generate channel weight vectors. and normalized to using the Sigmoid function. : in, This represents the Sigmoid function. and The learned weight matrix; (d) will Adaptive adjustment and input based on channel weights Perform residual connections to obtain the output. : 。 6. The method for tracing the origin of beef based on Raman spectroscopy and adaptive attention residual network according to claim 5, characterized in that, The process of stacking several layers of AAR modules can be represented as follows: in, Indicates the first Each AAR module performs a nonlinear transformation of the input features. This represents the number of AAR modules.
7. The method for tracing the origin of beef based on Raman spectroscopy and adaptive attention residual network according to claim 4, characterized in that, The feature extraction process can be described as follows: in, The input features are the output features of the convolutional layer module; , , These represent the first group of PAF modules, the second group of PAF modules, and the third group of PAF modules, respectively. , , They are respectively , , The output of .
8. The method for tracing the origin of beef based on Raman spectroscopy and adaptive attention residual network according to claim 1, characterized in that, The global feature aggregation module includes an average pooling layer; the classifier module includes a fully connected layer.
9. The method for tracing the origin of beef based on Raman spectroscopy and adaptive attention residual network according to claim 1, characterized in that, When training the Raman spectroscopy classification model, the cross-entropy loss function is used as the optimization objective: Where C represents the total number of categories. For real labels, To predict probabilities.
10. A beef origin traceability device based on Raman spectroscopy and an adaptive attention residual network, characterized in that, include: The sample preprocessing unit acquires beef samples and preprocesses them to obtain beef slices. The Raman spectroscopy acquisition unit performs Raman spectroscopy detection on beef sample slices to obtain raw Raman spectral data and preprocess it. Classification unit; The preprocessed Raman spectral data is input into a pre-trained Raman spectral classification model to output the origin of beef samples. The Raman spectral classification model includes an input convolutional layer module, a feature extraction module, a global feature aggregation module, and a classifier module connected in sequence.
Citation Information
Cited By
Soybean producing area traceability detection method based on laser-induced breakdown spectroscopy technology
CN121994781A
