Bacterial Raman spectrum chemical component cross-domain analysis method based on deep transfer learning

Through the deep transfer learning method, the problem of spectral data distribution changes caused by equipment differences and environmental complexity in the detection of complex biochemical samples using traditional Raman spectroscopy analysis technology has been solved. This has achieved fast and accurate chemical composition analysis and concentration prediction, improved detection efficiency and accuracy, and is suitable for complex sample detection across devices and environments.

CN120673875AActive Publication Date: 2025-09-19XUZHOU MEDICAL UNIVERSITY

Patent Information

Application Number
CN202510736273.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-04
Publication Date
2025-09-19
Estimated Expiration
2045-06-04

AI Technical Summary

Technical Problem

Traditional Raman spectroscopy analysis technology has problems with spectral data distribution changes caused by equipment differences, bacterial diversity and experimental environment complexity in the detection of complex biochemical samples, making it difficult to achieve fast and accurate chemical composition analysis and concentration prediction, especially when the generalization performance across devices and environments is significantly reduced.

Method used

A method based on deep transfer learning is adopted to construct a deep transfer learning model through multi-source data collection and preprocessing. A deep fully connected neural network and a multi-head self-attention mechanism are used to extract spectral features. Adversarial transfer learning is combined to eliminate distribution differences between devices. Small sample fine-tuning is achieved through nonlinear dimensionality reduction, dynamic domain adaptation and meta-learning fine-tuning strategies to output chemical component category determination and concentration prediction results.

Benefits of technology

The model's adaptability and detection efficiency for complex biological samples have been significantly improved, as have the accuracy and generalization capabilities of detection. It can quickly and accurately output chemical component classification and concentration prediction results under different environments and equipment, and is suitable for rapid detection and real-time monitoring of complex samples.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120673875A_ABST
    Figure CN120673875A_ABST
Patent Text Reader

Abstract

The invention discloses a bacteria Raman spectrum chemical component cross-domain analysis method based on deep transfer learning, and belongs to the field of Raman spectrum intelligent analysis, the method comprises the following steps: collecting multi-source Raman spectrum data, and pre-processing the multi-source Raman spectrum data to obtain pre-processed spectrum data; constructing a deep transfer learning model, extracting spectral features of the preprocessed spectral data by the deep transfer learning model through a deep full-connection neural network and a multi-head self-attention mechanism, and eliminating distribution difference between devices by using adversarial transfer learning to obtain a Raman spectrum feature vector; performing nonlinear dimension reduction on the Raman spectrum feature vector to obtain a dimension-reduced low-dimensional feature matrix; based on the dimensionality-reduced low-dimensional feature matrix, a dynamic field adaptation and meta-learning fine tuning strategy is adopted to realize small sample fine tuning, and an optimized model is obtained; and outputting chemical component category judgment and concentration prediction results based on the optimized model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of Raman spectroscopy intelligent detection, and in particular relates to a cross-domain analysis method of bacterial Raman spectroscopy chemical components based on deep transfer learning. Background Art

[0002] Traditional Raman spectroscopy analysis technology has long relied on feature selection models driven by manual experience. Its core methods (such as peak matching and semi-quantitative integration) face fundamental bottlenecks in the detection of complex biochemical samples. In the analysis of bacterial chemical components, due to the diversity of microbial metabolites, Raman spectra often show densely overlapping characteristic peak signals, such as β-lactam compounds at 1630-1660 cm -1 The highly overlapping vibration peaks in the range require manual analysis that relies on expert experience and repeated comparisons with the reference spectral library, and is prone to misjudgment due to subjective judgment bias. In addition, when detecting low-concentration chemical components, the imbalance in the signal-to-noise ratio between the fluorescence background noise and the target signal (the misjudgment rate exceeds 40% when the signal-to-noise ratio is <5) further limits the reliability of detection. The operational process of single-sample analysis takes more than 30 minutes, making it difficult for this technology to meet the needs of scenarios with strict timeliness requirements, such as real-time environmental monitoring.

[0003] Dynamic peak shift (±15cm) caused by bacterial metabolic activity -1 Fluctuations in the spectral distribution (e.g., fluctuations in the spectral distribution) and concentration gradients across different growth cycles (logarithmic phase / stationary phase) 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 within fixed wavenumber intervals, failing to adaptively capture the time-varying characteristics of bacterial chemical composition. This significantly reduces the model's generalization performance across devices, samples, and experimental environments.

[0004] Deep transfer learning, an innovative machine learning approach, can apply knowledge learned in one field to another related field, thereby improving the learning efficiency and effectiveness of new tasks. Therefore, to address the above issues, this paper proposes a cross-domain analysis method for bacterial Raman spectroscopy chemical composition based on a deep transfer learning framework. Summary of the Invention

[0005] In order to solve the above technical problems, the present invention proposes a cross-domain analysis method of bacterial Raman spectroscopy chemical composition based on deep transfer learning to solve the problems existing in the above-mentioned prior art.

[0006] To achieve the above objectives, the present invention provides a cross-domain analysis method for bacterial Raman spectroscopy chemical composition based on deep transfer learning, comprising:

[0007] Collecting multi-source Raman spectral data and preprocessing the multi-source Raman spectral data to obtain preprocessed spectral data;

[0008] Constructing a deep transfer learning model that extracts spectral features from the preprocessed spectral data using a deep fully connected neural network and a multi-head self-attention mechanism, and using adversarial transfer learning to eliminate distribution differences between devices to obtain a Raman spectral feature vector; performing nonlinear dimensionality reduction on the Raman spectral feature vector to obtain a low-dimensional feature matrix after dimensionality reduction;

[0009] Based on the low-dimensional feature matrix after dimensionality reduction, dynamic domain adaptation and meta-learning fine-tuning strategies are used to implement small sample fine-tuning to obtain an optimized model;

[0010] The optimized model outputs chemical component classification and concentration prediction results.

[0011] Optionally, the process of preprocessing the multi-source Raman spectral data to obtain preprocessed spectral data includes:

[0012] Based on the adaptive Savitzky-Golay filtering algorithm, local polynomial fitting is performed on the multi-source Raman spectral data to dynamically subtract the fluorescence background noise and obtain the baseline-corrected spectral data set.

[0013] Based on the baseline-corrected spectral dataset, the spectral data from different devices are nonlinearly aligned on the wavenumber axis using dynamic time warping technology to eliminate spectral peak shifts caused by device parameter differences; the spectral data from multiple source devices with eliminated spectral peak shifts are uniformly mapped to the reference wavenumber axis to construct a standardized dataset;

[0014] performing data enhancement processing on the standardized data set to obtain an enhanced spectral data set;

[0015] Preprocessed spectral data is constructed based on the enhanced spectral dataset.

[0016] Optionally, the process of performing data enhancement processing on the standardized data set to obtain an enhanced spectral data set includes:

[0017] applying zero-mean Gaussian noise to the standardized data set to obtain noise-enhanced spectral data;

[0018] Applying random translation perturbation to the wavenumber axis of the noise-enhanced spectral data to obtain wavenumber-perturbed spectral data;

[0019] performing nonlinear scaling on the intensity of the spectral data after the wavenumber disturbance to obtain intensity-adjusted spectral data;

[0020] Based on the baseline feature library collected by multi-source devices, the fluorescence background patterns of different devices are fitted by a generative adversarial network, 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 of the preprocessed spectral data by using a deep fully connected neural network and a multi-head self-attention mechanism includes:

[0022] 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; and introducing residual connections into the deep fully connected neural network to retain local detail information of the original spectral data;

[0023] The preliminary feature representation is processed using a multi-head self-attention mechanism, dynamically focusing on key discriminant spectral regions, obtaining spectral characteristic peaks and suppressing noise interference to obtain a multi-head splicing output;

[0024] The multi-head splicing output is subjected to layer normalization processing to output the spectral features of Raman spectral data.

[0025] Optionally, adversarial transfer learning is used to eliminate distribution differences between devices, and the process of obtaining a Raman spectrum feature vector includes:

[0026] Performing cross-domain comparative learning on the spectral features of the Raman spectral data, generating cross-device consistency features through device simulation enhancement, and forming positive sample pairs;

[0027] Randomly sample from the spectral data of different bacterial species to form negative sample pairs;

[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, and 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 spectrum feature vector to obtain a low-dimensional feature matrix after dimensionality reduction includes:

[0030] The high-dimensional feature vectors in the Raman spectrum feature vector are mapped to a low-dimensional space through nonlinear mapping while retaining key discriminant information to obtain a feature matrix after preliminary dimensionality reduction.

[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, and a feature matrix with optimized consistency is obtained.

[0032] Based on the feature matrix after consistency optimization, a maximum mean difference constraint is introduced into the UMAP optimization objective to force the low-dimensional feature distributions of different domains to be aligned, thereby obtaining an aligned low-dimensional feature matrix;

[0033] The target dimension number of dimensionality reduction is determined according to the requirements of cross-domain consistency and discriminability retention, and the aligned low-dimensional feature matrix is ​​reduced in dimension based on the target dimension number to obtain a reduced low-dimensional feature matrix.

[0034] Optionally, based on the low-dimensional feature matrix after dimensionality reduction, a dynamic domain adaptation and meta-learning fine-tuning strategy is used to implement small sample fine-tuning to obtain an optimized model, which includes:

[0035] Performing online distribution alignment and dynamic parameter adjustment on the low-dimensional feature matrix after dimensionality reduction using a dynamic adaptation network to obtain an adapted feature matrix;

[0036] The adapted feature matrix is ​​processed using a meta-learning fine-tuning strategy based on the MAML framework to obtain an optimized model.

[0037] Optionally, the process of outputting chemical component classification determination and concentration prediction results based on the optimized model includes:

[0038] Inputting the adapted feature matrix into the optimized model, performing classification processing using a Softmax classifier, and obtaining a probability distribution of chemical component categories;

[0039] The adapted feature matrix is ​​input into the optimized model, and quantile regression is used to perform regression processing to obtain a concentration prediction value and a confidence interval thereof;

[0040] The probability distribution of the chemical component category and the concentration prediction value and its confidence interval 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] Performing dimensionality reduction processing on the Raman spectrum feature vector using a domain-aware UMAP method to obtain a low-dimensional feature matrix for visualization;

[0043] Based on the low-dimensional feature matrix used for visualization, draw an attention weight heat map and mark the key wave number areas;

[0044] The low-dimensional feature matrix used for visualization is combined with the attention weight heat map to generate a visualization result for analyzing and explaining the discriminant logic of the model.

[0045] Compared with the prior art, the present invention has the following advantages and technical effects:

[0046] The cross-domain analysis method of bacterial Raman spectroscopy chemical components based on deep transfer learning of the present invention effectively solves the problem of spectral data distribution changes caused by equipment differences, bacterial species diversity and experimental environment complexity in traditional methods through multi-source data collection and preprocessing. This method uses 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 adaptability of the model to complex biological samples. Further, through nonlinear dimensionality reduction and dynamic domain adaptation and meta-learning fine-tuning strategies, the performance prediction of small data samples of new samples in different environments and different devices is realized, greatly improving the detection efficiency and accuracy. Compared with traditional methods, the present invention can not only quickly and accurately output chemical component category determination and concentration prediction results, but also has stronger generalization ability and robustness, and is particularly suitable for rapid detection and real-time monitoring of complex samples. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] The accompanying drawings, which constitute part of this application, are intended to provide a further understanding of this application. The exemplary embodiments and descriptions of this application are intended to explain this application and do not constitute an improper limitation on this application. In the accompanying drawings:

[0048] Figure 1 This is the overall process of the cross-domain analysis method of bacterial Raman spectroscopy chemical composition based on deep transfer learning in an embodiment of the present 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 the specific processing flow of the residual fully connected network layer and skip connection in the embodiment of the present invention;

[0051] Figure 4 This is the specific processing flow of the multi-head self-attention mechanism in an embodiment of the present invention;

[0052] Figure 5 This is the specific process of dynamically adapting the network according to the embodiment of the present invention;

[0053] Figure 6 This is the meta-learning θ update process based on the MAML framework in an embodiment of the present invention;

[0054] Figure 7 These are some results of the cross-domain analysis method of bacterial Raman spectroscopy chemical composition based on deep transfer learning in an embodiment of the present invention. DETAILED DESCRIPTION

[0055] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in this application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0056] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0057] Example 1

[0058] The overall process of the cross-domain analysis method and system of 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 the chemical composition of bacterial Raman spectra based on deep transfer learning, which aims to solve the problem of changes in spectral data distribution caused by equipment differences, bacterial species diversity and the complexity of the experimental environment in laboratory and clinical scenarios. Traditional methods are limited by the limitations of manual feature extraction and the insufficient nonlinear characterization capabilities of shallow models, and are difficult to cope with the challenges of cross-device spectral offsets, dynamic changes in bacterial species metabolism and low signal-to-noise ratio environments. This method constructs a feature extractor through deep transfer learning multi-source domain training, combines dynamic domain adaptation with meta-learning small sample fine-tuning strategies, significantly improves the adaptability of the model to complex biological samples, and has strong scalability. Through the research and development of this model, it is possible to achieve performance prediction of small data samples for new samples when they are collected from different environments and different equipment, providing an efficient solution for the rapid detection and real-time monitoring of complex clinical samples.

[0059] This method constructs a universal feature extractor through multi-source domain training, combining contrastive learning with domain adversarial training to eliminate device differences. It also introduces a dynamic adaptation network to align the target domain distribution in real time, and uses a meta-learning strategy to enable rapid small-sample fine-tuning for rare bacterial species. This technology overcomes the generalization bottleneck of traditional methods across devices, strains, and experimental environments, simultaneously optimizing chemical component classification and concentration prediction tasks, significantly improving detection efficiency and accuracy.

[0060] As a specific implementation of this embodiment, the following steps are included:

[0061] Step 1: Collect multi-source Raman spectral data and pre-process the multi-source Raman spectral data to obtain pre-processed spectral data; the specific implementation process is as follows:

[0062] Multi-source data acquisition: Traditional Raman spectroscopy data acquisition often relies on a single instrument to repeatedly collect a single type of bacteria to obtain laboratory data. This acquisition method has weak data generalization capabilities and requires repeated data annotation, making it difficult to form a relatively complete data set. To address the drawbacks of single-source acquisition, multi-source data acquisition can systematically integrate Raman spectroscopy data from different devices, diverse bacterial species, and complex experimental conditions to build a highly generalizable and robust training database. The multi-source nature of data can come from the following aspects:

[0063] (1) Differences in Raman spectrometers: Different Raman spectrometers can lead to significant differences in data acquisition performance. Mainstream Raman spectrometers include but are not limited to Thermo Fisher Scientific’s DXR3xi and iXR+, Dahua Technology’s HandyRaman-Pro and PortableRaman-2000, Bruker’s Senterra II and MultiRAM, and Renishaw’s inVia Qontor and Virsa. Raman spectrometers from different brands also have differences in device parameters, including laser wavelength, resolution, integration time, and power settings. Therefore, these factors need to be taken into account in the acquisition process to ensure the integrity of the original data.

[0064] (2) Diversity of bacterial species: The spectral data collected for different bacterial species may be significantly different. In order to ensure the stability of the spectral data after bacterial species collection and the full coverage of chemical composition diversity, multi-species coverage collection must be carried out. 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, Cryptococcus neoformans, etc., to ensure the complete coverage of the data set.

[0065] (3) Complexity of the experimental environment: Collection in a single experimental environment can easily lead to data that is too simple and not universal. Therefore, it is necessary to construct a complex experimental environment to ensure that the data covers clinical diversity. Complex experimental conditions include the collection of mixed strains, the collection of composite strains, and the collection under different culture conditions, growth cycles, and concentration gradients.

[0066] Furthermore, the multi-source Raman spectral data is preprocessed to obtain preprocessed spectral data, including: performing local polynomial fitting on the multi-source Raman spectral data based on an adaptive Savitzky-Golay filtering algorithm, dynamically subtracting fluorescence background noise, and obtaining a baseline-corrected spectral data set; based on the baseline-corrected spectral data set, performing nonlinear wavenumber axis alignment on spectral data from different devices through dynamic time warping technology to eliminate spectral peak shifts caused by differences in device parameters; uniformly mapping the spectral data with eliminated spectral peak shifts in multi-source devices to a reference wavenumber axis to construct a standardized data set; performing data enhancement processing on the standardized data set to obtain an enhanced spectral data set; and constructing preprocessed spectral data based on the enhanced spectral data set.

[0067] Data standardization: Raman spectral data is collected for different bacterial species under different conditions using different equipment, and the collected data are then standardized. The following describes the data standardization process using laboratory equipment 1 to collect spectra of bacterial samples produced under the same experimental conditions. After data collection, the data is processed to standardize it. The data standardization process primarily involves adaptive filtering and dynamic correction.

[0068] (1) Adaptive Savitzky-Golay filtering is used. The fluorescence background in the Raman spectrum can cause baseline drift, obscuring the true characteristic peak signal. Therefore, an adaptive Savitzky-Golay filtering algorithm can be used to dynamically correct the baseline through local polynomial fitting. The specific process of using adaptive filtering is as follows:

[0069] First, assume that the Raman spectrum data set collected by laboratory equipment 1 contains N samples, each sample consists of intensity values ​​of L wavenumber points, as shown in formula (1), Y1 is the total data set, Represents the original intensity value of the Nth sample at the Lth wavenumber point.

[0070]

[0071] Secondly, to prevent the baseline from being uneven due to local fitting, a sliding window is used to divide the spectrum into multiple local intervals, and polynomial fitting is performed independently in each window, thereby flexibly adapting to local changes in the baseline. fit (L) represents the baseline intensity of the Raman spectrum at wave number point L obtained by polynomial fitting; a m represents the polynomial coefficient, which is used to control the shape of the Raman spectrum fitting curve; k represents the order of the polynomial, which is used to control the complexity of the Raman spectrum fitting curve. The specific expression for fitting the original spectrum intensity using the polynomial is shown in formula (2).

[0072]

[0073] Then, use least squares optimization to obtain the optimal a m , by adjusting a m Minimize the sum of squared residuals between the fitted curve and the original Raman spectrum data. i, j represent the center position index of the current window and the index of the data point in the window respectively; Indicated by wave number point L i The residual square sum of the processing of the fitted polynomial curve and the original spectral intensity within the sliding window centered on is used to quantify the error of baseline fitting; W represents the wave number interval of the Raman spectral unit; b j ,c j They represent the wave value of the jth data point in the window and the original spectrum intensity of the jth data point in the window respectively. The process of minimizing the sum of squares of the residuals between the fitting curve and the original spectrum is shown in formula (3).

[0074]

[0075] Finally, the Raman spectrum intensity is calibrated by baseline subtraction to obtain the characteristic peak signal after removing the noise. corrected (L) represents the corrected spectral intensity, i.e., the pure characteristic peak signal after stripping the baseline; y raw (L) represents the original spectrum intensity, including baseline drift and characteristic peak signal; y baseline (L) represents low-frequency background interference. The process of removing noise and performing spectrum correction is shown in formula (4).

[0076] y corrected (L) = y raw (L)-y baseline (L) (4)

[0077] By matching mathematical variables with the specific wavenumber, intensity and characteristic peak of Raman spectrum, the core parameters of baseline correction W,k,a m The accurate modeling and stripping of the fluorescence background is achieved. Finally, the corrected spectral dataset Y is obtained. corrected This dataset serves as the reference spectrum for the DTW process described below, allowing for dynamic correction of spectral data collected by other devices and constructing the final standardized dataset. The corrected dataset is shown in Equation (5).

[0078]

[0079] (2) Use dynamic time warping (DTW) for dynamic correction. Since the laser wavelength calibration error, temperature drift or grating mechanical deviation of different spectrometers will cause the Raman peak position of the same chemical component to shift, directly inputting the model may lead to classification errors. Therefore, using DTW for nonlinear alignment of wavenumber axes can eliminate the systematic error between devices. Use laboratory device t to re-collect the spectrum of the bacterial sample collected by laboratory device 1 and use it as the target spectrum data set Y t , then DTW can be used for spectral processing. The specific process of using DTW is as follows:

[0080] First, suppose that the target spectrum data set collected by the t-th device in the laboratory contains N samples, and each sample consists of the intensity values ​​of L wavenumber points, as shown in formula (6), Y t is the data set composed of the t-th device, Represents the original intensity value of the Nth sample at the Lth wavenumber point.

[0081]

[0082] Secondly, the difference between the reference spectrum and the target spectrum at each wavenumber point is quantified to provide a basis for alignment. D(p,q) represents the reference spectrum wavenumber point L p With the target spectral wave number point L q The square of the Euclidean distance reflects the intensity difference between the two points; ref (L p ) represents the intensity value of the reference spectrum at wavenumber; y target (L q ) indicates the target spectrum at wave number L q 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, using the optimal path search, dynamic planning can be used to find the alignment path with the minimum cumulative cost. The calculation of the minimum cumulative cost is shown in formula (8). Here, Cost(p,q) represents the minimum cumulative cost from the starting point to the point (p,q); D(p,q) represents the distance value of the current point; min{} represents the minimum cumulative cost from the previous position to ensure global optimization.

[0085]

[0086] Finally, the target spectrum wavenumber axis is adjusted according to the optimal path and aligned with the reference spectrum using wavenumber remapping. The wavenumber intensity value after alignment is calculated as shown in formula (9). target (L q ) indicates the target spectrum at wave number L q The intensity value at y aligned (L p ) indicates that the target spectrum after alignment is at the reference wave number point L p The intensity value at ; P represents the optimal path set, which contains all aligned wavenumber point pairs (p, q).

[0087] y aligned (L p )=y target (L q )where (p,q)∈P (9)

[0088] Finally, a spectrally normalized dataset is obtained through DTW This dataset consists of the target spectral data of the tth device after alignment. The dataset of all aligned target spectral data is shown in formula (10). is the data set after the t-th device is aligned with the wave number point, represents the corrected intensity value of the Nth sample at the Lth wavenumber point.

[0089]

[0090] Using the above DTW data dynamic correction process, a standardized data set can be constructed for different devices for the same strain and the same experimental environment. Wavelength alignment systematically addresses the wavenumber inconsistencies in Raman spectroscopy data caused by device variations by quantifying differences using a distance matrix, searching for optimal paths using dynamic programming, and correcting for offsets using wavenumber remapping. This process not only improves data quality but also provides standardized input for model generalization across devices and scenarios.

[0091] Data enhancement: Raman spectral data are easily affected by environmental noise, equipment parameter fluctuations and the dynamic characteristics of bacterial metabolism during the acquisition process, resulting in problems such as uneven sample distribution and feature offset between devices in the original data set. The traditional spectral acquisition mode with a single device or fixed conditions is difficult to cover the complexity of real scenes, and it is easy for the model to fall into local overfitting, limiting the cross-domain generalization ability. To this end, the present invention proposes a hybrid data enhancement strategy guided by physical mechanisms. Through spectral morphological perturbations and equipment difference simulations, the diversity of training data is systematically expanded, and the robustness of the model to noise interference, wavenumber offset and intensity fluctuations is improved.

[0092] Furthermore, the process of performing data enhancement processing on the standardized data set to obtain an enhanced spectral data set includes: applying zero-mean Gaussian noise to the standardized data set 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; based on a baseline characteristic library collected by multi-source devices, fitting the fluorescence background patterns of different devices by generating an adversarial network, and superimposing the fluorescence background patterns of different devices on the intensity-adjusted spectral data to obtain an enhanced spectral data set.

[0093] The specific enhancement methods are as follows:

[0094] (1) Gaussian noise injection. First, to simulate the fluorescence background interference in low signal-to-noise ratio scenarios, the standardized data set Zero-mean Gaussian noise is applied to the spectral intensity in 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 actual detection scene. The noise injection method is shown in formula (11). aligned (L) represents the intensity value after correction at the Lth wave number point; y a (L) represents the Raman spectrum intensity injected with Gaussian noise; σ 2 Represents the noise variance; ∈ means that the mean is 0 and the variance is σ 2 Gaussian distributed random noise.

[0095]

[0096] (2) Random wavenumber shift. Secondly, random translation perturbation is applied to the spectral wavenumber axis to obtain the spectral data after wavenumber perturbation in order to address the peak shift caused by the equipment wavelength calibration error or temperature drift. Let the corrected wavenumber sequence be {L1, L2, ..., L n ,n=0,1,2,...}, the enhanced wave number sequence is {L1+Δ,L2+Δ,…,L n +Δ,n=0,1,2,...}, where Δ is a uniformly distributed random displacement used to simulate cross-device wavenumber offsets. This random displacement forces the model to learn discriminative features that are insensitive to spectral peak position.

[0097] (3) Dynamic intensity scaling. Then, in order 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). Where α represents the interval weight coefficient, and the spectral bands are divided by sliding windows and the scaling factors are independently sampled to simulate the dynamic intensity distribution caused by the growth cycle of the bacterial strain or changes in experimental conditions; Represents a uniformly distributed random scaling factor to simulate the growth cycle of bacterial strains or changes in experimental conditions.

[0098]

[0099] (4) Device baseline simulation. Finally, based on the baseline feature library collected by multi-source devices, the fluorescence background patterns of different devices are fitted by generative adversarial networks and superimposed on the pure spectral signal. The enhanced spectral intensity is shown in formula (13). 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 real device baseline, improving the model's adaptability to cross-device baseline drift.

[0100]

[0101] Finally, the enhanced spectral dataset was constructed by spectrally enhancing the standardized dataset. The specific expression is shown in formula (14). It represents the enhanced intensity value of the Nth sample at the Lth wave number point.

[0102]

[0103] The above enhancement strategy effectively expands the diversity and complexity of training data by combining physical mechanism-driven and data-driven approaches, providing data preparation for the subsequent use of deep transfer learning.

[0104] Step 2: Build a deep transfer learning model. 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 the Raman spectrum feature vector; perform nonlinear dimensionality reduction on the Raman spectrum feature vector to obtain a low-dimensional feature matrix after dimensionality reduction. The specific implementation process includes:

[0105] Deep transfer sample training: Laboratory data covers a single culture condition, while clinical samples involve complex scenarios such as mixed flora and complex culture media. Through deep transfer learning, spectral data from multiple laboratory devices, multiple strains, and multiple environments are integrated to construct a highly generalized feature space, allowing the model to be directly transferred to the analysis of complex clinical samples without retraining. Among them, deep transfer learning includes the construction of a deep fully connected neural network (DNN), the use of cross-domain adversarial transfer learning, and the nonlinear dimensionality reduction of domain-aware UMAP. The process of deep transfer learning is as follows: Figure 2 shown.

[0106] (1) Deep feature extractor design. The process of deep feature extractor design includes: Raman spectral data often leads to peak position shift and intensity fluctuation due to device differences and bacterial metabolic diversity. Traditional single-device training models are difficult to generalize, and cross-domain robust features need to be constructed. To this end, the present invention adopts a deep fully connected neural network, through residual connections and attention mechanisms, to solve the stability problem of feature extraction in high-noise environments.

[0107] Furthermore, the process of extracting spectral features of pre-processed spectral data through a deep fully connected neural network and a multi-head self-attention mechanism includes: inputting the pre-processed spectral data into a deep fully connected neural network, extracting preliminary feature representations of the spectral data through multiple fully connected layers; at the same time, introducing residual connections in the deep fully connected neural network to retain local detail information of the original spectral data; using a multi-head self-attention mechanism to process the preliminary feature representation, dynamically focusing on key discriminant spectral regions, obtaining spectral feature peaks and suppressing noise interference to obtain 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 specific processing flow is as follows:

[0108] First, after normalizing and enhancing the Raman spectral data, the Raman spectral dataset is obtained. Among them, y L represents the spectral intensity value at wave number point L; L represents the number of wave number points covered by the spectrum, reflecting the spectral resolution. The definition of the input matrix is ​​shown in formula (15).

[0109]

[0110] Then, a three-layer full connection is established through a single residual block structure to better obtain the chemical composition information corresponding to the spectral data. At the same time, the skip connection X proj Alleviate the gradient vanishing problem, retain the local details of the original spectrum, and avoid information loss in deep networks. The specific processing flow using the residual fully connected network layer and skip connection is as follows: Figure 3As shown. Among them, F1, F2, F3 represent the first, second and third layers of full connection; W1, W2, W3 represent weight matrices; b1, b2, b3 represent bias vectors; Swish (z) = z·σ (z) represents the activation function, where z represents the input; σ (z) represents the Sigmoid function, which is used to enhance nonlinear expression capabilities; X proj Represents the linear projection of the input X, which is used to ensure dimension matching. The expressions of the residual fully connected network layer and the skip connection are shown in formulas (16)(17)(18)(19)(20), and the preliminary feature representation F of the spectral data is obtained. 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, in order to dynamically focus on the key discriminant spectral region, obtain the spectral characteristic peaks, and suppress noise interference, a multi-head self-attention mechanism is introduced to process the preliminary feature representation so that the model can focus on the features of different spectral regions in parallel. The specific processing flow of the multi-head self-attention mechanism is as follows: Figure 4 The single-head attention calculation is shown in formula (21), where Q, K, V represent query, key, and value respectively; W Q ,W K ,W V Represents the learnable projection matrix. The attention weight is calculated as shown in formula (22), where Represents the scaling factor, which is used to prevent the dot product value from being too large and causing gradient instability. The multi-head splicing output is shown in formula (23), where h represents the number of heads; W O Represents 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] The attention weight is calculated through the attention weight matrix Softmax(·). Weakening irrelevant areas can retain key signals in the spectral feature peaks. Contact(·) represents splicing, which is used to merge multi-head information and improve the model's expressiveness.

[0121] Finally, after processing by a deep fully connected neural network and a multi-head self-attention mechanism, a 512-dimensional general feature vector is output. The calculation formula of the multi-head self-attention is shown in formula (24), and the final data output result is shown in formula (25). Among them, LayerNorm represents layer normalization, which can stabilize the training process; F final represents a 512-dimensional universal feature vector, encoding the robust spectral features across devices and strains; F final Indicated by F final (a), the output matrix composed of a=1,2,…,512.

[0122]

[0123] By using a deep fully connected neural network to deeply extract the spectral data, the spectral features of the Raman spectral data can be obtained. The key spectral feature data can be extracted and the data is prepared for the following contrastive learning.

[0124] (2) Adversarial transfer learning. The process of adversarial transfer learning includes: The core goal of adversarial transfer learning proposed in this embodiment is to solve the problem of spectral data distribution deviation from laboratory environments to clinical scenarios, and to achieve data migration from high-quality laboratory labeled data to complex clinical testing tasks. After traditional models are trained on a single device under fixed conditions in the laboratory, their performance often degrades significantly due to differences in equipment parameters in clinical data, the dynamic metabolic characteristics of bacterial strains, and interference from mixed samples.

[0125] Furthermore, adversarial transfer learning is used to eliminate distribution differences between devices and obtain the Raman spectral feature vector. The process includes: cross-domain comparative learning of the spectral features of 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; using the InfoNCE loss function to maximize the similarity of positive sample pairs, and generating domain-invariant features through domain adversarial training, and finally obtaining the Raman spectral feature vector optimized by adversarial transfer learning. To this end, adversarial transfer learning achieves cross-domain generalization capabilities through the following mechanisms:

[0126] First, the data input is And add domain label information, the specific representation is shown in formula (26) (27). (N) =0 indicates the field label of laboratory equipment, d (N) =1 indicates the domain label of clinical equipment.

[0127]

[0128] Secondly, cross-domain comparative learning is formed by constructing positive samples and screening negative samples, that is, applying device simulation enhancement to the same spectrum to generate cross-device consistency features, and randomly sampling from spectra of different strains to expand the feature discrimination boundary. Generate two enhanced versions through device simulation enhancement and To form a positive sample pair, the input feature matrix is ​​expanded as shown in formula (28). The labels of the positive sample pairs are consistent, that is, (N, a) and (N, b) belong to the same original sample N, which is used to maximize the similarity of the same type. Random sampling is performed from spectra of different bacterial species or different devices to form negative sample pairs. 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). Where j ≠ k, (j, M) and (k, M) represent negative samples from different bacterial species.

[0129]

[0130] Since the domain labels of the positive and negative sample pairs must be consistent with the original data, the domain label vector d is defined aug , as shown in formula (30).

[0131]

[0132] Then, the InfoNCE loss function is used to maximize the similarity of positive sample pairs and to evaluate the contrast of different Raman spectral data. The loss function is calculated as shown in formula (31). Represents two enhanced versions of the same Raman spectrum in the i-th positive sample and the feature vector extracted by DNN; represents the eigenvector of the kth negative sample, specifically the spectra from different bacterial species; s(·) represents the cosine similarity function, which is used to measure the similarity between two eigenvectors; τ 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 and align the feature distributions of different classes. That is, the domain classifier is first used to predict the input features from the laboratory data, and then the gradient of the domain classifier is multiplied by the negative coefficient -λ through the gradient reversal layer, forcing the feature extractor to generate domain-invariant features. Finally, the loss function is used to eliminate device differences, so that the spectral feature distributions from the laboratory and the clinical test overlap. The calculation of the total loss function is shown in formulas (32)(33). Where, d i represents the domain label of the i-th enhanced sample, which is the same as d in formula (30) aug Consistent, represents the probability of the predicted domain; Represents the cross entropy loss of the main task, which is used to measure the difference between the predicted result and the true label. It is calculated based on all samples B; represents the binary cross entropy loss for domain classification, which is used to measure 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 by cross-validation.

[0135]

[0136] Finally, the domain-invariant feature matrix output after adversarial transfer learning optimization is shown in formula (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 strains, thereby improving the accuracy of the chemical composition analysis of the bacterial strains and providing preparation for further model training.

[0139] (3) Nonlinear dimensionality reduction based on domain-aware UMAP: for Raman spectral feature vectors In order to solve the high dimensionality and cross-domain heterogeneity of the proposed method, this paper proposes an improved domain-aware UMAP (Uniform Manifold Approximation and Projection) dimensionality reduction strategy, which retains key discriminant information through nonlinear mapping and forces the alignment of feature distributions across devices and strains, significantly reducing the computational complexity and improving the generalization ability of the model.

[0140] Furthermore, the Raman spectrum feature vector is subjected to nonlinear dimensionality reduction to obtain a low-dimensional feature matrix after dimensionality reduction. The process includes: mapping the high-dimensional feature vector in the Raman spectrum feature vector to a low-dimensional space through nonlinear mapping while retaining key discriminant information to obtain a feature matrix after preliminary dimensionality reduction; minimizing the difference between the high-dimensional and low-dimensional manifold structures to ensure that the feature matrix after preliminary dimensionality reduction is consistent between different devices and strains, and obtaining a feature matrix after consistency optimization; based on the feature matrix after consistency optimization, introducing the maximum mean difference constraint in the UMAP optimization objective to force the alignment of low-dimensional feature distributions in different domains to obtain an aligned low-dimensional feature matrix; determining the target dimension number of dimensionality reduction according to the requirements of cross-domain consistency and discriminability retention, and reducing the aligned low-dimensional feature matrix based on the target dimension number of dimensionality reduction to obtain a low-dimensional feature matrix after dimensionality reduction. The following are the specific dimensionality reduction steps:

[0141] First, as shown in formula (35), F is the total input data set. The dimension of the input feature is determined to be 512 based on the number of devices used M = 6, the type of bacterial species K = 30, and the multiple experimental conditions P = 5. The final target dimension of dimensionality reduction is determined to be 64 by meeting the requirements of cross-domain consistency, discriminability retention, and real-time performance, that is, ensuring that the cosine similarity of the characteristics of similar bacterial species from different devices in the low-dimensional space is greater than 0.85, the classification accuracy loss after dimensionality reduction is ≤1.5%, and the single-sample dimensionality reduction time is less than 0.5ms.

[0142]

[0143] Secondly, using the cross-domain similarity metric, we define the domain-aware distance matrix D cross , combining the similarity of spectral features with the differences in device / strain labels, the matrix D cross The calculation formula is shown in formula (36), where I domain (i, j) represents the domain difference indicator function, which means that if samples i and j come from different devices or strains, the value is 1, otherwise it is 0; λ is the trade-off coefficient, and its optimal value is obtained through grid search optimization.

[0144]

[0145] Then, low-dimensional embedding is performed through UMAP, and the 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 dimension reduction mapping is solved to where w ij Represents the similarity weight of high-dimensional space; q ij Represents the similarity weight in 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 reproducing kernel Hilbert space; Corresponding to d in formula (27) (N) =0 and d (N) =1, indicating the features of laboratory spectral data and clinical spectral data after dimensionality reduction.

[0148]

[0149] Finally, the low-dimensional feature matrix after dimensionality reduction is obtained The specific content is shown in formula (39).

[0150]

[0151] Through domain-aware distance modeling and MMD joint optimization, the distribution offset problem of traditional dimensionality reduction methods in cross-device and cross-species scenarios is solved, while maintaining high discriminability, improving inference speed, and meeting clinical real-time requirements.

[0152] Step 3: Based on the low-dimensional feature matrix after dimensionality reduction, dynamic domain adaptation and meta-learning fine-tuning strategies are used to implement small sample fine-tuning to obtain the optimized model.

[0153] Furthermore, based on the low-dimensional feature matrix after dimensionality reduction, dynamic domain adaptation and meta-learning fine-tuning strategies are used to achieve small sample fine-tuning. The process of obtaining the optimized model includes: using a dynamic adaptation network to perform online distribution alignment and dynamic parameter adjustment on the low-dimensional feature matrix after dimensionality reduction to obtain the adapted feature matrix; and using a meta-learning fine-tuning strategy based on the MAML framework to process the adapted feature matrix to obtain the optimized model. The specific implementation process includes:

[0154] Dynamic domain adaptation and small sample fine-tuning: Due to the significant differences in hardware parameters of different Raman spectrometers, the spectra of the same chemical component show different wavenumber offsets and intensity distributions on different devices. The generalization performance of traditional static models drops sharply in cross-device scenarios, and the labeled data of 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. To this end, dynamic domain adaptation and small sample fine-tuning strategies can be used to improve the model's cross-device generalization ability and reduce the need for retraining with large amounts of labeled data, thereby achieving the goal of rapid training. The specific process is as follows:

[0155] (1) Dynamic Adaptive Network: First, the dynamic adaptive network solves the problem of cross-device and cross-scenario Raman spectral data distribution differences through online distribution alignment and dynamic parameter adjustment. Specifically, the dynamic adaptation layer dynamically adjusts the input features of Raman spectral data. The mapping method is shown in formula (40), where Z represents the input feature, specifically the global spectral feature extracted by the DNN; W a ReLU represents the adaptive layer's learnable weight matrix, which is used to dynamically adjust feature mapping relationships. α represents the dynamic scaling factor. ReLU represents the activation function, which is used to enhance nonlinear expression capabilities.

[0156] Z adapted =Z+α·ReLU(W a ·Z) (40)

[0157] Then, the distribution difference metric is used to quantify the difference between domains and trigger parameter updates to adapt to the data distribution of the laboratory. The calculation formula of MMD is shown in formula (41). Where MMD represents the maximum mean difference; φ(·) represents the kernel function used to map features to a high-dimensional space; Represent the feature vectors of the laboratory i-th data and clinical j-th data respectively. Since the laboratory and clinical labels are inherited from d in formula (30) aug ∈{0,1} 2N Then N s ,N t represent the sample sizes of laboratory data and clinical data, respectively, as shown in formulas (42)(43); represents the reproducing kernel Hilbert space.

[0158]

[0159] The adapted feature matrix The specific expression is shown in formula (44).

[0160]

[0161] The dynamic adaptive network systematically solves the limitation of traditional methods in Raman spectroscopy analysis, which rely on fixed feature extraction strategies and cannot adapt to wavelength offsets or baseline drifts of different devices, through real-time parameter adjustment and cross-domain feature alignment. In addition, the dynamic adaptation layer parameters are adjusted by measuring the distribution differences between devices in real time through the maximum mean difference, solving the distribution offset caused by device differences. The specific processing process of the dynamic adaptive network is as follows: Figure 5 shown.

[0162] (2) Based on the MAML (Model-Agnostic Meta-Learning) framework, the core goal of meta-learning fine-tuning is to learn a universal model initialization parameter θ through meta-training, so that when faced with new equipment sampling results or rare bacterial species data, only a small number of labeled samples are needed to quickly fine-tune a high-performance model. This is a good processing model for low-concentration samples or uncommon samples. The specific processing flow is as follows:

[0163] First, we need to construct tasks for meta-learning. For each task Corresponding to a new strain or new device scenario, including support set S i (denoting the i-th support set) and the query set Q i (represents the i-th query set), and its specific expression is shown in formula (45)(46). i There are K labeled samples for task-specific fine-tuning; Q i There are Q labeled samples for evaluating generalization performance.

[0164]

[0165] From Z adapted In the formula (30), laboratory data and clinical data are divided into two groups according to the domain labels, and multiple groups of tasks are constructed by random sampling.

[0166] First, we need to build a meta-training that can adapt to any new bacterial species through a small amount of gradient updates, perform task-specific fine-tuning through the inner loop, and update the meta-parameters through the outer loop to do some processing on the spectral dataset. The calculation formula for updating the model parameters θ and the query set The loss of θ is calculated by optimizing the initial parameter θ as shown in formula (47) (48). represents each task, α, β represent the inner and outer cycle learning rates, represents the loss function on the support set and query set; θ′ i represents the update parameters of the i-th process.

[0167]

[0168] Then, after building the basic framework of meta-training, it is necessary to quickly fine-tune the data samples through meta-testing, especially for small amounts of labeled data for new clinical devices or rare bacterial species. The model is adapted by single-step gradient update. The specific content of a small amount of labeled data and outer loop update is shown in formula (49) (50). target Represents the parameters after adaptation to clinical data; Denotes the loss function for the support set of clinical data.

[0169]

[0170] By using meta-training to optimize the initial parameters θ, we can adapt to multi-task generalization with only a small amount of sample data, significantly reduce the labeling cost, and have strong generalization capabilities across devices and strains. Even when facing clinical rare strains or new equipment labeling, we can achieve faster processing results. The meta-learning θ update process based on the MAML framework is as follows: Figure 6 shown.

[0171] Step 4: Output chemical component classification and concentration prediction results based on the optimized model. 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 separation processing will sever this natural association, resulting in insufficient information utilization. Clinical testing requires the simultaneous output of category and concentration information. The traditional serial process is time-consuming and prone to error accumulation. To address this problem, multi-task output can share the feature extraction layer, and the classification and regression tasks can be complementary and optimized to reduce error accumulation. The weights of key spectral regions can be dynamically adjusted according to the attention mechanism, which can also enhance the processing of sensitive data. The specific processing flow is as follows:

[0173] (1) Multi-task output

[0174] 1) Classification task output: First, the Softmax classifier is used to output the probability distribution of chemical component categories to determine the distribution of chemical components of the strain. Represents the classification weight matrix, which is used to associate feature vectors with categories; represents the classification bias term; K represents the number of tasks in the category. The calculation formula for classification probability is shown in formula (51).

[0175]

[0176] 2) Regression task output. Secondly, quantile regression is used to output the concentration prediction value and its confidence interval. Among them, the regression layer contains three output nodes, corresponding to the 10%, 50%, and 90% quantiles of the concentration value, and then the quantile loss is used to enhance the robustness to concentration outliers. The expression of the regression calculation is shown in formula (52)(53). Among them, represents the regression weight matrix; represents the regression bias term; ρ q Represents the quantile loss function, which is used to enhance the robustness to outliers.

[0177]

[0178] 3) Multi-task coordination mechanism. Finally, in the feature fusion stage, a multi-head self-attention mechanism is introduced to dynamically allocate the feature weights of the classification and regression tasks. task represents the gating weight vector, generated by the Sigmoid function; ⊙ represents element-wise multiplication, which suppresses irrelevant feature channels. The expression of the gating calculation is shown in formula (54).

[0179] Z task =Z adapted ⊙g task ,g task =σ(W gate ·Z adapted ) (54)

[0180] Finally, the output of the classification and regression results is the chemical composition category probability matrix and The concentration quantile prediction matrix is ​​specifically expressed as shown in formulas (55)(56).

[0181]

[0182] Chemical component classification and concentration quantitative analysis are achieved simultaneously through a multi-task collaborative output architecture, and its design takes into account the integrity and efficiency requirements of clinical testing.

[0183] (2) UMAP dimensionality reduction visualization: Although the high-dimensional features extracted by the deep transfer learning model have strong representation capabilities, their physical meaning and discrimination logic are often obscured. Through domain-aware UMAP dimensionality reduction projection and attention weight heat map, abstract features can be mapped to low-dimensional space and key wavenumber regions (such as 1630-1660 cm for β-lactam compounds) can be marked. -1 interval), the specific dimension reduction expression is shown in formula (57).

[0184]

[0185] As a specific implementation of this embodiment, during the model training and optimization phase, multi-source data from six mainstream Raman spectrometers such as Thermo Fisher, Bruker, and Dahua Technology were systematically integrated, covering 30 common clinical pathogens such as Staphylococcus aureus and Escherichia coli, and complex experimental environment spectral data under mixed strains, different culture conditions and concentration gradients were collected to build a highly generalizable training database. Data preprocessing uses adaptive Savitzky-Golay filtering to dynamically fit the baseline to eliminate fluorescence background noise, and combines dynamic time warping (DTW) technology to nonlinearly align the wavenumber offsets of different devices, controlling the wavelength calibration error to ±2cm. -1To ensure the reliability of data standardization input.

[0186] To further enhance the model's robustness to noise interference, device variability, and dynamic bacterial strain metabolism, Gaussian noise injection is used to simulate low signal-to-noise ratio scenarios, random wavenumber shifting is used to cover the wavelength drift range of the devices, and dynamic intensity scaling is used to adapt to concentration gradients. A generative adversarial network is used to simulate multi-device baseline characteristics, constructing a physically 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 robust cross-domain features. Adversarial transfer learning is used to eliminate inter-device distribution differences, and a meta-learning strategy (MAML) is introduced to enable rapid small-sample fine-tuning for new devices or rare bacterial strains. A multi-task collaborative output layer simultaneously optimizes chemical component classification and concentration quantile regression. Combined with domain-aware Unified Mapping (UMAP) dimensionality reduction to visualize key discriminant features, this significantly improves the model's efficiency in parsing high-dimensional, heterogeneous data. Experimental validation demonstrates that this method improves classification accuracy and regression fit by over 15% compared to traditional methods in complex biological samples, reducing detection time from 30 minutes to seconds. It demonstrates excellent robustness in clinical drug resistance phenotype identification and low-concentration drug monitoring, providing a highly effective solution for precision medicine and real-time monitoring. The final results are presented as follows Figure 7 shown.

[0187] The above are merely preferred embodiments of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.

Claims

1. A cross-domain analysis method for bacterial Raman spectroscopy chemical composition based on deep transfer learning, characterized by: The following steps are involved: Collecting multi-source Raman spectral data and preprocessing the multi-source Raman spectral data to obtain preprocessed spectral data; Constructing a deep transfer learning model that extracts spectral features from the preprocessed spectral data using a deep fully connected neural network and a multi-head self-attention mechanism, and using adversarial transfer learning to eliminate distribution differences between devices to obtain a Raman spectral feature vector; performing nonlinear dimensionality reduction on the Raman spectral feature vector to obtain a low-dimensional feature matrix after dimensionality reduction; Based on the low-dimensional feature matrix after dimensionality reduction, dynamic domain adaptation and meta-learning fine-tuning strategies are used to implement small sample fine-tuning to obtain an optimized model; The optimized model outputs chemical component classification and concentration prediction results.

2. The cross-domain analysis method of bacterial Raman spectroscopy chemical components based on deep transfer learning according to claim 1 is characterized in that: The process of preprocessing the multi-source Raman spectral data to obtain preprocessed spectral data includes: Based on the adaptive Savitzky-Golay filtering algorithm, local polynomial fitting is performed on the multi-source Raman spectral data to dynamically subtract the fluorescence background noise and obtain the baseline-corrected spectral data set. Based on the baseline-corrected spectral dataset, the spectral data from different devices are nonlinearly aligned on the wavenumber axis using dynamic time warping technology to eliminate spectral peak shifts caused by device parameter differences; the spectral data from multiple source devices with eliminated spectral peak shifts are uniformly mapped to the reference wavenumber axis to construct a standardized dataset; performing data enhancement processing on the standardized data set to obtain an enhanced spectral data set; Preprocessed spectral data is constructed based on the enhanced spectral dataset.

3. The cross-domain analysis method of bacterial Raman spectroscopy chemical components based on deep transfer learning according to claim 2 is characterized in that: The process of performing data enhancement processing on the standardized data set to obtain an enhanced spectral data set includes: applying zero-mean Gaussian noise to the standardized data set 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 spectral data after the wavenumber disturbance to obtain intensity-adjusted spectral data; Based on the baseline feature library collected by multi-source devices, the fluorescence background patterns of different devices are fitted by a generative adversarial network, and the fluorescence background patterns of different devices are superimposed on the intensity-adjusted spectral data to obtain an enhanced spectral dataset.

4. The cross-domain analysis method of bacterial Raman spectroscopy chemical components based on deep transfer learning according to claim 1 is characterized in that: The process of extracting the spectral features of the preprocessed spectral data by 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; and introducing residual connections into the deep fully connected neural network to retain local detail information of the original spectral data; The preliminary feature representation is processed using a multi-head self-attention mechanism, dynamically focusing on key discriminant spectral regions, obtaining spectral characteristic peaks and suppressing noise interference to obtain a multi-head splicing output; The multi-head splicing output is subjected to layer normalization processing to output the spectral features of Raman spectral data.

5. The cross-domain analysis method of bacterial Raman spectroscopy chemical components based on deep transfer learning according to claim 4 is characterized in that: The process of using adversarial transfer learning to eliminate distribution differences between devices and obtain Raman spectral feature vectors includes: Performing cross-domain comparative learning on the spectral features of the Raman spectral data, generating cross-device consistency features through device simulation enhancement, and forming positive sample pairs; Randomly sample from the spectral data of different bacterial species to form negative sample pairs; The InfoNCE loss function is used to maximize the similarity of positive sample pairs, and domain-invariant features are generated through domain adversarial training, and finally the Raman spectral feature vector optimized by adversarial transfer learning is obtained.

6. The cross-domain analysis method of bacterial Raman spectroscopy chemical components based on deep transfer learning according to claim 5 is characterized in that: The process of performing nonlinear dimensionality reduction on the Raman spectrum feature vector to obtain a low-dimensional feature matrix after dimensionality reduction includes: The high-dimensional feature vectors in the Raman spectrum feature vector are mapped to a low-dimensional space through nonlinear mapping while retaining key discriminant information to obtain a feature matrix after preliminary dimensionality reduction. 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, and a feature matrix with optimized consistency is obtained. Based on the feature matrix after consistency optimization, a maximum mean difference constraint is introduced into the UMAP optimization objective to force the low-dimensional feature distributions of different domains to be aligned, thereby obtaining an aligned low-dimensional feature matrix; The target dimension number of dimensionality reduction is determined according to the requirements of cross-domain consistency and discriminability retention, and the aligned low-dimensional feature matrix is ​​reduced in dimension based on the target dimension number to obtain a reduced low-dimensional feature matrix.

7. The cross-domain analysis method of bacterial Raman spectroscopy chemical components based on deep transfer learning according to claim 6 is characterized in that: Based on the low-dimensional feature matrix after dimensionality reduction, dynamic domain adaptation and meta-learning fine-tuning strategies are used to implement small sample fine-tuning. The process of obtaining the optimized model includes: Performing online distribution alignment and dynamic parameter adjustment on the low-dimensional feature matrix after dimensionality reduction using a dynamic adaptation network to obtain an adapted feature matrix; The adapted feature matrix is ​​processed using a meta-learning fine-tuning strategy based on the MAML framework to obtain an optimized model.

8. The cross-domain analysis method of bacterial Raman spectroscopy chemical components based on deep transfer learning according to claim 7 is characterized in that: The process of outputting chemical component classification determination and concentration prediction results based on the optimized model includes: Inputting the adapted feature matrix into the optimized model, performing classification processing using a Softmax classifier, and obtaining a probability distribution of chemical component categories; The adapted feature matrix is ​​input into the optimized model, and quantile regression is used to perform regression processing to obtain a concentration prediction value and a confidence interval thereof; The probability distribution of the chemical component category and the concentration prediction value and its confidence interval are integrated to output the final chemical component category determination and concentration prediction results.

9. The cross-domain analysis method of bacterial Raman spectroscopy chemical components based on deep transfer learning according to claim 7 is characterized in that: The method further includes a process of visualizing the extracted high-dimensional features, specifically comprising: Performing dimensionality reduction processing on the Raman spectrum feature vector using a domain-aware UMAP method to obtain a low-dimensional feature matrix for visualization; Based on the low-dimensional feature matrix used for visualization, draw an attention weight heat map and mark the key wave number areas; The low-dimensional feature matrix used for visualization is combined with the attention weight heat map to generate a visualization result for analyzing and explaining the discriminant logic of the model.

Citation Information

Patent Citations

  • Cross-instrument Raman spectrum qualitative analysis method based on transfer learning

    CN111523582A

  • Cross-scene remote sensing image depth adversarial transfer learning method based on double-channel attention mechanism

    CN114332649A

  • Raman spectrum classification method based on self-attention mechanism

    CN115130566A

  • Cross-tree-species near-infrared wood density determination method based on adversarial transfer learning

    CN116577241A

  • Microorganism Raman spectrum identification and classification method, electronic equipment and program product

    CN117851867A

Cited By

  • Intelligent urine component detection method based on spectrum identification and deep learning

    CN121190854A

  • Raman spectrum model migration transfer method based on standard substance

    CN121351933A

  • Ginseng-American ginseng multi-mode transfer learning identification method based on HyperspectraClassifier artificial intelligence deep learning model

    CN122200636A