Gas concentration prediction method based on static spectrum characteristics
By combining a deep learning model with time domain and frequency domain features, the problem of insufficient accuracy and stability of traditional gas concentration monitoring methods in multi-gas mixtures is solved, and high-precision prediction of gas concentration is achieved to meet the needs of diverse scenarios.
Patent Information
- Application Number
- CN202510989606.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-17
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2045-07-17
AI Technical Summary
Traditional gas concentration monitoring methods are greatly affected by environmental conditions and have difficulty effectively distinguishing concentration changes in multi-gas mixtures. Existing models ignore domain information, resulting in insufficient prediction accuracy and stability, and their applicability is particularly limited in diverse scenarios.
Multiple measurements are performed using a gas-sensitive resistor sensor. The time domain and frequency domain features are combined to predict gas concentration through a deep learning model. Missing value filling and outlier processing are used to fuse the time domain and frequency domain features, design a dynamic feature weighting mechanism, introduce a multi-head attention mechanism, and construct a deep learning network with no fixed length limit.
The accuracy and stability of gas concentration prediction have been significantly improved, especially in non-stationary data scenarios. The robustness and generalization ability of the model have been enhanced, and it can accurately capture the concentration changes in complex gas mixtures and adapt to the feature capture capabilities of different scenarios.
Smart Images

Figure CN120703178A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of gas concentration prediction. Background Art
[0002] Traditional gas concentration monitoring methods, widely used in environmental protection and industrial production, rely on chemical or physical sensors. However, these methods are significantly affected by environmental conditions (such as temperature, humidity, and pressure), resulting in poor accuracy and stability in monitoring results. In particular, when monitoring multi-gas mixtures, traditional technologies struggle to effectively distinguish concentration changes between different gases, and their real-time response capabilities are significantly limited.
[0003] In recent years, deep learning technology has been increasingly applied to gas concentration prediction. However, existing models primarily model time-domain features, neglecting implicit information in the signal's frequency domain. This single-perspective modeling approach struggles to capture the periodic variations of complex signals, limiting the model's applicability in diverse scenarios. Furthermore, in real-world applications, sensor data lengths are often inconsistent, and conventional zero-padding or cropping strategies can introduce unnecessary noise and information loss, further reducing the model's predictive power.
[0004] Furthermore, most current gas concentration prediction models typically require input data of uniform length. Since actual sensor data is typically acquired in time series, and different sensors have varying acquisition cycles and data lengths, directly processing variable-length data often requires zero-padding or cropping, which can lead to information loss and degraded model performance, resulting in poorly predicted gas concentrations. Summary of the Invention
[0005] The purpose of the present invention is to solve the problem of poor accuracy of the current method for predicting gas concentration, and proposes a gas concentration prediction method based on static spectrum characteristics.
[0006] A gas concentration prediction method based on static spectrum characteristics, the method comprising the following contents:
[0007] Step 1: Use a gas-sensitive resistor sensor to repeatedly measure multiple single historical gases and multiple mixed historical gases, and output a set of physical quantity characteristic combinations for each single historical gas and each mixed historical gas in each measurement;
[0008] Each set of physical quantity features is combined as each multidimensional time series, and the gas name and concentration label of each multidimensional time series are obtained at the same time, where all multidimensional time series have the same dimension;
[0009] Step 2, data processing: use missing value filling and outlier processing methods to process each multidimensional time series to obtain each processed multidimensional time series;
[0010] Step 3: Feature fusion: Based on the multiple processed multidimensional time series of each type of gas obtained from multiple measurements of each single gas and mixed gas, the time domain features and frequency domain features of the corresponding type of gas are obtained, and the time domain features and frequency domain features of the corresponding type of gas are fused to obtain a multidimensional feature matrix of the corresponding type of gas;
[0011] Step 4: Use each multidimensional feature matrix as input data and the corresponding gas name and concentration label as output data to train the deep learning model and obtain a trained deep learning model;
[0012] Step 5: Use a gas-sensitive resistor sensor to repeatedly measure the gas to be tested in the test environment. The output multiple multidimensional time series are processed and feature fused in turn to obtain the multidimensional feature matrix to be tested. The matrix is input into the trained deep learning model to predict the gas name and concentration.
[0013] Preferably, the dimension of all gas multidimensional time series is 3, including the resistance value output by the gas sensitive resistor sensor, the voltage value and the current value applied to the gas sensitive resistor sensor.
[0014] Preferably, in step 2, each multidimensional time series is processed using missing value filling and outlier processing methods, specifically:
[0015] Detect whether there are missing time points in each multidimensional time series. If so, use linear interpolation to obtain a resistance interpolation value based on the two resistance values at two adjacent moments of the missing time point, a voltage interpolation value based on the two voltage values at two adjacent moments of the missing time point, and a current interpolation value based on the two current values at two adjacent moments of the missing time point; and fill in the missing time point with the resistance interpolation value, voltage interpolation value, and current interpolation value.
[0016] Detect whether a physical quantity feature in each multidimensional time series is abnormal or missing. If the voltage value at a certain moment is abnormal or missing, eliminate the voltage value, calculate the mean of the voltage values at all moments, and fill the mean into the position of the eliminated voltage value; if the resistance value at a certain moment is abnormal or missing, eliminate the resistance value, calculate the mean of the resistance values at all moments, and fill the mean into the position of the eliminated resistance value; if the current value at a certain moment is abnormal or missing, eliminate the current value, calculate the mean of the current values at all moments, and fill the mean into the position of the eliminated current value.
[0017] Preferably, the linear interpolation processing method is:
[0018]
[0019] Where, X i,jis the feature X at the jth moment i , X i is the resistance value, voltage value or current value, X i,j+1 is the feature X at the j+1th moment i , t j+1 is the j+1th moment, t j is the jth moment, t m is the time corresponding to the missing value or outlier, X′ i,m is interpolation.
[0020] Preferably, the process of detecting whether a physical quantity feature in each multidimensional time series is abnormal or missing is:
[0021] The resistance value, voltage value and current value at each moment in each multidimensional time series are detected in turn to see whether they exceed the corresponding preset fluctuation range. If so, they are determined to be abnormal values; if not, they are determined to be normal values.
[0022] Preferably, the upper and lower limits of the preset fluctuation range are:
[0023] Upper bound = Q3 + 1.5 × IQR, lower bound = Q1 - 1.5 × IQR,
[0024] In the formula, IQR=Q3-Q1, IQR is the interquartile range, Q1 is the lower quartile, and Q3 is the upper quartile.
[0025] Preferably, in step 3, the time domain features include obtaining the mean resistance value, mean voltage value, mean current value, standard deviation of resistance value, standard deviation of voltage value, standard deviation of current value, maximum resistance value, maximum voltage value and maximum current value at each moment from multiple multidimensional time series obtained from multiple measurements.
[0026] Preferably, in step 3, the frequency domain feature is expressed as:
[0027]
[0028] Where X(k) is the spectral component of the frequency domain signal at frequency k, including amplitude-frequency characteristics and phase-frequency characteristics. x(n) is the physical quantity sequence in the time domain feature matrix, including the resistance value output by the gas-sensitive resistor sensor, the voltage value and current value applied to the gas-sensitive resistor sensor. N is the total number of time domain data points. k is the frequency index, corresponding to different frequency components. is a complex basis function.
[0029] Preferably, in step 4, the deep learning model includes a convolutional layer, a bidirectional LSTM layer, a multi-head attention layer, a flattening layer, a fully connected layer and an output layer.
[0030] The convolution layer is used to convert the multi-dimensional feature matrix into a 128-dimensional vector sequence and pass it to the bidirectional LSTM layer;
[0031] A bidirectional LSTM layer is used to convert the 128-dimensional vector sequence into a 256-dimensional vector sequence and pass it to the multi-head attention layer;
[0032] The multi-head attention layer is used to convert the 256-dimensional vector sequence into a three-dimensional time series feature tensor and pass it to the flattening layer;
[0033] The flattening layer is used to convert the three-dimensional time series feature tensor into a two-dimensional feature matrix and pass it to the fully connected layer;
[0034] The fully connected layer is used to convert the two-dimensional feature matrix into a 128-dimensional vector sequence and pass it to the output layer;
[0035] The output layer is used to establish a mapping relationship between the 128-dimensional vector sequence and the corresponding label.
[0036] Preferably, the method further comprises step 6:
[0037] Optimize the model: Calculate the loss function between the predicted gas names and concentrations and the labels used to train the deep learning model. Use the Adam optimizer to optimize the parameters in the deep learning model so that the loss function reaches the threshold.
[0038] The beneficial effects of the present invention are:
[0039] The present invention has significant advantages in terms of technology and application, and solves many limitations of traditional methods and existing technologies. The specific analysis is as follows:
[0040] 1. This invention achieves a comprehensive, multi-level analysis of gas signals by combining deep mining of time-domain and frequency-domain features. Compared to traditional models that rely solely on time-domain features, the inclusion of frequency-domain features effectively reveals periodic patterns in the signal, enabling the model to more accurately predict concentration changes in complex gas mixtures. In experiments, the model incorporating frequency-domain features improved prediction accuracy by over 25%, particularly in non-stationary data scenarios.
[0041] 2. The dynamic feature weighting mechanism (frequency and time domain) designed in this invention dynamically adjusts the weight distribution of time and frequency domain features based on the actual distribution of input data. This innovation not only improves the model's adaptability to different scenarios but also significantly enhances its ability to capture key features, significantly improving the model's robustness and generalization capabilities in multi-gas monitoring.
[0042] 3. The proposed deep learning network architecture, without fixed length constraints, avoids the information loss that can occur with traditional zero-padding or cropping operations. This architecture can directly process long-term, indeterminate time series data, effectively addressing the challenge of inconsistent lengths in multi-sensor data, thereby improving the model's prediction accuracy and stability.
[0043] 4. In terms of model design, this invention further enhances its ability to focus on key features by introducing a multi-head attention mechanism. Compared with existing technologies, this multi-head attention mechanism demonstrates significant advantages in complex multi-gas scenarios, enabling the model to maintain high-precision predictions even in situations with high signal noise or high data diversity.
[0044] 5. The overall technical solution of this invention has demonstrated excellent performance in multiple experiments. It significantly outperforms existing technologies in terms of prediction accuracy, robustness, and computational efficiency. In scenarios involving multi-gas mixtures, this method can accurately capture the concentration trends of different gases, providing efficient and reliable technical support for environmental protection, industrial safety, and public health.
[0045] In summary, the present invention has significant innovation and superiority in both theoretical depth and practical application value of gas concentration prediction. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 It is a flow chart of the gas concentration prediction method based on static spectrum characteristics;
[0047] Figure 2 Schematic diagram of the deep learning model structure. DETAILED DESCRIPTION
[0048] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making any creative efforts shall fall within the scope of protection of the present invention.
[0049] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.
[0050] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, but they are not intended to limit the present invention.
[0051] Example:
[0052] A gas concentration prediction method based on static spectrum characteristics, the method comprising the following contents:
[0053] Step 1: Use a gas-sensitive resistor sensor to repeatedly measure multiple single historical gases and multiple mixed historical gases, and output a set of physical quantity characteristic combinations for each single historical gas and each mixed historical gas in each measurement;
[0054] Each set of physical quantity features is combined as each multidimensional time series, and the gas name and concentration label of each multidimensional time series are obtained at the same time, where all multidimensional time series have the same dimension;
[0055] Step 2, data processing: use missing value filling and outlier processing methods to process each multidimensional time series to obtain each processed multidimensional time series;
[0056] Step 3: Feature fusion: Based on the multiple processed multidimensional time series of each type of gas obtained from multiple measurements of each single gas and mixed gas, the time domain features and frequency domain features of the corresponding type of gas are obtained, and the time domain features and frequency domain features of the corresponding type of gas are fused to obtain a multidimensional feature matrix of the corresponding type of gas;
[0057] Step 4: Use each multidimensional feature matrix as input data and the corresponding gas name and concentration label as output data to train the deep learning model and obtain a trained deep learning model;
[0058] Step 5: Use a gas-sensitive resistor sensor to repeatedly measure the gas to be tested in the test environment. The output multiple multidimensional time series are processed and feature fused in turn to obtain the multidimensional feature matrix to be tested. The matrix is input into the trained deep learning model to predict the gas name and concentration.
[0059] Specifically, the multiple repeated measurements in step 1 mean that, for example, oxygen is measured three times to obtain three sets of physical quantity characteristic combinations; for a mixed gas, such as a mixture of oxygen and hydrogen, it is measured three times to obtain three sets of physical quantity characteristic combinations.
[0060] Step 1 is to prepare training data. The collected gases are pre-prepared and can be single gases or mixed gases of two or more. For example, we need to let the gas flow into the bottle where the sensor is located for 5-20 seconds, or even longer. The label refers to the concentration and gas name. For example, a single gas label is 5 ppm oxygen, while a mixed gas label can be 5 ppm 50% oxygen and 5 ppm 50% hydrogen.
[0061] Step 3 means that if a single gas is repeatedly collected three times and then processed, three multidimensional time series are obtained. The time domain characteristics and frequency domain characteristics of the single gas are obtained using these three multidimensional time series. The time domain characteristics and frequency domain characteristics of other types of gases are obtained in the same way.
[0062] It is further defined that the dimension of all multidimensional time series is 3, including the resistance value output by the gas sensitive resistor sensor, the voltage value and the current value applied to the gas sensitive resistor sensor.
[0063] Specifically, in the gas concentration prediction task, the input data set comes from multiple measurements of different gases by multiple sensors: each sensor performs 3-10 repeated measurements on a single gas (such as gas 1, gas 2 to gas n). For example, sensor 1 measures gas 1 3-10 times to generate a time series data sequence {t1, R1, U1, I1}, {t2, R2, U2, I2}… {t n ,R n ,U n ,I n Sensor 2 uses the same logic to complete 3-10 measurements of gas 2 and form a corresponding data structure. For mixed gas scenarios, the concentration of each component is annotated synchronously during measurement (such as a mixture of m% concentration of gas x and n% concentration of gas y), and 3-10 repeated samplings are completed through the same sensor array. All raw data contain the values of physical quantities such as resistance (R), voltage (U), and current (I) at different time points, as well as the gas concentration label implicit in the file name (single gas concentration or the concentration of each component of a mixed gas). The output data set is a standardized feature matrix formed after preprocessing, in which each row corresponds to a multidimensional feature of a single time point on a unified time axis (such as {t, R, U, I}), and matches the corresponding single gas concentration value or mixed gas concentration label for training and prediction of deep learning models.
[0064] Further limiting, in step 2, each multidimensional time series is processed using missing value filling and outlier processing methods, specifically:
[0065] Detect whether there are missing time points in each multidimensional time series. If so, use linear interpolation to obtain a resistance interpolation value based on the two resistance values at two adjacent moments of the missing time point, a voltage interpolation value based on the two voltage values at two adjacent moments of the missing time point, and a current interpolation value based on the two current values at two adjacent moments of the missing time point; and fill in the missing time point with the resistance interpolation value, voltage interpolation value, and current interpolation value.
[0066] Detect whether a physical quantity feature in each multidimensional time series is abnormal or missing. If the voltage value at a certain moment is abnormal or missing, eliminate the voltage value, calculate the mean of the voltage values at all moments, and fill the mean into the position of the eliminated voltage value; if the resistance value at a certain moment is abnormal or missing, eliminate the resistance value, calculate the mean of the resistance values at all moments, and fill the mean into the position of the eliminated resistance value; if the current value at a certain moment is abnormal or missing, eliminate the current value, calculate the mean of the current values at all moments, and fill the mean into the position of the eliminated current value.
[0067] Further limiting, the linear interpolation method is:
[0068]
[0069] Where, X i,j is the feature X at the jth moment i , X i is the resistance value, voltage value or current value, X i,j+1 is the feature X at the j+1th moment i , t j+1 is the j+1th moment, t j is the jth moment, t m is the time corresponding to the missing value or outlier, X′ i,m is interpolation.
[0070] Specifically, no matter it is a single gas or a mixed gas, the characteristics obtained at each moment are composed of three characteristics: resistance value, voltage value and current value.
[0071] If the time point sequence is T={t1,t2,…,t N}, there are three characteristic values at each time point, namely resistance value, voltage value and current value. If there is a missing time point t m , then the resistance values at the two time points connected to the left and right of this time point are substituted into the linear interpolation formula to obtain the resistance interpolation value, which is then used to fill in the missing time point. Similarly, the voltage interpolation and current interpolation values are also used to fill in the missing time point in this way, so that the data at this time point is complete.
[0072] If time point t i If any value of R, U, or I is missing or abnormal, it can be filled by checking the mean of the historical data of the sensor. For example, for the missing point of resistance value R, the mean of all valid R values of the sensor is calculated. And use μ R Fill in missing positions.
[0073] Further defined, the process of detecting whether a physical quantity feature in each multidimensional time series is abnormal or missing:
[0074] The resistance value, voltage value and current value at each moment in each multidimensional time series are detected in turn to see whether they exceed the corresponding preset fluctuation range. If so, they are determined to be abnormal values; if not, they are determined to be normal values.
[0075] Further limiting, the upper and lower bounds of the preset fluctuation range are:
[0076] Upper bound = Q3 + 1.5 × IQR, lower bound = Q1 - 1.5 × IQR,
[0077] In the formula, IQR=Q3-Q1, IQR is the interquartile range, Q1 is the lower quartile, and Q3 is the upper quartile.
[0078] Specifically, Q1 is the lower quartile (25th percentile), which refers to the cutoff value for the top 25% of data after sorting from smallest to largest. Q3 is the upper quartile (75th percentile), which refers to the cutoff value for the top 75% of data after sorting from smallest to largest. IQR is the interquartile range, which measures the degree of dispersion of the data and reflects the fluctuation range of the middle 50% of data. The cutoff value refers to the value at a specific position in the data after sorting from smallest to largest (it can be a single value in the original data or the weighted average of two adjacent values).
[0079] It is further defined that in step 3, the time domain features include obtaining the mean resistance value, mean voltage value, mean current value, standard deviation of resistance value, standard deviation of voltage value, standard deviation of current value, maximum resistance value, maximum voltage value and maximum current value at each moment from multiple multidimensional time series obtained from multiple measurements.
[0080] Specifically, each acquisition obtains a set of multidimensional time series. After data processing, each processed multidimensional time series is obtained, and its format is:
[0081]
[0082] Among them, each row represents the complete features of a sampling point. i is the time point R i 、U i , I i are the resistance, voltage, and current values at that time point, respectively.
[0083] For example, if oxygen is measured three times, three processed multidimensional time series are obtained. The three resistance values, the three voltage values, and the three current values in the three processed multidimensional time series at time t1 are averaged, and the maximum and minimum values of the three resistance values, the maximum and minimum values of the three current values, and the maximum and minimum values of the three voltage values at time t1 are taken. The standard deviation of the voltage value, the standard deviation of the current value, and the standard deviation of the resistance value at time t1 are calculated; the calculated values are used as the time domain features at time t1; the process of obtaining the time domain features at other times is the same.
[0084] Among them, the mean is: Reflects the average level of the signal, where x i is the time domain data point, N is the total number of data;
[0085] The standard deviation is: Measures the amplitude of signal fluctuations;
[0086] The minimum value min(x) and the maximum value max(x) define the signal variation range.
[0087] Further limiting, in step 3, the frequency domain features are expressed as:
[0088]
[0089] Where X(k) is the spectral component of the frequency domain signal at frequency k, including amplitude-frequency characteristics and phase-frequency characteristics. x(n) is the physical quantity sequence in the time domain feature matrix, including the resistance value output by the gas-sensitive resistor sensor, the voltage value and current value applied to the gas-sensitive resistor sensor. N is the total number of time domain data points. k is the frequency index, corresponding to different frequency components. is a complex basis function.
[0090] Specifically, discrete Fourier transform (DFT) is used to obtain frequency domain features.
[0091] After frequency domain feature extraction, the positive frequency part is combined with the time domain statistical features (mean, standard deviation, etc.) to form a complete feature vector. The amplitude-frequency feature reveals the periodicity of the signal (such as the frequency characteristics of gas concentration fluctuations), and the phase-frequency feature reflects the phase offset of the signal. The combination of the two can more comprehensively describe the dynamic change trend of gas concentration.
[0092] In the input data of the deep learning model, the fused matrix is a multidimensional feature matrix that combines time domain and frequency domain features. Its structure is as follows:
[0093] Time domain feature matrix (including statistical features):
[0094]
[0095] Frequency domain feature matrix (including amplitude-frequency and phase-frequency features):
[0096]
[0097] |X i (f k )| is the time point (t i ) corresponds to the physical quantity (R, U, I) at the frequency (f k ) at the amplitude value (amplitude-frequency characteristics); ∠X i (f k ) frequency (f k ) is calculated by discrete Fourier transform (DFT): Among them, the modulus (|X(k)|) of (X(k)) is the amplitude frequency, the argument (∠X(k)) is the phase frequency, and (x(n)) is the time domain physical quantity sequence. f1,f2,…,f k are the extracted discrete frequency points (such as the first k main frequency components).
[0098] Each row of the fusion matrix corresponds to a single time point on the unified time axis, and each column contains the time domain statistical features, frequency domain amplitude-frequency features, and phase-frequency features of the time point.
[0099] Further defining, in step 4, the deep learning model includes convolutional layer, bidirectional LSTM layer, multi-head attention layer, flattening layer, fully connected layer and output layer,
[0100] The convolution layer is used to convert the multi-dimensional feature matrix into a 128-dimensional vector sequence and pass it to the bidirectional LSTM layer;
[0101] A bidirectional LSTM layer is used to convert the 128-dimensional vector sequence into a 256-dimensional vector sequence and pass it to the multi-head attention layer;
[0102] The multi-head attention layer is used to convert the 256-dimensional vector sequence into a three-dimensional time series feature tensor and pass it to the flattening layer;
[0103] The flattening layer is used to convert the three-dimensional time series feature tensor into a two-dimensional feature matrix and pass it to the fully connected layer;
[0104] The fully connected layer is used to convert the two-dimensional feature matrix into a 128-dimensional vector sequence and pass it to the output layer;
[0105] The output layer is used to establish a mapping relationship between the 128-dimensional vector sequence and the corresponding label.
[0106] Specifically, deep learning model construction:
[0107] The model input is the preprocessed fusion feature matrix, which contains time domain statistical features and frequency domain features:
[0108] Dimensions: 3D tensor: (number of samples processed in a single forward / backward pass, time steps, feature dimensions)
[0109] Matrix form:
[0110]
[0111] Data flow: batches of 128 examples (actual shape: (128,n,d), where n = time steps and d = feature dimension).
[0112] 1. Convolutional layer (Conv1D)
[0113] enter:
[0114] Shape: (128, n, d) (128 samples × n time steps × d-dimensional features)
[0115] Data type: 3D floating-point tensor
[0116] operate:
[0117] 128 convolution kernels slide along the time axis
[0118] Kernel size = 6, stride = 1, activation function ReLU
[0119] Calculation example (single time step):
[0120]
[0121] Output:
[0122] Shape: (128, n-5, 128)
[0123] (The time step is reduced by 5 due to kernel size 6)
[0124] Matrix example (single sample):
[0125]
[0126] Inter-layer role: extract local feature patterns, convert original features into high-dimensional representations, and provide BiLSTM with input rich in spatial information.
[0127] 2. Bidirectional LSTM layer (BiLSTM)
[0128] enter:
[0129] Shape: (128, n-5, 128)
[0130] Data (single time step): [0.24, 1.72, ..., 0.98] (128-dimensional vector)
[0131] operate:
[0132] Forward LSTM: processes the sequence from left to right
[0133]
[0134] Backward LSTM: Processes sequences from right to left
[0135]
[0136] Output splicing:
[0137]
[0138] Output:
[0139] Shape: (128, n-5, 256)
[0140] (128-dimensional forward + 128-dimensional backward)
[0141] Matrix example (single sample):
[0142]
[0143] Inter-layer role: Capture long-term temporal dependencies and expand the local features of CNN into high-level representations that include bidirectional context.
[0144] 3. Multi-head attention layer
[0145] enter:
[0146] Shape: (128, n-5, 256)
[0147] Data: 256-dimensional vector sequence output by BiLSTM
[0148] operate:
[0149] Linear projection generates Q / K / V matrices:
[0150] Q=XW Q ,K=XW K ,V=XW V , X is the input feature matrix, W Q is the projection weight matrix of the query, W K is the projection weight matrix of the key, W V is the projection weight matrix of value;
[0151] 8-head attention parallel calculation:
[0152] head iis the output of the i-th attention head, soft is a function used to normalize the weights, Q i is the query matrix corresponding to the i-th attention head, is the key matrix corresponding to the i-th attention head, V i is the value matrix corresponding to the i-th attention head, is the scaling factor, 32 is the feature dimension of each attention head;
[0153] Multi-head output splicing:
[0154] Z = Concat(head1,…,head8)W0, where Concat is a concatenation operation used to merge the outputs of the eight attention heads; W0 is the output projection weight matrix; and Z is the final output of the multi-head attention mechanism.
[0155] Output:
[0156] Shape: (128, n-5, 256)
[0157] (same as input time step)
[0158] Matrix example (single time step): [0.18, 0.02, ..., -0.11] (256-dimensional weighted features)
[0159] Inter-layer role: focus on key features, suppress noise, and provide purified feature representation for the fully connected layer.
[0160] 4. Flatten
[0161] enter:
[0162] Shape: (128, n-5, 256)
[0163] Data: 3D attention output tensor
[0164] operate:
[0165] Dimension transformation: (batch, timesteps, features) → (batch, timesteps×features)
[0166] Mathematical expression: reshape(Z, (128, (n-5) × 256))
[0167] Output:
[0168] Shape: (128, (n-5) × 256)
[0169] Matrix example (single sample): [0.18, 0.02, ..., -0.11, 0.15, ...] (length = (n-5) × 256)
[0170] Inter-layer interaction: quantize spatiotemporal features and adapt the processing format of the fully connected layer.
[0171] 5. Fully connected layer (Dense)
[0172] enter:
[0173] Shape: (128, (n-5) × 256)
[0174] Data: Flattened one-dimensional feature vector
[0175] operate:
[0176] Nonlinear transformation:
[0177] y=max(θ,W X +b), y is the output result after nonlinear transformation, which is usually the feature representation after activation processing (here an operation similar to the ReLU variant is used, and max is a function to implement threshold activation), θ is the threshold parameter used to control the starting point of activation, similar to the "0" threshold in ReLU, W X Represents the linear product of the weight matrix W and the input feature X (i.e., the linear transformation part, W and X perform matrix multiplication), b is the bias term, which is used to offset the linear transformation result to help the model fit more complex data;
[0178] Weight matrix:
[0179] m is the number of rows in the weight matrix, and n is the feature dimension before input to the fully connected layer (or the length of the feature sequence, etc., which needs to be determined in combination with the specific model input). It is the basic parameter for deriving the number of rows in the weight matrix m;
[0180] Output:
[0181] Shape: (128, 128)
[0182] Matrix example:
[0183]
[0184] Inter-layer interaction: feature space compression and abstraction, extracting the core pattern of concentration prediction.
[0185] 6. Output layer (Dense)
[0186] enter:
[0187] Shape: (128,128)
[0188] Data: 128-dimensional features output by the fully connected layer
[0189] operate:
[0190] Linear Regression:
[0191] The predicted value output by the model. For example, in a regression task, it is the predicted result of the true label y, which will be based on the input x and the parameters W learned by the model. out and b out It is calculated that W out is the weight matrix of the output layer (or weight vector, if x is a vector and the scenario is simple, it can be regarded as vector multiplication). It will be learned and adjusted during the model training process to perform a linear transformation on the input x, reflecting the linear relationship between the input features and the output prediction values; x is the feature vector (or feature matrix, depending on the specific dimension adaptation) input to the output layer, which is the feature representation passed to the output layer after being processed by the previous network layer; b out is the bias term of the output layer, and the weight W out Participate in linear calculations together, assist the model in fitting data, make linear transformations more flexible, and synchronize learning and updates during training.
[0192] Weight matrix:
[0193] (p = output dimension)
[0194] Output:
[0195] Single gas: shape (128, 1), scalar concentration values [0.85, 0.92, …, 0.78] T ,
[0196] Mixed gas: shape (128, 2), two-component concentration:
[0197]
[0198] Interlayer interaction: completes the final mapping of features to concentrations.
[0199] Through hierarchical feature transformation, the model achieves end-to-end mapping from raw sensor data to concentration prediction. The output of each layer serves as the structured input of the next layer, forming a gradually abstracted feature processing pipeline.
[0200] Further defined, the method further comprises step 6:
[0201] Optimize the model: Use the predicted gas names and concentrations and the labels used to train the deep learning model to calculate the loss function. Use the Adam optimizer to optimize the parameters in the deep learning model so that the loss function reaches the threshold.
[0202] Specifically, the loss function:
[0203] The loss function quantifies the difference between the model's predicted gas concentration value and the true concentration label. The core calculation is the mean square error (MSE), and the formula is:
[0204]
[0205] in, It is the predicted concentration (single gas is a scalar, mixed gas is a component concentration vector) output by the model based on the fusion characteristics of time domain and frequency domain (such as amplitude-frequency / phase-frequency characteristics extracted by Fourier transform, time domain statistical characteristics). i The true concentration value (single gas concentration or concentration of each component of a mixed gas) is extracted and annotated from the sensor data file name during preprocessing. N is the number of samples processed in a batch (e.g., batch size 128). This function converts the prediction error into an optimizable scalar value by finding the mean of the squared errors, directly guiding the model to learn the concentration mapping relationship.
[0206] In addition, to avoid overfitting in high-dimensional feature training, the loss function introduces an L2 regularization term:
[0207]
[0208] Among them, λ is the regularization strength, w is the weight parameter representing the network layer such as the convolution layer and BiLSTM layer. By penalizing the sum of squared weights, the model is forced to reduce complexity and improve the generalization ability of data from different scenarios.
[0209] Core goals and implementation mechanisms of optimization:
[0210] The core of the optimization is to iteratively adjust the learnable parameters in the neural network (such as convolution kernel weights, BiLSTM unit parameters, fully connected layer weights and biases, etc.) to gradually reduce the loss function value, ultimately achieving accurate mapping from the sensor's multi-dimensional features to gas concentration. This is specifically achieved through the Adam optimizer:
[0211] First, the gradient g is obtained by derivation of the parameters based on the loss function t , indicating the direction of parameter update; then using the first-order moment m t and the second moment v t The mean and variance of the cumulative gradient (m t =β1m t-1 +(1-β1)g t , β1=0.9、β2=0.999 to suppress noise), and
[0212]
[0213] Correct the initial deviation and finally
[0214]
[0215] Update parameters (η is the learning rate, ε=10 -8 Prevent division by zero), so that different parameters have independent adaptive learning rates, and efficiently handle the convergence requirements of high-dimensional inputs such as frequency domain features.
[0216] The optimization process is also supplemented by an early stopping mechanism. By monitoring the validation set loss, training is terminated when the loss has not decreased for K consecutive rounds to avoid overfitting the noise in the training data. At the same time, the dynamic feature weighting mechanism in the model architecture cooperates with the optimization process to automatically adjust the weight distribution of time domain and frequency domain features according to the characteristics of the input data, so that the optimization direction is more focused on the feature dimensions that play a key role in concentration prediction, further improving the prediction accuracy and model robustness in multi-gas mixing and variable-length data scenarios.
[0217] Model Evaluation:
[0218] The model evaluation phase uses the classic indicator system of regression tasks, including mean square error (MSE), root mean square error (RMSE), mean absolute error (MAE) and coefficient of determination (R 2 ) quantify the prediction performance. These indicators are consistent with the loss function design. Among them, MSE is used to quantify the overall prediction deviation and is more sensitive to large errors; RMSE is used to quantify the overall prediction deviation and is more sensitive to large errors. Restoring the error to the original concentration dimension facilitates intuitive evaluation of engineering scenarios;
[0219] Calculate the mean absolute error, which is more robust to outliers; R 2 pass Measures the model's ability to explain data variation. The closer it is to 1, the better the prediction effect.
[0220] The experimental data used the processed sensor sequence and was divided into training, validation, and test sets in a ratio of 7:1:2. Data preprocessing strictly followed the process of linear interpolation to align the time axis, IQR method to detect outliers, and mean filling of missing values. Batch processing used a batch size of 128, and the input three-dimensional tensor (number of samples × time step × feature dimension) was adapted to the requirements of the Conv1D layer (convolutional layer). The Adam optimizer (β1 = 0.9, β2 = 0.999) and the initial learning rate were 10 -3 , combined with an early stopping mechanism that terminates if the loss of the validation set does not decrease for five consecutive rounds, the dynamic feature weighting mechanism automatically integrates time domain (mean, standard deviation, etc.) and frequency domain (amplitude frequency, phase frequency) features.
[0221] The model is designed with time-frequency feature fusion, multi-head attention mechanism and variable-length input, which is more accurate than the traditional one in single gas concentration prediction. 2The accuracy rate of the two components of mixed gases reached 0.982, and the average accuracy rate of the two components of the mixed gas exceeded 95%. The cross-scenario generalization capability was improved by more than 30% compared with the traditional method. The real-time response delay in industrial measurements was less than 50ms. Its end-to-end feature processing flow provides a high-precision and robust technical solution for real-time monitoring of multiple gases, effectively solving the problems of traditional methods in background technologies being affected by environmental interference, insufficient multi-gas differentiation capabilities, and inefficient processing of variable-length data.
[0222] Although the present invention is described herein with reference to specific embodiments, it should be understood that these embodiments are merely illustrative of the principles and applications of the invention. It should be understood that many modifications may be made to the illustrative embodiments, and that other arrangements may be devised, without departing from the spirit and scope of the invention as defined by the appended claims. It should be understood that the various dependent claims and features described herein may be combined in ways other than those described in the original claims. It should also be understood that features described in conjunction with individual embodiments may be employed in conjunction with other described embodiments.
Claims
1. A gas concentration prediction method based on static spectrum characteristics, characterized in that: The method includes the following: Step 1: Use a gas-sensitive resistor sensor to repeatedly measure multiple single historical gases and multiple mixed historical gases, and output a set of physical quantity characteristic combinations for each single historical gas and each mixed historical gas in each measurement; Each set of physical quantity features is combined as each multidimensional time series, and the gas name and concentration label of each multidimensional time series are obtained at the same time, where all multidimensional time series have the same dimension; Step 2, data processing: use missing value filling and outlier processing methods to process each multidimensional time series to obtain each processed multidimensional time series; Step 3: Feature fusion: Based on the multiple processed multidimensional time series of each type of gas obtained by repeated measurements of each single gas and mixed gas, the time domain features and frequency domain features of the corresponding type of gas are obtained, and the time domain features and frequency domain features of the corresponding type of gas are fused to obtain a multidimensional feature matrix of the corresponding type of gas; Step 4: Use each multidimensional feature matrix as input data and the corresponding gas name and concentration label as output data to train the deep learning model and obtain a trained deep learning model; Step 5: Use a gas-sensitive resistor sensor to repeatedly measure the gas to be tested in the test environment. The output multiple multidimensional time series are processed and feature fused in turn to obtain the multidimensional feature matrix to be tested. The matrix is input into the trained deep learning model to predict the gas name and concentration.
2. The gas concentration prediction method based on static spectrum characteristics according to claim 1 is characterized in that: The dimension of all multidimensional time series is 3, including the resistance value output by the gas sensitive resistor sensor, the voltage value applied to the gas sensitive resistor sensor, and the current value.
3. The gas concentration prediction method based on static spectrum characteristics according to claim 2 is characterized in that: In step 2, each multidimensional time series is processed using missing value filling and outlier processing methods, specifically: Detect whether there are missing time points in each multidimensional time series. If so, use linear interpolation to obtain a resistance interpolation value based on the two resistance values at two adjacent moments of the missing time point, a voltage interpolation value based on the two voltage values at two adjacent moments of the missing time point, and a current interpolation value based on the two current values at two adjacent moments of the missing time point; and fill in the missing time point with the resistance interpolation value, voltage interpolation value, and current interpolation value. Detect whether a physical quantity feature in each multidimensional time series is abnormal or missing. If the voltage value at a certain moment is abnormal or missing, eliminate the voltage value, calculate the mean of the voltage values at all moments, and fill the mean into the position of the eliminated voltage value; if the resistance value at a certain moment is abnormal or missing, eliminate the resistance value, calculate the mean of the resistance values at all moments, and fill the mean into the position of the eliminated resistance value; if the current value at a certain moment is abnormal or missing, eliminate the current value, calculate the mean of the current values at all moments, and fill the mean into the position of the eliminated current value.
4. The gas concentration prediction method based on static spectrum characteristics according to claim 3 is characterized in that: The linear interpolation method is: Where, X i,j is the feature X at the jth moment i , X i is the resistance value, voltage value or current value, X i,j+1 is the feature X at the j+1th moment i , t j+1 is the j+1th moment, t j is the jth moment, t m is the moment corresponding to the missing value or outlier, X' i,m is interpolation.
5. The gas concentration prediction method based on static spectrum characteristics according to claim 3 is characterized in that: The process of detecting whether a physical quantity feature in each multidimensional time series is abnormal or missing: The resistance value, voltage value and current value at each moment in each multidimensional time series are detected in turn to see whether they exceed the corresponding preset fluctuation range. If so, they are determined to be abnormal values; if not, they are determined to be normal values.
6. The gas concentration prediction method based on static spectrum characteristics according to claim 5, characterized in that: The upper and lower bounds of the preset fluctuation range are: Upper bound = Q3 + 1.5 × IQR, lower bound = Q1 - 1.5 × IQR, In the formula, IQR=Q3-Q1, IQR is the interquartile range, Q1 is the lower quartile, and Q3 is the upper quartile.
7. The gas concentration prediction method based on static spectrum characteristics according to claim 1 or 6, characterized in that: In step 3, the time domain features include obtaining the mean resistance value, mean voltage value, mean current value, resistance value standard deviation, voltage value standard deviation, current value standard deviation, maximum resistance value, maximum voltage value and maximum current value at each moment from multiple multidimensional time series obtained from multiple measurements.
8. The gas concentration prediction method based on static spectrum characteristics according to claim 1 is characterized in that: In step 3, the frequency domain features are expressed as: Where X(k) is the spectral component of the frequency domain signal at frequency k, including amplitude-frequency characteristics and phase-frequency characteristics. x(n) is the physical quantity sequence in the time domain feature matrix, including the resistance value output by the gas-sensitive resistor sensor, the voltage value and current value applied to the gas-sensitive resistor sensor. N is the total number of time domain data points. k is the frequency index, corresponding to different frequency components. is a complex basis function.
9. The gas concentration prediction method based on static spectrum characteristics according to claim 1 or 7, characterized in that: In step 4, the deep learning model includes convolutional layer, bidirectional LSTM layer, multi-head attention layer, flattening layer, fully connected layer and output layer. The convolution layer is used to convert the multi-dimensional feature matrix into a 128-dimensional vector sequence and pass it to the bidirectional LSTM layer; A bidirectional LSTM layer is used to convert the 128-dimensional vector sequence into a 256-dimensional vector sequence and pass it to the multi-head attention layer; The multi-head attention layer is used to convert the 256-dimensional vector sequence into a three-dimensional time series feature tensor and pass it to the flattening layer; The flattening layer is used to convert the three-dimensional time series feature tensor into a two-dimensional feature matrix and pass it to the fully connected layer; The fully connected layer is used to convert the two-dimensional feature matrix into a 128-dimensional vector sequence and pass it to the output layer; The output layer is used to establish a mapping relationship between the 128-dimensional vector sequence and the corresponding label.
10. The gas concentration prediction method based on static spectrum characteristics according to claim 1, characterized in that: The method further comprises step 6: Optimize the model: Calculate the loss function between the predicted gas names and concentrations and the labels used to train the deep learning model. Use the Adam optimizer to optimize the parameters in the deep learning model so that the loss function reaches the threshold.
Citation Information
Patent Citations
Gas detection method and device capable of intelligently improving precision, program product and medium
CN118566443A
Electronic nose navigation method based on LSTM concentration gradient time sequence prediction assistance
CN119085632A
Long-term prediction method for concentration of dissolved gas in transformer oil
CN119848774A
Multi-task learning based RUL predication method under sensor fault condition
US20230350402A1