A fast hydrogen detection method based on autoencoder and fully connected layer

Through a combined neural network of the autoencoder and the fully connected layer, the resistance signal of the hydrogen sensor response-recovery curve is extracted, which solves the problem of long response time and large errors of hydrogen sensors in the prior art, and achieves fast and accurate hydrogen concentration detection.

CN116840305BActive Publication Date: 2025-08-26UNIV OF ELECTRONICS SCI & TECH OF CHINA
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202310824091.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-06
Publication Date
2025-08-26
Estimated Expiration
2043-07-06

AI Technical Summary

Technical Problem

The existing hydrogen sensors have a long response time and large errors, making it difficult to achieve fast and accurate hydrogen concentration detection.

Method used

A combined neural network of autoencoder and fully connected layer is used to extract the initial stage resistance signal of the hydrogen sensor response-recovery curve, feature extraction and drift compensation are performed, and noise is added to the model to improve generalization ability, and a hydrogen concentration prediction model is constructed.

Benefits of technology

It realizes rapid and accurate prediction of hydrogen concentration in the initial stage of the response, with an average relative error of less than 0.05%, which greatly shortens the training time and simplifies the difficulty of hardware implementation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116840305B_ABST
    Figure CN116840305B_ABST
Patent Text Reader

Abstract

The present invention provides a rapid hydrogen detection method based on an autoencoder and a fully connected layer. This method belongs to the field of gas sensor-based gas detection technology. The method uses a gas sensor to obtain a response-recovery curve, extracting the resistance signal at the initial stage of the response. This sample point is then formed with the corresponding hydrogen concentration. After drift compensation and normalization, Gaussian noise is added to obtain a noise sample set. This sample set is then proportionally expanded to obtain an expanded sample set. An autoencoder consisting of an encoder and a decoder is constructed. After training, the neural network structure and weights of the encoder are obtained. A hydrogen concentration prediction model is constructed based on the encoder and fully connected layer. After training, this model is used to rapidly detect the hydrogen gas to be tested. The present invention can achieve rapid hydrogen concentration prediction for the hydrogen gas to be tested, while tolerating errors caused by outliers in the data or drift characteristics of the gas sensor.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of gas detection based on gas sensors, and specifically relates to a method for rapid hydrogen detection based on an autoencoder and a fully connected layer. Background Art

[0002] In recent years, with the rapid development of hydrogen energy technology applications, hydrogen detection has garnered increasing attention. Commercial hydrogen sensors based on electrochemical or resistive signals typically have response times ranging from tens of seconds to several minutes. Reducing this response time by improving sensor design and packaging is a challenging task. Due to the flammable, explosive, colorless, and odorless nature of hydrogen, fast-response hydrogen sensors are urgently needed for hydrogen leak detection. Therefore, rapid hydrogen leak detection based on the initial response of a gas sensor is a worthy approach. By leveraging the initial response phase of a gas sensor's response-recovery curve, neural networks can achieve rapid gas detection. For example, Chinese patent application number 202211628182.8 discloses a method for rapid hydrogen concentration prediction based on a CNN-LSTM (convolutional neural network-long short-term memory network). This method extracts the initial response phase of the hydrogen sensor's response-recovery curve within the first 30 seconds, achieving an average relative error (ARE) of approximately 10% for hydrogen concentration prediction. However, this method suffers from a high ARE and a long response time, making it less than ideal. Therefore, it is necessary to seek a rapid hydrogen detection method with faster speed, smaller error and higher confidence. Summary of the Invention

[0003] In response to the technical problems existing in the above-mentioned prior art, the present invention proposes a rapid hydrogen detection method based on an autoencoder and a fully connected layer to achieve rapid detection of hydrogen concentration.

[0004] The technical solutions adopted in the present invention are as follows:

[0005] A method for rapid hydrogen detection based on an autoencoder and a fully connected layer, characterized by comprising the following steps:

[0006] S1. Test hydrogen with a gas sensor, collect response data of the gas sensor, and use the resistance change curves of the gas sensor in hydrogen and air as response-recovery curves; introduce hydrogen of different concentrations to obtain raw data consisting of different hydrogen concentrations and corresponding response-recovery curves;

[0007] S2. For each response-recovery curve in the original data, obtain the response starting point and extract the resistance signal within T time from the response starting point; combine a hydrogen concentration and the corresponding resistance signal into a sample point to obtain a sample set S;

[0008] S3. Drift compensation is performed on each resistance signal in the sample set S to obtain a sample set S′; each resistance signal and hydrogen concentration in the sample set S′ are then normalized to obtain a sample set S″;

[0009] S4. Add Gaussian noise to the sample set S″ to obtain the expanded noise sample set S noise ; Expand the sample set S″ in equal proportion to obtain the expanded sample set S original ; Specifically:

[0010] Randomly generate k noises with a mean of 0, a standard deviation of 0.1, and a Gaussian distribution. Add each noise to the sample set S″ to obtain a total of k noise sample sets before expansion. After combining, the expanded noise sample set S is obtained. noise , the sample size is k times of the sample set S″; k identical sample sets S″ are combined to obtain the expanded sample set S original ;

[0011] S5. Construct an autoencoder consisting of an encoder and a decoder. The encoder and decoder share a bottleneck layer. noise is the input of the encoder, the sample set S original The output of the decoder is used to train the autoencoder to obtain the trained autoencoder, and the neural network structure and weights of the encoder including the bottleneck layer are extracted;

[0012] S6. Build a hydrogen concentration prediction model. The hidden layer of its neural network consists of the encoder including the bottleneck layer extracted in S5 and a fully connected layer. The weights extracted in S5 are used and the model is finally connected to the output layer.

[0013] S7, using the resistance signal in the sample set S″ as input and the hydrogen concentration as output, training the hydrogen concentration prediction model to obtain a trained hydrogen concentration prediction model;

[0014] S8. Pass the hydrogen to be tested into the gas sensor, collect response data in real time, extract the resistance signal within T time from the response starting point in the response-recovery curve, obtain the resistance signal of the hydrogen to be tested after normalization, input it into the trained hydrogen concentration prediction model, and output the concentration of the hydrogen to be tested.

[0015] Furthermore, the value of T in S2 is 6 to 10, and the number m of corresponding resistance signals is determined by the value of T according to the adopted sampling frequency.

[0016] Furthermore, the sample set S in S2 is S={(R1, Y1), (R2, Y2), ..., (R N ,Y N )}; where N is the total number of sample points, determined according to the concentration range of hydrogen to be tested; Ri =(r i (1) ,r i (2) ,...,r i (m) ), i=1,2,...,N is the resistance signal of the i-th sample point, r i (j) ,j=1,2,...,m,i=1,2,...,N is the resistance value of the jth resistance signal in the i-th sample point; Y i ,i=1,2,...,N is the hydrogen concentration at the i-th sample point.

[0017] Furthermore, the specific process of performing drift compensation on each resistance signal in the sample set S in S3 is as follows:

[0018] S31, obtain the first resistance value r of each resistance signal in the sample set S. i (1) ,i=1,2,...,N, and calculate all the first resistance values ​​r i (1) ,i=1,2,...,the average value of N

[0019] S32, calculate the first resistance value r of the resistance signal of the i-th sample point i (1) ,i=1,2,...,N and the average value The difference Res i , i=1,2,...,N, then calculate the resistance signal R of the i-th sample point i =(r i (1) ,r i (2) ,...,r i (m) ),i=1,2,...,N and Res i ,i=1,2,...,N, is the resistance signal R of the i-th sample point after drift compensation. i ′=(r i ' (1) ,r i ' (2) ,...,r i ' (m) ),i=1,2,...,N;

[0020] S33. Traverse all sample points in the sample set S and repeat the process of S32 to complete the drift compensation of all resistance signals in the sample set S, and obtain the sample set S′.

[0021] Furthermore, the value range of k in S4 is 50 to 100.

[0022] Furthermore, the structure of the autoencoder in S5 includes:

[0023] 1 input layer, the number of neurons is m;

[0024] 1 output layer, the number of neurons is m;

[0025] There are three types of structural parameters of the hidden layer:

[0026] (1) One hidden layer, with the number of neurons ranging from 15 to 20;

[0027] (2) 3 hidden layers, with the number of neurons ranging from 20 to 30, 10 to 20, and 20 to 30 respectively;

[0028] (3) 5 hidden layers, with the number of neurons ranging from 25 to 30, 15 to 20, 10 to 15, 15 to 20, and 25 to 30 respectively;

[0029] Among them, as the number of hidden layers increases, the error of the prediction model decreases relatively. After the number of layers increases to a certain extent (5 layers), the error improvement is not obvious.

[0030] Furthermore, the number of neurons in the fully connected layer of the hydrogen concentration prediction model in S6 ranges from 5 to 10.

[0031] The beneficial effects of the present invention are:

[0032] 1. This paper proposes a rapid hydrogen detection method based on an autoencoder and a fully connected layer. By extracting the resistance signal in the initial response stage, feature extraction is implemented in the autoencoder, reducing the dimension and removing redundant features. Finally, a hydrogen concentration prediction model consisting of an encoder connected to a fully connected layer is used to more finely learn the resistance signal features, thereby achieving rapid prediction of the hydrogen concentration of the hydrogen to be tested.

[0033] 2. By adding noise to the resistance signal, the present invention improves the generalization ability of the hydrogen concentration prediction model and can tolerate the error caused by abnormal points in the data or the drift characteristics of the gas sensor;

[0034] 3. In the hardware implementation of the algorithm, the present invention uses an autoencoder to extract data features, fixes the encoder and its weights in the autoencoder, and has a simple network structure, which greatly shortens the training process, saves training time, and simplifies the difficulty of hardware implementation. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 This is a schematic diagram of obtaining the response starting point in the response-recovery curve used in Example 1;

[0036] Figure 2 A structural diagram of the autoencoder constructed for Example 1;

[0037] Figure 3 This is a structural diagram of the hydrogen concentration prediction model constructed in Example 1;

[0038] Figure 4 The relative error histogram and fitted normal distribution curve of the hydrogen concentration prediction in Example 1 are shown. DETAILED DESCRIPTION

[0039] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0040] Example 1

[0041] This embodiment proposes a method for rapid hydrogen detection based on an autoencoder and a fully connected layer, which specifically includes the following steps:

[0042] S1. Test hydrogen with a gas sensor, collect response data of the gas sensor, and use the resistance change curves of the gas sensor in hydrogen and air as response-recovery curves; introduce hydrogen of different concentrations to obtain raw data consisting of different hydrogen concentrations and corresponding response-recovery curves;

[0043] S2. For each response-recovery curve in the original data, use Figure 1 The method shown in the figure obtains the response starting point and extracts the resistance signal within T time (unit: s) after the response starting point; a hydrogen concentration and the corresponding resistance signal form a sample point, and a sample set S = {(R1, Y1), (R2, Y2), ..., (R N ,Y N )};

[0044] Where N is the total number of sample points, which is determined according to the concentration range of hydrogen to be tested; R i =(r i (1) ,r i (2) ,...,r i (m) ), i=1,2,...,N is the resistance signal of the i-th sample point, r i (j) ,j=1,2,...,m,i=1,2,...,N is the resistance value of the jth resistance signal in the i-th sample point; Y i, i=1,2,...,N is the hydrogen concentration at the i-th sample point; in this embodiment, T is 8 and m is 40;

[0045] S3. Drift compensation is performed on each resistance signal in the sample set S to obtain a sample set S′. Specifically,

[0046] S31, obtain the first resistance value r of each resistance signal in the sample set S. i (1) ,i=1,2,...,N, and calculate all the first resistance values ​​r i (1) ,i=1,2,...,the average value of N

[0047] S32, calculate the first resistance value r of the resistance signal of the i-th sample point i (1) ,i=1,2,...,N and the average value The difference Res i , i=1,2,...,N, then calculate the resistance signal R of the i-th sample point i =(r i (1) ,r i (2) ,...,r i (m) ),i=1,2,...,N and Res i ,i=1,2,...,N, is the resistance signal R of the i-th sample point after drift compensation. i ′=(r i ' (1) ,r i ' (2) ,...,r i ' (m) ),i=1,2,...,N;

[0048] S33, traverse all sample points in the sample set S, repeat the process of S32, complete the drift compensation of all resistance signals in the sample set S, and obtain the sample set S′;

[0049] S4. Perform maximum and minimum normalization on each resistance signal and hydrogen concentration in the sample set S′. The normalization formula is: Obtain a sample set S″; where x is the resistance signal or hydrogen concentration, max(x) is the maximum value among all x, min(x) is the minimum value among all x, and x′ is the normalized x;

[0050] S5. Add Gaussian noise to the sample set S″ to obtain the expanded noise sample set S noise; Expand the sample set S″ in equal proportion to obtain the expanded sample set S original ; Specifically:

[0051] Randomly generate k noises with a mean of 0, a standard deviation of 0.1, and a Gaussian distribution. Add each noise to the sample set S″ to obtain a total of k noise sample sets before expansion. After combining, the expanded noise sample set S is obtained. noise , the sample size is k times of the sample set S″; k identical sample sets S″ are combined to obtain the expanded sample set S original ; In this embodiment, k is 100;

[0052] S6. Construct an autoencoder consisting of an encoder and a decoder. The encoder and decoder share a bottleneck layer. The structure of the autoencoder is as follows: Figure 2 Shown, including:

[0053] 1 input layer, with 40 neurons;

[0054] 5 hidden layers, with the number of neurons being 28, 16, 10, 16, and 28 respectively;

[0055] 1 output layer, with 40 neurons;

[0056] The activation functions of the input layer, hidden layer, and output layer are all Leaky ReLU (leaky linear rectification) functions, and alpha (hyperparameter) is set to 0.2;

[0057] Take sample set S noise is the input of the encoder, the sample set S original The output of the decoder is used to train the autoencoder to obtain the trained autoencoder, and the neural network structure and weights of the encoder including the bottleneck layer are extracted;

[0058] S7, build a hydrogen concentration prediction model, the hidden layer of the neural network is composed of the encoder including the bottleneck layer extracted by S6 and a fully connected layer, and uses the weights extracted by S6, and finally connected to the output layer; the structure of the hydrogen concentration prediction model is as follows Figure 3 Shown, including:

[0059] 1 input layer, with 40 neurons;

[0060] 4 hidden layers, with 28, 16, 10, and 9 neurons respectively;

[0061] 1 output layer, the number of neurons is 1;

[0062] The activation functions of the input layer, hidden layer, and output layer are all Leaky ReLU functions, and alpha is set to 0.2;

[0063] S8. Using the resistance signal in the sample set S″ as input and the hydrogen concentration as output, the hydrogen concentration prediction model is trained to obtain a trained hydrogen concentration prediction model;

[0064] S9. Pass the hydrogen to be tested into the gas sensor, collect response data in real time, extract the resistance signal within T time from the response starting point in the response-recovery curve, obtain the resistance signal of the hydrogen to be tested after normalization, input it into the trained hydrogen concentration prediction model, and output the concentration of the hydrogen to be tested.

[0065] In this embodiment, the Adam optimizer is used to optimize the back propagation of the hydrogen concentration prediction model. The optimal parameters for hydrogen concentration prediction model training are shown in Table 1. After ten-fold cross validation, the hydrogen concentration prediction results are displayed by a histogram of relative errors, as shown in Table 1. Figure 4 As shown in the figure, the 95% confidence interval of the relative error obtained from the fitted normal distribution curve is [-2.92, 3.03], indicating high accuracy and good prediction results. In practical applications, the resistance signal of the gas sensor within 8 seconds of the start of the response can be used to predict the hydrogen concentration in the environment, with an average relative error of only 0.05%, achieving rapid hydrogen detection.

[0066] Table 1 Optimal hyperparameters for hydrogen concentration prediction model training

[0067]

[0068] The above description is only a specific embodiment of the present invention. Any feature disclosed in this specification, unless otherwise stated, can be replaced by other equivalent or alternative features with similar purposes; all disclosed features, or all steps in the methods or processes, except for mutually exclusive features and / or steps, can be combined in any way.

Claims

1. A rapid hydrogen detection method based on autoencoder and fully connected layer, characterized in that: The following steps are involved: S1. Test hydrogen with a gas sensor, collect response data of the gas sensor, and use the resistance change curves of the gas sensor in hydrogen and air as response-recovery curves; introduce hydrogen of different concentrations to obtain raw data consisting of different hydrogen concentrations and corresponding response-recovery curves; S2. For each response-recovery curve in the original data, obtain the response starting point and extract the resistance signal within T time from the response starting point; combine a hydrogen concentration and the corresponding resistance signal into a sample point to obtain a sample set S; S3. Drift compensation is performed on each resistance signal in the sample set S to obtain a sample set S′; each resistance signal and hydrogen concentration in the sample set S′ are then normalized to obtain a sample set S″; S4. Add Gaussian noise to the sample set S″ to obtain the expanded noise sample set S noise ; Expand the sample set S″ in equal proportion to obtain the expanded sample set S original Specifically: Randomly generate k noises with a mean of 0, a standard deviation of 0.1, and a Gaussian distribution. Add each noise to the sample set S″ to obtain a total of k noise sample sets before expansion. After combining, the expanded noise sample set S is obtained. noise , the sample size is k times of the sample set S″; k identical sample sets S″ are combined to obtain the expanded sample set S original ; S5. Construct an autoencoder consisting of an encoder and a decoder. The encoder and decoder share a bottleneck layer. noise is the input of the encoder, the sample set S original The output of the decoder is used to train the autoencoder to obtain the trained autoencoder, and the neural network structure and weights of the encoder including the bottleneck layer are extracted; S6. Build a hydrogen concentration prediction model. The hidden layer of its neural network consists of the encoder including the bottleneck layer extracted in S5 and a fully connected layer. The weights extracted in S5 are used and the model is finally connected to the output layer. S7, using the resistance signal in the sample set S″ as input and the hydrogen concentration as output, training the hydrogen concentration prediction model to obtain a trained hydrogen concentration prediction model; S8. Pass the hydrogen to be tested into the gas sensor, collect response data in real time, extract the resistance signal within T time from the response starting point in the response-recovery curve, obtain the resistance signal of the hydrogen to be tested after normalization, input it into the trained hydrogen concentration prediction model, and output the concentration of the hydrogen to be tested.

2. The method for rapid hydrogen detection based on an autoencoder and a fully connected layer according to claim 1, characterized in that: The value of T in S2 ranges from 6 to 10. The number m of corresponding resistance signals is determined by the value of T according to the sampling frequency.

3. The method for rapid hydrogen detection based on an autoencoder and a fully connected layer according to claim 2, characterized in that: The sample set S in S2 is S={(R1, Y1), (R2, Y2), ..., (R N ,Y N )}; where N is the total number of sample points, determined according to the concentration range of hydrogen to be tested; R i =(r i (1) ,r i (2) ,...,r i (m) ) is the resistance signal of the i-th sample point, r i (j) ,j=1,2,...,m is the resistance value of the jth resistance signal in the i-th sample point, Y i is the hydrogen concentration at the i-th sample point, where i = 1, 2, ..., N.

4. The method for rapid hydrogen detection based on an autoencoder and a fully connected layer according to claim 3, characterized in that: The specific process of drift compensation for each resistance signal in the sample set S in S3 is: S31, obtain the first resistance value r of each resistance signal in the sample set S. i (1) ,i=1,2,...,N, and calculate all the first resistance values ​​r i (1) Average value S32, calculate the first resistance value r of the resistance signal of the i-th sample point i (1) and the average The difference Res i , i=1,2,...,N, then calculate the resistance signal R of the i-th sample point i =(r i (1) ,r i (2) ,...,r i (m) ) and Res i The difference between the two values ​​is used as the resistance signal R of the i-th sample point after drift compensation. i ′=(r i ' (1) ,r i ' (2) ,...,r i ' (m) ),i=1,2,...,N; S33. Traverse all sample points in the sample set S and repeat the process of S32 to complete the drift compensation of all resistance signals in the sample set S, and obtain the sample set S′.

5. The method for rapid hydrogen detection based on an autoencoder and a fully connected layer according to claim 1, characterized in that: The value range of k in S4 is 50 to 100.

6. The method for rapid hydrogen detection based on an autoencoder and a fully connected layer according to claim 1, characterized in that: The structure of the autoencoder in S5 includes: 1 input layer, the number of neurons is m; 1 output layer, the number of neurons is m; There are three types of structural parameters of the hidden layer: (1) One hidden layer, with the number of neurons ranging from 15 to 20; (2) 3 hidden layers, with the number of neurons ranging from 20 to 30, 10 to 20, and 20 to 30 respectively; (3) There are five hidden layers with the number of neurons ranging from 25 to 30, 15 to 20, 10 to 15, 15 to 20, and 25 to 30.

7. The method for rapid hydrogen detection based on an autoencoder and a fully connected layer according to claim 1, characterized in that: The number of neurons in the fully connected layer of the hydrogen concentration prediction model in S6 ranges from 5 to 10.

Citation Information

Patent Citations

  • CNN-LSTM-based hydrogen concentration rapid prediction method

    CN115985406A

  • Method for reducing cross sensitivity on carbon monoxide by semiconductor hydrogen sensor

    CN108287183A

  • Sensor array neural network method for predicting concentration of mixed gas

    CN115860056A