Antibiotic identification method based on multi-source spectrum fusion and mixed attention mechanism
By combining multi-source spectral fusion and hybrid attention mechanism with deep learning and traditional methods, the problems of accuracy and speed in antibiotic identification in complex water environments were solved, and efficient antibiotic identification and monitoring were achieved.
Patent Information
- Application Number
- CN202510779153.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-12
- Publication Date
- 2025-09-23
AI Technical Summary
Existing technologies have difficulty in quickly and accurately identifying and distinguishing multiple antibiotics in complex water environments, especially when the spectral features are similar or there is background interference, which leads to misjudgment and identification difficulties.
Multi-source spectral fusion and hybrid attention mechanism are adopted to extract fluorescence and absorption spectral features through multi-scale deep convolutional neural network, and cross-attention and hybrid attention mechanisms are used for deep fusion and optimization, and finally combined with support vector machine for antibiotic identification.
The accuracy and robustness of antibiotic identification have been significantly improved, and it can effectively distinguish antibiotics with similar spectral characteristics in complex water environments, reduce misjudgments, and achieve rapid and real-time monitoring.
Smart Images

Figure CN120687899A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of water quality detection, and in particular to an antibiotic identification method based on multi-source spectral fusion and hybrid attention mechanism. Background Art
[0002] As a widely used drug, antibiotics will inevitably enter the water environment through sewage discharge during their production and use in the pharmaceutical, medical, animal husbandry and other industries.
[0003] Once antibiotics enter water bodies, their persistence, bioaccumulation, and potential toxicity can pose multiple risks, disrupting ecological balance and threatening human health and public health. Therefore, the rapid, accurate, and effective identification and monitoring of antibiotics in aquatic environments, particularly in pharmaceutical wastewater discharge, is a critical task in environmental protection. This is of vital strategic importance for controlling antibiotic pollution, safeguarding the ecological environment, and protecting human health.
[0004] Currently, the detection of antibiotics in water environments primarily relies on laboratory analysis, such as high-performance liquid chromatography-mass spectrometry and gas chromatography-mass spectrometry. While these methods are highly sensitive and accurate, they suffer from common shortcomings such as being time-consuming, labor-intensive, costly, and unable to provide rapid early warning.
[0005] Spectroscopic analysis technology, due to its rapidity, non-destructive nature, ease of use, and relatively low cost, holds great potential in environmental monitoring. Fluorescence spectroscopy and absorption spectroscopy are two commonly used molecular spectroscopy techniques. These techniques, respectively, reveal the molecular structure of a substance by detecting its luminescence properties upon excitation and its absorption properties at specific wavelengths. These techniques provide unique "fingerprints" for the rapid identification of antibiotics in aquatic environments.
[0006] However, the complexity of the aquatic environment, the potential for the coexistence of multiple antibiotics, and the close proximity of their spectral signatures (especially fluorescence and absorption peaks) due to the highly similar molecular structures of different antibiotics make it difficult to effectively distinguish and accurately identify trace antibiotics in water using only a single spectrum or traditional linear analysis methods, which can easily lead to confusion and misjudgment. Furthermore, spectral data is typically high-dimensional, containing a wealth of information accompanied by redundancy and noise. Efficiently extracting the most discriminative features from this complex data is a challenge facing spectral analysis in the field of environmental monitoring.
[0007] In recent years, deep learning technologies, such as convolutional neural networks, have demonstrated remarkable performance in processing high-dimensional data and automatically extracting features, achieving significant breakthroughs in image recognition and remote sensing image classification. However, effectively applying these advanced deep learning techniques, particularly multi-source data fusion and attention mechanisms, to the precise identification of antibiotic multidimensional spectral data, particularly for antibiotics with similar spectral characteristics in complex aquatic environments, remains a critical challenge. Summary of the Invention
[0008] To overcome the shortcomings of existing methods, this paper provides an antibiotic identification method based on multi-source spectral fusion and a hybrid attention mechanism. By integrating multi-source spectral data, extracting multi-scale deep features, and optimizing hybrid attention, this method significantly improves the accuracy and robustness of antibiotic identification in complex aquatic environments, effectively addressing the existing issues of poor differentiation between similar antibiotics and susceptibility to background interference. This method is suitable for monitoring antibiotic contamination in ambient water at pharmaceutical factory wastewater outfalls, providing technical support for water pollution prevention and control.
[0009] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0010] An antibiotic identification method based on multi-source spectral fusion and hybrid attention mechanism, the method comprising the following steps:
[0011] Step 1: preprocessing the collected fluorescence spectrum and absorption spectrum data;
[0012] Step 2: A multi-scale two-dimensional convolutional neural network (M2DCNN) is used to extract features from the fluorescence spectrum, while a multi-scale one-dimensional convolutional neural network (M1DCNN) is used to extract features from the absorption spectrum.
[0013] Step 3: The extracted fluorescence spectrum features and absorption spectrum features are deeply fused through the cross-attention mechanism;
[0014] Step 4: Apply the channel-space hybrid attention mechanism to optimize the fused features to generate the feature vector of the antibiotics;
[0015] In step 5, the feature vector is input into the support vector machine (SVM) classifier to identify the antibiotic category.
[0016] Furthermore, in step 1, the collected three-dimensional fluorescence spectrum data is converted into a two-dimensional image format to obtain a pre-processed fluorescence spectrum image I F , convert the two-dimensional absorption spectrum data into one-dimensional sequence data, and obtain the pre-processed absorption spectrum sequence S A .
[0017] Furthermore, in step 2, the fluorescence spectrum image I F and absorption spectrum sequence S A After using the multi-scale 2D Convolutional Neural Network (M2DCNN) and the multi-scale 1D Convolutional Neural Network (M1DCNN) to extract multi-scale features in parallel, the feature maps and feature sequences of different scales are concatenated to obtain the fused feature tensor F. F,concat and F A,concat , the features obtained are fluorescence spectrum features F F and absorption spectrum characteristics F A :
[0018] F F =M2DCNN(F F,concat ) (1)
[0019] F A =M1DCNN(S A,concat ) (2)
[0020] Furthermore, in step 3, the extracted fluorescence spectrum feature F F and absorption spectrum characteristics F A After the cross attention mechanism, it is fused into F fusion .
[0021] In order to perform cross attention calculation, we first need to transform F F and F A Convert to Query(Q),Key(K),Value(V) vectors that are more suitable for attention mechanism. This is usually achieved by flattening and linear projection (full connection). Assume that F F Flattened and projected into query Q∈R N×D k , F A After flattening, the projection is the key K∈R N×D k Sum value V∈R N×D v Here N is the length of the flattened feature sequence, D k , D v are the embedding dimensions for key / query and value respectively.
[0022] Q=Linear Q (Flatten(F F )) (3)
[0023] K=LinearK (Flatten(F A )) (4)
[0024] V=Linear V (Flatten(F A )) (5)
[0025] Among them, Flatten(.) represents the flattening operation, Linear X (.) represents linear projection (fully connected layer). The fused feature F fusion Calculated by the following formula:
[0026]
[0027] Among them, Q, K, V are query, key and value matrices respectively, K T is the transpose of K, D k is the dimension of the key vector, and the Softmax function is used to normalize the attention scores into a probability distribution.
[0028] In step 4, F fusion Perform global average pooling (AvgPool) and global maximum pooling (MaxPool), and then send it to a shared multi-layer perceptron (MLP) network, and then add the output of the MLP and generate the channel attention weight M through the Sigmoid activation function c (F fusion ):
[0029] M c (F fusion )=σ(MLP(AvgPool(F fusion ))+MLP(MaxPool(F fusion ))) (7)
[0030] Among them, MLP(.) represents a multi-layer perceptron network, σ(.) represents the Sigmoid activation function, M c (F fusion ) is the channel attention weight.
[0031] F fusion Average pooling (AvgPool_c) and maximum pooling (MaxPool_c) are performed along the channel dimension, and after splicing on the channel dimension, a convolution layer and Sigmoid function are used to generate a spatial attention map M. s (F fusion ):
[0032] M s (F fusion)=σ(Conv(Concat(AvgPool_c(F fusion ))),MaxPool_c(F fusion ))) (8)
[0033] Among them, Concat(.,.) is the concatenation operation, Conv(.) is the convolution operation, σ(.) represents the Sigmoid activation function, M s (F fusion ) represents the spatial attention weight generated by the spatial attention module.
[0034] The final optimized feature F optimized is the fusion feature F fusion After channel attention weight M c (F fusion ) and spatial attention weight M s (F fusion ) is obtained by weighting each element. The weight is automatically expanded to the same value as F through the broadcast mechanism. fusion Multiplication is performed on the same dimension.
[0035]
[0036] in, represents element-wise multiplication, F optimized represents the final feature tensor after spatial-spectral hybrid attention optimization. Here, M c (F fusion )’s channel weights are applied to F through a broadcast mechanism fusion At all spatial positions, M s (F fusion )’s spatial weights are applied via a broadcast mechanism F fusion on all channels.
[0037] In step 5, the optimized feature F optimized Vector conversion to f anti , and input into SVM classifier to identify antibiotic type y pred .
[0038] y pred =SVM(FullyConnected(Flatten(GlobalAvgPool(F optimized )))) (10)
[0039] Here, GlobalAvgPool(.) represents average pooling in the spatial dimension, which is then flattened into a one-dimensional vector by Flatten(.) and sent to the fully connected layer FullyConnected(.). SVM(.) represents the input of the SVM classifier.
[0040] Preferably, in step 4, the shared multi-layer perceptron network (MLP) includes 2 layers, and in the spatial attention mechanism, the convolution layer used to generate the spatial attention map uses a convolution kernel of size 7×7.
[0041] The technical concept of this invention is as follows: Deep fusion of multimodal spectral data and parallel feature extraction: This invention innovatively combines fluorescence and absorption spectral data and utilizes a dual-channel, multi-scale deep convolutional network to extract features in parallel, comprehensively capturing discriminative information about antibiotics. Adaptive optimization of fusion and attention mechanisms: This method achieves deep fusion of the two spectral features through a cross-attention mechanism and adaptively optimizes weights in conjunction with spatial-spectral hybrid attention, significantly enhancing the model's ability to identify key information.
[0042] The beneficial effects of the present invention are as follows:
[0043] 1. High-Precision Identification and Strong Differentiation: By leveraging the powerful nonlinear feature learning capabilities of deep learning, combined with the deep fusion of two complementary information sources, fluorescence and absorption spectra, this method can comprehensively and accurately capture the fingerprint characteristics of antibiotics in aquatic environments. Antibiotic feature vectors optimized through a hybrid attention mechanism are rich in highly abstract and discriminative information, effectively enhancing the model's ability to distinguish antibiotics with similar spectral features and close peaks, avoiding the confusion often associated with traditional methods.
[0044] 2. Robustness and Interference Resistance: By integrating information from different spectral modalities, the model leverages information redundancy and complementarity to effectively address interference from environmental factors such as water background, suspended solids, and organic matter, thereby improving the model's robustness in complex water environments. Furthermore, by combining deep learning feature extraction with the traditional SVM classifier, the SVM's advantages in handling high-dimensional features and nonlinear separability are fully utilized, further enhancing the model's interference resistance and generalization capabilities.
[0045] 3. Potential for rapid real-time monitoring: The essence of spectral analysis is rapid, non-destructive measurement. Combined with the fast reasoning capabilities of deep learning feature extraction models and the efficiency of SVM classification, this invention is expected to achieve rapid, even real-time, monitoring of antibiotics in water environments, providing timely data support for water pollution warning and emergency response, overcoming the time-consuming drawbacks of traditional methods. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 It is the overall flow chart of the present invention.
[0047] Figure 2 This is the internal structure diagram of the fluorescence spectrum feature extraction module.
[0048] Figure 3This is the internal structure diagram of the absorption spectrum feature extraction module.
[0049] Figure 4 Internal structure diagram of the feature fusion module and the channel-spatial hybrid attention optimization module. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the specific embodiments of the present invention are described in detail below with reference to the accompanying drawings. The specific embodiments of the present invention are not intended to limit the present invention, but to explain the present invention.
[0051] Reference Figures 1 to 4 , an antibiotic recognition method based on multi-source spectral fusion and hybrid attention mechanism, the method comprising the following steps:
[0052] Step 1: Dataset construction, preprocessing the collected fluorescence spectrum and absorption spectrum data;
[0053] Prepare a solution sample containing several known single antibiotics (e.g., cephalosporins, penicillins, tetracyclines, macrolides, fluoroquinolones, etc., with each antibiotic as a class representing a single pollutant that may be present in water). These samples can be simulated in the laboratory.
[0054] In order to improve the generalization and anti-interference ability of the model, an appropriate amount of simulated river water can be added to the data set.
[0055] A sufficient number of samples were collected to ensure that each antibiotic class contained a rich sample and covered possible concentration changes and environmental factors. The obtained data was divided into a training set (about 80%), a validation set (about 10%), and a test set (about 10%). The raw fluorescence spectrum data and absorption spectrum data were preprocessed to obtain the fluorescence spectrum image I F and absorption spectrum sequence S A .
[0056] Step 2, multi-scale feature extraction, uses a multi-scale two-dimensional convolutional neural network (M2DCNN) to extract features from the fluorescence spectrum, and a multi-scale one-dimensional convolutional neural network (M1DCNN) to extract features from the absorption spectrum. The process is as follows:
[0057] 2.1) Fluorescence spectral feature extraction module (M2DCNN):
[0058] This module uses the pre-processed fluorescence spectrum image I F As input, the deep spatial-spectral features F are extracted through the multi-scale two-dimensional convolutional neural network (M2DCNN) FAmong them, the preprocessed fluorescence spectrum image is to convert the three-dimensional fluorescence spectrum data into a two-dimensional image format, with the excitation wavelength and emission wavelength as the two spatial dimensions of the image and the fluorescence intensity as the pixel value.
[0059] Input preprocessed fluorescence spectrum image Among them H F , W F are the height and width of the preprocessed image respectively. M2DCNN contains P parallel convolution branches, each branch uses convolution kernels of different sizes to capture local features of different scales. For the p-th branch (p = 1, ..., P), its core operation is two-dimensional convolution, and the output of each branch is a feature map tensor
[0060]
[0061] in, is the pixel value of the convolutional layer output feature map of the p-th branch at the i-th row, j-th column, and k-th output channel, where i, j, and k represent the height, width, and channel index of the output feature map, respectively. in is the input of the current branch, K h ,K w is the height and width of the convolution kernel of the p-th branch, C in is the number of channels of the input feature map, S h ,S w are the steps of the p-th branch convolution operation in the height direction and width direction, m, n are the relative coordinate indexes in the height and width directions inside the convolution kernel, c is the input channel index, W m,n,c,k and B k are the convolution kernel weight and bias of the p-th branch respectively, and RELU(x)=max(0,x) is the activation function.
[0062] The output feature maps O of all P branches (1) ,O (2) ,…,O (p) First, it is adjusted to a unified spatial dimension and then concatenated in the channel dimension to form a comprehensive multi-scale feature tensor F F,concat The concatenated features are further extracted through additional convolutional layers, pooling layers, and activation functions to generate the fluorescence spectrum feature F. F .
[0063] F F,concat =Concat( (1) ,O (2) ,...,O (P) ) (12)
[0064] F F=M2DCNN(F F,concat ) (1)
[0065] Among them, M2DCNN represents the processing layer at the end of the module, and the final fluorescence spectrum feature is F F ∈R H’×W’×C F ,H',W',C F F F The height, width, and number of channels.
[0066] 2.2) Absorption spectrum feature extraction module (M1DCNN);
[0067] This module takes the preprocessed absorption spectrum sequence S A As input, the deep spectral feature F is extracted through the multi-scale one-dimensional convolutional neural network (M1DCNN) A Among them, the absorption spectrum sequence after preprocessing is the conversion of two-dimensional absorption spectrum data into one-dimensional sequence data, with wavelength as the index of the sequence and absorbance as the value of the sequence.
[0068] Input the preprocessed absorption spectrum sequence S A ∈R W A Among them, W A Is the wavelength dimension or length of the received spectrum sequence. M1DCNN contains Q parallel convolution branches. For the qth branch (q = 1, ..., Q), the output of each branch is a feature sequence tensor
[0069]
[0070] Among them, O i,k represents the value of the convolutional layer output feature sequence of the qth branch at the i-th position and the k-th output channel, i and k represent the length and channel index of the output feature sequence respectively, X in is the input feature sequence of the current branch, K l is the convolution kernel length of the qth branch, C in is the number of channels of the input feature sequence, S l is the convolution step size of the qth branch, m is the relative coordinate index in the direction inside the convolution kernel, c is the input channel index, W m,c,k and B k are the weight and bias of the convolution kernel of the qth branch respectively.
[0071] The output feature maps O of all Q branches (1) ,O (2) ,…,O (p)First, they are adjusted to a uniform length and then concatenated in the channel dimension to form a comprehensive multi-scale feature tensor F A,concat Subsequently, the concatenated features are further extracted through additional convolutional layers, pooling layers, and activation functions to generate the absorption spectrum feature F. A .
[0072] F A,concat =Concat( (1) ,O (2) ,...,O (P) ) (14)
[0073] F A =M1DCNN(F A,concat ) (2)
[0074] Among them, M1DCNN represents the processing layer at the end of the module, and the final absorption spectrum feature F A ∈R L’×C A ,L',C A F A length and number of channels.
[0075] Step 3: The extracted fluorescence spectrum features and absorption spectrum features are deeply fused through the cross-attention mechanism;
[0076] The cross-source spectral feature fusion module (cross attention) is responsible for integrating the fluorescence spectrum feature F output by M2DCNN F And the absorption spectrum feature F output by M1DCNN A Conduct deep integration to obtain complementary and more comprehensive information.
[0077] In order to perform cross attention calculation, we first need to transform F F and F A Convert to Query(Q),Key(K),Value(V) vectors that are more suitable for attention mechanism. This is usually achieved by flattening and linear projection (full connection). Assume that F F Flattened and projected into query Q∈R N×D k , F A After flattening, the projection is the key K∈R N×D k Sum value V∈R N×D v Here N is the length of the flattened feature sequence, D k , D v are the embedding dimensions for key / query and value respectively.
[0078] Q=Linear Q (Flatten(FF )) (3)
[0079] K=Linear K (Flatten(F A )) (4)
[0080] V=Linear V (Flatten(F A )) (5)
[0081] Among them, Flatten(.) represents the flattening operation, Linear X (.) indicates linear projection (fully connected layer).
[0082] The fused feature F fusion Calculated by the following formula:
[0083]
[0084] Among them, Q, K, V are query, key and value matrices respectively, K T is the transpose of K, D k is the dimension of the key vector, and the Softmax function is used to normalize the attention scores into a probability distribution.
[0085] Step 4: Apply the channel-space hybrid attention mechanism to optimize the fused features to generate the feature vector of antibiotics; this step further optimizes the fused features F fusion By learning the importance of different channels (spectral features) and different spatial locations (wavelength regions), we can highlight discriminative information and suppress redundant information. The process is as follows:
[0086] 4.1) Channel Attention (CA);
[0087] F fusion Perform global average pooling (AvgPool) and global maximum pooling (MaxPool) to compress the spatial information of each channel into two channel descriptors and
[0088]
[0089] Among them, F fusion [i,j,k] represents the fusion feature F fusion The values at spatial position (i, j) and channel k, H', W' and C fusion Represents the fusion feature F fusion The height, width and number of channels of i, j, k represent the height, width and channel index of the fusion feature map respectively. and They represent the channel descriptor vectors obtained after global average pooling and global maximum pooling respectively.
[0090] The above two channel descriptors and The outputs of the MLP are summed and the channel attention weights M are generated by the Sigmoid activation function. c (F fusion )∈R 1×1×C fusion :
[0091]
[0092] Among them, MLP(.) represents a multi-layer perceptron network, σ(.) represents the Sigmoid activation function, M c (F fusion ) is the channel attention weight.
[0093] 4.2) Spatial Attention (SA);
[0094] F fusion Average pooling (AvgPool_c) and maximum pooling (MaxPool_c) are performed along the channel dimension to compress the channel information of each spatial position into two two-dimensional spatial descriptors and
[0095]
[0096] in, and Represent the spatial descriptor vectors obtained after global average pooling and global maximum pooling, F fusion [i,j,k] represents the fusion feature F fusion The value at spatial position (i, j) and channel k, C fusion Represents the fusion feature F fusion Then, these two spatial descriptors and After splicing in the channel dimension, a convolution layer and a Sigmoid function are used to generate a spatial attention map M. s (F fusion ):
[0097]
[0098] Among them, Concat(.,.) is the concatenation operation, Conv(.) is the convolution operation, σ(.) represents the Sigmoid activation function, M s (F fusion ) represents the spatial attention weight map generated by the spatial attention module.
[0099] The final optimized feature F optimized is the fusion feature F fusion After channel attention weight M c (F fusion ) and spatial attention weight M s (F fusion ) is obtained by weighting each element. The weight is automatically expanded to the same value as F through the broadcast mechanism. fusion Multiplication is performed on the same dimension.
[0100]
[0101] in, represents element-wise multiplication, F optimized represents the final feature tensor after spatial-spectral hybrid attention optimization. Here, M c (F fusion )’s channel weights are applied to F through a broadcast mechanism fusion At all spatial positions, M s (F fusion )’s spatial weights are applied via a broadcast mechanism F fusion This attention strategy enables the model to focus on important spectral feature dimensions and key spectral spatial regions at the same time, thereby more effectively highlighting discriminative information and suppressing redundant information.
[0102] Step 5, input the feature vector into the support vector machine (SVM) classifier to identify the antibiotic category;
[0103] Optimize feature F optimized After global average pooling and one or more fully connected layers, the final antibiotic feature vector f is obtained anti ∈R D , where D is the eigenvector f anti Dimensions;
[0104] f anti =FullyConnected(Flatten(GlobalAvgPool(F optimized ))) (twenty one)
[0105] Among them, GlobalAvgPool(.) here represents the average pooling of the spatial dimension, which is then flattened into a one-dimensional vector by Flatten(.) and sent to the fully connected layer FullyConnected(.), f anti Used for subsequent classification and regression;
[0106] Using the antibiotic feature vector f extracted above anti , using support vector machine (SVM) as a classifier to classify f anti Mapped to K predefined antibiotic categories, input SVM classifier to identify antibiotic type y pred
[0107] y pred =SVM(FullyConnected(Flatten(GlobalAvgPool(F optimized )))) (10)
[0108] Among them, GlobalAvgPool(.) here represents the average pooling of the spatial dimension, which is then flattened into a one-dimensional vector through Flatten(.) and sent to the fully connected layer FullyConnected(.). SVM(.) represents the input SVM classifier
[0109] Predicted antibiotic class y pred ∈{1,2,…,K}, identify the specific types of antibiotics present in the water sample.
[0110] The contents described in the embodiments of this specification are merely an enumeration of the implementation forms of the inventive concept. The scope of protection of the present invention should not be regarded as limited to the specific forms described in the embodiments. The scope of protection of the present invention also extends to equivalent technical means that can be conceived by those skilled in the art based on the inventive concept.
Claims
1. An antibiotic identification method based on multi-source spectral fusion and hybrid attention mechanism, characterized in that: The method comprises the following steps: Step 1: preprocessing the collected fluorescence spectrum and absorption spectrum data; Step 2: Extract features from the fluorescence spectrum using a multi-scale two-dimensional convolutional neural network, and simultaneously extract features from the absorption spectrum using a multi-scale one-dimensional convolutional neural network; Step 3: The extracted fluorescence spectrum features and absorption spectrum features are deeply fused through the cross-attention mechanism; Step 4: Apply the channel-space hybrid attention mechanism to optimize the fused features to generate the feature vector of the antibiotics; Step 5: Input the feature vector into the support vector machine classifier to identify the antibiotic category.
2. The antibiotic identification method based on multi-source spectral fusion and hybrid attention mechanism according to claim 1 is characterized in that: In step 1, the collected three-dimensional fluorescence spectrum data is converted into a two-dimensional image format to obtain a pre-processed fluorescence spectrum image I F , convert the two-dimensional absorption spectrum data into one-dimensional sequence data, and obtain the pre-processed absorption spectrum sequence S A .
3. The antibiotic identification method based on multi-source spectral fusion and hybrid attention mechanism according to claim 2, characterized in that: In step 2, the fluorescence spectrum image I F and absorption spectrum sequence S A After using the multi-scale two-dimensional convolutional neural network M2DCNN and the multi-scale one-dimensional convolutional neural network M1DCNN to extract multi-scale features in parallel, the feature maps and feature sequences of different scales are spliced together. (Concatenation) obtains the fused feature tensor F F,concat and F A,concat , the features obtained are fluorescence spectrum features F F and absorption spectrum characteristics F A : F F =M2DCNN(F F,concat ) (1) F A =M1DCNN(S A,concat ) (2) 4. The antibiotic identification method based on multi-source spectral fusion and hybrid attention mechanism according to claim 3 is characterized in that: In step 3, the extracted fluorescence spectrum feature F F and absorption spectrum characteristics F A After the cross attention mechanism, it is fused into F fusion , the process is: In order to perform cross attention calculation, we first need to transform F F and F A Convert to Query(Q),Key(K),Value(V) vectors that are more suitable for the attention mechanism by flattening and linear projection; assuming that F F Flatten and project into query F A Flattened and projected as key Sum Here N is the length of the flattened feature sequence, D k , D v are the embedding dimensions of key / query and value respectively; Q=Linear Q (Flatten(F F )) (3) K=Linear K (Flatten(F A )) (4) V=Linear V (Flatten(F A )) (5) Among them, Flatten(.) represents the flattening operation, Linear X (.) represents linear projection (fully connected layer), the fused feature F fusion Calculated by the following formula: Among them, Q, K, V are query, key and value matrices respectively, K T is the transpose of K, D k is the dimension of the key vector, and the Softmax function is used to normalize the attention scores into a probability distribution.
5. The antibiotic identification method based on multi-source spectral fusion and hybrid attention mechanism according to claim 4, characterized in that: In step 4, F fusion Perform global average pooling AvgPool and global maximum pooling MaxPool, then send them to a shared multi-layer perceptron MLP network, and then add the output of the MLP and generate the channel attention weight M through the Sigmoid activation function c (F fusion ): M c (F fusion )=σ(MLP(AvgPool(F fusion ))+MLP(MaxPool(F fusion ))) (7) Among them, MLP(.) represents a multi-layer perceptron network, σ(.) represents the Sigmoid activation function, M c (F fusion ) is the channel attention weight; F fusion Average pooling (AvgPool_c) and maximum pooling (MaxPool_c) are performed along the channel dimension, and after splicing on the channel dimension, a convolution layer and Sigmoid function are used to generate a spatial attention map M. s (F fusion ): M s (F fusion )=σ(Conv(Concat(AvgPool_c(F fusion ))),MaxPool_c(F fusion ))) (8) Among them, Concat(.,.) is the concatenation operation, Conv(.) is the convolution operation, σ(.) represents the Sigmoid activation function, M s (F fusion ) represents the spatial attention weight generated by the spatial attention module; The final optimized feature F optimized is the fusion feature F fusion After channel attention weight M c (F fusion ) and spatial attention weight M s (F fusion ) is obtained by weighting each element, and the weight is automatically expanded to the same value as F through the broadcast mechanism. fusion Multiply the same dimensions; in, represents element-wise multiplication, F optimized represents the final feature tensor after spatial-spectral hybrid attention optimization, M c (F fusion )’s channel weights are applied to F through a broadcast mechanism fusion At all spatial positions, M s (F fusion )’s spatial weights are applied via a broadcast mechanism F fusion on all channels.
6. The antibiotic identification method based on multi-source spectral fusion and hybrid attention mechanism according to claim 5, characterized in that: In step 5, the optimized feature F optimized Vector conversion to f anti , and input into SVM classifier to identify antibiotic type y pred ; y pred =SVM(FullyConnected(Flatten(GlobalAvgPool(F optimized ))))(10) Here, GlobalAvgPool(.) represents average pooling in the spatial dimension, which is then flattened into a one-dimensional vector by Flatten(.) and sent to the fully connected layer FullyConnected(.). SVM(.) represents the input of the SVM classifier.
7. The antibiotic identification method based on multi-source spectral fusion and hybrid attention mechanism according to claim 5, characterized in that: In step 4, the shared multi-layer perceptron network MLP includes 2 layers. In the spatial attention mechanism, the convolution layer used to generate the spatial attention map uses a convolution kernel of size 7×7.