A hydrogen concentration rapid prediction method based on CNN-LSTM
By constructing a neural network model based on CNN-LSTM and using multi-sensor data for filtering and normalization, the prediction model was optimized, solving the problem of long response time of gas sensors and realizing rapid and accurate prediction of hydrogen concentration.
Patent Information
- Application Number
- CN202211628182.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-17
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2042-12-17
AI Technical Summary
Existing gas sensors have long response times, making it difficult to quickly and accurately predict hydrogen concentration in the initial stage, which affects the early warning and prevention of gas hazard accidents.
A CNN-LSTM-based neural network model was adopted. Data from hydrogen, temperature, and humidity sensors were filtered and normalized to construct the neural network model. The model was trained by adjusting the learning rate and the number of iterations to optimize the prediction model and reduce the influence of ambient temperature and humidity on the measurement results.
It enables rapid and accurate prediction of hydrogen concentration in the early stages of hydrogen diffusion, significantly shortening the detection time and improving the accuracy and efficiency of prediction.
Smart Images

Figure CN115985406B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of gas concentration prediction, and particularly relates to a hydrogen concentration rapid prediction method based on CNN-LSTM. BACKGROUND
[0002] In people's production and life, accurate and rapid prediction of toxic and harmful gases in the environment can play a warning and prevention role in the occurrence of gas danger accidents, and is of great significance to human health and safety, social harmony and stability.
[0003] The concentration of gas is generally detected by a gas sensor. The current problem is that the reaction of gas molecules with the surface of the gas sensor is slow, and the response time of the gas sensor is long. The response of the sensor gradually increases with time from the start of detection by the gas sensor, and it usually takes several minutes for the detection value to tend to be stable, which is called a detection saturation state. The concentration obtained by detection in this state is the detection saturation concentration of the gas. Therefore, predicting the concentration of the gas in the initial stage of the detection response curve of the gas sensor is crucial for practical application. SUMMARY
[0004] In order to quickly predict the concentration of hydrogen in the environment, the present application provides a hydrogen concentration prediction method, which can realize rapid prediction of the hydrogen concentration in the environment.
[0005] The technical scheme provided by the present application is: a hydrogen concentration rapid prediction method based on CNN-LSTM, wherein CNN refers to Convolutional Neural Networks, and LSTM refers to Long Short-Term Memory. That is, the hydrogen concentration in the environment is predicted in the initial stage of hydrogen diffusion through a neural network model, as shown in Figure 1 The technical scheme provided by the present application is: a hydrogen concentration rapid prediction method based on CNN-LSTM, wherein CNN refers to Convolutional Neural Networks, and LSTM refers to Long Short-Term Memory. That is, the hydrogen concentration in the environment is predicted in the initial stage of hydrogen diffusion through a neural network model, as shown in
[0006] (1) Hydrogen sensors Sensor1 and Sensor2 are arranged in the gas test environment to test the hydrogen concentration, a temperature sensor is arranged to test the environmental temperature, and a humidity sensor is arranged to test the environmental humidity, so as to obtain the data measured by each sensor;
[0007] The hydrogen concentration of the test environment is set;
[0008] (2) The data measured by each sensor is filtered;
[0009] (3) The data processed in step (2) is normalized;
[0010] The data of Sensor1 in the initial stage of detection is normalized and used as the input input_1 of the model in step (4).
[0011] Sensor2 in the detection of the initial stage of the data after normalization as step (4) in the input of the model input_2;
[0012] Temperature sensor data and humidity sensor in the detection of the initial stage of the data after normalization as step (4) in the input of the model input_3;
[0013] Sensor1 in the detection of the saturated state of the data after normalization as step (4) in the output of the model output1;
[0014] Sensor2 in the detection of the saturated state of the data after normalization as step (4) in the output of the model output2;
[0015] The hydrogen concentration of the set test environment as step (4) in the output of the model output3;
[0016] (4) Construct a neural network model, which includes input layer, convolution layer, LSTM layer, full connection layer and output layer in turn, that is, the input of the input layer connects the input of the convolution layer, the output of the convolution layer is the input of the LSTM layer, the output of the LSTM is the input of the full connection layer, and the output of the full connection layer is connected to the output layer;
[0017] The input layer includes input input_1, input_2 and input_3;
[0018] The output layer includes output output1, output2 and output3;
[0019] (5) Use the data in step (3) to repeatedly train the neural network model in step (4) to obtain a prediction model;
[0020] (6) Input the data in step (3) into the prediction model to obtain the predicted value of the hydrogen concentration, and the set test environment hydrogen concentration as the true value, calculate the prediction error between the true value and the predicted value for model evaluation.
[0021] As preferred, in step (2), the data collected by each sensor is cut, aligned, and outliers are removed, and then filtered.
[0022] As preferred, in step (2), the sensor data is filtered using a sliding average filtering algorithm, and the formula of the sliding average filtering algorithm is as follows:
[0023]
[0024] Where v t is the sensor data before filtering, is filtered sensor data, m is the size of the sliding window.
[0025] As a preferred, in the step (3), the normalization formula is as follows:
[0026]
[0027] wherein is filtered sensor data, is the minimum value in the filtered sensor data, is the maximum value in the filtered sensor data, x t is normalized sensor data.
[0028] As a preferred, in the step (3), Sensor1 and Sensor2 data in the initial stage of detection are normalized, and then differentiated and integrated, the differentiation formula is as follows:
[0029] d t = x t+1 - x t
[0030] The integration formula is as follows:
[0031]
[0032] wherein, x t is normalized Sensor1 data and Sensor2 data, d t is differentiated Sensor1 data and Sensor2 data, s t is integrated Sensor1 data and Sensor2 data;
[0033] The differentiated and integrated Sensor1 data is input input_4 of the model in the step (4);
[0034] The differentiated and integrated Sensor2 data is input input_5 of the model in the step (4);
[0035] The input layer in the step (4) further includes input input_4 and input_5.
[0036] As a preferred, after the step (3), a plurality of groups of data are obtained, a part of which is used as training data for the step (5), and a part of which is used as test data for the step (6).
[0037] As preferred, in step (3), the data after reaching the detection saturation state of Sensor 1 is normalized, and then the average value is taken as the output output1 of the model in step (4); the data after reaching the detection saturation state of Sensor 2 is normalized, and then the average value is taken as the output output2 of the model in step (4).
[0038] As preferred, the initial detection stage refers to a period of 10s-150s from the start of detection, preferably 10s, 30s, 60s, 90s, 120s, 150s from the start of detection.
[0039] As preferred, the data after reaching the detection saturation state refers to the detection data in a period of 10s-150s from the start of reaching the detection saturation state, preferably 10s, 30s, 60s, 90s, 120s, 150s from the start of reaching the detection saturation state.
[0040] As preferred, in step (4), the convolution layer is a one-dimensional convolution network Conv1D.
[0041] As preferred, in step (4), the LSTM layer includes an LSTM connection with a depth of 4.
[0042] As preferred, in step (4), the fully connected layer includes 2 Dense layers.
[0043] As preferred, in step (5), the prediction model is obtained by adjusting the learning rate and the number of iterations.
[0044] As preferred, the optimizer of the neural network model is set to Adam, the Loss function is set to MAPE, the Batch is set to 32, the data processed in step (3) is used to repeatedly train the neural network model, the learning rate and the number of iterations are adjusted to obtain the prediction model.
[0045] As preferred, in step (5), the model is evaluated by the mean absolute percentage error, and the formula of the mean absolute percentage error is as follows:
[0046]
[0047] Where N is the number of samples, y k is the true value, is the predicted value.
[0048] As preferred, in the neural network model, input_1 and input_2 are combined into input_4 and input_5 respectively after one-dimensional convolution operation, and then combined into input_3, and then passed through 3 LSTM layers and connected to the output layer through the fully connected layer.
[0049] Compared with the prior art, the neural network model is constructed, the hydrogen concentration, the temperature and the humidity in the environment are detected by using the sensor, the measured data are filtered and normalized to serve as the input of the model, the saturated data of the measured hydrogen concentration and the set hydrogen concentration serve as the output of the model, then the measured data are used to repeatedly train the model to obtain a prediction model, the measured data are used to evaluate the prediction model, the prediction model is adjusted according to the prediction error to obtain an optimized prediction model. The prediction model can be used to predict the hydrogen concentration in the environment in the initial stage of hydrogen diffusion by using the data of the sensor in the initial detection stage, the hydrogen concentration is rapidly predicted, and the detection time is greatly shortened. In addition, the temperature and the humidity of the environment are input into the neural network together with the measured hydrogen concentration, so that the influence of the temperature and the humidity of the environment on the measurement result is reduced. BRIEF DESCRIPTION OF DRAWINGS
[0050] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings used in the embodiments will be briefly introduced as follows. Obviously, the drawings below refer to some embodiments of the present application, and the drawings can also be used to obtain other drawings without creative labor for those skilled in the art. Among them:
[0051] Figure 1 is a flow diagram of the hydrogen concentration rapid prediction method based on CNN-LSTM of the present application.
[0052] Figure 2 is a response graph of two hydrogen sensors to different concentrations of hydrogen in embodiment 1.
[0053] Figure 3 is a distribution diagram of the saturation values of the responses of two sensors in embodiment 1.
[0054] Figure 4 is a response change graph of two hydrogen sensors over time in embodiment 1, wherein (a) is a change graph of sensor Sensor1, and (b) is a change graph of sensor Sensor2.
[0055] Figure 5 is a MAPE graph of each output of different models in embodiments 1-6.
[0056] Figure 6 is a MAPE graph of the prediction results of model 5 in embodiment 5 under different initial detection stage conditions.
[0057] Figure 7 is a comparison diagram of the predicted values and the true values of Sensor1 in model 5.
[0058] Figure 8is a diagram of the comparison between the predicted value of Sensor1 in model5 and the true value.
[0059] Figure 9 is a diagram of the comparison between the predicted value of the environmental hydrogen concentration in model5 and the true value.
[0060] Figure 10 is a diagram of the model structure of model 1 in Example 1 and the MAPE of each output.
[0061] Figure 11 is a diagram of the model structure of model 2 in Example 2 and the MAPE of each output.
[0062] Figure 12 is a diagram of the model structure of model 3 in Example 3 and the MAPE of each output.
[0063] Figure 13 is a diagram of the model structure of model 4 in Example 4 and the MAPE of each output.
[0064] Figure 14 is a diagram of the model structure of model 5 in Example 5 and the MAPE of each output.
[0065] Figure 15 is a diagram of the model structure of model 6 in Example 6 and the MAPE of each output. DETAILED DESCRIPTION
[0066] The application will be further described in conjunction with the embodiments and the accompanying drawings. It should be noted that the following embodiments are intended to facilitate the understanding of the application and do not limit the application in any way.
[0067] Example 1:
[0068] (1) In the gas test environment, hydrogen sensor Sensor1 and hydrogen sensor Sensor2 are set for testing the hydrogen concentration, temperature sensor is set for testing the environmental temperature, and humidity sensor is set for testing the environmental humidity.
[0069] In this embodiment, the environmental temperature of the gas test environment is set to 30℃, 35℃, 40℃, 45℃, and 50℃, respectively; the environmental humidity is set to 20%, 30%, 40%, 50%, 60%, and 70%, respectively; and the environmental hydrogen concentration is randomly set between 0-20000ppm.
[0070] Under the same temperature and humidity, when hydrogen with concentrations of 2000ppm, 6000ppm, 10000ppm, 14000ppm, and 18000ppm is introduced, the output values of the two hydrogen sensors are as shown in Figure 2
[0071] The output value scatter plot of the two hydrogen sensors reaching the detection saturation state under different temperature and humidity and when different concentrations of hydrogen are passed in is shown in Figure 3 The scatter plot change reflects the influence of temperature and humidity on the output value.
[0072] The output value of the two hydrogen sensors over time when the concentration of hydrogen passed in is 2000ppm, 6000ppm, 10000ppm, 14000ppm and 18000ppm under the same temperature and humidity is shown in Figure 4 It can be seen that the detection of the hydrogen concentration in the environment by each hydrogen sensor requires a certain time, and the response of the sensor gradually increases over time from the start of detection by each hydrogen sensor (i.e., the detection start time is 0), and the increase is particularly large in the initial detection stage (e.g., the time period of 30s, 60s, 90s, 120s and 150s from the detection start time in Figure 3 ), and the output value of the sensor is stable at the detection time T, i.e., reaches the detection saturation state. The time period from the detection start time to the time T when the detection saturation state is reached is called the detection saturation time. In this embodiment, the detection saturation time is about 12 minutes, and the detection time = detection saturation time + 30s.
[0073] The data measured by each sensor at different times during the entire detection time is collected, i.e., the hydrogen concentration measured by the hydrogen sensor Sensor1, the hydrogen concentration measured by the hydrogen sensor Sensor2, the ambient temperature measured by the temperature sensor and the ambient humidity measured by the humidity sensor.
[0074] (2) The data collected by each sensor is cut, aligned, and outliers are removed, and a sliding average filtering algorithm is used to filter the data of each sensor, and the formula of the sliding average filtering algorithm is as follows:
[0075]
[0076] where v t is the sensor data before filtering, is the sensor data after filtering, and m is the size of the sliding window.
[0077] (3) The filtered data obtained in step (2) is normalized, and the formula for normalization is as follows:
[0078]
[0079] where is the filtered sensor data, is the minimum value in the filtered sensor data,
[0080] is the maximum value in the filtered sensor data, and xt is normalized sensor data.
[0081] The data in the initial stage of detection in each sensor data is normalized, and in this embodiment, the data in the time period of 0-30s in the middle is selected as the data in the initial stage of detection. Figure 4 The normalized Sensor1 data is used as the input input_1 of the model in step (4), the normalized Sensor2 data is used as the input input_2 of the model in step (4), and the normalized temperature sensor data and humidity sensor data are used as the input input_3 of the model in step (4).
[0082] The data in the time period of 30s after reaching the saturation state in the Sensor1 data and the Sensor2 data is normalized, and then the average value is taken as the data of Sensor1 and Sensor2 in the detection of the saturation state, which is called saturation data. The saturation data of Sensor1 is used as the output output1 of the model in step (4), and the saturation data of Sensor2 is used as the output output2 of the model in step (4).
[0083] The input input_1, input_2, input_3 and the output output1, output2 are used as a group of sample data, and in this embodiment, 228 groups of sample data are obtained by experimental testing, 68 groups are used as test sample data, and 160 groups are used as training sample data.
[0084] (4) A neural network model is constructed, the input of the model is input_1, input_2 and input_3, and the output of the model is output1, output2 and output3. The input input_1, input_2 and input_3 and the output output1 and output2 are as described in step (3), and the output output3 is the true hydrogen concentration of the test environment, i.e., the hydrogen concentration of the test environment set in step (1).
[0085] In this embodiment, the neural network model is denoted as model1, and the structure of model1 is as shown in Figure 10 -(a), the input_1, input_2 and input_3 are connected and merged and then subjected to 1-layer LSTM operation, the output of the LSTM is commonly output to 3 fully connected nodes, and the fully connected nodes are respectively connected to the model outputs output1, output2 and output3.
[0086] (5) In order to evaluate the influence of different parameters on the prediction effect and find the optimal parameters, the optimizer of the model is set to Adam, the loss function is set to MAPE, and the batch is set to 32. The training sample data in step (3) is used to train the neural network model model 1. By adjusting the learning rate and the number of iterations, the prediction model is obtained by repeating the training.
[0087] (6) The test sample data in step (3) is input into the prediction model to obtain the predicted hydrogen concentration output by the prediction model. The average absolute percentage error is used to evaluate the model, and the average absolute percentage error formula is as follows:
[0088]
[0089] where N is the number of samples, y k is the true hydrogen concentration, is the predicted hydrogen concentration. The prediction error between the true hydrogen concentration and the predicted hydrogen concentration is calculated, and the initial prediction model is adjusted according to the prediction error to obtain the optimized prediction model model 1.
[0090] The minimum average absolute percentage error of the output 1 of the model 1 model corresponding to different learning rates and iteration numbers is 26.95%, as shown in Figure 10 (b).
[0091] The minimum average absolute percentage error of the output 2 of the model 1 model corresponding to different learning rates and iteration numbers is 25.20%, as shown in Figure 10 (c).
[0092] The minimum average absolute percentage error of the output 3 of the model 1 model corresponding to different learning rates and iteration numbers is 28.70%, as shown in Figure 10 (d).
[0093] Example 2:
[0094] (1) The same as step (1) in example 1.
[0095] (2) The same as step (2) in example 1.
[0096] (3) The same as step (3) in example 1.
[0097] (4) Construct a neural network model, the input of the model is input_1, input_2, input_3, and the output of the model is output1, output2, output3. The input input_1, input_2, input_3 and the output output1, output2 are as described in step (3), and output3 is the true hydrogen concentration of the test environment, that is, the hydrogen concentration of the test environment set in step (1).
[0098] In this embodiment, the neural network model is denoted as model 2, and the structure of model 2 is as shown in Figure 11 -(a). input_1 and input_2 are respectively subjected to one-dimensional convolution (Conv1D ReLU), and are respectively combined (Concatenate) with input_3 to input the LSTM (LSTM Sigmoid) layer, and are connected to the model output output1, output2, output3 after passing through the full connection layer (Dense Sigmoid).
[0099] (5) In order to evaluate the influence of different parameters on the prediction effect and find the optimal parameters, the optimizer of the model is set to Adam, the loss function is set to MAPE, the batch is set to 32, the training sample in step (3) is used to train the neural network model model2, and the prediction model is obtained by adjusting the learning rate and the number of iterations.
[0100] (6) The test sample data in step (3) is input into the prediction model to obtain the predicted hydrogen concentration output by the prediction model, and the average absolute percentage error is used to evaluate the model. The average absolute percentage error formula is as follows:
[0101]
[0102] Where N is the number of samples, y k is the true hydrogen concentration, is the predicted hydrogen concentration. The prediction error between the true hydrogen concentration and the predicted hydrogen concentration is calculated, and the initial prediction model is adjusted according to the prediction error to obtain the optimized prediction model model 2.
[0103] The minimum average absolute percentage error of output1 of model 2 model corresponding to different learning rates and iteration numbers is 20.8%, as shown in Figure 11 -(b).
[0104] The minimum average absolute percentage error of output2 of model 2 model corresponding to different learning rates and iteration numbers is 15.95%, as shown in Figure 11 -(c).
[0105] The average absolute percentage error of the output 3 of the model 2 is 19.25% at different learning rates and iteration numbers, as shown in Table 2. Figure 11 (d).
[0106] Example 3:
[0107] (1) The same as step (1) in Example 1.
[0108] (2) The same as step (2) in Example 1.
[0109] (3) The filtered data obtained in step (2) is normalized, and the normalization formula is as follows
[0110]
[0111] wherein is the filtered sensor data, is the minimum value in the filtered sensor data, is the maximum value in the filtered sensor data, x t is the normalized sensor data.
[0112] The data in the initial detection stage of each sensor data is normalized, and in this embodiment, the time period of 0-30s in Figure 4 is selected as the initial detection stage. The normalized data of Sensor 1 is used as the input input_1 of the model in step (4), the normalized data of Sensor 2 is used as the input input_2 of the model in step (4), and the normalized data of temperature and humidity is used as the input input_3 of the model in step (4).
[0113] The differential and integral of Sensor 1 data and Sensor 2 data are calculated, and the differential formula is as follows:
[0114] d t = x t+1 -x t
[0115] The integral formula is as follows:
[0116]
[0117] wherein, x t is the normalized Sensor 1 data and Sensor 2 data, d t is the differential Sensor 1 data and Sensor 2 data, s t is the integral Sensor 1 data and Sensor 2 data.
[0118] Sensor1 data after differentiation and integration as the input of the model in step (4) input_4;
[0119] Sensor2 data after differentiation and integration as the input of the model in step (4) input_5;
[0120] The input input_1, input_2, input_3, input_4, input_5 and the output output1, output2 are a set of sample data, in this embodiment, 228 sets of sample data are obtained by experimental test, 68 sets are used as test sample data and 160 sets are used as training sample data.
[0121] (4) Construct a neural network model, the input of the model is input_1, input_2, input_3, input_4, input_5, and the output of the model is output1, output2, output3. The input input_1, input_2, input_3 and the output output1, output2 are described in step (3), and output3 is the true hydrogen concentration of the test environment, that is, the hydrogen concentration of the test environment set in step (1).
[0122] In this embodiment, the neural network model is denoted as model 3, and the structure of model 3 is as shown in Figure 12 -(a), input_1, input_2 are combined with input_4, input_5 respectively after one-dimensional convolution operation, and input_3 is combined together through 1 layer LSTM and full connection layer to output output1, output2, output3.
[0123] (5) In order to evaluate the influence of different parameters on the prediction effect and find the optimal parameters, the optimizer of the model is set to Adam, the loss function is set to MAPE, the batch is set to 32, the training sample in step (3) is used to train the neural network model model3, and the prediction model is obtained by adjusting the learning rate and the number of iterations and repeating the training.
[0124] (6) The test sample data in step (3) is input into the prediction model to obtain the predicted hydrogen concentration output by the prediction model, and the average absolute percentage error is used to evaluate the model, and the average absolute percentage error formula is as follows:
[0125]
[0126] Where N is the number of samples, y k is the true hydrogen concentration, To predict the hydrogen concentration. Calculate the prediction error between the true hydrogen concentration and the predicted hydrogen concentration, adjust the initial prediction model according to the prediction error, and obtain the optimized prediction model model 3.
[0127] The minimum result of the average absolute percentage error of output1 of model 3 model corresponding to different learning rates and iteration times is 18.80%, as shown in Figure 12 -(b).
[0128] The minimum result of the average absolute percentage error of output2 of model 3 model corresponding to different learning rates and iteration times is 14.40%, as shown in Figure 12 -(c).
[0129] The minimum result of the average absolute percentage error of output3 of model 3 model corresponding to different learning rates and iteration times is 16.60%, as shown in Figure 12 -(d).
[0130] Example 4:
[0131] (1) The same as step (1) in Example 3.
[0132] (2) The same as step (2) in Example 3.
[0133] (3) The same as step (3) in Example 3.
[0134] (4) Construct a neural network model, the input of the model is input_1, input_2, input_3, input_4, input_5, and the output of the model is output1, output2, output3. The input input_1, input_2, input_3 and the output output1, output2 are described in step (3), and output3 is the true hydrogen concentration of the test environment, that is, the hydrogen concentration of the test environment set in step (1).
[0135] In this embodiment, the neural network model is denoted as model 4, and the structure of model 4 is shown in Figure 13 -(a). After one-dimensional convolution operation of input_1 and input_2, respectively, input_4 and input_5 are combined, and input_3 is combined through 2 layers of LSTM and then connected to the model output output1, output2, output3 through a fully connected layer.
[0136] (5) In order to evaluate the influence of different parameters on the prediction effect and find the optimal parameters, the optimizer of the model is set to Adam, the loss function is set to MAPE, and the batch is set to 32. The training sample in step (3) is used to train the neural network model model 1. By adjusting the learning rate and the number of iterations, the prediction model is obtained by repeating the training.
[0137] (6) The test sample data in step (3) is input into the prediction model to obtain the predicted hydrogen concentration output by the prediction model. The average absolute percentage error is used to evaluate the model, and the average absolute percentage error formula is as follows:
[0138]
[0139] Where N is the number of samples, y k is the true hydrogen concentration, is the predicted hydrogen concentration. The prediction error between the true hydrogen concentration and the predicted hydrogen concentration is calculated, and the initial prediction model is adjusted according to the prediction error to obtain the optimized prediction model model 4.
[0140] The minimum average absolute percentage error of output 1 of model 4 model corresponding to different learning rates and iteration numbers is 16.50%, as shown in Figure 13 (b).
[0141] The minimum average absolute percentage error of output 2 of model 4 model corresponding to different learning rates and iteration numbers is 13.90%, as shown in Figure 13 (c).
[0142] The minimum average absolute percentage error of output 3 of model 4 model corresponding to different learning rates and iteration numbers is 15.25%, as shown in Figure 13 (d).
[0143] Example 5:
[0144] (1) The same as step (1) in Example 3.
[0145] (2) The same as step (2) in Example 3.
[0146] (3) The same as step (3) in Example 3.
[0147] (4) Construct a neural network model, the input of the model is input_1, input_2, input_3, input_4, input_5, and the output of the model is output1, output2, output3. The input input_1, input_2, input_3 and the output output1, output2 are as described in step (3), and output3 is the true hydrogen concentration of the test environment, that is, the hydrogen concentration of the test environment set in step (1).
[0148] In this embodiment, the neural network model is denoted as model 5, and the structure of model 5 is as shown in Figure 14 -(a). After one-dimensional convolution operation of input_1 and input_2, input_4 and input_5 are combined respectively, and then input_3 is combined together, and then passed through 3 layers of LSTM, and then connected to the model output output1, output2, output3 through a fully connected layer.
[0149] (5) In order to evaluate the influence of different parameters on the prediction effect and find the optimal parameters, the optimizer of the model is set to Adam, the Loss function is set to MAPE, the Batch is set to 32, and the training sample in step (3) is used to train the neural network model model1. By adjusting the learning rate and the number of iterations, the prediction model is obtained by repeating the training.
[0150] (6) The test sample data in step (3) is input into the prediction model to obtain the predicted hydrogen concentration output by the prediction model. The average absolute percentage error is used to evaluate the model, and the average absolute percentage error formula is as follows:
[0151]
[0152] Where N is the number of samples, y k is the true hydrogen concentration, is the predicted hydrogen concentration. The prediction error between the true hydrogen concentration and the predicted hydrogen concentration is calculated, and the initial prediction model is adjusted according to the prediction error to obtain the optimized prediction model model 5.
[0153] The minimum average absolute percentage error of output1 of model 5 model corresponding to different learning rates and iteration numbers is 13.7%, as shown in Figure 14 -(b).
[0154] The minimum average absolute percentage error of output2 of model 5 model corresponding to different learning rates and iteration numbers is 10.8%, as shown in Figure 14 -(c).
[0155] The average absolute percentage error of the output 3 of the model 5 is 12.8% at different learning rates and iteration numbers, as shown in Table 6. Figure 14 -(d).
[0156] Example 6:
[0157] (1) The same as step (1) in Example 3.
[0158] (2) The same as step (2) in Example 3.
[0159] (3) The same as step (3) in Example 3.
[0160] (4) A neural network model is constructed, the input of the model is input_1, input_2, input_3, input_4, input_5, and the output of the model is output1, output2, output3. The input input_1, input_2, input_3 and the output output1, output2 are as described in step (3), and output3 is the true hydrogen concentration of the test environment, i.e., the hydrogen concentration of the test environment set in step (1).
[0161] In this embodiment, the neural network model is denoted as model 6, and the structure of the model 6 is as shown in Figure 6. Figure 15 -(a), after one-dimensional convolution operation of input_1 and input_2, input_4 and input_5 are combined respectively, and then input_3 is combined together, and then passed through 4 layers of LSTM, and then connected to the model output output1, output2, output3 through a fully connected layer.
[0162] (5) In order to evaluate the influence of different parameters on the prediction effect and find the optimal parameters, the optimizer of the model is set to Adam, the Loss function is set to MAPE, the Batch is set to 32, the training sample in step (3) is used to train the neural network model model1, and the prediction model is obtained by adjusting the learning rate and the number of iterations.
[0163] (6) The test sample data in step (3) is input into the prediction model to obtain the predicted hydrogen concentration output by the prediction model, and the average absolute percentage error is used to evaluate the model, and the average absolute percentage error formula is as follows:
[0164]
[0165] Where N is the number of samples, y k is the true hydrogen concentration, To predict hydrogen concentration, the prediction error between the actual hydrogen concentration and the predicted hydrogen concentration is calculated. Based on the prediction error, the initial prediction model is adjusted to obtain the optimized prediction model, model 6.
[0166] The minimum mean absolute percentage error (MAS) of output1 for model 6 across different learning rates and iteration numbers is 18.50%. Figure 15 As shown in -(b).
[0167] The minimum mean absolute percentage error (MAS) of output2 for model 6 across different learning rates and iteration numbers is 14.15%. Figure 15 As shown in -(c).
[0168] The minimum mean absolute percentage error (MAS) of output3 for model 6 across different learning rates and iteration numbers is 16.15%. Figure 15 -(d).
[0169] For Examples 1-6, with the same dataset, the prediction results of different models are as follows: Figure 5 As shown, model 5 in Example 5 has the smallest error, meaning that model 5 is the best model.
[0170] For model 5, without changing the model structure, increase the detection initial stage time, such as... Figure 4 As shown, the initial detection phases were selected as the first 30s, 60s, 90s, 120s, and 150s, respectively. Figure 6 As shown, the mean absolute percentage error of each output prediction result gradually decreases. The scatter plots of the output prediction results when different time lengths are selected in the initial detection stage are shown below. Figures 7-9 As shown, Figure 7 This is a diagram showing the comparison between the predicted and actual values of Sensor1. Figure 8 This is a diagram showing the comparison between the predicted and actual values of Sensor2. Figure 9 This is a diagram showing the comparison between predicted and actual values of hydrogen concentration in the environment.
[0171] In practical applications, Model 5 is used to predict the hydrogen concentration in the environment by using sensor data in the initial detection stage during the early stages of hydrogen diffusion, thus achieving rapid prediction of hydrogen concentration and significantly shortening the detection time.
[0172] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A CNN-LSTM-based hydrogen concentration rapid prediction method, characterized in that, The method comprises the following steps: (1) setting a hydrogen sensor Sensor1 and a hydrogen sensor Sensor2 in a gas test environment for testing hydrogen concentration, a temperature sensor for testing ambient temperature, and a humidity sensor for testing ambient humidity, and obtaining data measured by each sensor; Setting the hydrogen concentration of the test environment; (2) filtering the data measured by each sensor; (3) normalizing the data processed in step (2); The data of Sensor1 in the initial detection stage after normalization is used as the input input_1 of the model in step (4); The data of Sensor2 in the initial detection stage after normalization is used as the input input_2 of the model in step (4); The data of the temperature sensor and the humidity sensor in the initial detection stage after normalization are used as the input input_3 of the model in step (4); The data of Sensor1 in the saturated state after normalization is used as the output output1 of the model in step (4); The data of Sensor2 in the saturated state after normalization is used as the output output2 of the model in step (4); The set hydrogen concentration of the test environment is used as the output output3 of the model in step (4); (4) constructing a neural network model, which comprises an input layer, a convolution layer, an LSTM layer, a full connection layer, and an output layer in sequence, i.e. the input of the input layer is connected to the input of the convolution layer, the output of the convolution layer is used as the input of the LSTM layer, the output of the LSTM is used as the input of the full connection layer, and the output of the full connection layer is connected to the output layer; The input layer comprises input input_1, input_2, and input_3; The output layer comprises output output1, output2, and output3; (5) repeatedly training the neural network model in step (4) using the data in step (3) to obtain a prediction model; (6) inputting the data in step (3) into the prediction model to obtain the predicted value of the hydrogen concentration, setting the set hydrogen concentration of the test environment as the true value, and calculating the prediction error between the true value and the predicted value for evaluating the model.
2. The method of rapidly predicting a hydrogen concentration according to claim 1, characterized by, In step (2), the data collected by each sensor is cut, aligned, and outliers are removed, and then filtered.
3. The method of rapidly predicting a hydrogen concentration according to claim 1, characterized by, In step (2), the sensor data is filtered using a sliding average filtering algorithm, and the formula of the sliding average filtering algorithm is as follows: where v t is the sensor data before filtering, is the sensor data after filtering, and m is the size of the sliding window.
4. The method of rapidly predicting a hydrogen concentration according to claim 1, wherein In step (3), the normalization processing formula is as follows: wherein is filtered sensor data, is a minimum value in the filtered sensor data, is a maximum value in the filtered sensor data, x t is normalized sensor data.
5. The method of rapidly predicting a hydrogen concentration according to claim 1, wherein In step (3), the data of Sensor1 and Sensor2 in the initial detection stage after normalization is differentiated and integrated, and the differentiation formula is as follows: d t = x t+1 - x t The integral formula is as follows: where x t is the normalized Sensor1 data and Sensor2 data, d t is the differentiated Sensor1 data and Sensor2 data, s t is the integrated Sensor1 data and Sensor2 data; The data of Sensor1 after differentiation and integration is used as the input input_4 of the model in step (4); The data of Sensor2 after differentiation and integration is used as the input input_5 of the model in step (4); The input layer in step (4) further comprises input input_4 and input_5.
6. The method of rapidly predicting a hydrogen concentration according to claim 1, wherein After step (3) processing, several groups of data are obtained, part of which is used as training data for step (5), and part of which is used as test data for step (6).
7. The method of rapidly predicting hydrogen concentration according to claim 1, wherein In step (3), the data after reaching the detection saturation state of Sensor1 is normalized, and then the average value is taken as the output output1 of the model in step (4); the data after reaching the detection saturation state of Sensor2 is normalized, and then the average value is taken as the output output2 of the model in step (4).
8. The method of rapidly predicting hydrogen concentration according to claim 1, wherein The initial stage of detection refers to a period of 10s-150s from the start of detection.
9. The method of rapidly predicting a hydrogen concentration according to claim 8, wherein The initial stage of detection is 10s, 30s, 60s, 90s, 120s, 150s from the start of detection.
10. The method of rapidly predicting hydrogen concentration according to claim 1, wherein The data after reaching the detection saturation state refers to the detection data in a period of 10s-150s from the start of reaching the detection saturation state.
11. The method of rapidly predicting a hydrogen concentration according to claim 10, wherein The data after reaching the detection saturation state is 10s, 30s, 60s, 90s, 120s, 150s from the start of reaching the detection saturation state.
12. The method of rapidly predicting hydrogen concentration according to claim 1, wherein In step (4), the convolution layer is a one-dimensional convolution network Conv1D.
13. The method of rapidly predicting hydrogen concentration according to claim 1, wherein In step (4), the LSTM layer includes an LSTM connection with a depth of 4.
14. The method of rapidly predicting hydrogen concentration according to claim 1, wherein In step (4), the fully connected layer includes 2 Dense layers.
15. The method of rapidly predicting hydrogen concentration according to claim 1, wherein In step (5), the prediction model is obtained by adjusting the learning rate and the number of iterations.
16. The method of rapidly predicting hydrogen concentration according to claim 1, wherein The optimizer of the neural network model is set to Adam, the Loss function is set to MAPE, the Batch is set to 32, the data processed in step (3) is used to repeatedly train the neural network model, the learning rate and the number of iterations are adjusted, and the prediction model is obtained.
17. The method of rapidly predicting hydrogen concentration according to claim 16, wherein In step (5), the model is evaluated by the mean absolute percentage error, and the formula of the mean absolute percentage error is as follows: where N is the number of samples, y k is the true value, is the predicted value.
18. The method of rapidly predicting hydrogen concentration according to claim 5, wherein In the neural network model, input_1 and input_2 are combined into input_4 and input_5 respectively after one-dimensional convolution operation, and then combined into input_3, and then passed through 3 LSTM layers and connected to the output layer through the fully connected layer.
Citation Information
Patent Citations
CNN and LSTM fused neural network-based air PM2.5 concentration prediction method
CN108009674A
Multi-scale short-time traffic flow prediction modeling and prediction method and system based on LSTM-GASVR
CN113674524A