Error compensation method for thermal conductivity type hydrogen sensor based on dynamic collaborative optimization
Through the global-local dual-mode collaborative optimization framework and dynamic weight update mechanism, the BP neural network is optimized, and the accuracy of thermally conductive hydrogen sensors is reduced in complex environments is solved, and high-precision hydrogen concentration detection is achieved.
Patent Information
- Application Number
- CN202510468697.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-15
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2045-04-15
AI Technical Summary
The existing thermally conductive hydrogen sensors have reduced accuracy under the influence of temperature and humidity changes in complex environments, and the existing compensation methods are insufficiently adaptable under dynamic changing conditions, making it difficult to achieve high-precision hydrogen concentration detection.
Build a global-local dual-mode collaborative optimization framework, adopts a weight update mechanism of dynamic switching of multi-scale parameter search and gradient guidance, optimizes the weight matrix of the BP neural network, and realizes adaptive iterative optimization.
It realizes high-precision detection of hydrogen concentration in complex environments, has environmental sensitivity, strong model generalization, and low compensation error.
Smart Images

Figure CN120404836A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of hydrogen sensor detection, and particularly relates to an error compensation method for a thermal conductivity hydrogen sensor based on dynamic collaborative optimization. Background Art
[0002] As a new energy source, hydrogen energy has many advantages, but it has the defects of being flammable and explosive. With the development of hydrogen energy vehicles in the field of new energy vehicles, the detection of hydrogen concentration is very important. The thermal conductivity hydrogen sensor has the advantages of low price and high precision. However, in a complex environment, the continuous changes in temperature and humidity have a certain impact on the precision of the hydrogen sensor. Therefore, establishing a temperature and humidity compensation model is an effective way to reduce the non-linear influence of temperature and humidity on the gas-sensitive element, so as to achieve accurate detection of polluted gases.
[0003] The commonly used gas sensor compensation methods in the prior art mainly include the following four: hardware compensation method, linear regression algorithm, non-linear regression algorithm, and machine learning algorithm. However, these methods have the following deficiencies: the hardware compensation method completely depends on the hardware performance of the sensor itself, resulting in unstable compensation effects and being difficult to apply to different scenarios; the linear regression algorithm can only handle simple linear data relationships, and the accuracy drops significantly when facing the complex non-linear relationship between temperature, humidity and gas concentration; while the traditional non-linear regression algorithm and traditional machine learning algorithm can handle non-linear problems, but their generalization ability is limited and they are insufficiently adaptable under dynamically changing temperature and humidity conditions. Summary of the Invention
[0004] To solve the above problems, the present invention discloses an error compensation method for a thermal conductivity hydrogen sensor based on dynamic collaborative optimization. By constructing a global-local dual-mode collaborative optimization framework and dynamically switching the multi-scale parameter search and gradient-guided weight update mechanism, the adaptive iterative optimization of the neural network weight matrix is realized. The method has the characteristics of sensitive environmental perception, strong model generalization, and low compensation error, and finally achieves high-precision detection of hydrogen concentration.
[0005] To achieve the above object, the technical solution of the present invention is as follows:
[0006] An error compensation method for a thermal conductivity hydrogen sensor based on dynamic collaborative optimization, comprising the following steps:
[0007] (1) Collect the real-time environmental parameters of the target area and the output voltage of the sensor conditioning circuit, and the environmental parameters include the measured values of temperature and humidity;
[0008] (2) Input the environmental parameters and the output voltage into the preprocessed hydrogen concentration detection model, and output the hydrogen concentration value after temperature and humidity compensation;
[0009] The hydrogen concentration detection model is constructed through the following steps:
[0010] (21) Establish a BP neural network model including an input layer, a hidden layer, and an output layer, where the hidden layer uses the non-linear activation function Tan-Sigmoid (tansig), and the output layer uses the linear activation function Purelin;
[0011] (22) Its training data set includes input data and label data; the input data includes sample temperature values, sample humidity values, and the output voltage of the sample hydrogen sensor conditioning circuit; the label data is the sample hydrogen gas concentration value.
[0012] (23) Use a multi-modal method of dynamic collaborative optimization to optimize the weights and thresholds of the BP neural network to obtain an optimized neural network model; use the optimized neural network model to train the sample data set to obtain a hydrogen concentration detection model.
[0013] As a preferred implementation, the preprocessing of the model input data in step (2) includes:
[0014] Perform data outlier cleaning and standardization preprocessing on the collected environmental parameters and voltage signals;
[0015] Input the preprocessed and standardized temperature and humidity data and voltage signals into the detection model together.
[0016] As a preferred implementation, the dynamic collaborative optimization process (or called the temperature and humidity compensation method) in step (23) includes:
[0017] S1. Initialize the collaborative optimization parameters, including population size, dynamic learning coefficient, and parameter update rate constraint;
[0018] S2. Calculate the population fitness value, and the fitness function uses the mean square error between the predicted value and the true value:
[0019]
[0020] In the formula: y i is the i-th predicted value; x i is the i-th true value; n is the number of predicted samples.
[0021] S3. Initialization stage: Use a multi-modal collaborative search strategy to generate an initial parameter matrix with spatial distribution characteristics, and widely cover the parameter space through swarm intelligence optimization to effectively avoid the parameter sensitivity and local extreme value trap caused by traditional random initialization;
[0022] Method for generating the initial weight matrix:
[0023] S31. Generate the first optimized solution set through multi-modal collaborative search;
[0024] S32. Apply a normal distribution perturbation with a standard deviation of 0.1 to the solution set to generate an extended parameter subset;
[0025] S33. Merge the initial solution set and the extended subset to construct a mixed initial parameter matrix.
[0026] S4. Global-local collaborative update stage:
[0027] S41. Starting from the mixed initial parameter matrix, perform global optimization operations to update the parameter distribution: where the global optimization operations include:
[0028] Elite retention strategy: Retain the top 10% of the parameter groups with the best fitness;
[0029] Parameter recombination: Cross-fuse the retained parameters so that good parameter features can be retained;
[0030] Diversity perturbation: Apply Gaussian noise with a decreasing variance to the recombined parameters to increase interference and prevent overfitting;
[0031] S42. Dynamic mode switching stage: If the global optimal fitness has not improved for 5 consecutive generations, activate the dynamic neighborhood search mechanism:
[0032] Update the parameter direction through the historical gradient correlation rule:
[0033] θ j (t + 1) = θ j (t) + 0.2×(ωV j (t) + α·(β1·(P local - θ j (t)) + β2·(P global - θ j (t))))
[0034] where V j (t) is the update speed of individual j at time t, α is the learning rate, β1, β2, ω are dynamically adjusted coefficients, P local is the historical optimal parameter, P global is the global optimal parameter, 0.2 is the update step coefficient, θ j (t) is the current position of individual j, θ j (t + 1) is the updated position of individual j;
[0035] S43. Inject the updated parameter group into the global parameter pool and reset the stagnation counter;
[0036] S5. Output the optimal parameter combination: After reaching the maximum number of iterations, extract the weight matrix and threshold vector with the optimal fitness; load the weight matrix and threshold vector into the neural network to complete model deployment.
[0037] The beneficial effects of the present invention are as follows:
[0038] A method for compensating the error of a thermal conductivity hydrogen sensor based on dynamic cooperative optimization according to the present invention takes the output voltage of the conditioning circuit of the thermal conductivity hydrogen sensor and the temperature and humidity parameters as inputs and the true calibrated concentration as the output, constructs a neural network model based on error backpropagation, and proposes a two-stage cooperative optimization strategy. (1) In the initialization stage, a multi-modal cooperative search strategy is adopted to generate an initial weight matrix with spatial distribution characteristics, and the parameter space is widely covered through swarm intelligence optimization, effectively avoiding the parameter sensitivity and local extreme value traps caused by traditional random initialization; (2) In the iterative optimization stage, parameter update is realized by dynamically switching between global exploration and local search modes: when it is detected that the model convergence stagnates, a weight update mechanism based on swarm velocity guidance is automatically activated, and the search direction is dynamically adjusted using historical gradient information and neighborhood correlation. At the same time, the optimization results are fed back to the global search process through information update to obtain the optimal weight parameters. Finally, the output voltage of the conditioning circuit of the thermal conductivity hydrogen sensor and the temperature and humidity parameters are input into the trained model to obtain the hydrogen concentration value after temperature and humidity compensation.
[0039] Through the complementary capabilities of in-depth exploration and rapid response of the global-local dual-mode cooperative optimization mechanism, the present invention effectively solves the problem of non-linear compensation of temperature and humidity in a complex hydrogen environment, has the characteristics of fast convergence speed and good network performance, can achieve the purpose of accurate detection, and provides an innovative solution for suppressing environmental disturbances and improving the adaptive performance of gas detection equipment. Description of the Drawings
[0040] Figure 1 It is a schematic diagram of the optimization process of a multi-modal neural network with dynamic cooperative optimization of the present invention.
[0041] Figure 2 It is a hierarchical diagram of the BP neural network related to the present invention. Detailed Embodiments
[0042] The following further clarifies the present invention in conjunction with the drawings and specific embodiments. It should be understood that the following specific embodiments are only used to illustrate the present invention and not to limit the scope of the present invention.
[0043] As shown in the figure, a method for compensating the error of a thermal conductivity hydrogen sensor based on dynamic cooperative optimization according to the present invention includes the following steps:
[0044] Step 1: Obtain the environmental parameters of the target area in the current stage and the output voltage of the hydrogen sensor conditioning circuit; the environmental parameters include the temperature value and the humidity value;
[0045] Step 2: Perform data cleaning on the environmental parameters of the target area in the current stage and the output voltage of the hydrogen sensor conditioning circuit, that is, outlier detection and elimination. Perform normalization processing on the retained data, and the formula is expressed as:
[0046]
[0047] where X is the feature parameter data set, x is the original feature value, and x norm is the normalized feature value.
[0048] Then input the processed data into the hydrogen gas concentration detection model to determine the hydrogen gas concentration value of the target area in the current stage.
[0049] Among them, the hydrogen gas concentration detection model is determined according to the dynamically cooperative optimized multi-modal neural network model and the sample training data set; the sample training data set includes input data and label data; the input data includes the sample temperature value, the sample humidity value and the output voltage of the sample hydrogen sensor conditioning circuit; the label data is the sample hydrogen gas concentration value.
[0050] The sample data required in this embodiment is obtained based on a commercial hydrogen sensor under different temperature and humidity conditions with different hydrogen concentrations, including the temperature and humidity values detected by the environmental temperature and humidity sensor and the voltage value output by the signal conditioning circuit of the sensor under this condition.
[0051] The following details the determination process of the hydrogen gas concentration detection model.
[0052] The determination process of the hydrogen gas concentration detection model is as follows:
[0053] Step S1: Collect the gas concentration data of the area to be detected and preprocess the collected data.
[0054] Specifically, obtain the temperature and humidity data detected by the temperature and humidity sensor in the environment and the hydrogen response voltage collected by the hydrogen probe, and perform data preprocessing on the detected data including data cleaning, feature extraction and normalization.
[0055] Step S2: Establish a BP neural network model including an input layer, a hidden layer and an output layer.
[0056] The BP neural network can contain different hidden layers. However, through theory, it can be obtained that there can be one or more hidden layers. Too many hidden layers will make the network structure very complex and the operation efficiency low. In practice, it is found that one hidden layer can achieve good network performance. Finally, the present invention chooses to use one hidden layer to optimize the algorithm.
[0057] The transfer function of the hidden layer designed in the present invention is the S-shaped tangent (tansig) function, which can control the signal within a limited range. In the output layer, the (purelin) function with linear transfer function is used.
[0058] Specifically, the number of nodes in the input layer of the BP neural network model corresponds to the number of sensor information for detecting gas concentration, including the circuit output voltage, ambient temperature, and ambient humidity. The number of nodes in the output layer of the BP neural network model is 1, that is, the compensated concentration value.
[0059] In this embodiment, the multi-modal neural network prediction model with dynamic collaborative optimization has three input parameters: sensor output voltage, temperature, and humidity, and one output parameter is the compensated sensor concentration. Therefore, an input layer with 3 nodes and an output layer with 1 node should be constructed. Then, according to the formula the number of nodes in the hidden layer is obtained (c is the number of nodes in the hidden layer, m is the number of nodes in the input layer, L is the number of nodes in the output layer, and the constant a is generally between 1 and 10). Therefore, the number of nodes in the hidden layer of this network is between 3 and 12.
[0060] In this embodiment, in order to determine the number of nodes in the hidden layer of the sensor temperature and humidity compensation model, taking the data measured by the hydrogen gas sensor as an example, a training sample is constructed for gas concentration in different temperature and humidity environments, and the BP neural network is iteratively trained with different numbers of hidden layer neurons. Taking the mean square error MSE as an index, the optimal number of hidden layers hiddennum_best is determined.
[0061] The BP neural network model is designed as a Figure 2 fully connected neural network as shown. Each connection line represents a weight coefficient. Before training, the weight coefficients of this BP neural network model are all random numbers, and after training, the weight coefficients of this BP neural network model are the optimal weights suitable for temperature and humidity compensation.
[0062] Step S3: Roughly determine the range of the optimal parameter group using the multi-modal collaborative search strategy
[0063] Step S3-1, the parameters are encoded according to certain rules and updated within a specified range at a specified rate;
[0064] Initialization parameter group: Set the maximum boundary range for parameter optimization, and generate an initial population using real number coding rules. Each individual θ = [θ1, θ2…θ n corresponds to the neural network weight matrix.
[0065] Use the mean square error (MSE) as the fitness function to calculate the fitness value of each individual in the parameter group;
[0066] Within the preset parameter update rate constraints [Vmin, Vmax] and parameter value range [Pmin, Pmax], perform dynamic parameter updates:
[0067] Dynamic adjustment rule:
[0068] θ new = θ old + ɑ·(β1·(P local - θ old ) + β2·(P global - θ old ))
[0069] Parameter update formula:
[0070] θ j (t + 1) = θ j (t) + 0.2×Δθ j
[0071] Where, V j (t + 1) is the update speed of individual j at time t + 1, V j (t) is the update speed of individual j at time t, α is the learning rate, β1, β2, ω are dynamic adjustment coefficients, P local is the historical optimal parameter, P global is the global optimal parameter at this time, 0.2 is the update step coefficient, θ j (t) is the current position of individual j, θ j (t + 1) is the position of individual j after update;
[0072] Step S3-2, perform cyclic updates on the parameters until the fitness reaches the convergence accuracy or the required maximum number of iterations.
[0073] Individual optimal update: Each parameter individual θ i records the parameter combination corresponding to its historical optimal fitness In each round of iteration, if the current fitness E(θ i ) is better than the historical record then update the individual optimal parameter
[0074] Global optimal update: The individual parameter combination with the optimal fitness in the entire parameter group is retained, which is called the global extreme value P global . After each iteration, compare the fitness value E(θ i ) of this parameter with the fitness value of the current global optimum If F(θ i ) < F(P global ), then update the global optimal parameter P global = θ i .
[0075] Step S4: Parameter expansion and local optimization based on dynamic collaboration
[0076] Expansion parameter generation: Apply a normal distribution perturbation with a standard deviation of 0.1 to the initial optimization solution set obtained by the multi-modal collaborative search strategy to generate a diverse expansion solution set; use the expansion solution set as the input parameter group for the local optimization stage;
[0077] Local optimization iteration:
[0078] Adopt local optimization operations to save the parameter groups with the top 10% fitness. And cross-exchange the weight values in the retained parameters to generate new parameters so that good parameter characteristics can be retained;. For example, for two parameter individuals θ i and θ j , new individuals θ new1 and θ new2 can be generated by using the two-point crossover method:
[0079] θ new1 = [θ i1 , …, θ il , θ j(l+1) , …, θ jn
[0080] θ new2 = [θ j1 , …, θ jl , θ i(l+1) , …, θ in
[0081] where l is the randomly selected crossover point.
[0082] Apply the diversity perturbation mechanism, add Gaussian noise ∈ with a decreasing variance to the original parameter group θ to balance local search and global exploration and prevent overfitting. The variance σ 2 (t) of the Gaussian noise with a decreasing variance decreases as the number of iterations t increases. For example, the following formula can be used:
[0083]
[0084] θ new = θ + ∈, ∈ ~ N(0, σ 2 (t))
[0085] where is the initial variance, λ is the attenuation coefficient, and t is the number of iterations. In this way, local exploration and global exploration are balanced to prevent overfitting.
[0086] When it is detected that the fitness has not improved for several consecutive generations, the weight update mechanism guided by the population velocity is automatically activated, and the search direction is dynamically adjusted using historical gradient information and neighborhood correlation. For example, the following formula can be used to update the parameters:
[0087] θ new = θ old + γ·V avg
[0088] where γ is the adjustment coefficient and V avg is the population average velocity vector.
[0089] 1. Parameter fusion and iteration: Feed the optimized parameter group back to the global parameter pool; reset the stagnation counter and continue to perform global-local iterative optimization until the best fitness and the maximum number of iterations are reached as the end conditions;
[0090] Step S5: Neural network deployment and verification.
[0091] Introduce the globally best solution obtained by dynamic collaborative optimization into the BP neural network to obtain the corresponding initial weights and thresholds. On this basis, continuously train the BP neural network until the end state is reached to obtain the weights of the neural network. After inputting the environmental parameters and voltage values into the network, the hydrogen detection output value after temperature and humidity compensation can be obtained.
[0092] It should be noted that the above content only illustrates the technical idea of the present invention and cannot be used to limit the protection scope of the present invention. For those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and refinements can be made, and these improvements and refinements all fall within the protection scope of the claims of the present invention.
Claims
1. Error compensation method for thermal conductivity hydrogen sensor based on dynamic collaborative optimization, characterized in that: It includes the following steps: (1) Collect the real-time environmental parameters of the target area and the output voltage of the sensor conditioning circuit, where the environmental parameters include the measured values of temperature and humidity; (2) Input the environmental parameters and the output voltage into the preprocessed hydrogen concentration detection model, and output the hydrogen concentration value after temperature and humidity compensation; The hydrogen concentration detection model is constructed through the following steps: (21) Establish a BP neural network model including an input layer, a hidden layer, and an output layer, where the hidden layer uses a non-linear activation function and the output layer uses a linear activation function; (22) Its training data set includes input data and label data; the input data includes sample temperature values, sample humidity values, and the output voltage of the sample hydrogen sensor conditioning circuit; the label data is the sample hydrogen gas concentration value; (23) Use a multi-modal method of dynamic collaborative optimization to optimize the weights and thresholds of the BP neural network to obtain an optimized neural network model; use the optimized neural network model to train the sample data set to obtain a hydrogen concentration detection model.
2. The error compensation method for a thermal conductivity hydrogen sensor based on dynamic collaborative optimization according to claim 1, wherein: The preprocessing of the model input data in step (2) includes: Perform outlier detection and elimination on the temperature value, humidity value, and output voltage; perform normalization processing on the retained data, and the formula is expressed as: Where X is the feature parameter dataset, x is the original feature value, x norm is the normalized eigenvalue.
3. The error compensation method for a thermal conductivity hydrogen sensor based on dynamic collaborative optimization according to claim 1, wherein: The network structure of the BP neural network model described in step (23) is determined by the following method: An empirical formula is used to determine the initial range of the number of hidden layer nodes: where c is the number of hidden layer nodes, m is the number of input layer nodes, L is the number of output layer nodes, and the constant a ranges from 1 to 10; Traverse and test within the initial range, and select the number of hidden layer nodes with the smallest training error as the final structure.
4. The error compensation method for a thermal conductivity hydrogen sensor based on dynamic collaborative optimization according to claim 1, wherein: The dynamic collaborative optimization process described in step (23) includes: S1. Initialize the collaborative optimization parameters, including the population size, dynamic learning coefficient, and parameter update rate constraint; S2. Calculate the population fitness value, and the fitness function uses the mean square error between the predicted value and the true value: Where: y i is the i-th predicted value; x i is the i-th true value; n is the number of predicted samples; S3. Initialization stage: Use a multi-modal collaborative search strategy to generate an initial parameter matrix with spatial distribution characteristics, and widely cover the parameter space through swarm intelligence optimization to effectively avoid the parameter sensitivity and local extreme value trap caused by traditional random initialization; S4. Global-local collaborative update stage: S5. Output the optimal parameter combination: After reaching the maximum number of iterations, extract the weight matrix and threshold vector with the best fitness; load the weight matrix and threshold vector into the neural network to complete model deployment.
5. The error compensation method for a thermal conductivity hydrogen sensor based on dynamic collaborative optimization according to claim 3, characterized in that: The generation method of the initial weight matrix in step S3 includes S31. Generate the first optimization solution set through multi-modal collaborative search; S32. Apply a normal distribution perturbation with a standard deviation of 0.1 to the solution set to generate an extended parameter subset; S33. Merge the initial solution set and the extended subset to construct a mixed initial parameter matrix.
6. The error compensation method of the thermal conductivity hydrogen sensor based on dynamic collaborative optimization according to claim 4, wherein: Step S4 is specifically as follows: S41. Starting from the mixed initial parameter matrix, perform a global optimization operation to update the parameter distribution: where the global optimization operation includes: Elite retention strategy: Retain the top 10% of the parameter groups with the best fitness; Parameter recombination: Cross-fuse the retained parameters so that good parameter characteristics can be retained; Diversity perturbation: Apply Gaussian noise with a decreasing variance to the recombined parameters to increase interference and prevent overfitting; S42. Dynamic mode switching stage: If the global optimal fitness has not improved for 5 consecutive generations, activate the dynamic neighborhood search mechanism: Update the parameter direction through the historical gradient correlation rule: θ j θ(t + 1) = j θ(t)+0.2×(ωV j (t)+α·(β1·(P local -θ j (t))+β2·(P global -θ j (t)))) where V j (t) is the update speed of individual j at time t, α is the learning rate, β1, β2, ω are dynamic adjustment coefficients, P local is the historical optimal parameter, P global is the global optimal parameter, 0.2 is the update step coefficient, θ j (t) is the current position of individual j, θ j (t + 1) is the position of individual j after update; S43. Inject the updated parameter group into the global parameter pool and reset the stagnation counter.
Citation Information
Patent Citations
Optimized control method for hydrogen fuel cell
CN119275316A
Method and systems for determining a measurement error in a hydrogen concentration measurement
EP4160205A1
Cited By
Linear closed-loop optimization method for semiconductor gas sensor with adjustable voltage dynamic compensation
CN120948563A