A rapid hydrogen detection method based on 1DCNN and GRU
By combining the hydrogen concentration prediction model of 1DCNN and GRU, the problems of long response time and high computational complexity of existing hydrogen detection methods are solved, and fast, stable and accurate hydrogen concentration prediction is achieved, which is suitable for use in low-cost and real-time application scenarios.
Patent Information
- Application Number
- CN202411204708.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2044-08-30
AI Technical Summary
The existing hydrogen detection methods have problems such as long response time, low sensitivity, poor selectivity or susceptibility to environmental factors. In addition, two-dimensional convolutional neural networks have high computational complexity and memory requirements, making it difficult to meet the needs of low-cost and real-time applications.
A hydrogen concentration prediction model combined with one-dimensional convolutional neural network (1DCNN) and gated recursive unit (GRU) is used to obtain the response-recovery change curve through the hydrogen sensor, extract the resistance signal characteristics, and set up the Dropout layer and GRU layer in the model to build a hydrogen concentration prediction model and design a specific loss function to reduce the impact of test errors.
Fast, stable and accurate hydrogen concentration prediction is achieved, reducing the computational complexity and number of parameters, and is suitable for application on real-time and cost-constrained hardware devices.
Smart Images

Figure CN119167015B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of gas detection based on gas sensors, and particularly relates to a rapid hydrogen detection method based on 1DCNN and GRU. Background Art
[0002] With the rapid development of hydrogen energy, the safety issue of hydrogen has attracted increasing attention. Hydrogen has the characteristics of flammability and explosiveness, and its leakage detection is crucial for ensuring industrial safety and the safety of people's lives and property. Traditional hydrogen detection methods, such as electrochemical sensors and metal oxide semiconductor sensors, have limitations such as long response time, low sensitivity, poor selectivity, or being easily affected by environmental factors.
[0003] In order to improve the speed and accuracy of hydrogen detection, in recent years, the application of deep learning technology in the field of sensor signal processing has gradually increased. By using the initial response stage in the response–recovery curve of gas sensors, neural networks can achieve rapid gas detection. For example, Chinese Patent with the application number CN 202310824091.X discloses a rapid hydrogen detection method based on an autoencoder (AEN) and a fully connected layer. This method uses an autoencoder to extract feature values and a fully connected layer to output prediction results. However, as an unsupervised learning model, the training process of the autoencoder requires a large amount of data and computing resources. In addition, the autoencoder performs well on the training data but may be difficult to generalize to unseen data, especially when a large amount of data is used during the training process. The confidence interval of the verification result of the above method is relatively large, and the 95% confidence interval of the relative error is [-2.92, 3.03]. This is because when using the autoencoder for anomaly detection, problems such as unstable and inconsistent results may be encountered, thus failing to achieve the ideal effect. Therefore, it is necessary to seek a rapid hydrogen detection method with better stability and higher confidence.
[0004] The success of convolutional neural networks (CNNs) in image and signal recognition has inspired the exploration of applying them to rapid detection algorithms. Compared with autoencoders, CNNs exhibit more powerful feature extraction capabilities in image recognition and classification tasks. Through convolutional layers and pooling layers, CNNs can capture local features of images and achieve invariance to input changes, while reducing the risk of overfitting. Currently, most research focuses on two-dimensional convolutional neural networks (2D-CNNs). 2D-CNNs perform well in processing data with rich spatial structures, but they have high computational complexity, a large number of parameters, high memory requirements, and strong dependence on spatial structure information.
[0005] In contrast, when processing one-dimensional data such as time series, audio signals, or text, 1D-CNN can capture local patterns and long-range dependencies in the sequence with relatively low computational costs and memory requirements, demonstrating higher flexibility and efficiency. Therefore, the present invention proposes a method for rapid hydrogen detection based on 1DCNN. Summary of the Invention
[0006] In view of the above technical problems existing in the prior art, the present invention provides a rapid hydrogen detection method based on 1DCNN and GRU, which can achieve rapid prediction of hydrogen concentration with low structural complexity and high prediction accuracy, and is particularly suitable for applications with low computational complexity, real-time, and low cost.
[0007] The technical solution adopted by the present invention is as follows:
[0008] A rapid hydrogen detection method based on 1DCNN and GRU, comprising the following steps:
[0009] S1. Test the hydrogen concentration through a hydrogen sensor, alternately introduce hydrogen with known concentrations and air into the hydrogen sensor to obtain a set of response-recovery change curves regarding resistance; introduce hydrogen with different concentrations to obtain raw data composed of different true hydrogen concentrations and corresponding response-recovery change curves.
[0010] S2. For each response-recovery change curve in the raw data, obtain the response starting point and extract the resistance signal within T time after the response starting point; form a sample point by combining a true hydrogen concentration with the resistance signal within the corresponding T time. Through maximum-minimum normalization of the resistance signal and normalization of the true hydrogen concentration, obtain the sample set S.
[0011] S3. Perform drift compensation on each resistance signal in the sample set S to obtain the sample set S'.
[0012] S4. Construct a hydrogen concentration prediction model, with the resistance signal in the sample set S' as the input and the true hydrogen concentration as the output, and train the hydrogen concentration prediction model to obtain the trained hydrogen concentration prediction model.
[0013] Among them, the hydrogen concentration prediction model is obtained by setting a Dropout layer and a GRU layer before the output layer of the 1DCNN neural network model.
[0014] S5. Introduce the hydrogen to be tested into the gas sensor, extract the resistance signal within T time after the response starting point in its response-recovery change curve, and after normalization, input it into the trained hydrogen concentration prediction model to output the predicted concentration of the hydrogen to be tested.
[0015] Furthermore, the structure of the hydrogen concentration prediction model includes, in sequence:
[0016] 1 input layer;
[0017] 1 fully connected layer;
[0018] At least one set of alternating 1 convolutional layer and 1 max pooling layer;
[0019] 1 Dropout layer;
[0020] 1 GRU layer;
[0021] 1 output layer.
[0022] Further, the value of T in S2 is 6 to 10, and according to the sampling frequency adopted, the corresponding number of resistance signals m is determined by the value of T.
[0023] Further, the sample set S in S2 = {(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) ), 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 j-th resistance signal in the i-th sample point; Y i , i = 1, 2,..., N is the true hydrogen concentration of the i-th sample point.
[0024] Further, the specific process of performing drift compensation on each resistance signal in the sample set S in S3 is as follows:
[0025] S31. Obtain the first resistance value of each resistance signal in the sample set S and calculate the average value of all the first resistance values r i (1) , i = 1, 2,..., N
[0026] S32. Calculate the difference Res i (1) , i = 1, 2,..., N between the first resistance value r of the resistance signal of the i-th sample point and the average value i , i = 1, 2,..., N, and then calculate the resistance signal R i= (r i (1) , r i (2) ,..., r i (m) ), i = 1, 2,..., N and the difference between Res i , i = 1, 2,..., N is used as the resistance signal of the i-th sample point after drift compensation
[0027] 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'.
[0028] Further, the loss function loss of the hydrogen concentration prediction model is as follows:
[0029]
[0030] In the formula, δ lower and δ upper respectively represent the preset low error threshold and high error threshold; represents the predicted hydrogen concentration of the i-th sample point.
[0031] Further, the value range of δ lower is 0.0001 - 0.001, and the value range of δ upper is 0.01 - 0.1.
[0032] Further, the number of features included in the feature vector of the input layer is m; the number of features included in the feature vector of the convolutional layer is 100 - 130; the number of features included in the feature vector of the max pooling layer is 1 - 2; the random discard probability of neurons in the Dropout layer is 0.1 - 0.3; the number of features included in the feature vector of the GRU layer is 1 - 64.
[0033] The beneficial effects of the present invention are as follows:
[0034] The present invention proposes a rapid hydrogen detection method based on 1DCNN and GRU. By setting GRU layers and Dropout layers at specific positions in the 1DCNN structure, a hydrogen concentration prediction model is constructed. Among them, the 1DCNN structure can be used to capture local features, such as frequency patterns in the sensor output curve, which is more efficient, has fewer parameters, and lower training costs when processing resistance signal time series data. Setting a GRU layer before the output layer can capture dynamic changes and long-term dependencies in the resistance signal time series data, make up for the limitations of one-dimensional time series signals and two-dimensional images respectively, and enhance the robustness and generalization ability of the algorithm. And setting a Dropout layer before the GRU layer pays more attention to the regularization of the input data, which helps to reduce the mutual dependence between input features, prevent the network from overly relying on certain specific features, force the network to learn more robust feature representations, improve the generalization ability of the model, and setting the Dropout layer after the convolutional layer helps to reduce the overload of the GRU layer and reduce the complexity and computational burden of subsequent layers;
[0035] In addition, due to the existence of small perturbations in the hydrogen sensor itself, resulting in test errors such as jump points in the original data, it is necessary to balance the sensitivity of the hydrogen concentration prediction model to errors within the error range between the true hydrogen concentration and the predicted hydrogen concentration of the sample points. Specifically: when the error is too small or too large, more attention is paid to reducing the square of the error to avoid the large impact of the small perturbations of the hydrogen sensor input on the output and extreme predicted values on the loss function; while when the error is within a reasonable range, it is hoped that the model pays more attention to reducing the absolute value of the error. Furthermore, for the original data obtained by the hydrogen sensor, the present invention specifically designs the loss function of the hydrogen concentration prediction model to avoid the influence of test errors on feature extraction;
[0036] Furthermore, the hydrogen concentration prediction model proposed by the present invention has the characteristics of strong feature extraction ability, low structural complexity, and high prediction accuracy, and can achieve rapid, stable, and accurate hydrogen leakage detection; in the hardware implementation of the algorithm, the present invention has low computational complexity and relatively few parameters, and is suitable for implementation on real-time and cost-constrained hardware devices such as mobile devices and embedded systems. Description of the Drawings
[0037] Figure 1 Schematic diagram of extracting the resistance signal within T time after the response start point according to the response-recovery change curve in Embodiment 1;
[0038] Figure 2 Schematic diagram of the structure of the hydrogen concentration prediction model constructed in Embodiment 1;
[0039] Figure 3 Curve of the mean absolute error (MAE) of hydrogen concentration prediction varying with the training batch in Embodiment 1;
[0040] Figure 4 It is the distribution diagram of the relative error of the predicted hydrogen concentration after ten-fold cross-validation in Example 1 varying with the training batches. Specific embodiments
[0041] To better understand the purpose and functions of the present invention, the present invention will be described in more detail below with reference to the accompanying drawings. In the following specific embodiments, many specific details are set forth to provide a thorough understanding of the embodiments of the present invention. However, those skilled in the art will understand that the embodiments of the present invention can be implemented without these specific details.
[0042] Example 1
[0043] This example provides a rapid hydrogen detection method based on 1DCNN and GRU, which specifically includes the following steps:
[0044] S1. Perform hydrogen concentration tests through a hydrogen sensor. Alternately introduce hydrogen with known concentrations and air into the hydrogen sensor to obtain a set of response-recovery change curves regarding resistance; introduce hydrogen with different concentrations to obtain raw data composed of different true hydrogen concentrations and corresponding response-recovery change curves.
[0045] S2. For each response-recovery change curve in the raw data, use the method as Figure 1 shown to obtain the response starting point, and extract the resistance signals within T time after the response starting point. The number of resistance signals included within T time is m; form a sample point by combining one true hydrogen concentration with the resistance signals within the corresponding T time. Through maximum-minimum normalization of the resistance signals and normalization of the true hydrogen concentration, obtain a sample set S = {(R1, Y1), (R2, Y2),..., (R N , Y N )} composed of N sample points;
[0046] where N = 300 is the total number of sample points; 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 j-th resistance signal in the i-th sample point; Y i , i = 1, 2,..., N is the true hydrogen concentration of the i-th sample point;
[0047] In this embodiment, T is taken as 8 and m is taken as 40;
[0048] S3. Perform drift compensation on each resistance signal in the sample set S to obtain the sample set S', and the specific process is as follows:
[0049] S31. Obtain the first resistance value r of each resistance signal in the sample set S i (1) , i = 1, 2,..., N, and calculate the average value of all the first resistance values r i (1) , i = 1, 2,..., N
[0050] S32. Calculate the difference Res between 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 . Then calculate the difference between the resistance signal R i = (r i i (1) i , r (2) i ,..., r (m) i ), i = 1, 2,..., N of the resistance signal of the i-th sample point and Res i , i = 1, 2,..., N, and use it as the resistance signal of the i-th sample point after drift compensation
[0051] 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';
[0052] S4. Construct a hydrogen concentration prediction model, the structure of which is as Figure 2 shown, including in sequence:
[0053] 1 input layer, with 40 neurons;
[0054] 1 fully connected layer, with 64 neurons;
[0055] Two groups of alternating 1 convolutional layer and 1 max pooling layer; among them, in the first group, the number of convolutional kernels of the convolutional layer is 112, the size of the convolutional kernel is 1, and the size of the pooling window of the max pooling layer is 2; in the second group, the number of convolutional kernels of the convolutional layer is 128, the size of the convolutional kernel is 1, and the size of the pooling window of the max pooling layer is 2;
[0056] 1 Dropout layer, with a random dropout probability of 0.2;
[0057] 1 GRU layer with 48 neurons;
[0058] 1 output layer with 1 neuron;
[0059] Among them, the activation function of the convolutional layer is the ReLU function, and the size of the convolutional kernel is 1;
[0060] The loss function loss of the hydrogen concentration prediction model is:
[0061]
[0062] In the formula, δ lower = 0.005 and δ upper = 0.05 respectively represent the preset low error threshold and high error threshold; represents the predicted hydrogen concentration of the i-th sample point;
[0063] Due to the small perturbation of the hydrogen sensor itself, there are test errors such as jump points in the original data. It is necessary to balance the sensitivity of the hydrogen concentration prediction model to errors within the error range between the true hydrogen concentration and the predicted hydrogen concentration of the sample point. Specifically: when the error is too small or too large, more attention is paid to reducing the square of the error to avoid the large impact of the small perturbation of the hydrogen sensor input on the output and extreme predicted values on the loss function; when the error is within a reasonable range, it is hoped that the model pays more attention to reducing the absolute value of the error; furthermore, for the original data obtained from the hydrogen sensor, the loss function of the above hydrogen concentration prediction model is specifically designed in this embodiment to avoid the impact of test errors on feature extraction;
[0064] S5. Using the resistance signal in the sample set S′ as the input and the true hydrogen concentration as the output, train the hydrogen concentration prediction model to obtain the trained hydrogen concentration prediction model;
[0065] S6. Pass the hydrogen to be tested into the gas sensor, extract the resistance signal within T time after the response starting point in its response-recovery change curve, and after normalization, input it into the trained hydrogen concentration prediction model to output the predicted concentration of the hydrogen to be tested.
[0066] In this embodiment, the Adam optimizer is used to optimize the backpropagation of the hydrogen concentration prediction model, and the best parameters for training the hydrogen concentration prediction model are shown in Table 1.
[0067] Table 1
[0068]
[0069] Figure 3The curve of the mean absolute error of hydrogen concentration prediction varying with the training batches indicates that the hydrogen concentration prediction model is completed after 250 batches of training; Figure 4 The distribution diagram of the relative error of the predicted hydrogen concentration after ten-fold cross-validation varying with the training batches shows that Figure 4 it can be seen that the relative error values vary little among different training batches and the error values of different batches are roughly the same, indicating that the hydrogen rapid detection method based on 1DCNN and GRU provided in this embodiment has good stability and consistency, the error is concentrated within 1%, and the uncertainty of the model prediction is small.
[0070] In practical applications, the resistance signal of the hydrogen sensor within 8 s after the start of the response can be used to predict the hydrogen concentration in the environment. To verify the advancement of the hydrogen rapid detection method based on 1DCNN and GRU provided in this embodiment, the prediction effects of the hydrogen detection methods of the models that only use the 1DCNN model, use the 1DCNN+Dropout+GRU model, and use the 1DCNN+Dropout+GRU+specific loss function are compared. Specifically:
[0071] The hydrogen detection method that only uses the 1DCNN model, that is, the hydrogen concentration prediction model in this embodiment is adjusted to a 1DCNN network. The average relative error during prediction is 0.73%. Through error analysis, the 95% confidence interval of its relative error is [-0.70343, 0.30707];
[0072] The hydrogen detection method that uses the 1DCNN+Dropout+GRU model, that is, the loss function of the hydrogen concentration prediction model in this embodiment is adjusted to the mean squared error. The average relative error during prediction is only 0.36%. Through error analysis, the 95% confidence interval of its relative error is [-0.03571, 0.22582];
[0073] The hydrogen detection method that uses the 1DCNN+Dropout+GRU+specific loss function model, that is, adopts the hydrogen rapid detection method based on 1DCNN and GRU proposed in this embodiment. The average relative error during prediction is further reduced to 0.30%. Through error analysis, the 95% confidence interval of its relative error is [-0.00231, 7.09473E-4].
[0074] In summary, it can be seen that the hydrogen concentration prediction model constructed by setting GRU layers and Dropout layers at specific positions in the 1DCNN structure can achieve faster, more stable and accurate hydrogen detection under the loss function specifically designed in this embodiment, and has a low structure and computational complexity, with relatively few parameters, making it suitable for implementation on real-time and cost-constrained hardware devices such as mobile devices and embedded systems.
[0075] The above embodiments are only used to illustrate the technical methods of the present invention and not to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical methods of the present invention can be modified or equivalently replaced without departing from the spirit and scope of the technical methods of the present invention.
Claims
1. A rapid hydrogen detection method based on 1DCNN and GRU, characterized in that, It includes the following steps: S1. Perform hydrogen concentration testing through a hydrogen sensor. Alternately introduce hydrogen with known concentrations and air into the hydrogen sensor to obtain a set of response-recovery change curves regarding resistance; Introduce hydrogen with different concentrations to obtain the original data composed of different true hydrogen concentrations and the corresponding response-recovery change curves; S2. For each response-recovery change curve in the original data, obtain the response starting point and extract the resistance signal within a time T after the response starting point. Combine a true hydrogen concentration and the resistance signal within the corresponding time T into a sample point. Through maximum-minimum normalization of the resistance signal and normalization of the true hydrogen concentration, obtain the sample set S; S3. Perform drift compensation on each resistance signal in the sample set S to obtain the sample set S'; S4. Construct a hydrogen concentration prediction model. Use the resistance signals in the sample set S' as the input and the true hydrogen concentration as the output to train the hydrogen concentration prediction model to obtain the trained hydrogen concentration prediction model; Among them, the hydrogen concentration prediction model is obtained by setting a Dropout layer and a GRU layer before the output layer of the 1DCNN neural network model; S5. Introduce the hydrogen to be tested into the gas sensor, extract the resistance signal within a time T after the response starting point in its response-recovery change curve. After normalization, input it into the trained hydrogen concentration prediction model to output the predicted concentration of the hydrogen to be tested.
2. The rapid hydrogen detection method based on 1DCNN and GRU according to claim 1, characterized in that, The structure of the hydrogen concentration prediction model includes, in sequence: 1 input layer; 1 fully connected layer; At least one group of alternating 1 convolutional layer and 1 max pooling layer; 1 Dropout layer; 1 GRU layer; 1 output layer.
3. The hydrogen rapid detection method based on 1DCNN and GRU according to claim 2, wherein In S2, the value of T is 6 - 10. According to the sampling frequency adopted, determine the corresponding number m of resistance signals based on the value of T.
4. The hydrogen rapid detection method based on 1DCNN and GRU according to claim 3, characterized in that The sample set S described in S2 = {(R1, Y1), (R2, Y2),..., (R N , Y N )}; where N is the total number of sample points, determined according to the concentration range of the hydrogen to be tested; is the resistance signal of the i-th sample point, is the resistance value of the j-th resistance signal in the i-th sample point; Y i , i = 1, 2,..., N is the true hydrogen concentration of the i-th sample point.
5. The rapid hydrogen detection method based on 1DCNN and GRU according to claim 4, characterized in that, The specific process of performing drift compensation on each resistance signal in the sample set S in S3 is: S31. Obtain the first resistance value of each resistance signal in the sample set S and calculate all the first resistance values for the average value S32. Calculate the first resistance value of the resistance signal of the i-th sample point and the average value to obtain the difference Res i , where i = 1, 2,..., N. Then calculate the resistance signal of the i-th sample point and Res i , where i = 1, 2,..., N. Take the difference as the resistance signal of the i-th sample point after drift compensation S33. Traverse all sample points in the sample set S, 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'.
6. The rapid hydrogen detection method based on 1DCNN and GRU according to claim 5, wherein, The loss function loss of the hydrogen concentration prediction model is: Where, δ lower and δ upper respectively represent a preset low error threshold and a high error threshold; represents the predicted hydrogen concentration of the i-th sample point.
7. The rapid hydrogen detection method based on 1DCNN and GRU according to claim 6, characterized in that δ lower has a value range of 0.0001 to 0.001, and δ upper has a value range of 0.01 to 0.
1.
8. The rapid hydrogen detection method based on 1DCNN and GRU according to claim 3, characterized in that, The feature vector of the input layer includes m features; the feature vector of the convolutional layer includes 100 - 130 features; the feature vector of the max pooling layer includes 1 - 2 features; the random discard probability of neurons in the Dropout layer is 0.1 - 0.3; the feature vector of the GRU layer includes 1 - 64 features.
Citation Information
Patent Citations
Rapid hydrogen detection method based on auto-encoder and full connection layer
CN116840305A
Cutting tool wear monitoring method based on multiscale deep convolutional recurrent neural network
CN110509109A
Underwater target recognition method based on GRU and one-dimensional CNN neural network fusion
CN110807365A