Bacterial raman spectrum chemical component cross-domain analysis method based on deep transfer learning
Patent Information
- Application Number
- CN202510736273.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-04
- Publication Date
- 2026-08-21
- Estimated Expiration
- 2045-06-04
AI Technical Summary
[0002]传统拉曼光谱分析技术长期依赖于人工经验驱动的特征选取模式,其核心方法(如峰位匹配、半定量积分)在复杂生化样本检测中面临根本性瓶颈
[0046] This invention presents a cross-domain analysis method for bacterial Raman spectroscopy chemical composition based on deep transfer learning. Through multi-source data acquisition and preprocessing, it effectively addresses the problem of spectral data distribution variations caused by equipment differences, bacterial species diversity, and the complexity of experimental environments in traditional methods. This method utilizes a deep fully connected neural network and a multi-head self-attention mechanism to extract spectral features, combined with adversarial transfer learning to eliminate distribution differences between devices, significantly improving the model's adaptability to complex biological samples. Furthermore, through nonlinear dimensionality reduction, dynamic domain adaptation, and meta-learning fine-tuning strategies, it achieves performance prediction of small data samples of new samples under different environments and devices, greatly improving detection efficiency and accuracy. Compared with traditional methods, this invention not only outputs chemical composition category determination and concentration prediction results quickly and accurately, but also possesses stronger generalization ability and robustness, making it particularly suitable for rapid detection and real-time monitoring of complex samples.
Smart Images

Figure CN120673875B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of intelligent Raman spectroscopy detection technology, and particularly relates to a cross-domain analysis method for the chemical composition of bacterial Raman spectra based on deep transfer learning. Background Technology
[0002] Traditional Raman spectroscopy has long relied on feature selection driven by human experience, and its core methods (such as peak matching and semi-quantitative integration) face fundamental bottlenecks in the detection of complex biochemical samples. In bacterial chemical composition analysis, due to the diversity of microbial metabolites, Raman spectra often exhibit densely overlapping characteristic peak signals, typically seen in β-lactam compounds at 1630-1660 cm⁻¹. -1 The highly overlapping vibrational peaks within the range necessitate manual analysis relying on expert experience and repeated comparisons with reference spectral libraries, and are prone to misjudgment due to subjective bias. Furthermore, when detecting low-concentration chemical components, the imbalance between the fluorescence background noise and the signal-to-noise ratio (SNR) of the target signal (false positive rate exceeding 40% when SNR < 5) further limits the reliability of the detection. The operation process, with a single-sample analysis time exceeding 30 minutes, makes this technology unsuitable for demanding scenarios requiring high timeliness, such as real-time environmental monitoring.
[0003] Dynamic spectral peak shifts (±15cm) caused by bacterial metabolic activity -1 The fluctuations in concentration (both fluctuating and varying during different growth cycles, logarithmic and stationary phases) make it difficult for traditional machine learning models (such as support vector machines and random forests) to establish stable spectral-chemical mapping relationships. Furthermore, these methods often rely on static feature extraction strategies with fixed wavenumber intervals, failing to adaptively capture the time-varying characteristics of bacterial chemical components, resulting in a significant decrease in the model's generalization performance across devices, samples, and experimental environments.
[0004] Deep transfer learning, as an innovative machine learning approach, can apply knowledge learned in one domain to another related domain, thereby improving the learning efficiency and effectiveness of new tasks. Therefore, to address the aforementioned problems, this invention proposes a cross-domain method for the analysis of bacterial Raman spectroscopy chemical composition based on a deep transfer learning framework. Summary of the Invention
[0005] To address the aforementioned technical problems, this invention proposes a cross-domain analysis method for the chemical composition of bacterial Raman spectra based on deep transfer learning, thereby resolving the issues present in the prior art.
[0006] To achieve the above objectives, this invention provides a method for cross-domain analysis of bacterial Raman spectroscopy chemical composition based on deep transfer learning, comprising:
[0007] Multi-source Raman spectral data are acquired and preprocessed to obtain preprocessed spectral data.
[0008] A deep transfer learning model is constructed, which extracts the spectral features of the preprocessed spectral data through a deep fully connected neural network and a multi-head self-attention mechanism, and uses adversarial transfer learning to eliminate distribution differences between devices to obtain Raman spectral feature vectors; the Raman spectral feature vectors are then subjected to nonlinear dimensionality reduction to obtain a low-dimensional feature matrix.
[0009] Based on the reduced-dimensional feature matrix, a small-sample fine-tuning strategy using dynamic domain adaptation and meta-learning fine-tuning is adopted to obtain the optimized model.
[0010] Based on the optimized model, the output results include chemical component category determination and concentration prediction.
[0011] Optionally, the process of preprocessing the multi-source Raman spectral data to obtain preprocessed spectral data includes:
[0012] The adaptive Savitzky-Golay filtering algorithm is used to perform local polynomial fitting on multi-source Raman spectral data and dynamically subtract fluorescence background noise to obtain the baseline-corrected spectral dataset.
[0013] Based on the baseline-corrected spectral dataset, the wavenumber axis of the spectral data from different devices is nonlinearly aligned using dynamic time warping technology to eliminate peak shifts caused by differences in device parameters; the peak-shifted spectral data from multiple sources are uniformly mapped to the reference wavenumber axis to construct a standardized dataset.
[0014] The standardized dataset is augmented to obtain an augmented spectral dataset;
[0015] Preprocessed spectral data is constructed based on the enhanced spectral dataset.
[0016] Optionally, the process of performing data augmentation on the standardized dataset to obtain the augmented spectral dataset includes:
[0017] Zero-mean Gaussian noise is applied to the standardized dataset to obtain noise-enhanced spectral data;
[0018] A random translation perturbation is applied to the wavenumber axis of the noise-enhanced spectral data to obtain wavenumber-perturbed spectral data;
[0019] The intensity of the wavenumber-perturbed spectral data is nonlinearly scaled to obtain intensity-adjusted spectral data.
[0020] Based on a baseline feature library collected from multiple devices, a generative adversarial network is used to fit the fluorescence background patterns of different devices, and the fluorescence background patterns of different devices are superimposed on the intensity-adjusted spectral data to obtain an enhanced spectral dataset.
[0021] Optionally, the process of extracting spectral features from the preprocessed spectral data using a deep fully connected neural network and a multi-head self-attention mechanism includes:
[0022] The preprocessed spectral data is input into a deep fully connected neural network, and preliminary feature representations of the spectral data are extracted through multiple fully connected layers. At the same time, residual connections are introduced into the deep fully connected neural network to preserve local detail information of the original spectral data.
[0023] The preliminary feature representation is processed using a multi-head self-attention mechanism to dynamically focus on key discrimination spectral regions, obtain spectral feature peaks and suppress noise interference, and obtain multi-head splicing output;
[0024] The multi-head splicing output is processed by layer normalization to output the spectral characteristics of the Raman spectral data.
[0025] Optionally, the process of using adversarial transfer learning to eliminate distribution differences between devices and obtain Raman spectral feature vectors includes:
[0026] Cross-domain comparative learning is performed on the spectral features of the Raman spectral data, and cross-device consistency features are generated through device simulation enhancement to form positive sample pairs.
[0027] Negative sample pairs are formed by randomly sampling from the spectral data of different bacterial species.
[0028] The InfoNCE loss function is used to maximize the similarity of positive sample pairs, and domain-invariant features are generated through domain adversarial training. Finally, the Raman spectral feature vector optimized by adversarial transfer learning is obtained.
[0029] Optionally, the process of performing nonlinear dimensionality reduction on the Raman spectral eigenvectors to obtain a lower-dimensional eigenma matrix includes:
[0030] By nonlinear mapping, high-dimensional feature vectors in Raman spectrum feature vectors are mapped to low-dimensional space while retaining key discrimination information, resulting in a preliminary dimensionality-reduced feature matrix.
[0031] By minimizing the difference between high-dimensional and low-dimensional manifold structures, the feature matrix after initial dimensionality reduction is ensured to be consistent across different devices and strains, thus obtaining a consistent optimized feature matrix.
[0032] Based on the feature matrix optimized by the consistency, a maximum mean difference constraint is introduced into the UMAP optimization objective to force the low-dimensional feature distributions of different domains to align, thereby obtaining the aligned low-dimensional feature matrix.
[0033] The target dimension number for dimensionality reduction is determined based on the requirements of cross-domain consistency and discriminant preservation. The aligned low-dimensional feature matrix is then dimensionality reduced based on the target dimension number to obtain the dimensionality-reduced low-dimensional feature matrix.
[0034] Optionally, based on the reduced-dimensional feature matrix, the process of using dynamic domain adaptation and meta-learning fine-tuning strategies to achieve small-sample fine-tuning and obtain the optimized model includes:
[0035] The reduced low-dimensional feature matrix is subjected to online distribution alignment and dynamic parameter adjustment using a dynamic adaptation network to obtain the adapted feature matrix.
[0036] The adapted feature matrix is processed using a meta-learning fine-tuning strategy based on the MAML framework to obtain the optimized model.
[0037] Optionally, the process of outputting chemical component category determination and concentration prediction results based on the optimized model includes:
[0038] The optimized model is input with the adapted feature matrix, and a Softmax classifier is used for classification to obtain the probability distribution of chemical component categories.
[0039] The optimized model is input with the adapted feature matrix, and quantile regression is used for regression processing to obtain the concentration prediction value and its confidence interval.
[0040] The probability distribution, concentration prediction, and confidence interval of the chemical component categories are integrated to output the final chemical component category determination and concentration prediction results.
[0041] Optionally, the method further includes a process of visualizing the extracted high-dimensional features, specifically including:
[0042] The Raman spectral feature vectors are subjected to dimensionality reduction using the domain-aware UMAP method to obtain a low-dimensional feature matrix for visualization.
[0043] Based on the low-dimensional feature matrix used for visualization, an attention weight heatmap is drawn, and key wavenumber regions are labeled.
[0044] The low-dimensional feature matrix used for visualization is combined with the attention weight heatmap to generate visualization results, which are used to analyze and explain the model's discrimination logic.
[0045] Compared with the prior art, the present invention has the following advantages and technical effects:
[0046] This invention presents a cross-domain analysis method for bacterial Raman spectroscopy chemical composition based on deep transfer learning. Through multi-source data acquisition and preprocessing, it effectively addresses the problem of spectral data distribution variations caused by equipment differences, bacterial species diversity, and the complexity of experimental environments in traditional methods. This method utilizes a deep fully connected neural network and a multi-head self-attention mechanism to extract spectral features, combined with adversarial transfer learning to eliminate distribution differences between devices, significantly improving the model's adaptability to complex biological samples. Furthermore, through nonlinear dimensionality reduction, dynamic domain adaptation, and meta-learning fine-tuning strategies, it achieves performance prediction of small data samples of new samples under different environments and devices, greatly improving detection efficiency and accuracy. Compared with traditional methods, this invention not only outputs chemical composition category determination and concentration prediction results quickly and accurately, but also possesses stronger generalization ability and robustness, making it particularly suitable for rapid detection and real-time monitoring of complex samples. Attached Figure Description
[0047] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:
[0048] Figure 1 This is the overall flowchart of the cross-domain analysis method for bacterial Raman spectroscopy chemical composition based on deep transfer learning in this embodiment of the invention;
[0049] Figure 2 This is a flowchart of deep transfer learning according to an embodiment of the present invention;
[0050] Figure 3 This is a specific processing flow for the residual fully connected network layer and skip connections in an embodiment of the present invention;
[0051] Figure 4 The following is a detailed processing flow of the multi-head self-attention mechanism in an embodiment of the present invention;
[0052] Figure 5 This describes the specific processing steps for dynamically adapting the network in an embodiment of the present invention.
[0053] Figure 6 This is a meta-learning θ update process based on the MAML framework in an embodiment of the present invention;
[0054] Figure 7 The figures shown are partial results of the cross-domain analysis method for bacterial Raman spectroscopy chemical composition based on deep transfer learning, as described in an embodiment of the present invention. Detailed Implementation
[0055] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0056] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0057] Example 1
[0058] The overall process of a cross-domain analysis method and system for bacterial Raman spectroscopy chemical composition based on deep transfer learning is as follows: Figure 1 As shown, this embodiment provides a cross-domain analysis method for bacterial Raman spectroscopy chemical composition based on deep transfer learning, aiming to address the problem of spectral data distribution variations caused by equipment differences, bacterial species diversity, and the complexity of experimental environments in laboratory and clinical settings. Traditional methods are limited by the limitations of manual feature extraction and the insufficient nonlinear representation capabilities of shallow models, making it difficult to cope with challenges such as cross-device spectral shifts, dynamic changes in bacterial metabolism, and low signal-to-noise ratio environments. This method constructs a feature extractor through deep transfer learning multi-source domain training, combined with dynamic domain adaptation and meta-learning small-sample fine-tuning strategies, significantly improving the model's adaptability to complex biological samples and exhibiting strong scalability. Through the development of this model, it is possible to predict the performance of new samples collected in different environments and with different devices using small data samples, providing an efficient solution for the rapid detection and real-time monitoring of complex clinical samples.
[0059] This invention constructs a universal feature extractor through multi-source domain training, combines contrastive learning and domain adversarial training to eliminate device differences, introduces a dynamic adaptation network to align the target domain distribution in real time, and achieves rapid small-sample fine-tuning for rare bacterial species through a meta-learning strategy. This technology overcomes the generalization bottleneck of traditional methods across devices, bacterial species, and experimental environments, simultaneously optimizing the tasks of chemical component classification and concentration prediction, significantly improving detection efficiency and accuracy.
[0060] As a specific implementation method of this embodiment, the following steps are included:
[0061] Step 1: Acquire multi-source Raman spectral data and preprocess the multi-source Raman spectral data to obtain preprocessed spectral data; the specific implementation process is as follows:
[0062] Multi-source data acquisition: Traditional Raman spectroscopy data acquisition often relies on repeatedly collecting data from a single type of bacteria using a single instrument to obtain laboratory data. This acquisition method has weak generalization ability, requires repeated data annotation, and makes it difficult to form a relatively complete dataset. To overcome the drawbacks of single acquisition, multi-source data acquisition systematically integrates Raman spectroscopy data from different devices, diverse bacterial species, and complex experimental conditions, enabling the construction of a highly generalizable and robust training database. The multi-source nature of the data can come from the following aspects:
[0063] (1) Differences in Raman spectrometers: Different Raman spectrometers result in significant differences in data acquisition performance. Mainstream Raman spectrometers include, but are not limited to, Thermo Fisher Scientific's DXR3xi and iXR+, CloudMinds' HandyRaman-Pro and PortableRaman-2000, Bruker's Senterra II and MultiRAM, and Renishaw's inVia Qontor and Virsa. Furthermore, Raman spectrometers from different brands also exhibit differences in equipment parameters, including laser wavelength, resolution, integration time, and power settings. Therefore, these factors need to be considered within the acquisition range to ensure the integrity of the raw data.
[0064] (2) Diversity of bacterial species: The collected spectral data may vary significantly for different bacterial species. To ensure the stability of the spectral data after collection and the full coverage of chemical composition diversity, it is necessary to conduct multi-species comprehensive collection. The bacterial types that can be collected should include 30 common clinical pathogenic microorganisms such as Staphylococcus aureus, Staphylococcus epidermidis, Streptococcus pneumoniae, Escherichia coli, Pseudomonas aeruginosa, Klebsiella pneumoniae, vancomycin-resistant enterococci, Candida albicans, Candida glabrata, and Cryptococcus neoformans, to ensure the complete coverage of the dataset.
[0065] (3) Complexity of the experimental environment: Data collection in a single experimental environment is prone to being too simplistic and lacking universality. Therefore, it is necessary to construct a complex experimental environment to ensure that the data covers the diversity of clinical practice. Complex experimental conditions include the collection of mixed strains, the collection of compound strains, and the collection under different culture conditions, growth cycles, and concentration gradients.
[0066] Furthermore, the preprocessing of multi-source Raman spectral data to obtain preprocessed spectral data includes: performing local polynomial fitting on the multi-source Raman spectral data based on the adaptive Savitzky-Golay filtering algorithm to dynamically subtract fluorescence background noise, resulting in a baseline-corrected spectral dataset; based on the baseline-corrected spectral dataset, performing nonlinear alignment of the wavenumber axis on the spectral data from different devices using dynamic time warping technology to eliminate peak shifts caused by differences in device parameters; uniformly mapping the peak-shift-corrected spectral data from multiple sources to the reference wavenumber axis to construct a standardized dataset; performing data augmentation on the standardized dataset to obtain an enhanced spectral dataset; and constructing preprocessed spectral data based on the enhanced spectral dataset.
[0067] Data standardization: Raman spectroscopy data of different bacterial strains under different environments and using different equipment are acquired, and the acquired results are then standardized. The following example, using laboratory equipment 1 to acquire spectra of bacterial samples prepared under the same experimental conditions, illustrates the data standardization process. After data acquisition, the data is processed to standardize it. The data standardization process mainly includes adaptive filtering and dynamic correction.
[0068] (1) Adaptive Savitzky-Golay filtering is used. Fluorescence background in the Raman spectrum causes baseline drift, masking the true characteristic peak signals. Therefore, an adaptive Savitzky-Golay filtering algorithm can be used to dynamically correct the baseline through local polynomial fitting. The specific process of adaptive filtering is as follows:
[0069] First, assume that the Raman spectrum dataset collected by laboratory equipment 1 contains N samples, each sample consisting of intensity values of L wavenumber points, as shown in formula (1), where Y1 is the total dataset. This represents the original intensity value of the Nth sample at the Lth wavenumber point.
[0070]
[0071] Secondly, to prevent baseline non-uniformity caused by local fitting, a sliding window is used to divide the spectrum into multiple local intervals, and polynomial fitting is performed independently within each window, thus flexibly adapting to local variations in the baseline. fit (L) represents the baseline intensity of the Raman spectrum obtained by polynomial fitting at the wavenumber point L; a m represents the polynomial coefficients, used to control the shape of the Raman spectrum fitting curve; k represents the order of the polynomial, used to control the complexity of the Raman spectrum fitting curve. The specific expression for fitting the original spectral intensity using a polynomial is shown in formula (2).
[0072]
[0073] Then, the optimal a is obtained using least squares optimization. m By adjusting a m This minimizes the sum of squared residuals between the fitted curve and the original Raman spectrum data. i and j represent the center index of the current window and the index of the data point within the window, respectively. Indicated by wavenumber point L i The sum of squared residuals between the fitted polynomial curve and the processed original spectral intensity within a sliding window centered on the baseline is used to quantify the error of the baseline fitting; W represents the wavenumber interval of the Raman spectral unit; b j ,c j Let $\mathbf{j}$ and $\mathbf{j}$ represent the wave value of the j-th data point within the window and the original spectral intensity of the j-th data point within the window, respectively. The process of minimizing the sum of squared residuals between the fitted curve and the original spectrum is shown in formula (3).
[0074]
[0075] Finally, the characteristic peak signals after noise removal were obtained by calibrating the Raman spectral intensity through baseline subtraction. corrected (L) represents the corrected spectral intensity, i.e., the pure characteristic peak signal after baseline stripping; y raw (L) represents the original spectral intensity, including baseline drift and characteristic peak signals; y baseline (L) represents low-frequency background interference. The process of removing noise and performing spectral correction is shown in formula (4).
[0076] y corrected (L)=y raw (L)-y baseline (L) (4)
[0077] By mapping mathematical variables to the specific wavenumbers, intensities, and characteristic peaks of Raman spectra, the core parameters for baseline correction, W,k,a, are determined. m Accurate modeling and removal of the fluorescent background were achieved. Finally, the corrected spectral dataset Y was obtained. corrected This dataset serves as the reference spectrum for DTW described below, enabling dynamic correction of spectral data acquired by other devices and the construction of the final standardized dataset. The corrected dataset is shown in Equation (5).
[0078]
[0079] (2) Dynamic Time Warping (DTW) is used for dynamic correction. Because laser wavelength calibration errors, temperature drift, or grating mechanical deviations in different spectrometers can cause Raman peak shifts for the same chemical component, directly inputting these into the model may lead to classification errors. Therefore, DTW is used for nonlinear alignment of the wavenumber axis to eliminate systematic errors between devices. The bacterial samples collected by laboratory device 1 are re-acquired using laboratory device t, and this data is used as the target spectral dataset Y. t Then, DTW can be used for spectral processing. The specific process of using DTW is as follows:
[0080] First, suppose the target spectral dataset collected by the t-th device in the laboratory contains N samples, each sample consisting of the intensity values of L wavenumber points, as shown in formula (6), Y t Let t be the dataset consisting of the t-th device. This represents the original intensity value of the Nth sample at the Lth wavenumber point.
[0081]
[0082] Secondly, quantifying the differences between the reference spectrum and the target spectrum at each wavenumber point provides a basis for alignment. D(p,q) represents the wavenumber point L of the reference spectrum. p With the target spectral wavenumber point L q The square of the Euclidean distance reflects the intensity difference between the two points; y ref (L p ) represents the intensity value of the reference spectrum at the wavenumber; y target (L q ) indicates that the target spectrum is at wavenumber L q The intensity value at the specified location. The calculation of the Raman spectrum intensity difference is shown in formula (7).
[0083] D(p,q)=(y ref (L p )-y target (L q )) 2 (7)
[0084] Then, optimal path search can be used to dynamically program and find the alignment path with the minimum cumulative cost. The calculation of the minimum cumulative cost is shown in Equation (8). Where Cost(p,q) represents the minimum cumulative cost from the starting point to point (p,q); D(p,q) represents the distance value of the current point; min{} means selecting the minimum cumulative cost from the previous position to ensure global optimum.
[0085]
[0086] Finally, the target spectral wavenumber axis is adjusted according to the optimal path, and wavenumber remapping is used to align it with the reference spectrum. The wavenumber intensity value after alignment is calculated as shown in formula (9). Where, y target (L q ) indicates that the target spectrum is at wavenumber L q Intensity value at y; aligned (L p () indicates that the aligned target spectrum is at the reference wavenumber point L. p The intensity value at the location; P represents the optimal path set, which contains all aligned wavenumber point pairs (p, q).
[0087] y aligned (L p )=y target (L q (9) where (p,q)∈P
[0088] Finally, a spectrally normalized dataset was obtained through DTW. This dataset consists of the aligned target spectral data of the t-th device. All aligned target spectral datasets are shown in Equation (10). For the dataset after aligning the wavenumber points for the t-th device, This represents the corrected intensity value of the Nth sample at the Lth wavenumber point.
[0089]
[0090] Using the above DTW data dynamic correction process, standardized datasets of the same bacterial species under the same experimental conditions can be constructed using different devices. Wavelength alignment systematically solves the problem of wavenumber inconsistency in Raman spectroscopy data caused by device differences by quantifying differences through distance matrix, searching for the optimal path through dynamic programming, and correcting offsets through wavenumber remapping. This process not only improves data quality but also provides standardized input for model generalization across devices and scenarios.
[0091] Data Augmentation: Raman spectroscopy data is susceptible to interference from environmental noise, equipment parameter fluctuations, and the dynamic characteristics of microbial metabolism during acquisition, leading to problems such as uneven sample distribution and feature shifts between devices in the original dataset. Traditional single-device or fixed-condition spectral acquisition modes cannot cover the complexity of real-world scenarios, easily causing models to fall into local overfitting and limiting cross-domain generalization ability. To address this, this invention proposes a hybrid data augmentation strategy guided by physical mechanisms. By simulating spectral morphological perturbations and device differences, it systematically expands the diversity of training data and improves the model's robustness to noise interference, wavenumber shifts, and intensity fluctuations.
[0092] Furthermore, the process of augmenting the standardized dataset to obtain the augmented spectral dataset includes: applying zero-mean Gaussian noise to the standardized dataset to obtain noise-enhanced spectral data; applying random translation perturbation to the wavenumber axis of the noise-enhanced spectral data to obtain wavenumber-perturbed spectral data; performing nonlinear scaling on the intensity of the wavenumber-perturbed spectral data to obtain intensity-adjusted spectral data; and, based on a baseline feature library collected from multiple sources, fitting the fluorescence background patterns of different sources using a generative adversarial network, and superimposing the fluorescence background patterns of different sources onto the intensity-adjusted spectral data to obtain the augmented spectral dataset.
[0093] The specific enhancement methods are as follows:
[0094] (1) Gaussian noise injection. First, to simulate fluorescence background interference in low signal-to-noise ratio scenarios, the standardized dataset is... Zero-mean Gaussian noise is applied to the spectral intensity in the image to obtain the noise-enhanced spectral data. The noise amplitude is dynamically adjusted according to the target signal-to-noise ratio to ensure that the enhanced data covers the noise distribution range of the real detection scene. The noise injection method is shown in formula (11). Where, y aligned (L) represents the intensity value after correction at the Lth wavenumber point; y a (L) represents the Raman spectral intensity of the injected Gaussian noise; σ 2 Indicates the noise variance; ∈ indicates that it follows a pattern with a mean of 0 and a variance of σ. 2 Gaussian distributed random noise.
[0095]
[0096] (2) Random Wavenumber Shift. Next, to address the spectral peak shift caused by equipment wavelength calibration errors or temperature drift, a random translation perturbation is applied to the spectral wavenumber axis to obtain the perturbed spectral data. Let the corrected wavenumber sequence be {L1, L2, ..., L...} n The enhanced wavenumber sequence is {L1+Δ, L2+Δ, ..., L}, where n = 0, 1, 2, ... n +Δ,n=0,1,2,...}, where Δ is a random displacement following a uniform distribution, used to simulate cross-device wavenumber shift. By simulating cross-device wavenumber shift through random displacement, the model is forced to learn discriminative features that are insensitive to spectral peak positions.
[0097] (3) Dynamic intensity scaling. Then, to adapt to the intensity fluctuations caused by different concentration gradients or laser power differences, the intensity of the spectral data after wavenumber perturbation is nonlinearly scaled to obtain the intensity-adjusted spectral data. A piecewise linear transformation function is used to randomly adjust the intensity gain of different wavenumber intervals, as shown in formula (12). Wherein, α represents the interval weighting coefficient. The spectral bands are divided by a sliding window and the scaling factor is sampled independently to simulate the dynamic intensity distribution caused by changes in the bacterial growth cycle or experimental conditions. This represents a uniformly distributed random scaling factor, simulating the growth cycle of bacterial strains or changes in experimental conditions.
[0098]
[0099] (4) Equipment Baseline Simulation. Finally, based on the baseline feature library collected from multiple equipment sources, the fluorescence background patterns of different equipment are fitted using a generative adversarial network and superimposed onto the pure spectral signal. The enhanced spectral intensity is shown in Equation (13). Wherein, y aug (L) represents the enhanced spectral intensity; y b (L) represents the characteristic peak signal after dynamic intensity scaling, and z is the latent space noise vector, which follows a standard normal distribution. Through adversarial training, G can generate interference patterns that are highly consistent with the baseline of real devices, improving the model's adaptability to baseline drift across devices.
[0100]
[0101] Finally, an enhanced spectral dataset was constructed by spectral augmentation of the standardized dataset. The specific expression is shown in formula (14). Wherein, This represents the enhanced intensity value of the Nth sample at the Lth wavenumber point.
[0102]
[0103] The aforementioned enhancement strategies, by combining physical mechanism-driven and data-driven approaches, effectively expand the diversity and complexity of training data, providing data preparation for subsequent use of deep transfer learning.
[0104] Step 2: Construct a deep transfer learning model. This model extracts spectral features from the preprocessed spectral data using a deep fully connected neural network and a multi-head self-attention mechanism. Adversarial transfer learning is then used to eliminate distribution differences between devices, resulting in Raman spectral feature vectors. These feature vectors are then subjected to nonlinear dimensionality reduction to obtain a low-dimensional feature matrix. The specific implementation process includes:
[0105] Deep transfer learning for sample training: Laboratory data covers single culture conditions, while clinical samples involve complex scenarios such as mixed microbiota and multi-culture media. Deep transfer learning integrates spectral data from multiple laboratory devices, microbial species, and environments to construct a highly generalized feature space, enabling the model to be directly transferred to the analysis of complex clinical samples without retraining. Deep transfer learning includes the construction of a deep fully connected neural network (DNN), the use of cross-domain adversarial transfer learning, and nonlinear dimensionality reduction using domain-aware UMAP. The deep transfer learning process is as follows: Figure 2 As shown.
[0106] (1) Design of a deep feature extractor: The design process of a deep feature extractor includes: Raman spectroscopy data often suffers from peak position shifts and intensity fluctuations due to differences in equipment and the diversity of bacterial metabolism. Traditional single-device training models are difficult to generalize, and it is necessary to construct cross-domain robust features. To this end, this invention adopts a deep fully connected neural network, and solves the stability problem of feature extraction in high-noise environments through residual connections and attention mechanisms.
[0107] Furthermore, the process of extracting spectral features from preprocessed spectral data using a deep fully connected neural network and a multi-head self-attention mechanism includes: inputting the preprocessed spectral data into a deep fully connected neural network, extracting preliminary feature representations of the spectral data through multiple fully connected layers; simultaneously introducing residual connections into the deep fully connected neural network to preserve local detail information of the original spectral data; processing the preliminary feature representations using a multi-head self-attention mechanism to dynamically focus on key discrimination spectral regions, obtain spectral feature peaks, and suppress noise interference to obtain a multi-head stitched output; and then processing the multi-head stitched output through layer normalization to output the spectral features of the Raman spectral data. The specific processing flow is as follows:
[0108] First, after standardizing and augmenting the Raman spectral data, a Raman spectral dataset is obtained. Among them, y L The value represents the spectral intensity at wavenumber point L; L represents the number of wavenumber points covered by the spectrum, reflecting the spectral resolution. The input matrix is defined as shown in formula (15).
[0109]
[0110] Then, a three-layer fully connected layer is established through a single residual block structure to better obtain the chemical composition information corresponding to the spectral data. Simultaneously, skip connections X are utilized. proj To mitigate the vanishing gradient problem, preserve local details of the original spectrum, and avoid information loss in deep networks, the specific processing flow using residual fully connected network layers and skip connections is as follows: Figure 3As shown in the diagram. Here, F1, F2, F3 represent the first, second, and third fully connected layers; W1, W2, W3 represent the weight matrices; b1, b2, b3 represent the bias vectors; Swish(z) = z·σ(z) represents the activation function, where z represents the input; σ(z) represents the sigmoid function, used to enhance non-linear expressiveness; X proj The linear projection of input X is used to ensure dimension matching. The expressions for the residual fully connected network layers and skip connections are shown in equations (16)(17)(18)(19)(20), yielding the preliminary feature representation F of the spectral data. out .
[0111]
[0112] F1 = Swish(W1·X + b1) (17)
[0113] F2 = Swish(W2·F1 + b2) (18)
[0114] F3 = Swish(W3·F2 + b3) (19)
[0115] F out =F3+X proj (20)
[0116] Secondly, to dynamically focus on key discriminative spectral regions, acquire spectral feature peaks, and suppress noise interference, a multi-head self-attention mechanism is introduced to process the initial feature representation, enabling the model to focus on features of different spectral regions in parallel. The specific processing flow of the multi-head self-attention mechanism is as follows: Figure 4 As shown. The single-head attention calculation is shown in formula (21), where Q, K, and V represent the query, key, and value, respectively; W Q W K W V Let represent the learnable projection matrix. The attention weights are calculated as shown in formula (22), where represents the scaling factor, used to prevent the gradient from becoming unstable due to excessively large dot product values. The multi-head concatenation output is shown in formula (23), where h represents the number of heads; W O This indicates the output projection matrix.
[0117] Q = W Q ·F out K = W K ·F out V = W V ·F out (twenty one)
[0118]
[0119] MultiHead(Fout = Contact(head1,…,head) h W O (twenty three)
[0120] Attention weights are calculated using the attention weight matrix Softmax(·), which weakens irrelevant regions and preserves key signals by removing spectral feature peaks; Contact(·) represents concatenation, used to merge multi-head information and improve the model's expressive power.
[0121] Finally, after processing by a deep fully connected neural network and a multi-head self-attention mechanism, a 512-dimensional universal feature vector is output. The calculation formula for multi-head self-attention is shown in formula (24), and the final output result is shown in formula (25). Here, LayerNorm represents layer normalization, which can stabilize the training process; F... final This represents a 512-dimensional universal feature vector that encodes robust spectral features across devices and species; F final Indicated by F final The output matrix is composed of (a), a = 1, 2, ..., 512.
[0122]
[0123] By using a deep fully connected neural network to extract the spectral features of the Raman spectral data, key spectral features can be extracted, and data preparation is provided for the subsequent use of contrastive learning.
[0124] (2) Adversarial transfer learning. The process of adversarial transfer learning includes: The core objective of adversarial transfer learning proposed in this embodiment is to solve the problem of spectral data distribution shift from laboratory environment to clinical scenario, and to realize data transfer from high-quality labeled laboratory data to complex clinical testing tasks. Traditional models, after being trained under single equipment and fixed conditions in the laboratory, often experience a significant performance decline due to differences in equipment parameters, dynamic characteristics of bacterial metabolism, and interference from mixed samples in clinical data.
[0125] Furthermore, the process of eliminating distributional differences between devices and obtaining Raman spectral feature vectors using adversarial transfer learning includes: performing cross-domain comparative learning on the spectral features of the Raman spectral data; generating cross-device consistent features through device simulation enhancement to form positive sample pairs; randomly sampling from the spectral data of different bacterial species to form negative sample pairs; maximizing the similarity of positive sample pairs using the InfoNCE loss function; and generating domain-invariant features through domain adversarial training, ultimately obtaining the Raman spectral feature vectors optimized by adversarial transfer learning. To this end, adversarial transfer learning achieves cross-domain generalization capability through the following mechanisms:
[0126] First, the data input is And add domain tag information, the specific representation of which is shown in formulas (26) and (27). Where, d (N) =0 indicates the domain label for laboratory equipment, d (N) =1 indicates the domain label for clinical devices.
[0127]
[0128] Secondly, cross-domain comparative learning is achieved through the construction of positive samples and the screening of negative samples. This involves applying device simulation enhancements to the same spectrum to generate cross-device consistent features, and randomly sampling from the spectra of different bacterial species to expand the feature discrimination boundary. For each original spectral sample... Enhanced versions were generated through device simulation. and Positive sample pairs are constructed, and the input feature matrix is expanded as shown in formula (28). The positive sample pairs have identical labels, i.e., (N,a) and (N,b) belong to the same original sample N, used to maximize similarity within the same class. Negative sample pairs are formed by randomly sampling from the spectra of different bacterial species or different devices. If the total number of samples is N, M non-similar samples are randomly selected, and the negative sample feature matrix is shown in formula (29). Here, j≠k, and (j,M) and (k,M) represent negative samples from different bacterial species.
[0129]
[0130] Since the domain labels of positive and negative sample pairs must be consistent with the original data, a domain label vector d is defined. aug Specifically, as shown in formula (30).
[0131]
[0132] Then, the InfoNCE loss function is used to maximize the similarity of positive sample pairs, which is used to evaluate the contrastive direction of different Raman spectral data. The calculation of the loss function is shown in formula (31). This represents two enhanced versions of the same Raman spectrum in the i-th positive sample, and the feature vectors extracted by DNN; represents the feature vector of the k-th negative sample, specifically referring to the spectrum from different bacterial species; s(·) represents the cosine similarity function, used to measure the similarity between two feature vectors; τ represents the temperature coefficient, which controls the smoothness of the similarity distribution and is used to enhance the ability to distinguish difficult samples; N represents the number of samples in the current training batch; B=2N+M means that the current training batch contains 2N positive samples and M negative samples.
[0133]
[0134] Finally, through domain adversarial training, the feature extractor is forced to generate device-independent domain-invariant features, aligning the feature distributions of different classes. Specifically, the domain classifier first predicts the input features from laboratory data, then a gradient inversion layer multiplies the gradient of the domain classifier by a negative coefficient -λ, forcing the feature extractor to generate domain-invariant features. Finally, a loss function eliminates device differences, causing the spectral feature distributions from the laboratory and clinical testing to overlap. The total loss function is calculated as shown in formulas (32) and (33). Where d i This represents the domain label of the i-th augmented sample, and d in formula (30) aug Consistent Indicates the probability of the predicted domain; The cross-entropy loss of the main task is used to measure the difference between the predicted result and the true label, and its calculation is based on all samples B. The binary cross-entropy loss, representing the domain classification, measures whether the features generated by the feature extractor can be distinguished as laboratory data or clinical data. Its calculation is based only on positive sample pairs. γ represents the weight coefficient of the domain adversarial loss, which is determined through cross-validation.
[0135]
[0136] Finally, the domain-invariant feature matrix output after adversarial transfer learning optimization is shown in Equation (34).
[0137]
[0138] By using adversarial transfer learning, we can obtain the same or similar chemical composition analysis from different collection devices and different bacterial species, thereby improving the accuracy of bacterial chemical composition analysis and preparing for further model training.
[0139] (3) Nonlinear dimensionality reduction based on domain-aware UMAP: targeting Raman spectral feature vectors To address the high dimensionality and cross-domain heterogeneity of the model, this invention proposes an improved domain-aware UMAP (Uniform Manifold Approximation and Projection) dimensionality reduction strategy. This strategy preserves key discriminative information through nonlinear mapping while forcing feature distribution alignment across devices and bacterial species, significantly reducing computational complexity and improving model generalization ability.
[0140] Further, the process of nonlinearly reducing the Raman spectral eigenvectors to obtain the reduced low-dimensional eigenma matrix includes: mapping high-dimensional eigenvectors in the Raman spectral eigenvectors to a low-dimensional space through nonlinear mapping while retaining key discriminant information, resulting in a preliminary reduced-dimensional eigenma matrix; minimizing the difference between the high-dimensional and low-dimensional manifold structures to ensure consistency of the preliminary reduced-dimensional eigenma matrix across different devices and strains, resulting in a consistency-optimized eigenma matrix; based on the consistency-optimized eigenma matrix, introducing a maximum mean difference constraint in the UMAP optimization objective to force the low-dimensional feature distributions of different domains to align, resulting in an aligned low-dimensional eigenma matrix; determining the target dimensionality for dimensionality reduction based on the requirements of cross-domain consistency and discriminant retention, and then reducing the aligned low-dimensional eigenma matrix based on the target dimensionality to obtain the reduced low-dimensional eigenma matrix. The specific dimensionality reduction steps are as follows:
[0141] First, as shown in formula (35), F is the total input dataset. Based on the number of devices used, M = 6 categories, the number of bacterial species, K = 30 species, and the number of experimental conditions, P = 5, the dimension of the input features is determined to be 512. By satisfying cross-domain consistency, discriminative preservation, and real-time performance, that is, ensuring that the cosine similarity of the same bacterial species features of different devices in the low-dimensional space is >0.85, the classification accuracy loss after dimensionality reduction is ≤1.5%, and the dimensionality reduction time per sample is <0.5ms, the final target dimension of dimensionality reduction is determined to be 64.
[0142]
[0143] Secondly, by utilizing cross-domain similarity metrics, a domain-aware distance matrix D is defined. cross Combining spectral feature similarity with differences in equipment / strain labels, matrix D cross The calculation formula is shown in formula (36), where I domain (i,j) represents the domain difference indicator function, specifically, if samples i and j come from different devices or strains, the value is 1, otherwise it is 0; λ is the tradeoff coefficient, which obtains its optimal value through grid search optimization.
[0144]
[0145] Then, low-dimensional embedding is performed using UMAP, and a dimensionality reduction loss function is defined by minimizing the difference between the high-dimensional and low-dimensional manifold structures. The calculation process is shown in formula (37), and the dimensionality reduction mapping is solved. Where w ij q represents the similarity weights in high-dimensional space; ij This represents the similarity weight in the low-dimensional space.
[0146]
[0147] Finally, by introducing the maximum mean difference (MMD) constraint into the UMAP optimization objective, the low-dimensional feature distributions of different domains are forced to align. The calculation formula of the maximum mean difference constraint is shown in formula (38), where φ(·) represents the Gaussian kernel function. Represents the regenerated nucleus Hilbert space; respectively correspond to d in formula (27) (N) =0 and d (N) =1 indicates the dimensionality reduction features of laboratory spectral data and clinical spectral data.
[0148]
[0149] Finally, the low-dimensional feature matrix after dimensionality reduction is obtained. Its specific content is shown in formula (39).
[0150]
[0151] By combining domain-aware distance modeling with MMD joint optimization, the distribution offset problem of traditional dimensionality reduction methods in cross-device and cross-species scenarios is solved. At the same time, it maintains high discriminability, improves inference speed, and meets the real-time clinical needs.
[0152] Step 3: Based on the reduced-dimensional feature matrix, a small-sample fine-tuning strategy using dynamic domain adaptation and meta-learning is adopted to obtain the optimized model.
[0153] Furthermore, based on the dimensionality-reduced low-dimensional feature matrix, a small-sample fine-tuning strategy using dynamic domain adaptation and meta-learning fine-tuning is employed to obtain the optimized model. The process includes: applying a dynamic adaptation network to the dimensionality-reduced low-dimensional feature matrix for online distribution alignment and dynamic parameter adjustment to obtain the adapted feature matrix; and then processing the adapted feature matrix using a meta-learning fine-tuning strategy based on the MAML framework to obtain the optimized model. The specific implementation process includes:
[0154] Dynamic Domain Adaptation and Few-Sample Fine-Tuning: Due to significant differences in hardware parameters among different Raman spectrometers, the spectra of the same chemical component exhibit wavenumber shifts and intensity distribution differences on different devices. Traditional static models experience a sharp drop in generalization performance across devices, and labeled data for rare clinical bacterial species or newly emerging drug-resistant strains is scarce. Traditional methods require repeated labeling of data for each device, which is costly. Therefore, a strategy of dynamic domain adaptation and few-sample fine-tuning can be used to improve the model's cross-device generalization ability and reduce the need for retraining with large amounts of labeled data, achieving rapid training. The specific process is as follows:
[0155] (1) Dynamic Adaptation Network: First, the dynamic adaptation network solves the problem of Raman spectral data distribution differences across devices and scenarios through online distribution alignment and dynamic parameter adjustment. Specifically, it dynamically adjusts the input features of the Raman spectral data through a dynamic adaptation layer. The mapping method is shown in formula (40), where Z represents the input features, specifically the global spectral features extracted by the DNN; W a α represents the learnable weight matrix of the adaptation layer, used to dynamically adjust the feature mapping relationship; α represents the dynamic scaling coefficient. ReLU represents the activation function, used to enhance non-linear expressive power.
[0156] Z adapted =Z+α·ReLU(W a ·Z) (40)
[0157] Then, the distribution difference measure is used to quantify inter-domain differences and trigger parameter updates to adapt to the data distribution in the laboratory. The formula for calculating MMD is shown in Equation (41). Where MMD represents the maximum mean difference; φ(·) represents the kernel function used to map features to a high-dimensional space; Let represent the feature vectors of the i-th data point from the laboratory and the j-th data point from the clinical setting, respectively. Since the laboratory and clinical labels are inherited from formula (30), d... aug ∈{0,1} 2N Then N s N t These represent the sample sizes of laboratory data and clinical data, respectively, as shown in formulas (42) and (43). Represents the regenerated nucleus Hilbert space.
[0158]
[0159] The adapted feature matrix The specific expression is shown in formula (44).
[0160]
[0161] The dynamic adaptation network systematically addresses the limitations of traditional methods in Raman spectroscopy analysis, which rely on fixed feature extraction strategies and cannot adapt to wavelength shifts or baseline drift across different devices, by adjusting parameters in real time and aligning with cross-domain features. Furthermore, it achieves real-time measurement of distribution differences between devices through the maximum mean difference, enabling adjustment of the dynamic adaptation layer parameters and resolving distribution shifts caused by device differences. The specific processing steps of the dynamic adaptation network are as follows: Figure 5 As shown.
[0162] (2) Based on the MAML (Model-Agnostic Meta-Learning) framework, the core objective of meta-learning fine-tuning is to learn a general model initialization parameter θ through meta-training. This allows for rapid fine-tuning of a high-performance model with only a small number of labeled samples when faced with sampling results from new devices or rare bacterial species. This is a good model for handling low-concentration or uncommon samples. The specific processing flow is as follows:
[0163] First, it is necessary to construct tasks for meta-learning, for each task... For a new strain of bacteria or a new device scenario, it includes support for set S i (representing the i-th support set) and query set Q i (representing the i-th query set), its specific expression is shown in formulas (45) and (46). Where, S i There are K labeled samples used for task-specific fine-tuning; Q i There are Q labeled samples used to evaluate generalization performance.
[0164]
[0165] From Z adapted Laboratory data and clinical data were divided according to the domain labels of formula (30), and multiple task groups were constructed by random sampling.
[0166] First, a meta-training mechanism needs to be constructed to adapt to any new bacterial species through a small number of gradient updates. This involves task-specific fine-tuning via an inner loop and updating meta-parameters via an outer loop, thereby processing the spectral dataset. This is based on the support set. The formula for updating model parameter θ and based on the query set The loss is calculated by optimizing the initial parameter θ, as shown in formulas (47) and (48). Let α and β represent the inner and outer loop learning rates for each task. Represents the loss function on the support set and query set; θ′ i This represents the update parameter for the i-th process.
[0167]
[0168] Then, after establishing the basic framework for meta-training, meta-testing is needed to quickly fine-tune the data samples, specifically for small amounts of labeled data from new clinical devices or rare bacterial species. The model is adapted through single-step gradient updates. The specific details of the small amount of labeled data and the outer loop update are shown in formulas (49) and (50). Where θ target This indicates the parameters after adaptation to clinical data; This represents the loss function for the clinical data support set.
[0169]
[0170] By optimizing the initial parameters θ through meta-training, multi-task generalization can be achieved with only a small amount of sample data, significantly reducing annotation costs. It also demonstrates strong generalization ability across devices and bacterial species, achieving faster processing even when annotating rare clinical bacterial species or new devices. The meta-learning θ update process based on the MAML framework is as follows: Figure 6 As shown.
[0171] Step 4: Based on the optimized model, output the chemical component category determination and concentration prediction results. The specific implementation process includes:
[0172] Multi-task output and visualization: In Raman spectroscopy, the position of characteristic peaks indicates the category of chemical components, and the intensity is directly related to the concentration. Traditional separate processing severs this natural correlation, leading to insufficient information utilization. Furthermore, clinical testing requires simultaneous output of category and concentration information; traditional sequential processes are time-consuming and prone to error accumulation. To address this issue, multi-task output allows for the sharing of feature extraction layers, complementary optimization of classification and regression tasks to reduce error accumulation, and dynamic adjustment of key spectral region weights based on attention mechanisms, thus enhancing the processing of sensitive data. The specific processing flow is as follows:
[0173] (1) Multi-task output
[0174] 1) Classification Task Output: First, a Softmax classifier is used to output the probability distribution of chemical component categories, thereby determining the distribution of chemical components in the bacterial strain. Among these, This represents the classification weight matrix, used to associate feature vectors with categories; represents the classification bias term; K represents the number of tasks in each category. The formula for calculating the classification probability is shown in formula (51).
[0175]
[0176] 2) Regression Task Output. Next, quantile regression is used to output the predicted concentration value and its confidence interval. The regression layer contains three output nodes, corresponding to the 10%, 50%, and 90% quantiles of the concentration value, respectively. Furthermore, quantile loss is used to enhance robustness to concentration outliers. The regression calculation expressions are shown in formulas (52) and (53). Represents the regression weight matrix; ρ represents the regression bias term; q This represents the quantile loss function, used to enhance robustness to outliers.
[0177]
[0178] 3) Multi-task collaborative mechanism. Finally, a multi-head self-attention mechanism is introduced in the feature fusion stage to dynamically allocate feature weights for classification and regression tasks. Wherein, g task represents the gate weight vector, generated by the Sigmoid function; ⊙ represents element-wise multiplication, suppressing irrelevant feature channels. The expression for gate calculation is shown in formula (54).
[0179] Z task =Z adapted ⊙g task ,g task =σ(W gate ·Z adapted (54)
[0180] Ultimately, the classification and regression results are output as a probability matrix of chemical component categories. and The concentration quantile prediction matrix is expressed in the form of formulas (55) and (56).
[0181]
[0182] The multi-task collaborative output architecture enables simultaneous determination of chemical component categories and quantitative analysis of concentrations, and its design takes into account both the integrity and efficiency requirements of clinical testing.
[0183] (2) UMAP Dimensionality Reduction and Visualization: Although high-dimensional features extracted by deep transfer learning models have strong representational capabilities, their physical meaning and discriminative logic are often obscured. By using domain-aware UMAP dimensionality reduction projection and attention weight heatmaps, abstract features can be mapped to a low-dimensional space, and key wavenumber regions (such as 1630-1660 cm⁻¹ for β-lactam compounds) can be labeled. -1 (interval), the specific dimensionality reduction expression is shown in formula (57).
[0184]
[0185] As a specific implementation method in this embodiment, during the model training and optimization phase, multi-source data from six mainstream Raman spectrometers, including Thermo Fisher, Bruker, and CloudMinds, were systematically integrated, covering 30 common clinical pathogens such as Staphylococcus aureus and Escherichia coli. Spectral data from complex experimental environments with mixed bacterial strains, different culture conditions, and concentration gradients were also collected to construct a highly generalizable training database. Data preprocessing employed adaptive Savitzky-Golay filtering to dynamically fit the baseline and eliminate fluorescence background noise. Dynamic time warping (DTW) technology was used to non-linearly align the wavenumber shifts of different devices, controlling the wavelength calibration error within ±2 cm⁻¹. -1Within this scope, ensure the reliability of standardized data input.
[0186] To further enhance the model's robustness to noise interference, device differences, and dynamic bacterial metabolism, Gaussian noise injection simulates low signal-to-noise ratio scenarios, random wavenumber shift covers the device wavelength drift range, intensity dynamic scaling adapts to concentration gradient changes, and generative adversarial networks simulate baseline features across multiple devices, constructing a physical mechanism-driven augmented dataset. The model architecture is based on a deep transfer learning framework, employing a residual fully connected network and a multi-head self-attention mechanism to extract cross-domain robust features. Adversarial transfer learning eliminates distribution differences between devices, and a meta-learning strategy (MAML) is introduced to enable rapid small-sample fine-tuning for new devices or rare bacterial species. A multi-task collaborative output layer synchronously optimizes chemical component classification and concentration quantile regression, combined with domain-aware UMAP dimensionality reduction to visualize key discriminant features, significantly improving the model's parsing efficiency for high-dimensional heterogeneous data. Experimental results show that this method improves classification accuracy and regression fit by more than 15% in complex biological samples compared to traditional methods, reduces detection time from 30 minutes to seconds, and demonstrates excellent robustness in clinical drug resistance phenotype discrimination and low-concentration drug monitoring, providing an efficient solution for precision medicine and real-time monitoring. The final results are presented as follows Figure 7 As shown.
[0187] The above are merely preferred embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A cross-domain method for analyzing the chemical composition of bacteria using Raman spectroscopy based on deep transfer learning, characterized in that, Includes the following steps: Multi-source Raman spectral data are acquired and preprocessed to obtain preprocessed spectral data. A deep transfer learning model is constructed. The deep transfer learning model extracts the spectral features of the preprocessed spectral data through a deep fully connected neural network and a multi-head self-attention mechanism, and uses adversarial transfer learning to eliminate the distribution differences between devices to obtain Raman spectral feature vectors. The Raman spectrum feature vectors are subjected to nonlinear dimensionality reduction to obtain a low-dimensional feature matrix. The process of extracting spectral features from the preprocessed spectral data includes: inputting the preprocessed spectral data into a deep fully connected neural network, extracting preliminary feature representations of the spectral data through multiple fully connected layers; simultaneously introducing residual connections into the deep fully connected neural network to preserve local detail information of the original spectral data; processing the preliminary feature representations using a multi-head self-attention mechanism to dynamically focus on key discrimination spectral regions, obtain spectral feature peaks and suppress noise interference, and obtaining a multi-head splicing output; and processing the multi-head splicing output through layer normalization to output the spectral features of the Raman spectral data. The process of eliminating distribution differences between devices and obtaining Raman spectral feature vectors by using adversarial transfer learning includes: performing cross-domain comparative learning on the spectral features of the Raman spectral data, generating cross-device consistency features through device simulation enhancement to form positive sample pairs; randomly sampling from the spectral data of different bacterial species to form negative sample pairs; maximizing the similarity of positive sample pairs using the InfoNCE loss function, and generating domain-invariant features through domain adversarial training, finally obtaining the Raman spectral feature vectors optimized by adversarial transfer learning. The process of performing nonlinear dimensionality reduction on the Raman spectral feature vectors to obtain a lower-dimensional feature matrix includes: mapping high-dimensional feature vectors in the Raman spectral feature vectors to a lower-dimensional space through nonlinear mapping while retaining key discriminant information, resulting in a preliminary dimensionality-reduced feature matrix; ensuring consistency of the preliminary dimensionality-reduced feature matrix across different devices and strains by minimizing the difference between the high-dimensional and low-dimensional manifold structures, resulting in a consistency-optimized feature matrix; introducing a maximum mean difference constraint in the UMAP optimization objective based on the consistency-optimized feature matrix to force the low-dimensional feature distributions of different domains to align, resulting in an aligned low-dimensional feature matrix; determining the target dimensionality reduction dimension based on the requirements of cross-domain consistency and discriminant retention, and performing dimensionality reduction on the aligned low-dimensional feature matrix based on the target dimensionality reduction dimension to obtain the lower-dimensional feature matrix. Based on the reduced-dimensional feature matrix, a small-sample fine-tuning strategy using dynamic domain adaptation and meta-learning is employed to obtain an optimized model. The process includes: applying a dynamic adaptation network to the reduced-dimensional feature matrix for online distribution alignment and dynamic parameter adjustment to obtain an adapted feature matrix; and applying a meta-learning fine-tuning strategy based on the MAML framework to the adapted feature matrix to obtain an optimized model. Based on the optimized model, the chemical component category determination and concentration prediction results are output. The method also includes a process of visualizing the extracted high-dimensional features, specifically including: performing dimensionality reduction on the Raman spectral feature vector using the domain-aware UMAP method to obtain a low-dimensional feature matrix for visualization; drawing an attention weight heatmap based on the low-dimensional feature matrix for visualization and marking key wavenumber regions; and combining the low-dimensional feature matrix for visualization with the attention weight heatmap to generate a visualization result for analyzing and interpreting the model's discrimination logic.
2. The cross-domain analysis method for bacterial Raman spectroscopy chemical composition based on deep transfer learning according to claim 1, characterized in that, The process of preprocessing the multi-source Raman spectral data to obtain preprocessed spectral data includes: The adaptive Savitzky-Golay filtering algorithm is used to perform local polynomial fitting on multi-source Raman spectral data and dynamically subtract fluorescence background noise to obtain the baseline-corrected spectral dataset. Based on the baseline-corrected spectral dataset, the wavenumber axis of the spectral data from different devices is nonlinearly aligned using dynamic time warping technology to eliminate peak shifts caused by differences in device parameters; the peak-shifted spectral data from multiple sources are uniformly mapped to the reference wavenumber axis to construct a standardized dataset. The standardized dataset is augmented to obtain an augmented spectral dataset; Preprocessed spectral data is constructed based on the enhanced spectral dataset.
3. The cross-domain analysis method for bacterial Raman spectroscopy chemical composition based on deep transfer learning according to claim 2, characterized in that, The process of performing data augmentation on the standardized dataset to obtain the augmented spectral dataset includes: Zero-mean Gaussian noise is applied to the standardized dataset to obtain noise-enhanced spectral data; A random translation perturbation is applied to the wavenumber axis of the noise-enhanced spectral data to obtain wavenumber-perturbed spectral data; The intensity of the wavenumber-perturbed spectral data is nonlinearly scaled to obtain intensity-adjusted spectral data. Based on a baseline feature library collected from multiple devices, a generative adversarial network is used to fit the fluorescence background patterns of different devices, and the fluorescence background patterns of different devices are superimposed on the intensity-adjusted spectral data to obtain an enhanced spectral dataset.
4. The method for cross-domain analysis of bacterial Raman spectroscopy chemical composition based on deep transfer learning according to claim 1, characterized in that, The process of outputting chemical component category determination and concentration prediction results based on the optimized model includes: The optimized model is input with the adapted feature matrix, and a Softmax classifier is used for classification to obtain the probability distribution of chemical component categories. The optimized model is input with the adapted feature matrix, and quantile regression is used for regression processing to obtain the concentration prediction value and its confidence interval. The probability distribution, concentration prediction, and confidence interval of the chemical component categories are integrated to output the final chemical component category determination and concentration prediction results.
Citation Information
Patent Citations
Raman spectrum classification method based on self-attention mechanism
CN115130566A