A gas transient signal rapid detection method based on mamba and ordinal metric learning
By employing Mamba and ordinal metric learning methods and utilizing the transient signals of gas sensors, the problems of long detection cycles and low accuracy in existing technologies are solved, achieving low-latency, high-precision gas detection that is suitable for environmental monitoring and industrial safety.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NORTHEASTERN UNIV CHINA
- Filing Date
- 2026-01-21
- Publication Date
- 2026-05-15
AI Technical Summary
Existing gas sensors rely on steady-state signals, resulting in long detection cycles and insufficient utilization of transient signals. Furthermore, transient signals exhibit high intra-class variance and low inter-class separability, making it difficult to achieve low-latency, high-precision gas detection.
A method based on Mamba and ordinal metric learning is adopted to obtain the transient dynamic response signal of the gas sensor through temperature modulation, extract features using a Mamba encoder, and optimize the embedding vector through bidirectional Mamba layers and metric learning to achieve rapid detection of gas type and concentration.
It significantly improves the feature separability and accuracy of gas detection, shortens the detection time, and has strong model robustness, maintaining good performance in noisy and sensor drift environments.
Smart Images

Figure CN121561352B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of gas detection and analysis technology, and in particular to a rapid detection method for gas transient signals based on Mamba and ordinal metric learning. Background Technology
[0002] Gas sensors, especially semiconductor gas sensors, are widely used in environmental monitoring, industrial safety, and medical diagnostics due to their low cost, high sensitivity, and rapid response. To improve the selectivity and discriminative power of gas sensors, temperature modulation strategies (TMS) are widely employed. TMS obtains high-dimensional dynamic response signals by periodically changing the sensor's heating voltage, enabling it to operate at different temperatures. However, current TMS signal analysis primarily focuses on the steady-state response stage, i.e., waiting for the sensor signal to stabilize before data acquisition and analysis. This steady-state signal-based analysis method has significant limitations: high detection delay, requiring a long time for the sensor to reach steady state, resulting in a long overall detection cycle, making it difficult to meet the real-time or rapid response application requirements.
[0003] The underutilization of transient information is a significant drawback. Steady-state analysis methods neglect the transient dynamic response signal from the moment the sensor contacts the gas until it reaches steady state. This signal typically contains rich and unique gas characteristic information. The challenges of transient signals are further compounded by their high intra-class variance (the same gas may exhibit significant differences in different measurements), low inter-class separability (different gases may be poorly distinguishable in the early stages of a transient process), and susceptibility to environmental factors such as temperature, humidity, and sensor aging. These characteristics make it extremely challenging to directly utilize transient signals for high-precision identification and quantitative analysis.
[0004] While some studies have attempted to accelerate TMS detection by optimizing heating waveforms or combining them with traditional machine learning methods, these approaches often fail to fully exploit the deep features of transient signals or require large-scale datasets for calibration and training, resulting in limited model generalization capabilities. Therefore, there is an urgent need for a method that can effectively utilize the transient dynamic response signals of gas sensors and overcome their inherent challenges to achieve low-latency, high-precision gas detection. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention provides a rapid gas transient signal detection method based on Mamba and ordinal metric learning. Addressing the problems of long detection cycles and insufficient utilization of transient signals due to gas sensors' reliance on steady-state signals, as well as the inherent high intra-class variance and low inter-class separability of transient signals, this method effectively utilizes the transient dynamic response signal of the gas sensor to achieve low-latency, high-precision gas detection.
[0006] On one hand, this invention provides a fast detection method for gas transient signals based on Mamba and ordinal metric learning, comprising the following steps:
[0007] Step 1: By applying a periodic temperature-modulated heating voltage to the gas sensor, the transient dynamic response signal of the gas sensor after contact with the gas to be measured is obtained;
[0008] Step 2: Extract gas features using the Mamba encoder;
[0009] Step 2.1: Construct a neural network using the existing Mamba state-space model as a deep feature extractor to capture the complex time dependencies and nonlinear relationships in transient dynamic response signals;
[0010] Step 2.2: Perform standardization, noise enhancement, and amplitude amplification preprocessing on the transient dynamic response signal to obtain the enhanced signal. ;
[0011] The standardization specifically uses Z-Score standardization, with the following formula:
[0012] ;
[0013] Where x is the original data value, μ is the mean of the data, and σ is the standard deviation of the data;
[0014] The formulas for noise and amplitude enhancement are as follows:
[0015] ;
[0016] in For standardized data, As a scale of amplitude, It is Gaussian noise. It is the signal after enhancement processing. It is a normal distribution. and It is variance;
[0017] Step 2.3: The transient dynamic response signal of the enhanced signal at each time step t is as follows: At each time step, the step size is linearly projected onto the model width, as follows:
[0018] ;
[0019] in , These are the weights and biases for linear dimensionality increase. It is a Mamba dimension. It is the input signal after dimensional upgrading.
[0020] Step 2.4: Use a bidirectional Mamba layer to dynamically adjust the state space parameters of the Mamba state space model to capture key temporal dependencies in long sequences;
[0021] Specifically as follows: After obtaining the bidirectional Mamba state-space model The formula is as follows:
[0022] ;
[0023] ;
[0024] ;
[0025] in, Represents input signal Positive Represents input signal The opposite, It is the hidden state vector obtained after passing through the forward Mamba layer. This represents the hidden state vector obtained after the reverse Mamba layer. It is a combination of bidirectional hidden vectors.
[0026] The state space formula for a bidirectional Mamba layer is as follows:
[0027] ;
[0028] ;
[0029] in , , and It is a learnable parameter matrix. It is input. It is the output. and Let represent the hidden state vectors at time t and time t-1, respectively;
[0030] Step 2.5: Use the Mamba encoder to process the input transient signal. Transforming h into a fixed-dimensional embedding vector z, the specific implementation process is as follows: T Through a linear header, that is, a fully connected layer, it is mapped to an intermediate embedding vector z. raw The formula is as follows:
[0031] ;
[0032] in and These are weights and biases;
[0033] Step 3: Use metric learning to obtain the embedding vector from the Mamba encoder, and optimize it by calculating the loss function. Different triplet samples are selected for different tasks to achieve rapid detection of gas transient signals.
[0034] Step 3.1: Obtain the intermediate embedding vector z raw Then, depending on whether the task is a classification task or a regression task, different final processing methods are adopted to obtain the final embedding vector.
[0035] For classification tasks:
[0036] ;
[0037] For regression tasks:
[0038] ;
[0039] Step 3.2: For each anchored sample z a Select a positive sample z from the same class. p A negative sample z from a different class n ;
[0040] The loss function L is defined as:
[0041] ;
[0042] Where m is the boundary hyperparameter;
[0043] Step 3.3: For different task types, the selection methods for positive and negative samples in metric learning differ, as detailed below:
[0044] Classification task: For the gas type identification task, positive samples are selected from other samples of the same gas type as the anchor sample, and negative samples are selected from samples of different gas types than the anchor sample;
[0045] Regression task: For concentration prediction: Introduce a neighborhood negative sampling strategy; for anchored sample z a and its concentration C a :
[0046] Positive sample z p Selected from z a Having the same gas type and the same concentration C a The sample;
[0047] negative sample z n Selected from z a C having the same gas type but different concentrationsn The sample;
[0048] Neighborhood negative sampling: Preferential selection with C a Samples with small concentration differences are used as neighboring negative samples, or the weights of the loss function are adjusted so that the distance between the anchor sample and the negative samples adjacent to the concentration is smaller than the distance between the anchor sample and the negative samples not adjacent to the concentration.
[0049] On the other hand, this application proposes a computer-readable storage medium storing executable instructions that, when executed, cause a processor to perform the aforementioned method for rapid detection of gas transient signals based on Mamba and ordinal metric learning.
[0050] Thirdly, this application proposes a computer program product, including a computer program or instructions that, when executed by a processor, implement the aforementioned method for rapid detection of gas transient signals based on Mamba and ordinal metric learning.
[0051] The beneficial effects of adopting the above technical solution are as follows:
[0052] This invention provides a fast gas transient signal detection method based on Mamba and ordinal metric learning, significantly improving feature separability: Through the synergistic effect of the Mamba encoder and metric learning, transient signals that originally had high intra-class variance and low inter-class separability are transformed into compact intra-class and separable inter-class embedding vectors; improving detection accuracy: While significantly reducing detection latency, the accuracy of gas type identification is also greatly improved; achieving low-latency and fast detection: Effectively utilizing the rich information of transient signals, without waiting for steady state, greatly shortening the time required for gas detection, meeting the needs of real-time applications; and demonstrating strong model robustness: The ordinal metric learning strategy makes concentration prediction more robust in the embedding space, maintaining good performance even in the face of small noise or sensor drift. Attached Figure Description
[0053] Figure 1 This is a flowchart of a rapid gas transient signal detection method based on Mamba and ordinal metric learning in an embodiment of the present invention;
[0054] Figure 2 These are the temperature modulation mode and gas response curve of the gas sensor in this embodiment of the invention;
[0055] Figure 3 This is an FDR analysis diagram of the signals before and after the MOML framework is applied in an embodiment of the present invention;
[0056] Among them, (a) - FDR analysis of the original signal of the classification task, (b) - FDR analysis of the MOML signal of the classification task, (c) - FDR analysis of the original signal of the regression task, and (d) - FDR analysis of the MOML signal of the regression task.
[0057] Figure 4 This is a visualization of the t-SNE and PCA of the signals before and after the MOML framework is applied in this embodiment of the invention;
[0058] Among them, (a) is the t-SNE visualization of the original signal of the classification task, (b) is the t-SNE visualization of the MOML signal of the classification task, (c) is the PCA visualization of the original signal of the regression task, and (d) is the PCA visualization of the MOML signal of the regression task. Detailed Implementation
[0059] The specific implementation methods of this application will be further described in detail below with reference to the accompanying drawings and embodiments.
[0060] Example 1:
[0061] On the one hand, this invention provides a fast detection method for gas transient signals based on Mamba and ordinal metric learning, such as... Figure 1 As shown, it includes the following steps:
[0062] Step 1: By applying a periodic temperature-modulated heating voltage to the gas sensor, the transient dynamic response signal of the gas sensor after contact with the gas to be measured is obtained;
[0063] Step 2: Extract gas features using the Mamba encoder;
[0064] Step 2.1: Construct a neural network using the existing Mamba state-space model (Mamba Encoder) as a deep feature extractor to capture the complex time dependencies and nonlinear relationships in transient dynamic response signals;
[0065] Step 2.2: Perform normalization, noise enhancement, and amplitude augmentation preprocessing on the transient dynamic response signal to improve model robustness. Obtain the enhanced signal. ;
[0066] The standardization specifically uses Z-Score standardization, with the following formula:
[0067] ;
[0068] Where x is the original data value, μ is the mean of the data, and σ is the standard deviation of the data;
[0069] The formulas for noise and amplitude enhancement are as follows:
[0070] ;
[0071] in For standardized data, As a scale of amplitude, It is Gaussian noise. It is the signal after enhancement processing. It is a normal distribution. and It is variance;
[0072] Step 2.3: The transient dynamic response signal of the enhanced signal at each time step t is as follows: At each time step, the step size is linearly projected onto the model width. In this embodiment, the model width is set to 128 dimensions, as detailed below:
[0073] ;
[0074] in , These are the weights and biases for linear dimensionality increase. It is a Mamba dimension. It is the input signal after dimensional upgrading.
[0075] Step 2.4: Use a bidirectional Mamba layer to dynamically adjust the state space parameters of the Mamba state space model so that it can adaptively focus on important information according to the content of the input sequence, thereby capturing the key temporal dependencies in long sequences;
[0076] Specifically as follows: After obtaining the bidirectional Mamba state-space model The formula is as follows:
[0077] ;
[0078] ;
[0079] ;
[0080] in, Represents input signal Positive Represents input signal The opposite, It is the hidden state vector obtained after passing through the forward Mamba layer. This represents the hidden state vector obtained after the reverse Mamba layer. It is a combination of bidirectional hidden vectors.
[0081] The state space formula for a bidirectional Mamba layer is as follows:
[0082] ;
[0083] ;
[0084] in , , and It is a learnable parameter matrix. It is input. It is the output. and Let represent the hidden state vectors at time t and time t-1, respectively;
[0085] Step 2.5: Use the Mamba encoder to process the input transient signal. This is transformed into a fixed-dimensional embedding vector z, which is a compact representation of the original signal in the new feature space. The specific implementation process is as follows: h... T Through a linear header, that is, a fully connected layer, it is mapped to an intermediate embedding vector z. raw The formula is as follows:
[0086] ;
[0087] in and These are weights and biases;
[0088] Step 3: Use metric learning to obtain the embedding vector from the Mamba encoder, and optimize it by calculating the loss function. Different triplet samples are selected for different tasks to achieve rapid detection of gas transient signals.
[0089] Step 3.1: Obtain the intermediate embedding vector z raw Then, depending on whether the task is a classification task or a regression task, different final processing methods are adopted to obtain the final embedding vector.
[0090] For classification tasks:
[0091] ;
[0092] z raw Dividing by its own L2 norm, this operation projects all the embedding vectors z onto a unit hypersphere. After doing so, when the model performs metric learning, it no longer focuses on the length information of the vectors, but is forced to distinguish different gas categories solely by the "direction" of the vectors (i.e. the angle or cosine similarity between the vectors).
[0093] For regression tasks:
[0094] ;
[0095] In regression tasks, the length (magnitude) of a vector can be used by the model to encode a very important piece of information—the magnitude of concentration. Therefore, the length information of the vector is preserved.
[0096] Step 3.2: The core of the metric learning module is the triplet loss function. For each anchored sample z... a Select a positive sample z from the same class. p A negative sample z from a different class n ;
[0097] The loss function L is defined as:
[0098] ;
[0099] Where m is the boundary hyperparameter; the loss function aims to make the distance between the anchor sample and the positive sample smaller than the distance between the anchor sample and the negative sample, while maintaining at least a margin of m.
[0100] Step 3.3: For different task types, the selection methods for positive and negative samples in metric learning differ, as detailed below:
[0101] Classification task: For the gas type identification task, positive samples are selected from other samples of the same gas type as the anchor sample, and negative samples are selected from samples of different gas types than the anchor sample;
[0102] Regression task: For concentration prediction (ordinal metric learning): Introduce a neighborhood negative sampling strategy; for anchor sample z a and its concentration C a :
[0103] Positive sample z p Selected from z a Having the same gas type and the same concentration C a The sample;
[0104] negative sample z n Selected from z a C having the same gas type but different concentrations n The sample;
[0105] Neighborhood negative sampling: when selecting negative samples z n At that time, we must not only ensure its concentration It is also necessary to consider the anchor sample C a and negative sample C n The concentration difference between samples categorizes negative samples into "neighborhood negative samples" and "non-neighborhood negative samples." The specific sampling strategy is: preferentially select samples with concentrations similar to C... aSamples with small concentration differences are used as neighboring negative samples, or the weights of the loss function are adjusted so that the distance between the anchor sample and the negative samples adjacent to the anchor sample is smaller than the distance between the anchor sample and the negative samples not adjacent to the anchor sample. Through this strategy, the samples in the embedding space can not only distinguish gas types, but also reflect the ordinal relationship of gas concentrations to some extent. That is, samples with similar concentration values are closer in the embedding space, and the greater the concentration difference, the farther apart they are.
[0106] In this embodiment, to verify the effectiveness of the Mamba encoder cross-metric learning model (MOML), Fisher discriminant ratio analysis was used to quantify the changes in between-class and within-class variance before and after signal reconstruction. In addition, classic t-SNE and PCA visualizations were used to visually demonstrate the relationship between features of the sensor signal before and after reconstruction. Finally, classic machine learning models were used to train and predict the signals before and after reconstruction to verify the effect of MOML in "increasing the between-class variance and reducing the within-class variance".
[0107] Example 2:
[0108] This embodiment uses a metal oxide semiconductor gas sensor as an example to illustrate the proposed method for rapid detection of transient gas signals based on Mamba and metric learning through the detection of hydrogen, methane, butanone, and ethanol. The method includes the following parts:
[0109] Step 1: Perform data acquisition and preprocessing. The specific steps are as follows:
[0110] Step 1.1: Acquire the dynamic response signal of the gas sensor. The temperature modulation mode and original dynamic response signal of the gas sensor are as follows: Figure 2 As shown, the gas sensor is periodically heated using a square wave. Each modulation cycle is 20 seconds.
[0111] Step 1.2: Perform Z-score normalization on the acquired raw transient dynamic response signal X(t) to eliminate dimensional differences caused by different sensors or gas concentrations. The formula is as follows:
[0112] ;
[0113] Where x is the original data value. The mean of the data. denoted as the standard deviation of the data.
[0114] Step 1.3: To improve the model's generalization ability and robustness, data augmentation operations such as adding random noise and amplitude jitter can be performed on the training data. The specific formulas are as follows:
[0115] ;
[0116] In this embodiment, the temperature modulation signal period is 20s and the sampling frequency is 5Hz. Therefore, the length of a sensor signal is 100 time steps, and the dimension is 100. The dimension of the Mamba model is 128.
[0117] Step 2: Process the sensor response signal using the MOML framework. The specific steps are as follows:
[0118] Step 2.1: Preprocessed transient dynamic response signal of the gas sensor It has 100 dimensions, and each time the step size is linearly projected onto the model width.
[0119] ;
[0120] in , These are the weights and biases for linear dimensionality increase. It is a Mamba dimension, set to 128.
[0121] Step 2.2: Using a bidirectional Mamba layer, the state space parameters of Mamba are dynamically adjusted so that it can adaptively focus on important information based on the content of the input sequence, thereby effectively capturing the key temporal dependencies in long sequences.
[0122] Specifically as follows: The state-space model obtained from bidirectional Mamba is as follows. The formula is as follows:
[0123] ;
[0124] ;
[0125] ;
[0126] The state-space formula for Mamba is as follows:
[0127] ;
[0128] ;
[0129] Where A, B, C, and D are all learnable parameter matrices;
[0130] Step 2.3: Use the Mamba encoder to process the input transient signal. Convert into a fixed-dimensional embedding vector This embedding vector z is a compact representation of the original signal in the new feature space. The specific implementation process is as follows: the output of the Mamba encoder... A linear header, i.e., a fully connected layer, is used to map to an intermediate embedding vector. The formula is as follows: ;
[0131] in and These are weights and biases.
[0132] In this embodiment, the gases are classified into five categories: air, hydrogen, methane, butanone, and ethanol. The concentration range of the gases is 0~250 ppm.
[0133] Step 3: Use metric learning to obtain the embedding vectors from the Mamba model. The specific steps are as follows:
[0134] Step 3.1: After obtaining Subsequently, depending on whether the task was "classification" or "regression", different final processing methods were adopted to obtain the final embedding vector.
[0135] For classification tasks: ;
[0136] Will Dividing a vector by its own L2 norm projects all embedded vectors z onto a unit hypersphere. After doing this, the model no longer focuses on the length of the vectors when performing metric learning, but is forced to distinguish different gas categories solely by the "direction" of the vectors (i.e., the angle or cosine similarity between vectors).
[0137] For regression tasks: ;
[0138] In regression tasks, the length (magnitude) of a vector can be used by the model to encode a very important piece of information—the magnitude of concentration. Therefore, the length information of the vector is preserved.
[0139] Step 3.2: The core of the metric learning module is the triplet loss function. For each anchored sample... We need to select a positive sample of the same type. A negative sample from an outlier .
[0140] The loss function is defined as: ;
[0141] Where m is the boundary hyperparameter. This loss function aims to ensure that the distance between the anchor sample and the positive sample is less than the distance between the anchor sample and the negative sample, while maintaining at least a margin of m.
[0142] Step 3.3: For different tasks in Step 3.1, the selection methods for positive and negative samples in metric learning are different, as follows:
[0143] Classification task: For the gas type identification task, positive samples are selected from other samples of the same gas type as the anchor sample, and negative samples are selected from samples of different gas types than the anchor sample.
[0144] Concentration prediction task (ordinal metric learning): This invention innovatively introduces a neighborhood negative sampling strategy. For anchored samples... and its concentration :
[0145] Positive samples Selected from and Having the same gas type and the same concentration The sample.
[0146] negative samples Selected from and They have the same gas type but different concentrations. The sample.
[0147] Neighborhood negative sampling: in selecting negative samples At that time, we must not only ensure its concentration It also needs to be based on the anchored sample and negative samples The concentration difference between samples categorizes negative samples into "neighborhood negative samples" and "non-neighborhood negative samples." The specific sampling strategy is: preferentially select samples with... Samples with small concentration differences are used as neighboring negative samples, or the weights of the loss function are adjusted so that the distance between the anchor sample and the negative samples adjacent to the anchor sample is smaller than the distance between the anchor sample and the negative samples not adjacent to the anchor sample. Through this strategy, the samples in the embedding space can not only distinguish gas types, but also reflect the ordinal relationship of gas concentrations to some extent. That is, samples with similar concentration values are closer in the embedding space, and the greater the concentration difference, the farther apart they are.
[0148] In this example, the Fisher discriminant ratio analysis results are as follows: Figure 3 As shown in (a), (b), (c), and (d), after processing with the MOML framework, the Fisher discriminant ratio (FDR) for both gas type and gas concentration in the embedding space was significantly improved. Specifically, in the gas type recognition task, the FDR improved by more than 10 times, and in the gas concentration prediction task, the FDR even improved by more than 100 times. This indicates that the MOML framework effectively compresses intra-class variance and increases inter-class variance.
[0149] t-SNE and PCA visualizations, such as Figure 4As shown in (a), (b), (c), and (d) in the t-SNE plot, samples of different gas types form clearly separated clusters after MOML processing, while the sample points of the original signal (before processing) are highly aliased. In the PCA plot, samples of different concentrations after MOML processing exhibit obvious gradient distributions or ordinal relationships, confirming the effectiveness of ordinal metric learning.
[0150] The performance evaluation results of the classic machine learning model for gas detection are shown in Tables 1 and 2.
[0151] In the comparison of gas type identification results, the MOML framework combined with LightGBM achieved a gas type identification accuracy of 96.7% on the test set, which is a significant improvement compared to the LightGBM method based on the original signal (86.4%).
[0152] In the comparison of gas concentration prediction results, the root mean square error (RMSE) of hydrogen concentration prediction on the test set using the MOML framework combined with GB is 1.4, which is significantly lower than the method based on the original signal (4.8).
[0153] Table 1. Gas Category Prediction Results (Accuracy):
[0154]
[0155] Table 2 Gas Concentration Prediction Results (RMSE):
[0156]
[0157] Example 3:
[0158] This embodiment proposes a computer-readable storage medium that stores executable instructions. When these instructions are executed, if they are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium.
[0159] The computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the rapid gas transient signal detection method based on Mamba and ordinal metric learning described in the various embodiments of this application.
[0160] The aforementioned storage media include: flash memory, hard disk, multimedia card, card-type memory (e.g., SD (Secure Digital Memory Card) or DX (Memory Data Register, MDR) memory, random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, server, APP (Application) application store, and other media capable of storing program verification codes. These media store computer programs, which, when executed by a processor, can implement the various steps of the aforementioned rapid detection method for gas transient signals based on Mamba and ordinal metric learning.
[0161] Example 4:
[0162] This embodiment proposes a computer program product, including a computer program or instructions, which, when executed by a processor, implements the aforementioned method for rapid detection of gas transient signals based on Mamba and ordinal metric learning.
[0163] Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or part of the technical solution, can be embodied in the form of a computer program product.
[0164] The various embodiments in this application are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.
[0165] The scope of protection of this application is not limited to the embodiments described above. Obviously, those skilled in the art can make various modifications and variations to this disclosure without departing from the scope and spirit of this disclosure. If such modifications and variations fall within the scope of the methods disclosed herein and their equivalents, then the intent of this disclosure also includes such modifications and variations.
Claims
1. A fast detection method for gas transient signals based on Mamba and ordinal metric learning, characterized in that, Includes the following steps: Step 1: By applying a periodic temperature-modulated heating voltage to the gas sensor, the transient dynamic response signal of the gas sensor after contact with the gas to be measured is obtained; Step 2: Extract gas features using the Mamba encoder; Step 2.1: Construct a neural network using the existing Mamba state-space model as a deep feature extractor to capture the complex time dependencies and nonlinear relationships in transient dynamic response signals; Step 2.2: Perform standardization, noise enhancement, and amplitude amplification preprocessing on the transient dynamic response signal to obtain the enhanced signal. ; Step 2.3: The transient dynamic response signal of the enhanced signal at each time step t is as follows: At each time step, the step size is linearly projected onto the model width, as follows: ; in , These are the weights and biases for linear dimensionality increase. It is a Mamba dimension. It is the input signal after dimensional upgrading; Step 2.4: Use a bidirectional Mamba layer to dynamically adjust the state space parameters of the Mamba state space model to capture key temporal dependencies in long sequences; Step 2.5: Use the Mamba encoder to process the input transient signal. Transforming h into a fixed-dimensional embedding vector z, the specific implementation process is as follows: T Through a linear header, that is, a fully connected layer, it is mapped to an intermediate embedding vector z. raw The formula is as follows: ; in and These are weights and biases; Step 3: Use metric learning to obtain the embedding vector from the Mamba encoder, and optimize it by calculating the loss function. Different triplet samples are selected for different tasks to achieve rapid detection of gas transient signals. Step 3.1: Obtain the intermediate embedding vector z raw Then, depending on whether the task is a classification task or a regression task, different final processing methods are adopted to obtain the final embedding vector; Step 3.2: For each anchored sample z a Select a positive sample z from the same class. p A negative sample z from a different class n ; The loss function L is defined as: ; Where m is the boundary hyperparameter; Step 3.3: For different task types, select different positive and negative samples for metric learning; The selection of positive and negative samples for different metrics learning is as follows: Classification task: For the gas type identification task, positive samples are selected from other samples of the same gas type as the anchor sample, and negative samples are selected from samples of different gas types than the anchor sample; Regression task: For concentration prediction: Introduce a neighborhood negative sampling strategy; for anchored sample z a and its concentration C a : Positive sample z p Selected from z a Having the same gas type and the same concentration C a The sample; negative sample z n Selected from z a C having the same gas type but different concentrations n The sample; Neighborhood negative sampling: Preferential selection with C a Samples with small concentration differences are used as neighboring negative samples, or the weights of the loss function are adjusted so that the distance between the anchor sample and the negative samples adjacent to the concentration is smaller than the distance between the anchor sample and the negative samples not adjacent to the concentration.
2. The method for rapid detection of gas transient signals based on Mamba and ordinal metric learning according to claim 1, characterized in that, The standardization described in step 2.2 specifically uses Z-Score standardization, as shown in the following formula: ; Where x is the original data value, μ is the mean of the data, and σ is the standard deviation of the data; The formulas for noise and amplitude enhancement are as follows: ; in For standardized data, As a scale of amplitude, It is Gaussian noise. It is the signal after enhancement processing. It is a normal distribution. and It is variance.
3. The method for rapid detection of gas transient signals based on Mamba and ordinal metric learning according to claim 2, characterized in that, Step 2.4 is as follows: After obtaining the bidirectional Mamba state-space model The formula is as follows: ; ; ; in, Represents input signal Positive Represents input signal The opposite, It is the hidden state vector obtained after passing through the forward Mamba layer. This represents the hidden state vector obtained after the reverse Mamba layer. It is a combination of two-way hidden vectors; The state space formula for a bidirectional Mamba layer is as follows: ; ; in , , and It is a learnable parameter matrix. It is input. It is the output. and Let represent the hidden state vectors at time t and time t-1, respectively.
4. The method for rapid detection of gas transient signals based on Mamba and ordinal metric learning according to claim 3, characterized in that, Step 3.1 describes different final processing methods to obtain the final embedding vector, as follows: For classification tasks: ; For regression tasks: 。 5. A computer-readable storage medium, characterized in that, It stores executable instructions that, when executed, cause the processor to perform a method for rapid detection of gas transient signals based on Mamba and ordinal metric learning, as described in any one of claims 1-4.
6. A computer program product, characterized in that, Includes a computer program or instructions that, when executed by a processor, implement the method for rapid detection of gas transient signals based on Mamba and ordinal metric learning as described in any one of claims 1-4.