Terahertz metamaterial molecular fingerprint sensing method and system based on multi-task learning
By employing a multi-task learning framework and a cross-sample perspective correlation model, the problem of accuracy in identifying and quantifying structurally similar molecules in terahertz metamaterial sensing technology was solved, achieving efficient molecular identification and concentration prediction, and improving detection efficiency and robustness.
Patent Information
- Application Number
- CN202511684019.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-17
- Publication Date
- 2026-02-10
AI Technical Summary
Existing terahertz metamaterial sensing technology suffers from reduced recognition accuracy and quantitative precision when distinguishing molecules with similar structures. Furthermore, existing deep learning models cannot effectively achieve the intrinsic coupling between molecular recognition and quantification, resulting in limitations in system integration and detection efficiency.
A multi-task learning framework is adopted, which integrates physical prior features and cross-sample perspective association models to construct a unified multi-task learning model. A lightweight fully connected network and a molecular fingerprint cross-sample decoder are used for feature extraction, and an adaptive multi-task loss function is introduced to achieve high-precision molecular recognition and concentration prediction.
High-precision molecular recognition and concentration prediction were achieved under single-angle terahertz spectroscopy, which improved the model's discrimination ability and robustness, solved the problem of identifying similar molecules with severe spectral overlap, and met the requirements of real-time detection.
Smart Images

Figure CN121506334A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of terahertz biosensing applications, and particularly relates to a terahertz metamaterial molecular fingerprint sensing method and system based on multi-task learning. BACKGROUND
[0002] The statements in this section merely provide background information related to the application and do not necessarily constitute prior art.
[0003] Terahertz spectroscopy has developed into a key detection technology with non-destructive and non-labeled characteristics in the biomedical, food safety and other fields, due to the unique fingerprint absorption characteristics of biological and chemical molecules in this band. In recent years, terahertz metamaterial sensors have significantly improved the detection sensitivity and specificity by enhancing the local electromagnetic field, and have promoted the terahertz detection from qualitative identification to quantitative analysis. However, the existing terahertz metamaterial sensing technology still faces three major bottlenecks: (1) There are certain difficulties in distinguishing the spectra of similar structures. For α-amino acids (such as glutamic acid and glutamine) and other highly similar molecules, their terahertz molecular fingerprints have serious spectral overlap, and traditional methods that rely on manual extraction of spectral peak positions, amplitudes and other features cannot capture subtle differences, resulting in a significant decrease in recognition accuracy and quantitative precision.
[0004] (2) In order to improve the distinguishing ability, the existing technology often uses angle multiplexing strategy to generate full-angle-frequency resonance envelope, but smaller angle step will lead to a sharp increase in scanning time, which cannot meet the real-time detection demand; and simplifying the scanning process will lose key features, further weakening the detection performance.
[0005] (3) Although deep learning has been applied in terahertz metamaterial design and detection, existing models mostly focus on single task or only achieve analyte classification, or only complete concentration quantification, and cannot model the inherent coupling relationship between recognition and quantification, resulting in limited system integration and detection efficiency. As a core paradigm of multi-objective collaborative optimization, multi-task learning (MTL) has made breakthroughs in computer vision, near-infrared spectroscopy and other fields, but in the field of terahertz molecular fingerprint sensing, there is no multi-task learning framework for the dual-task design of distinguishing similar structures and concentration quantification, which cannot solve the performance and efficiency bottlenecks of existing technology in complex analysis scenarios, and seriously restricts the practical application of terahertz metamaterial sensing technology. SUMMARY
[0006] In order to overcome the above-mentioned deficiencies of the prior art, the present application provides a terahertz metamaterial molecular fingerprint perception method and system based on multi-task learning, which realizes high-precision molecular identification and concentration prediction under single-angle terahertz spectroscopy by fusing physical prior features, constructing a cross-sample angle correlation model, and introducing an adaptive multi-task loss function.
[0007] In order to achieve the above-mentioned purpose, one or more embodiments of the present application provide the following technical solutions: The present application provides a terahertz metamaterial molecular fingerprint perception method based on multi-task learning in a first aspect; The terahertz metamaterial molecular fingerprint perception method based on multi-task learning comprises: Obtaining the terahertz reflectance spectrum of the sample to be measured, and extracting the physical features of the reflectance spectrum; The terahertz reflectance spectrum, the corresponding incident angle and the physical features are jointly input into the trained multi-task learning model; the multi-task learning model encodes the reflectance spectrum, the incident angle and the physical features through a lightweight fully connected network, and maps them to a unified embedding space; a molecular fingerprint cross-sample decoder is used to extract features from the encoded feature vectors, and a shared layer is used to fuse and compress them into a compact latent representation; The latent representation is input into the classification head and the regression head of the multi-task learning model, and the molecular category identification result and the concentration prediction result of the sample to be measured are output.
[0008] As a further technical solution, the physical features of the reflectance spectrum include the peak intensity of the left resonance peak, the peak intensity of the right resonance peak, the frequency position of the left resonance peak, the frequency position of the right resonance peak, and the peak frequency difference between the frequency positions of the left and right resonance peaks.
[0009] As a further technical solution, the multi-task learning model encodes the reflectance spectrum, the incident angle and the physical features through a lightweight fully connected network, and maps them to a unified embedding space, comprising: The terahertz reflectance spectrum is input into a first lightweight fully connected network, which maps it from a one-dimensional sequence to a fixed-dimensional spectral embedding vector; The incident angle is input into a second lightweight fully connected network, which maps it from a scalar value to a fixed-dimensional angle embedding vector; The physical features are input into corresponding lightweight fully connected networks respectively, which map each scalar-form physical feature to a fixed-dimensional physical sub-embedding vector; the physical sub-embedding vectors are spliced to form a unified physical feature embedding vector; Among them, the spectral embedding vector, the angle embedding vector and the physical feature embedding vector have the same feature dimension, thereby forming the unified embedding space.
[0010] As a further technical solution, the molecular fingerprint cross-sample decoder is used for feature extraction on the encoded feature vector, and the shared layer is used for fusion and compression into a compact latent representation, including: The spectrum embedding vector, angle embedding vector and physical feature embedding vector are spliced to form a fusion feature vector; The fusion feature vector is input into the molecular fingerprint cross-sample decoder for deep feature extraction to obtain an initial feature representation of each sample in the batch; The initial feature representation is input into a shared layer for dimension reduction and information compression, and the initial feature representation is input into a contrastive learning projection head, and after normalization processing, a corresponding normalized embedding vector is obtained; based on the normalized embedding vector, according to the molecular category and concentration value of the sample as a grouping identifier, a positive and negative sample pair within the training batch is constructed, and sample embedding vectors belonging to the same group are constructed as a positive sample pair, and sample embedding vectors not belonging to the same group are constructed as a negative sample pair; The supervised contrastive loss based on the positive and negative sample pairs is calculated to generate the compact latent representation.
[0011] As a further technical solution, the supervised contrastive loss is:
[0012] Wherein, is the supervised contrastive loss; is the total number of samples in the training batch; is the positive pair set of sample ; and are vector representations of samples in the same group; is a temperature coefficient for controlling the scale of similarity; is the sample index.
[0013] As a further technical solution, the latent representation is input into the classification head and regression head of the multi-task learning model to output the molecular category recognition result and concentration prediction result of the sample to be tested, including: The compact latent representation is input into the classification head, which is composed of at least one fully connected layer and a Softmax activation function, and outputs a probability distribution vector with a dimension equal to the total number of molecular categories to be identified. The category corresponding to the maximum probability value is taken as the molecular category recognition result; The compact latent representation is input into the regression head, which is composed of at least one fully connected layer, and outputs a continuous scalar representing the concentration value as the concentration prediction result; The classification head and the regression head are parallel task-specific network branches that work simultaneously in the training and inference processes and share feature information from the same latent representation.
[0014] As a further technical solution, the multi-task learning model is obtained by training a joint loss function, and the joint loss function is as follows:
[0015] wherein, is a joint loss; is an adaptive weight parameter of the classification task; is a cross-entropy loss of the classification task; is an adaptive weight parameter of the regression task; is a mean square error loss of the regression task; is a weight coefficient of the supervised contrast loss; is a supervised contrast loss.
[0016] The second aspect of the present application provides a terahertz metamaterial molecular fingerprint perception system based on multi-task learning.
[0017] The terahertz metamaterial molecular fingerprint perception system based on multi-task learning comprises: A spectrum data acquisition module configured to obtain a terahertz reflectance spectrum of a sample to be measured and extract physical features of the reflectance spectrum; A data processing module configured to input the terahertz reflectance spectrum, the corresponding incident angle and the physical features into a trained multi-task learning model; the multi-task learning model encodes the reflectance spectrum, the incident angle and the physical features through a lightweight fully connected network and maps them to a unified embedding space; a molecular fingerprint cross-sample decoder is used to extract features of the encoded feature vectors, and a shared layer is used to fuse and compress them into a compact latent representation; A result output module configured to input the latent representation into a classification head and a regression head of the multi-task learning model and output molecular category recognition results and concentration prediction results of the sample to be measured.
[0018] The third aspect of the present application provides a computer readable storage medium having a program stored thereon, wherein the program is executed by a processor to implement the steps of the terahertz metamaterial molecular fingerprint perception method based on multi-task learning according to the first aspect of the present application.
[0019] The fourth aspect of the present application provides an electronic device comprising a memory, a processor and a program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the terahertz metamaterial molecular fingerprint perception method based on multi-task learning according to the first aspect of the present application.
[0020] The one or more technical solutions have the following beneficial effects: The application overcomes the problem of one-sided feature extraction and weak model generalization ability caused by ignoring the internal correlation between tasks in the traditional single-task model by constructing a unified multi-task learning framework to jointly optimize the molecular classification and concentration regression tasks at the shared feature representation level. In the process of obtaining spectral data, a detection paradigm based on single-angle terahertz spectrum is proposed. By introducing physical feature fusion and cross-sample correlation modeling, the model can fully mine the molecular fingerprint information from a single measurement without the need for time-consuming full-angle scanning.
[0021] The application takes the resonance peak position, intensity, spacing and other key physical descriptors as multi-modal inputs. This physical-guided feature fusion mechanism enables the model to directly focus on the electromagnetic response features most sensitive to molecular structure differences, thereby exhibiting excellent discrimination ability when facing similar molecules with severe spectral overlap, while improving the transparency and interpretability of the model decision-making process. By introducing a supervised contrast learning mechanism, the application explicitly constrains the model to learn the invariant and essential fingerprint feature representation of the same molecule under different observation angles. This training method makes the model naturally robust to measurement angle fluctuations, background noise and minor manufacturing errors. In addition, the adaptive multi-task loss weighting mechanism ensures that the classification and regression tasks converge stably and balancedly during training, avoiding training instability caused by task difficulty differences, and further enhancing the model's generalization performance.
[0022] The advantages of the additional aspects of the application will be partially given in the following description, partially become obvious from the following description, or be known by the practice of the application. BRIEF DESCRIPTION OF DRAWINGS
[0023] The accompanying drawings, which form a part of this description, are included to provide further understanding of the application, and are incorporated in and constitute a part of this description. The illustrative embodiments of the application and their description serve to explain the application. They do not, however, limit the application, which is defined through the patent claims.
[0024] Figure 1 The method flowchart of the first embodiment.
[0025] Figure 2 The MF-CS decoder module structure and multi-task loss optimization schematic diagram in the first embodiment.
[0026] Figure 3 The application method and other method comparison experimental result schematic diagram in the first embodiment.
[0027] Figure 4 The system structure diagram of the second embodiment. DETAILED DESCRIPTION
[0028] It should be noted that the following detailed description is exemplary in nature and is intended to provide further description of the application. Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs.
[0029] It should be noted that the terms used herein are only intended to describe specific embodiments and are not intended to limit the exemplary embodiments according to the present application.
[0030] In the case of no conflict, the embodiments in the present application and the features in the embodiments can be combined with each other.
[0031] Embodiment one The present embodiment discloses a terahertz metamaterial molecular fingerprint perception method based on multi-task learning; As Figure 1 shown, the terahertz metamaterial molecular fingerprint perception method based on multi-task learning comprises: Step S1, obtaining the terahertz reflectance spectrum of the sample to be measured, and extracting the physical features of the reflectance spectrum; Step S2, inputting the terahertz reflectance spectrum, the corresponding incident angle and the physical features into the trained multi-task learning model; the multi-task learning model encodes the reflectance spectrum, the incident angle and the physical features through a lightweight fully connected network, and maps them to a unified embedding space; a molecular fingerprint cross-sample decoder is used to extract features from the encoded feature vectors, and a shared layer is used to fuse and compress them into a compact latent representation; Step S3, inputting the latent representation into the classification head and regression head of the multi-task learning model, and outputting the molecular class recognition result and the concentration prediction result of the sample to be measured.
[0032] Specifically, it further includes the following contents: Step S1, obtaining the terahertz reflectance spectrum of the sample to be measured, and extracting the physical features of the reflectance spectrum.
[0033] In this embodiment, α-amino acids were used as the test sample. The α-amino acids were dissolved in a suitable solvent to prepare a homogeneous solution. This solution was then uniformly coated onto the sensing surface of the terahertz metamaterial sensing device using a micropipette and allowed to air dry at room temperature, forming a uniform solid film with a thickness of 1.50-2.00 μm. The film was ensured to be free of cracks and bubbles to avoid affecting the accuracy of spectral acquisition. A terahertz time-domain spectroscopy (THz-TDS) system was used as the spectral acquisition module. The acquisition optical path was constructed as follows: the pre-processed terahertz metamaterial sensing device was fixed on an angle-adjustable stage. The stage angle was adjusted so that the angle between the terahertz wave incident direction and the normal to the surface of the sensing device, i.e., the incident angle, was within the range of 2°-20°. The frequency acquisition range and the number of spectral sampling points of the THz-TDS system were set to cover the terahertz molecular fingerprint frequency band of the target α-amino acid. The THz-TDS system emits terahertz waves to illuminate the sample film on the surface of the sensing device at a set incident angle. The system receives the reflected terahertz signal and converts it into a raw time-domain signal. The raw time-domain signal is then subjected to a Fourier transform to obtain the raw reflection spectrum in the frequency domain. The system's built-in baseline correction module is then invoked. Using the reflection spectrum acquired by a blank sensing device without a sample at the same incident angle as the baseline, the background signal interference from the substrate is eliminated through difference calculation. This yields the corrected reflection spectrum containing only the molecular fingerprint information of the sample to be tested, thus completing the spectral acquisition process.
[0034] Furthermore, the corrected reflectance spectrum is smoothed using a Savitzky-Golay filtering algorithm to remove high-frequency noise while preserving the resonance peak characteristics. Based on the resonance mechanism of the terahertz metamaterial sensor, the device forms two significant high-contrast resonance peaks (left and right peaks) in the 1.25-2.2 THz frequency band. A peak detection algorithm is used to scan the smoothed spectral curve to identify the positions of the two resonance peaks: the lower-frequency peak is defined as the "left peak," and the higher-frequency peak as the "right peak." The physical characteristics of the reflectance spectrum include: the peak intensity of the left resonance peak, the peak intensity of the right resonance peak, the frequency position of the left resonance peak, the frequency position of the right resonance peak, and the peak frequency difference between the left and right resonance peaks. The highest point of the spectral curve corresponding to the left peak is located, and the ordinate of this point is used as the peak intensity (LPV) of the left resonance peak, and the abscissa (frequency value) is used as the peak intensity (LPF) of the right resonance peak. Similarly, the highest point of the spectral curve corresponding to the right peak is located, and the ordinate of this point is used as the frequency position (RPV) of the left resonance peak, and the abscissa as the frequency position (RPF) of the right resonance peak.
[0035] Finally, the spectral coupling degree of the two resonance peaks is reflected by calculating the peak frequency difference between the left and right resonance peak positions. By directly correlating the interaction strength between the sample molecules and the metamaterial, structurally similar α-amino acids are distinguished. After extraction, the five parameters LPV, LPF, RPV, RPF, and PFD are integrated into a 5-dimensional physical feature vector for the subsequent construction of multimodal inputs for the multi-task learning framework.
[0036] Step S2: The terahertz reflection spectrum, the corresponding incident angle, and the physical features are input into the trained multi-task learning model. The multi-task learning model encodes the reflection spectrum, incident angle, and physical features through a lightweight fully connected network and maps them to a unified embedding space. The encoded feature vector is extracted using a molecular fingerprint cross-sample decoder and fused and compressed into a compact latent representation through a shared layer.
[0037] The multi-task learning model is configured with three independent lightweight fully connected networks to perform dimensionality adaptation and feature encoding for terahertz reflection spectra, incident angles, and physical features, respectively. Specifically, for the reflection spectra acquired by the terahertz time-domain spectroscopy (THz-TDS) system, a first lightweight network consisting of one fully connected layer, an activation function, and batch normalization is used: the first layer takes 800 dimensions as input and 128 dimensions as output, uses the ReLU activation function, and a batch normalization layer is set after the fully connected layer to suppress gradient vanishing, ultimately encoding the 800-dimensional spectral vector into a 128-dimensional spectral feature embedding vector.
[0038] For a single incident angle in the range of 2°-20°, a second lightweight network with one fully connected layer is used: the first layer takes 1 dimension as input and 16 dimensions as output (ReLU activation), and encodes the 1-dimensional angle value into a 16-dimensional angle feature embedding vector.
[0039] For the five physical features (each one-dimensional) extracted from the reflectance spectrum—left peak amplitude (LPV), left peak frequency (LPF), right peak amplitude (RPV), right peak frequency (RPF), and peak frequency difference (PFD)—a third set of networks is constructed using five lightweight fully connected networks with identical structures. Each network takes a one-dimensional physical feature as input and an eight-dimensional output (ReLU activation), encoding the five one-dimensional physical features into an eight-dimensional feature embedding vector.
[0040] The above three sets of feature embedding vectors are concatenated to obtain a 184-dimensional fused feature vector. The space in which this 184-dimensional vector is located is the unified feature embedding space. This space simultaneously carries spectral fingerprint details, angular scene information, and physical peak correlation information, providing highly discriminative input for the extraction of dedicated layers in subsequent classification and regression tasks.
[0041] Furthermore, the MF-CS decoder receives the 184-dimensional fused feature vector output from the unified feature embedding space. Through cross-angle correlation modeling, fingerprint feature enhancement, and overfitting suppression, it extracts core features strongly correlated with molecular fingerprints. The specific process is as follows: First, the unified feature embedding spatial output, which is obtained by concatenating 184-dimensional fused feature vectors (128-dimensional spectrum, 16-dimensional angle, and 40-dimensional physical features), is input into the fully connected module of the shared layer. This module takes 184 dimensions as input and 64 dimensions as output, and introduces non-linear feature representation capabilities with the ReLU activation function. At the same time, a batch normalization (BN) layer is set to normalize the output features, suppress the gradient vanishing problem, and improve training stability, ultimately generating a 64-dimensional intermediate feature vector. This fully connected module learns the common association patterns of molecular fingerprints under different incident angles through training, and can capture stable fingerprint information of the same analyte in multi-angle measurements, effectively suppressing feature drift caused by angle changes.
[0042] The 64-dimensional intermediate feature vector is input into the projection head module, which consists of two fully connected layers. The first layer takes 64 dimensions as input and 128 dimensions as output (ReLU activation), and the second layer takes 128 dimensions as input and 128 dimensions as output. After mapping the intermediate features to a higher-dimensional space through two linear transformations, L2 normalization is applied to obtain a 128-dimensional normalized feature vector. Combined with the sample group identifier (group_ids, samples with the same analyte and concentration but different incident angles are grouped together), the cosine similarity between the normalized feature vectors of different samples is calculated. This is optimized through supervised contrastive loss: the feature vectors of positive sample pairs in the same group are brought closer together, while the feature vectors of negative sample pairs in different groups are pushed further apart. This automatically strengthens the feature dimensions directly related to molecular fingerprints, such as resonance peak amplitude, frequency, and peak spacing, while weakening noise and background interference dimensions. Finally, the 64-dimensional intermediate feature vector output by the shared layer is used as the potential representation of the core fingerprint features, providing input for the dedicated layers of subsequent classification and regression tasks.
[0043] Step S3: Input the latent representation into the classification head and regression head of the multi-task learning model, and output the molecular category identification result and concentration prediction result of the sample to be tested.
[0044] Combination Figure 2First, the 64-dimensional feature is a potential representation of the core fingerprint feature after fusion and compression through a shared layer. During the training phase, it is optimized through the contrastive learning mechanism of the MF-CS decoder (using this feature as input, after projection head mapping and L2 normalization, the cross-angle sample similarity is calculated, and the molecular fingerprint-related dimensions are strengthened and angle drift is suppressed through supervised contrastive loss). Finally, it carries the core information of molecular category differentiation and concentration quantification.
[0045] The classification head receives 64-dimensional core fingerprint features and directly outputs the probability distribution of 6 α-amino acid categories through a fully connected layer (64 input dimensions and 6 output dimensions). The category label corresponding to the maximum value in the score vector is selected by the argmax function, which is the molecular category identification result of the sample to be tested.
[0046] The regression head receives 64-dimensional core fingerprint features and passes them through a two-layer fully connected network. The first layer has an input dimension of 64 and an output dimension of 32, and includes ReLU activation. The second layer has an input dimension of 32 and an output dimension of 1, outputting a normalized concentration prediction value. Then, it is denormalized by the MinMaxScaler used in the training phase to obtain the true concentration prediction result of the sample to be tested.
[0047] Finally, the molecular category identification results and concentration prediction results are output simultaneously, completing the entire detection process.
[0048] Furthermore, a loss function is introduced during model training. Specifically, the MF-CS decoder processes the 64-dimensional core fingerprint feature vector output from the shared layer using a built-in projection head (proj_head). The projection head consists of two lightweight fully connected networks: the first layer takes the 64-dimensional feature vector as input and outputs a 128-dimensional vector, incorporating a ReLU activation function to introduce non-linear mapping capabilities; the second layer takes the 128-dimensional feature vector as input and outputs a 128-dimensional vector, maintaining dimensional consistency to accommodate subsequent similarity calculations. This projection head maps the 64-dimensional core fingerprint feature vector to a fixed-dimensional (D=128) embedding vector and performs L2 normalization to obtain a normalized embedding vector. Where B is the training batch size and D is the embedding vector dimension. Then, the cosine similarity between embeddings from different angles is calculated, as shown in the following formula:
[0049] in, , These are sample embeddings; This is the temperature scaling factor.
[0050] Building upon this, a supervised contrastive loss is applied during training to enforce cross-perspective consistency. Based on the analyte ID and concentration group identifier, and according to the molecular category and concentration value of the samples as group identifiers, positive and negative sample pairs are constructed within the training batch: embedding vectors of samples belonging to the same group are constructed as positive sample pairs, and embedding vectors of samples not belonging to the same group are constructed as negative sample pairs; the supervised contrastive loss based on these positive and negative sample pairs is calculated to generate the compact latent representation.
[0051] The supervised comparison loss formula is:
[0052] in, To monitor and compare losses; This represents the total number of samples in the training batch. For the sample The set of opposites; and A vector representation of samples in the same group; This is a temperature coefficient used to control the scale of similarity. For sample index.
[0053] Furthermore, the multi-task learning model is trained using a joint loss function, which is shown below:
[0054] in, For joint losses; For classification tasks, adaptive weight parameters are used. Cross-entropy loss for classification tasks; For adaptive weight parameters of the regression task; The mean squared error loss for the regression task; Weighting coefficients for the comparative loss to be monitored; To monitor and compare losses.
[0055] Furthermore, to verify the effectiveness of the MTL framework proposed in this invention, a set of baseline models representing the latest developments in terahertz metamaterial sensing and deep learning were selected for comparison with the method of this invention. Specifically, for reproducibility, the Adam optimizer was used with a learning rate of 0.001, a batch size of 133, and a training epoch of 200. All inputs were normalized using MinMaxScaler to ensure consistent scaling. To simulate real-world measurement uncertainties, 1% additive Gaussian noise was introduced into the training data. These consistent preprocessing and training protocols ensured the comparability and reproducibility of the experimental results, as shown in the figure. Figure 3As shown, the method provided by this invention exhibits strong performance in both tasks. In the classification task, it achieves an ACC of 99.72%, significantly outperforming all baseline methods. While models such as FCNN (89.19%) are competitive in their original application domains, they cannot handle extreme similarities between THz molecular fingerprints due to severe spectral overlap. In contrast, this invention leverages its multi-task structure to extract and distinguish subtle spectral cues, thereby significantly improving classification accuracy. In the regression task, this invention achieves a MAE of 0.0491, lower than the MAE of all regression-only models. While several baselines perform well in other metamaterial sensing environments, they fail to adequately capture subtle concentration-dependent changes when the spectra of structurally similar analytes strongly overlap. By jointly optimizing classification and regression, this invention effectively resolves feature ambiguity, preserves fine-grained information, and reduces prediction errors. These results demonstrate that this invention overcomes the inherent limitations of traditional single-task architectures and task-specific optimizations in feature generalization, providing excellent adaptability and accuracy in distinguishing highly similar THz molecular fingerprints.
[0056] Example 2 This embodiment discloses a terahertz metamaterial molecular fingerprint sensing system based on multi-task learning; like Figure 4 As shown, the terahertz metamaterial molecular fingerprint sensing system based on multi-task learning includes: The spectral data acquisition module is configured to acquire the terahertz reflectance spectrum of the sample to be tested and extract the physical characteristics of the reflectance spectrum. The data processing module is configured to: input the terahertz reflection spectrum, the corresponding incident angle, and the physical features into a trained multi-task learning model; the multi-task learning model encodes the reflection spectrum, incident angle, and physical features through a lightweight fully connected network and maps them to a unified embedding space; the encoded feature vector is extracted using a molecular fingerprint cross-sample decoder and fused and compressed into a compact latent representation through a shared layer; The result output module is configured to input the latent representation into the classification head and regression head of the multi-task learning model, and output the molecular category identification result and concentration prediction result of the sample to be tested. Example 3 The purpose of this embodiment is to provide a computer-readable storage medium.
[0057] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the terahertz metamaterial molecular fingerprint sensing method based on multi-task learning as described in Example 1.
[0058] Example 4 The purpose of this embodiment is to provide an electronic device.
[0059] An electronic device includes a memory, a processor, and a program stored in the memory and executable on the processor. When the processor executes the program, it implements the steps in the terahertz metamaterial molecular fingerprint sensing method based on multi-task learning as described in Example 1.
[0060] The steps and methods involved in the apparatuses of Embodiments 2, 3, and 4 above correspond to those in Embodiment 1. For specific implementation details, please refer to the relevant description section of Embodiment 1. The term "computer-readable storage medium" should be understood as a single medium or multiple media including one or more instruction sets; it should also be understood as including any medium capable of storing, encoding, or carrying an instruction set for execution by a processor and enabling the processor to perform any of the methods in this invention.
[0061] Those skilled in the art will understand that the modules or steps of the present invention described above can be implemented using general-purpose computer devices. Optionally, they can be implemented using computer-executable program code, thereby allowing them to be stored in a storage device for execution by a computer device, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. The present invention is not limited to any particular combination of hardware and software.
[0062] While the specific embodiments of the present invention have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of the present invention are still within the scope of protection of the present invention.
Claims
1. A terahertz metamaterial molecular fingerprint sensing method based on multi-task learning, characterized in that, include: Obtain the terahertz reflectance spectrum of the sample to be tested and extract the physical characteristics of the reflectance spectrum; The terahertz reflection spectrum, the corresponding incident angle, and the physical features are input into a trained multi-task learning model. The multi-task learning model encodes the reflection spectrum, incident angle, and physical features through a lightweight fully connected network and maps them to a unified embedding space. The encoded feature vector is extracted using a molecular fingerprint cross-sample decoder and then fused and compressed into a compact latent representation through a shared layer. The latent representation is input into the classification head and regression head of the multi-task learning model, which outputs the molecular category identification result and concentration prediction result of the sample to be tested.
2. The terahertz metamaterial molecular fingerprint sensing method based on multi-task learning as described in claim 1, characterized in that, The physical characteristics of the reflection spectrum include: the peak intensity of the left resonance peak, the peak intensity of the right resonance peak, the frequency position of the left resonance peak, the frequency position of the right resonance peak, and the peak frequency difference between the frequency positions of the left and right resonance peaks.
3. The terahertz metamaterial molecular fingerprint sensing method based on multi-task learning as described in claim 1, characterized in that, The multi-task learning model encodes the reflection spectrum, incident angle, and physical features through a lightweight fully connected network and maps them to a unified embedding space, including: The terahertz reflection spectrum is input into a first lightweight fully connected network, which maps it from a one-dimensional sequence to a fixed-dimensional spectral embedding vector. The incident angle is input into the second lightweight fully connected network, which maps it from a scalar value to a fixed-dimensional angle embedding vector. The physical features are input into the corresponding lightweight fully connected networks, and each scalar physical feature is mapped to a fixed-dimensional physical sub-embedding vector. The physical sub-embedding vectors are concatenated to form a unified physical feature embedding vector. The spectral embedding vector, the angular embedding vector, and the physical feature embedding vector have the same feature dimension, thus forming the unified embedding space.
4. The terahertz metamaterial molecular fingerprint sensing method based on multi-task learning as described in claim 1, characterized in that, Feature extraction is performed on the encoded feature vector using a molecular fingerprint cross-sample decoder, and then fused and compressed into a compact latent representation through a shared layer, including: The spectral embedding vector, angle embedding vector, and physical feature embedding vector are concatenated to form a fused feature vector; The fused feature vector is input into the molecular fingerprint cross-sample decoder for deep feature extraction to obtain the initial feature representation of each sample in the batch; The initial feature representation is input into a shared layer for dimensionality reduction and information compression, and then input into a contrastive learning projector. After normalization, the corresponding normalized embedding vector is obtained. Based on the normalized embedding vector, positive and negative sample pairs are constructed within the training batch according to the molecular category and concentration value of the sample as group identifiers. The embedding vectors of samples belonging to the same group are constructed as positive sample pairs, and the embedding vectors of samples not belonging to the same group are constructed as negative sample pairs. The supervised contrastive loss based on the positive and negative sample pairs is calculated to generate the compact latent representation.
5. The terahertz metamaterial molecular fingerprint sensing method based on multi-task learning as described in claim 4, characterized in that, The supervised comparison loss is: in, To monitor and compare losses; This represents the total number of samples in the training batch. For the sample The set of opposites; and A vector representation of samples in the same group; This is a temperature coefficient used to control the scale of similarity. For sample index.
6. The terahertz metamaterial molecular fingerprint sensing method based on multi-task learning as described in claim 1, characterized in that, The latent representation is input into the classification head and regression head of a multi-task learning model, which outputs the molecular category identification result and concentration prediction result of the sample to be tested, including: A compact latent representation is input into a classification head, which consists of at least one fully connected layer and a Softmax activation function, and outputs a probability distribution vector with a dimension equal to the total number of molecular categories to be identified. The category corresponding to the highest probability value is taken as the molecular category identification result. A compact latent representation is input into the regression head, which consists of at least one fully connected layer, and outputs a continuous scalar representing the concentration value as the concentration prediction result. The classification head and the regression head are parallel task-specific network branches that work simultaneously during training and inference and share feature information from the same latent representation.
7. The terahertz metamaterial molecular fingerprint sensing method based on multi-task learning as described in claim 1, characterized in that, The multi-task learning model is trained using a joint loss function, which is shown below: in, For joint losses; For classification tasks, adaptive weight parameters are used. Cross-entropy loss for classification tasks; For adaptive weight parameters of the regression task; The mean squared error loss for the regression task; Weighting coefficients for the comparative loss to be monitored; To monitor and compare losses.
8. A terahertz metamaterial molecular fingerprint sensing system based on multi-task learning, characterized in that, include: The spectral data acquisition module is configured to acquire the terahertz reflectance spectrum of the sample to be tested and extract the physical characteristics of the reflectance spectrum. The data processing module is configured to: input the terahertz reflection spectrum, the corresponding incident angle, and the physical features into a trained multi-task learning model; the multi-task learning model encodes the reflection spectrum, incident angle, and physical features through a lightweight fully connected network and maps them to a unified embedding space; the encoded feature vector is extracted using a molecular fingerprint cross-sample decoder and fused and compressed into a compact latent representation through a shared layer; The result output module is configured to input the latent representation into the classification head and regression head of the multi-task learning model, and output the molecular category identification result and concentration prediction result of the sample to be tested.
9. A computer-readable storage medium having a program stored thereon, characterized in that, When executed by the processor, the program implements the steps in the terahertz metamaterial molecular fingerprint sensing method based on multi-task learning as described in any one of claims 1-7.
10. An electronic device comprising a memory, a processor, and a program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps in the terahertz metamaterial molecular fingerprint sensing method based on multi-task learning as described in any one of claims 1-7.