An infrared gas sensor online upgrade system and method
By designing an online upgrade system for infrared gas sensors and using Bayesian inference and deep learning algorithms, statistical analysis and model training of gas concentration data are realized, which solves the problem of sensor recognition accuracy declining when the environment changes, and improves adaptability and Flexibility, and the online upgrade module reduces upgrade costs and improves the intelligence level of the sensor.
Patent Information
- Application Number
- CN202410524319.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-29
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2044-04-29
AI Technical Summary
Existing infrared gas sensors cannot adaptively adjust their working parameters and recognition algorithms when environmental conditions change, resulting in reduced recognition accuracy and reliability. They lack effective anomaly detection and data preprocessing mechanisms, and the upgrade process is time-consuming and costly.
Design an online upgrade system for infrared gas sensors, including a data acquisition and processing module, a scene matching module, a priority extraction module and a gas identification model generation module. It uses Bayesian inference and deep learning algorithms to implement statistical analysis and models of gas concentration data. training, perform online upgrades, and introduce anomaly detection models to improve data quality.
It improves the adaptability and flexibility of the infrared gas sensor, enhances the accuracy and reliability of gas identification, realizes remote automatic upgrade of the sensor, shortens the upgrade cycle and reduces the cost, and improves the intelligence level and application capabilities of the sensor. .
Smart Images

Figure CN118098443B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of sensor optimization technology, and more specifically, to an infrared gas sensor online upgrade system and method. Background Art
[0002] The patent with application publication number CN117234566A discloses a sensor hot upgrade method, device, system, electronic device and storage medium, including: sending a first program to at least one partition controller, the partition controller is connected to at least one sensor, and the first program is an upgrade program for the sensor; synchronously controlling at least one partition controller to upgrade at least one connected sensor one by one based on the first program. The sensor hot upgrade method, device, system, electronic device and storage medium send a first program for upgrading the sensor to at least one partition controller, and synchronously control the at least one partition controller to upgrade the sensors connected to each one one by one, without shutting down or isolating the sensor, and can realize online hot upgrade, which is relatively simple to operate; at the same time, because each partition controller synchronously upgrades the sensors connected to each one one by one, the upgrade efficiency is relatively high, which can meet the needs of large-scale rapid batch upgrades of sensors.
[0003] However, when existing infrared gas sensors are exposed to different environmental conditions, such as changes in temperature, humidity, and background gas composition, the existing infrared gas sensors cannot adaptively adjust their operating parameters and recognition algorithms, resulting in decreased recognition accuracy and reliability; the generalization ability is limited, making it difficult to adapt to changing gas recognition tasks; in actual environments, gas concentration data may be affected by factors such as sensor failure and electrical interference, resulting in outliers or noise; existing infrared gas sensors lack effective anomaly detection and data preprocessing mechanisms, resulting in decreased recognition accuracy and reliability; when existing infrared gas sensors need to be upgraded and maintained, technicians are usually required to perform manual operations on site, and the upgrade process is time-consuming and costly, affecting the maintainability and practical application of the sensor.
[0004] In view of this, the present invention proposes an infrared gas sensor online upgrade system and method to solve the above problems. Summary of the invention
[0005] In order to overcome the above defects of the prior art and to achieve the above purpose, the present invention provides the following technical solutions: an online upgrade system for infrared gas sensors, comprising: a data acquisition and processing module, for collecting gas concentration data detected by the infrared gas sensor; and performing statistical analysis on the gas concentration data to obtain concentration distribution functions of n kinds of gases;
[0006] A scene matching module is used to obtain m environmental scene probabilities based on the concentration distribution function of n gases using the Bayesian inference method;
[0007] A priority extraction module is used to extract the probability of the environment scene with the largest probability among the m environment scenes, and take the environment scene corresponding to the largest environment scene probability as a priority upgrade object;
[0008] The gas identification model generation module is used to obtain the gas identification model through deep learning algorithm training for the priority upgrade objects;
[0009] The online upgrade module is used to send the gas identification model to the infrared gas sensor chip and upgrade the infrared gas sensor online; each module is connected by wired and / or wireless means to realize data transmission between modules.
[0010] Furthermore, the method for acquiring the gas concentration data includes:
[0011] An infrared gas sensor chip is used to detect n types of gases in the environment and their corresponding concentrations. The n types of gases and their corresponding concentrations are raw gas concentration data. The raw gas concentration data is preprocessed to obtain gas concentration data.
[0012] Furthermore, the preprocessing method includes:
[0013] Input the original gas concentration data into the pre-built gas identification model to label the gas types;
[0014] The original gas concentration data with marked gas types are grouped according to gas types; each group of data includes a gas and the corresponding concentration value; that is, n groups of preliminary gas data are obtained;
[0015] For each set of preliminary gas data, an anomaly detection model is constructed; the anomaly detection model is used to detect and remove outliers in the preliminary gas data; and gas concentration data is obtained.
[0016] Furthermore, the gas identification model is constructed in the following manner:
[0017] Collect h groups of labeled samples as a data set, where each sample contains the concentration values of n gases and the corresponding gas type labels;
[0018] Define the basic network structure of the gas recognition model, which includes input layer, embedding layer, gas correlation modeling layer, local feature extraction layer, global feature capture layer, feature fusion layer and output layer;
[0019] The input layer takes the concentration values of n gases as input and encodes them into an n-dimensional concentration vector; the embedding layer maps the concentration value of each gas to a high-dimensional semantic space to obtain an embedding vector; then The embedding vector of the gas is ; Index for gas;
[0020] Gas correlation modeling layer For any two gases and , calculate the interaction tensor of their embedding vectors ;in is the tensor outer product operator, Indicates gas and The interaction tensor between the concentration values; all the resulting interaction tensors Splice them together to form a high-order tensor ;
[0021] The local feature extraction layer uses a 1D convolutional layer to extract local features of the embedded gas concentration sequence, capture the interaction pattern of different gas concentration values locally, and obtain the local feature tensor ;
[0022] The global feature capture layer converts the local feature tensor and the gas concentration correlation tensor Perform splicing to construct fusion feature tensor ;in, is the tensor concatenation operator;
[0023] exist Use the self-attention mechanism to learn the global gas concentration pattern and obtain the global feature tensor ;
[0024] The feature fusion layer transforms the local feature tensor and the global feature tensor Fusion is performed to obtain the fusion feature vector ;
[0025] The output layer is based on the fused feature vector , use the fully connected layer and softmax function to classify and predict the output of gas types;
[0026] Divide the data set into a training set and a validation set; normalize the concentration values so that they fall within the range of 0-1; initialize the parameters of each layer of the gas recognition model and set the initial learning rate;
[0027] Define the training loss function of the gas recognition model; sample a batch of data from the training set in turn; input the data into the gas recognition model, and calculate the function value of the training loss function between the output of the gas recognition model and the actual gas type label;
[0028] The back propagation algorithm is used to calculate the gradient of the parameters of each layer, and the Adam optimizer is used to update the parameters of the gas recognition model according to the gradient;
[0029] The performance of the gas recognition model is evaluated on the validation set, and the parameters of the gas recognition model with the best performance are saved, thus completing the construction of the gas recognition model.
[0030] Furthermore, the construction method of the anomaly detection model includes:
[0031] Defining an infrastructure of an anomaly detection model, the infrastructure comprising a feature extraction layer, a feature aggregation layer, an isolation tree generation layer, a threshold layer, and an outlier removal layer;
[0032] The feature extraction layer first performs automatic feature extraction on the preliminary concentration data of each gas through a 1D convolutional layer to obtain the high-order feature vector of each gas concentration data;
[0033] The feature aggregation layer concatenates the high-order feature vectors of all gases to form a joint vector of anomaly scores;
[0034] The isolation tree generation layer is used to generate the isolation forest; the isolation forest is used to divide the anomaly score joint vector into outliers;
[0035] For each preliminary gas data , get its anomaly score joint vector , starting from the root node along each isolation tree, it is routed to a leaf node according to the size relationship of the eigenvalues;
[0036] statistics The number of nodes passed by is recorded as the path length ; Through predefined functions The path length Convert to anomaly score ,in, is the total number of nodes in the isolation tree;
[0037] Predefined functions ;in, yes The expected path length on a given isolation tree;
[0038] The anomaly scores calculated for all isolation trees are averaged to form the isolation forest pair The final anomaly score of
[0039] The threshold layer introduces the Gaussian mixture model method to fit the probability density distribution of the joint vector of anomaly scores;
[0040] Integrate the probability density distribution to the threshold corresponding to the set confidence level as the discrimination threshold for the current anomaly detection;
[0041] The outlier removal layer marks the corresponding data points whose final anomaly scores are greater than or equal to the discrimination threshold as outliers; for the preliminary concentration data of each gas, those data points marked as outliers are removed to obtain the gas concentration data of the gas.
[0042] Furthermore, the generation method of the isolation forest includes:
[0043] Step 1: Collect f groups of preliminary gas data from the historical process, and manually remove abnormal values from the preliminary gas data to form normal data samples; initialize the root node of each isolation tree in the isolation forest, and the root node contains all normal data samples;
[0044] Step 2: For the non-leaf nodes of the current isolation tree, randomly select a feature dimension q, which is a dimension in the joint vector of anomaly scores;
[0045] Step 3: For the selected feature dimension q, randomly sample a split point p from the value distribution of the feature dimension; use the split point p to divide the normal data sample of the current node into two parts according to the size of the feature value; the feature value is the value corresponding to each component in the anomaly score joint vector;
[0046] Step 4: divide the normal data samples of the current node into a left child node and a right child node according to the split point, the left child node contains normal data samples whose value of feature dimension q is less than the split point p; the right child node contains normal data samples whose value of feature dimension q is greater than or equal to the split point p;
[0047] Step 5: For the newly generated left child node and right child node, repeat steps 2-4 and continue to recursively split the child nodes until all normal data samples in the child nodes have exactly the same values in all feature dimensions;
[0048] Repeat steps 2-5 until a complete isolation tree is constructed; then repeat steps 1-6 to generate an isolation forest consisting of t isolation trees.
[0049] Furthermore, the method of statistically analyzing the gas concentration data includes:
[0050] The n groups of gas concentration data are fitted with the kernel density estimation method respectively; the unbiased probability density function estimation value of the gas concentration distribution corresponding to the n groups of gas concentration data is obtained;
[0051] The method of using the kernel density estimation method to perform data distribution fitting includes:
[0052] For the data points in the gas concentration data, the kernel density estimate corresponding to the data point is calculated according to the predefined kernel function and the optimal bandwidth;
[0053] The kernel function is defined as: ;in, Represents the distance between data points;
[0054] The calculation formula for calculating the kernel density estimate corresponding to the data point is:
[0055] ; In the formula, For data points The kernel density estimate of ; is the total number of data points; is the optimal bandwidth; is the index of the second data point; is the index of the first data point;
[0056] Divide the data points into B subsets, calculate the kernel density estimation value of each subset in parallel on different processors or computing nodes, and finally merge the results; assign the calculation task of kernel density estimation to C threads of GPU to speed up the calculation process;
[0057] The kernel density estimates of all data points are normalized to obtain an unbiased probability density function estimate of the gas concentration distribution;
[0058] The normalization formula is:
[0059] ;in, is the normalized unbiased probability density function estimate;
[0060] The concentration distribution function is obtained by estimating the unbiased probability density function of the gas concentration distribution using a log-normal distribution method to obtain a parameterized distribution model, and the parameterized distribution model is the concentration distribution function.
[0061] Furthermore, the m environmental scene probabilities are obtained in the following manner:
[0062] Step 1: Establish a scene library containing M kinds of environmental scenes; and the value of M is greater than the value of m; for each environmental scene, predefine the concentration distribution function of the gas contained therein, that is, the scene feature distribution function;
[0063] Step 2: Calculate the similarity of the concentration distribution functions of n gases using KL divergence;
[0064] The calculation formula for calculating the similarity using KL divergence is: ;in, For the Gases in environmental scenarios The similarity under For the The concentration distribution function of the gas; is the concentration value; For environmental scenes The concentration distribution function of Indicates the integral number;
[0065] Step 3: Use the Bayesian inference method to calculate the posterior probability of each environmental scenario; given the concentration distribution function of n gases, the environmental scenario is obtained The posterior probability ;
[0066] but ;in, For the environmental scene The likelihood probability of observing the concentration distribution function of n gases under the following conditions; For environmental scenes The prior probability of is the marginal probability of the concentration distribution function of n gases;
[0067] The concentration distribution functions of various gases are conditionally independent under a given environmental scenario;
[0068] Then the likelihood probability ;in, is the multiplication sign, is the base of the exponential function;
[0069] Step 4: Sort the acquired posterior probabilities in descending order, and select the posterior probabilities corresponding to the first m environmental scenes as the m environmental scene probabilities.
[0070] Furthermore, the gas identification model is obtained by:
[0071] Collect infrared gas sensor data in environmental scenes corresponding to priority upgrade objects at fixed historical time periods, wherein the infrared gas sensor data includes gas types and concentration values corresponding to the gas types; numerically encode the gas types; perform training preprocessing on the infrared gas sensor data to obtain gas concentration time series data;
[0072] The framework structure of the gas recognition model is defined to adopt the basic network structure of the gated recurrent unit model, which includes a gas output layer, a first gas GRU layer, a second gas GRU layer, a gas attention layer, a gas pooling layer, a feature fully connected layer, and a gated output layer;
[0073] Take the data in the gas concentration time series data as samples; define the comprehensive loss function of the gas identification model ;in, is the cross entropy loss function; is the balance factor; is the concentration estimation loss function;
[0074] Cross Entropy Loss Function ; In the formula, is the total number of data in the gas concentration time series data; is the sample index; Index for gas types; is the total number of gas types; For the The samples belong to The real label of the gas type; The gas identification model predicts The samples belong to Probability of gas species;
[0075] Concentration Estimation Loss Function ; In the formula, For the In the sample The actual concentration value of the gas type; The gas identification model predicts In the sample The concentration value of the gas type;
[0076] Initialize the parameters of the gas identification model and set the initial learning rate of the gas identification model;
[0077] The gas identification model is trained using gas concentration time series data, and the parameters of the gas identification model are optimized using the back propagation algorithm and the Adam optimizer.
[0078] During the training process, when the function value of the comprehensive loss function reaches the preset loss threshold, the training is stopped and the gas recognition model at this time is saved, and the construction of the gas recognition model is completed.
[0079] Furthermore, the training preprocessing method includes:
[0080] Analyze the distribution of infrared gas sensor data and identify abnormal values that are significantly deviated from the normal range; set a corresponding abnormal value threshold for each gas type, and mark the concentration value of the corresponding gas type that is greater than the abnormal value threshold as an abnormal value;
[0081] For outliers, directly remove them from the infrared gas sensor data or replace them with the average or median of adjacent data points;
[0082] Perform sliding window averaging on the retained infrared gas sensor data, and replace each concentration value of the corresponding gas type with the average value of a fixed number of concentration values around it to obtain the averaged data;
[0083] Randomly translate the substitution data to obtain translation data;
[0084] Normalize the translation data; directly use the encoded gas types; use the normalized translation data and the corresponding encoded gas types as model training data; sort and encode the model training data according to the collected time sequence to obtain gas concentration time series data;
[0085] The input data of the gas input layer is gas concentration time series data, and the input data is divided according to the time step to form a three-dimensional tensor;
[0086] Define the input dimension and output dimension of the first gas GRU layer and the second gas GRU layer; used to output the gas hidden state;
[0087] The gas attention layer takes the hidden state as the query, key, and value; it generates attention weights by calculating the similarity between the query and the key, and applies them to the value to get the weighted sum result;
[0088] The gas pooling layer is used to perform a pooling operation on the weighted sum of the outputs of the gas attention layer. The pooling operation is maximum pooling or average pooling, which compresses the features in the time dimension into a vector of a fixed length, which is the overall feature.
[0089] The overall features output by the gas pooling layer are passed through one or T feature fully connected layers to perform feature transformation and dimension adjustment to obtain fully connected features;
[0090] The gated output layer uses the Softmax activation function to convert the fully connected features output by the fully connected layer into the probability distribution of gas types and their corresponding concentration values.
[0091] The technical effects and advantages of the infrared gas sensor online upgrade system and method of the present invention are as follows:
[0092] The present invention improves the adaptability and flexibility of the infrared gas sensor, and can automatically adjust and optimize according to changes in environmental scenes; adopts a deep learning algorithm to construct a gas recognition model, improves the generalization ability and robustness of the model, and can adapt to gas recognition tasks in different environments; introduces anomaly detection models and data preprocessing technology, effectively improves the quality and reliability of gas concentration data, and improves the accuracy of gas recognition; realizes simultaneous recognition of gas types and concentrations, and provides more comprehensive and accurate gas recognition results; realizes remote automatic upgrade of the sensor through an online upgrade module, shortens the upgrade cycle, reduces the upgrade cost, and improves the maintainability of the sensor; comprehensively improves the intelligence level and practical application ability of the infrared gas sensor; can not only automatically adjust and optimize according to environmental changes to achieve the adaptability and flexibility of the sensor, but also provide high-precision, high-reliability, and comprehensive gas recognition results. BRIEF DESCRIPTION OF THE DRAWINGS
[0093] Figure 1 A schematic diagram of an online upgrade system for an infrared gas sensor of the present invention;
[0094] Figure 2 A schematic diagram of an online upgrade method for an infrared gas sensor of the present invention;
[0095] Figure 3 It is a schematic diagram of an electronic device of the present invention. DETAILED DESCRIPTION
[0096] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0097] Example 1
[0098] See also Figure 1 As shown, the infrared gas sensor online upgrade system described in this embodiment includes: a data acquisition and processing module, which is used to obtain gas concentration data detected by the infrared gas sensor; and to perform statistical analysis on the gas concentration data to obtain concentration distribution functions of n types of gases;
[0099] A scene matching module is used to obtain m environmental scene probabilities based on the concentration distribution function of n gases using the Bayesian inference method;
[0100] A priority extraction module is used to extract the probability of the environment scene with the largest probability among the m environment scenes, and take the environment scene corresponding to the largest environment scene probability as a priority upgrade object;
[0101] The gas identification model generation module is used to obtain the gas identification model through deep learning algorithm training for the priority upgrade objects;
[0102] The online upgrade module is used to send the gas identification model to the infrared gas sensor chip and upgrade the infrared gas sensor online; each module is connected by wired and / or wireless means to realize data transmission between modules.
[0103] Furthermore, the method for acquiring the gas concentration data includes:
[0104] The infrared gas sensor chip is used to detect n types of gases in the environment and their corresponding concentrations. The n types of gases and their corresponding concentrations are the original gas concentration data.
[0105] Preprocessing the original gas concentration data to obtain gas concentration data;
[0106] The pre-processing method includes:
[0107] Input the original gas concentration data into the pre-built gas identification model to label the gas types;
[0108] The gas identification model is constructed in the following manner:
[0109] Collect h groups of labeled samples as a data set, where each sample contains the concentration values of n gases and the corresponding gas type labels;
[0110] Define the basic network structure of the gas recognition model, which includes input layer, embedding layer, gas correlation modeling layer, local feature extraction layer, global feature capture layer, feature fusion layer and output layer;
[0111] The input layer takes the concentration values of n gases as input and encodes them into an n-dimensional concentration vector; the embedding layer maps the concentration value of each gas to a high-dimensional semantic space to obtain an embedding vector; then The embedding vector of the gas is ; is the gas index, and its value range is [1, n];
[0112] Gas correlation modeling layer For any two gases and , calculate the interaction tensor of their embedding vectors ;in is the tensor outer product operator, Indicates gas and The interaction tensor between the concentration values; all the resulting interaction tensors Splice them together to form a high-order tensor ;
[0113] The local feature extraction layer uses a 1D convolutional layer to extract local features of the embedded gas concentration sequence, capture the interaction pattern of different gas concentration values locally, and obtain the local feature tensor ;
[0114] The global feature capture layer converts the local feature tensor and the gas concentration correlation tensor Perform splicing to construct fusion feature tensor ;in, is the tensor concatenation operator;
[0115] exist The self-attention mechanism is used to capture the long-range dependencies between different gas concentration features, learn the global gas concentration pattern, and obtain the global feature tensor ;
[0116] The feature fusion layer transforms the local feature tensor and the global feature tensor Fusion is performed to obtain the fusion feature vector ;
[0117] The output layer is based on the fused feature vector , use the fully connected layer and softmax function to classify and predict the output of gas types;
[0118] Divide the data set into a training set and a validation set. The specific division ratio can be determined according to the actual situation, for example, 80% training set and 20% validation set.
[0119] Normalize the concentration value to fall within the range of 0-1; initialize the parameters of each layer of the gas recognition model and set the initial learning rate;
[0120] The loss function of the gas recognition model is defined as a cross entropy loss function; a batch of data is sampled from the training set in turn; the data is input into the gas recognition model, and the function value of the cross entropy loss function between the output of the gas recognition model and the actual gas type label is calculated;
[0121] The back propagation algorithm is used to calculate the gradient of the parameters of each layer, and the Adam optimizer is used to update the parameters of the gas recognition model according to the gradient;
[0122] Evaluate the performance of the gas recognition model on the validation set, save the parameters of the gas recognition model with the best performance, and complete the construction of the gas recognition model. In this way, automatic labeling can be achieved by building a gas recognition model based on deep learning.
[0123] The original gas concentration data with marked gas types are grouped according to gas types; each group of data includes a gas and the corresponding concentration value; that is, n groups of preliminary gas data are obtained;
[0124] For each set of preliminary gas data, an anomaly detection model is constructed; the anomaly detection model is used to detect and remove outliers in the preliminary gas data; and gas concentration data is obtained;
[0125] The construction method of the anomaly detection model includes:
[0126] Defining an infrastructure of an anomaly detection model, the infrastructure comprising a feature extraction layer, a feature aggregation layer, an isolation tree generation layer, a threshold layer, and an outlier removal layer;
[0127] The feature extraction layer first performs automatic feature extraction on the preliminary concentration data of each gas through a 1D convolutional layer to obtain the high-order feature vector of each gas concentration data;
[0128] The feature aggregation layer concatenates the high-order feature vectors of all gases to form a joint vector of anomaly scores;
[0129] The isolation tree generation layer is used to generate the isolation forest; the isolation forest is used to divide the anomaly score joint vector into outliers;
[0130] The generation method of the isolation forest includes:
[0131] Step 1: Collect f groups of preliminary gas data from the historical process, and manually remove abnormal values from the preliminary gas data to form normal data samples; initialize the root node of each isolation tree in the isolation forest, and the root node contains all normal data samples;
[0132] Step 2: For the non-leaf nodes of the current isolation tree, randomly select a feature dimension q, which is a dimension in the joint vector of anomaly scores;
[0133] Step 3: For the selected feature dimension q, randomly sample a split point p from the value distribution of the feature dimension; use the split point p to divide the normal data sample of the current node into two parts according to the size of the feature value; the feature value is the value corresponding to each component in the anomaly score joint vector;
[0134] Step 4: divide the normal data samples of the current node into a left child node and a right child node according to the split point, the left child node contains normal data samples whose value of feature dimension q is less than the split point p; the right child node contains normal data samples whose value of feature dimension q is greater than or equal to the split point p;
[0135] Step 5: For the newly generated left child node and right child node, repeat steps 2-4 and continue to recursively split the child nodes until all normal data samples in the child nodes have exactly the same values in all feature dimensions;
[0136] Repeat steps 2-5 until a complete isolation tree is constructed; then repeat steps 1-6 to generate an isolation forest consisting of t isolation trees;
[0137] For each preliminary gas data , get its anomaly score joint vector , starting from the root node along each isolation tree, it is routed to a leaf node according to the size relationship of the eigenvalues;
[0138] statistics The number of nodes passed by is recorded as the path length ; Through predefined functions The path length Convert to anomaly score ,in, is the total number of nodes in the isolation tree;
[0139] Predefined functions ;in, yes The expected path length on a given isolation tree;
[0140] The anomaly scores calculated for all isolation trees are averaged to form the isolation forest pair The final anomaly score of
[0141] Since gas concentration data may drift, we cannot pre-set a global threshold. Therefore, an adaptive mechanism is needed to dynamically adjust the anomaly threshold. The threshold layer introduces an adaptive threshold model based on probability density, and uses the Gaussian mixture model method to fit the probability density distribution of the anomaly score joint vector.
[0142] Integrate the probability density distribution to the threshold corresponding to the set confidence level as the discrimination threshold for the current anomaly detection; the confidence level can be determined according to the actual situation, for example, 99%;
[0143] The outlier removal layer marks the corresponding data points whose final anomaly scores are greater than or equal to the discrimination threshold as outliers; for the preliminary concentration data of each gas, those data points marked as outliers are removed to obtain the gas concentration data of the gas;
[0144] It should be noted that the process of fitting the probability density distribution of the anomaly score joint vector by the Gaussian mixture model method can be understood as preparing the anomaly score joint vector as the input data of the Gaussian mixture model; determining the number of components of the Gaussian mixture model, and using the model selection criteria or prior knowledge to select the appropriate number of components; initializing the parameters of the Gaussian mixture model, including the mean, covariance matrix and mixing coefficient of each component; these parameters can be initialized using a clustering algorithm or a random initialization method; estimating the parameters of the Gaussian mixture model using the expectation maximization algorithm, specifically, calculating the posterior probability that each sample belongs to each Gaussian distribution component based on the current model parameters; updating the parameters of the Gaussian mixture model based on the calculated posterior probability, including the mixing coefficient, mean and covariance matrix; repeating the above steps until the model parameters converge or the maximum number of iterations is reached; after the fitting is completed, a Gaussian mixture model is obtained, which can represent the probability density distribution of the anomaly score joint vector.
[0145] Furthermore, the method of statistically analyzing the gas concentration data includes:
[0146] The n groups of gas concentration data are fitted with the kernel density estimation method respectively; the unbiased probability density function estimation value of the gas concentration distribution corresponding to the n groups of gas concentration data is obtained;
[0147] The method of using the kernel density estimation method to perform data distribution fitting includes:
[0148] For the data points in the gas concentration data, the kernel density estimate corresponding to the data point is calculated according to the predefined kernel function and the optimal bandwidth;
[0149] The kernel function is defined as: ;in, Represents the distance between data points; this kernel function When , it has non-zero values, and its shape is like a bell curve with a width of 2 and a height of 3 / 4;
[0150] The calculation formula for calculating the kernel density estimate corresponding to the data point is:
[0151] ; In the formula, For data points The kernel density estimate of ; is the total number of data points; is the optimal bandwidth; is the index of the second data point; is the index of the first data point; both are data indexes, but they are not the same at the same time, that is, they index the same data point;
[0152] Divide the data points into B subsets, calculate the kernel density estimation value of each subset in parallel on different processors or computing nodes, and finally merge the results; use the large-scale parallel computing capability of the GPU to assign the calculation task of the kernel density estimation to the C threads of the GPU to speed up the calculation process;
[0153] Normalizing the kernel density estimates of all data points to obtain an unbiased probability density function estimate of the gas concentration distribution; the purpose of the normalization is to ensure that the estimated probability density function satisfies the properties of the probability density function, that is, it is non-negative and its integral is 1;
[0154] The normalization formula is:
[0155] ;in, is the normalized unbiased probability density function estimate;
[0156] The concentration distribution function is obtained by estimating the unbiased probability density function of the gas concentration distribution using a log-normal distribution method to obtain a parameterized distribution model, which is the concentration distribution function.
[0157] It should be noted that the lognormal distribution method assumes that the logarithm of the gas concentration obeys the normal distribution. The gas concentration data is logarithmically transformed, and then the parameters of the normal distribution (mean and standard deviation) are estimated using the maximum likelihood estimation method. The estimated parameters are substituted into the probability density function of the lognormal distribution to obtain a parameterized concentration distribution model, namely the concentration distribution function.
[0158] Furthermore, the m environmental scene probabilities are obtained by:
[0159] Step 1: Establish a scene library containing M kinds of environmental scenes, for example, the environmental scenes include kitchen, bedroom, living room, bathroom, etc.; and the value of M is greater than the value of m; for each environmental scene, pre-define the concentration distribution function of the gas contained therein, that is, the scene feature distribution function;
[0160] Step 2: Calculate the similarity of the concentration distribution functions of n gases using KL divergence. KL divergence is used to measure the similarity between the observed gas concentration distribution function and the scene feature distribution function.
[0161] The calculation formula for calculating the similarity using KL divergence is: ;in, For the Gases in environmental scenarios The similarity under For the The concentration distribution function of the gas; is the concentration value; For environmental scenes The concentration distribution function of Indicates the integral sign; the smaller the KL divergence, the more similar the two distribution functions are;
[0162] Step 3: Use the Bayesian inference method to calculate the posterior probability of each environmental scenario; given the concentration distribution function of n gases, the environmental scenario is obtained The posterior probability ;
[0163] but ;in, For the environmental scene The likelihood probability of observing the concentration distribution function of n gases under the following conditions; For environmental scenes The prior probability of is the marginal probability of the concentration distribution function of n gases;
[0164] The concentration distribution functions of various gases are conditionally independent under a given environmental scenario;
[0165] Then the likelihood probability ;in, is the multiplication sign, is the base of the exponential function;
[0166] Step 4: sort the acquired posterior probabilities in descending order, and select the posterior probabilities corresponding to the first m environmental scenes as the m environmental scene probabilities;
[0167] In order to better identify and calculate, a scene division threshold is preset. When the maximum posterior probability is less than or equal to the scene division threshold, the current environment does not belong to any scene in the scene library; then the environmental scenes in the scene library are further supplemented.
[0168] Furthermore, the gas identification model is obtained by:
[0169] Collect infrared gas sensor data in environmental scenes corresponding to priority upgrade objects at fixed historical time periods, wherein the infrared gas sensor data includes gas types and concentration values corresponding to the gas types; and numerically encode the gas types;
[0170] The infrared gas sensor data is subjected to training preprocessing; the training preprocessing method includes:
[0171] Analyze the distribution of infrared gas sensor data and identify abnormal values that are significantly deviated from the normal range; the abnormal values may be caused by sensor failure, environmental interference, etc.
[0172] For each gas type, a corresponding abnormal value threshold is set, and the concentration value of the corresponding gas type greater than the abnormal value threshold is marked as an abnormal value; the abnormal value threshold can be determined according to the statistical characteristics (such as mean, standard deviation) of the infrared gas sensor data or domain knowledge;
[0173] For outliers, directly remove them from the infrared gas sensor data to ensure the quality of the training data or replace them with the average or median of adjacent data points;
[0174] Perform sliding window averaging on the retained infrared gas sensor data, and replace each concentration value of the corresponding gas type with the average value of a fixed number of concentration values around it to obtain the averaged data;
[0175] The translation data is randomly translated to simulate a small change in the position of the infrared gas sensor; the translation data is obtained; the amount of the translation is randomly selected within a certain range, for example, between -5 and 5 units;
[0176] Normalize the translation data and map the concentration value to [0-1]; use the encoded gas types directly; use the normalized translation data and the corresponding encoded gas types as model training data; sort and encode the model training data according to the collection time sequence to obtain gas concentration time series data.
[0177] The framework structure of the gas recognition model is defined to adopt the basic network structure of the gated recurrent unit model, which includes a gas output layer, a first gas GRU layer, a second gas GRU layer, a gas attention layer, a gas pooling layer, a feature fully connected layer, and a gated output layer;
[0178] The input data of the gas input layer is gas concentration time series data, and the input data is divided according to the time step to form a three-dimensional tensor;
[0179] Define the input dimension and output dimension of the first gas GRU layer and the second gas GRU layer; used to output the gas hidden state; this process can increase or decrease the number of gas GRU layers and the output dimension of each layer according to the amount of data;
[0180] The gas attention layer takes the hidden state as the query, key, and value; it generates attention weights by calculating the similarity between the query and the key, and applies them to the value to get the weighted sum result;
[0181] The gas pooling layer is used to perform a pooling operation on the weighted summation results output by the gas attention layer to extract the overall features of the entire gas concentration time series data; using maximum pooling or average pooling, the features in the time dimension are compressed into a vector of a fixed length, which is the overall feature;
[0182] The overall features output by the gas pooling layer are passed through one or T feature fully connected layers to perform feature transformation and dimension adjustment; a fully connected feature is obtained; the output dimension of the fully connected layer is set according to the number of gas types;
[0183] The gated output layer uses the Softmax activation function to convert the fully connected features output by the fully connected layer into the probability distribution of gas types and their corresponding concentration values.
[0184] Take the data in the gas concentration time series data as samples; define the comprehensive loss function of the gas identification model ;in, is the cross entropy loss function; is the balance factor; is the concentration estimation loss function;
[0185] Cross Entropy Loss Function ; In the formula, is the total number of data in the gas concentration time series data; is the sample index; Index for gas types; is the total number of gas types; For the The samples belong to The true label of the gas type (0 or 1); The gas identification model predicts The samples belong to Probability of gas species;
[0186] Concentration Estimation Loss Function ; In the formula, For the In the sample The actual concentration value of the gas type; The gas identification model predicts In the sample The concentration value of the gas type;
[0187] According to the actual gas types and concentration values, the cross entropy loss and concentration estimation loss are calculated, and their weighted sum is used to obtain the total loss function; by minimizing the comprehensive loss function, the model can simultaneously learn to accurately classify gas types and estimate gas concentrations, providing more comprehensive gas recognition results.
[0188] Initialize the parameters of the gas identification model and set the initial learning rate of the gas identification model;
[0189] The gas identification model is trained using gas concentration time series data, and the parameters of the gas identification model are optimized using the back propagation algorithm and the Adam optimizer.
[0190] During the training process, when the function value of the comprehensive loss function reaches the preset loss threshold, the training is stopped and the gas recognition model at this time is saved, that is, the construction of the gas recognition model is completed;
[0191] In order to further improve the accuracy of model prediction, multiple gas identification models with different structures or parameters are trained, and their prediction results are integrated, for example, by voting, weighted averaging and other methods.
[0192] This embodiment improves the adaptability and flexibility of the infrared gas sensor, and can automatically adjust and optimize according to changes in environmental scenes; a deep learning algorithm is used to construct a gas recognition model, which improves the generalization ability and robustness of the model and can adapt to gas recognition tasks in different environments; the introduction of anomaly detection models and data preprocessing technology effectively improves the quality and reliability of gas concentration data and improves the accuracy of gas recognition; simultaneous recognition of gas types and concentrations is achieved, providing more comprehensive and accurate gas recognition results; remote automatic upgrades of sensors are achieved through online upgrade modules, shortening the upgrade cycle, reducing upgrade costs, and improving the maintainability of sensors; the intelligence level and practical application capabilities of infrared gas sensors are comprehensively improved; not only can the sensors be automatically adjusted and optimized according to environmental changes to achieve adaptability and flexibility, but they can also provide high-precision, high-reliability, and comprehensive gas recognition results.
[0193] Example 2
[0194] See also Figure 2 As shown, the part not described in detail in this embodiment is described in Example 1, which provides an infrared gas sensor online upgrade method, including:
[0195] S1. Obtain gas concentration data detected by the infrared gas sensor; and perform statistical analysis on the gas concentration data to obtain concentration distribution functions of n types of gases;
[0196] S2. Using the Bayesian inference method, the probability of m environmental scenarios is obtained based on the concentration distribution function of n gases;
[0197] S3, extracting the environmental scene probability with the largest probability from among m environmental scenes, and taking the environmental scene corresponding to the largest environmental scene probability as a priority upgrade object;
[0198] S4. For priority upgrade targets, obtain a gas recognition model through deep learning algorithm training;
[0199] S5. Send the gas recognition model to the infrared gas sensor chip and upgrade the infrared gas sensor online.
[0200] Example 3
[0201] See also Figure 3 As shown, this embodiment discloses an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the operation mode of the above-mentioned infrared gas sensor online upgrade method is implemented.
[0202] Since the electronic device introduced in this embodiment is an electronic device used to implement an infrared gas sensor online upgrade method in the embodiment of this application, based on the infrared gas sensor online upgrade method introduced in the embodiment of this application, the technical personnel of this field can understand the specific implementation of the electronic device of this embodiment and its various variations, so how the electronic device implements the method in the embodiment of this application is not described in detail here. As long as the technical personnel of this field implement the electronic device used in the infrared gas sensor online upgrade method in the embodiment of this application, it belongs to the scope of protection of this application.
[0203] The above formulas are all dimensionless and numerical calculations. The formula is a formula for the most recent real situation obtained by collecting a large amount of data and performing software simulation. The preset parameters and thresholds in the formula are set by technicians in this field according to actual conditions.
[0204] The above is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technical users in this technical field, some improvements and modifications without departing from the principle of the present invention should also be regarded as the protection scope of the present invention.
Claims
1. An infrared gas sensor online upgrade system, It is characterized in that include: A data acquisition and processing module is used to collect gas concentration data detected by the infrared gas sensor; The gas concentration data are statistically analyzed to obtain the concentration distribution function of n gases; A scene matching module is used to obtain m environmental scene probabilities based on the concentration distribution function of n gases using the Bayesian inference method; A priority extraction module is used to extract the probability of the environment scene with the largest probability among the m environment scenes, and take the environment scene corresponding to the largest environment scene probability as a priority upgrade object; The gas identification model generation module is used to obtain the gas identification model through deep learning algorithm training for the priority upgrade objects; Online upgrade module, used to send the gas recognition model to the infrared gas sensor chip and upgrade the infrared gas sensor online; Each module is connected by wired and / or wireless means to achieve data transmission between modules; The method for obtaining the gas concentration data includes: The infrared gas sensor chip is used to detect n types of gases in the environment and their corresponding concentrations, and the n types of gases and their corresponding concentrations are the original gas concentration data; the original gas concentration data is preprocessed to obtain gas concentration data; The pre-processing method includes: Input the original gas concentration data into the pre-built gas labeling model to label the gas types; The original gas concentration data with marked gas types are grouped according to gas types; each group of data includes a gas and the corresponding concentration value; that is, n groups of preliminary gas data are obtained; For each set of preliminary gas data, an anomaly detection model is constructed; the anomaly detection model is used to detect and remove outliers in the preliminary gas data; and gas concentration data is obtained; The gas labeling model is constructed in the following manner: Collect h groups of labeled samples as a data set, where each sample contains the concentration values of n gases and the corresponding gas type labels; Define the basic network structure of the gas annotation model, which includes input layer, embedding layer, gas correlation modeling layer, local feature extraction layer, global feature capture layer, feature fusion layer and output layer; The input layer takes the concentration values of n gases as input and encodes them into an n-dimensional concentration vector; the embedding layer maps the concentration value of each gas to a high-dimensional semantic space to obtain an embedding vector; then The embedding vector of the gas is ; Index for gas; Gas correlation modeling layer For any two gases and , calculate the interaction tensor of their embedding vectors ;in is the tensor outer product operator, Indicates gas and The interaction tensor between the concentration values; all the resulting interaction tensors Splice them together to form a high-order tensor ; The local feature extraction layer uses a 1D convolutional layer to extract local features of the embedded gas concentration sequence, capture the interaction pattern of different gas concentration values locally, and obtain the local feature tensor ; The global feature capture layer converts the local feature tensor and the gas concentration correlation tensor Perform splicing to construct a fusion feature tensor ;in, is the tensor concatenation operator; exist Use the self-attention mechanism to learn the global gas concentration pattern and obtain the global feature tensor ; The feature fusion layer transforms the local feature tensor and the global feature tensor Fusion is performed to obtain the fusion feature vector ; The output layer is based on the fused feature vector , use the fully connected layer and softmax function to classify and predict the output of gas types; Divide the data set into a training set and a validation set; normalize the concentration values so that they fall within the range of 0-1; initialize the parameters of each layer of the gas labeling model and set the initial learning rate; Define the training loss function of the gas labeling model; sample a batch of data from the training set in turn; input the data into the gas labeling model, and calculate the function value of the training loss function between the output of the gas labeling model and the actual gas type label; The back-propagation algorithm is used to calculate the gradients of the parameters of each layer, and the Adam optimizer is used to update the parameters of the gas labeling model according to the gradients. Evaluate the performance of the gas labeling model on the validation set and save the parameters of the gas labeling model with the best performance, thus completing the construction of the gas labeling model. The method of statistically analyzing the gas concentration data includes: The n groups of gas concentration data are fitted with the kernel density estimation method respectively; the unbiased probability density function estimation value of the gas concentration distribution corresponding to the n groups of gas concentration data is obtained; The method of using the kernel density estimation method to perform data distribution fitting includes: For the data points in the gas concentration data, the kernel density estimate corresponding to the data point is calculated according to the predefined kernel function and the optimal bandwidth; The kernel function is defined as: ;in, Represents the distance between data points; The calculation formula for calculating the kernel density estimate corresponding to the data point is: ; In the formula, For data points The kernel density estimate of ; is the total number of data points; is the optimal bandwidth; is the index of the second data point; is the index of the first data point; Divide the data points into B subsets, calculate the kernel density estimation value of each subset in parallel on different processors or computing nodes, and finally merge the results; assign the calculation task of kernel density estimation to C threads of GPU to speed up the calculation process; The kernel density estimates of all data points are normalized to obtain an unbiased probability density function estimate of the gas concentration distribution; The normalization formula is: ;in, is the normalized unbiased probability density function estimate; The concentration distribution function is obtained by estimating the unbiased probability density function of the gas concentration distribution using a log-normal distribution method to obtain a parameterized distribution model, which is the concentration distribution function. The method for obtaining the m environmental scene probabilities includes: Step 1: Establish a scene library containing M kinds of environmental scenes; and the value of M is greater than the value of m; for each environmental scene, predefine the concentration distribution function of the gas contained therein, that is, the scene feature distribution function; Step 2: Calculate the similarity of the concentration distribution functions of n gases using KL divergence; The calculation formula for calculating the similarity using KL divergence is: ;in, For the Gases in environmental scenarios The similarity under For the The concentration distribution function of the gas; is the concentration value; For environmental scenes The concentration distribution function of Indicates the integral number; Step 3: Use the Bayesian inference method to calculate the posterior probability of each environmental scenario; given the concentration distribution function of n gases, the environmental scenario is obtained The posterior probability ; but ;in, For the environmental scene The likelihood probability of observing the concentration distribution function of n gases under the following conditions; For environmental scenes The prior probability of is the marginal probability of the concentration distribution function of n gases; The concentration distribution functions of various gases are conditionally independent under a given environmental scenario; Then the likelihood probability ;in, is the multiplication sign, is the base of the exponential function; Step 4: sort the acquired posterior probabilities in descending order, and select the posterior probabilities corresponding to the first m environmental scenes as the m environmental scene probabilities; The method for obtaining the gas identification model includes: Collect infrared gas sensor data in environmental scenes corresponding to priority upgrade objects at fixed historical time periods, wherein the infrared gas sensor data includes gas types and concentration values corresponding to the gas types; numerically encode the gas types; perform training preprocessing on the infrared gas sensor data to obtain gas concentration time series data; The framework structure of the gas recognition model is defined to adopt the basic network structure of the gated recurrent unit model, which includes a gas input layer, a first gas GRU layer, a second gas GRU layer, a gas attention layer, a gas pooling layer, a feature fully connected layer, and a gated output layer; Take the data in the gas concentration time series data as samples; define the comprehensive loss function of the gas identification model ;in, is the cross entropy loss function; is the balance factor; is the concentration estimation loss function; Cross Entropy Loss Function ; In the formula, is the total number of data in the gas concentration time series data; is the sample index; Index for gas types; is the total number of gas types; For the The samples belong to The real label of the gas type; The gas identification model predicts The samples belong to The probability of a gas type; Concentration Estimation Loss Function ; In the formula, For the In the sample The actual concentration value of the gas type; The gas identification model predicts In the sample The concentration value of the gas type; Initialize the parameters of the gas identification model and set the initial learning rate of the gas identification model; The gas identification model is trained using the gas concentration time series data, and the parameters of the gas identification model are optimized using the back propagation algorithm and the Adam optimizer. During the training process, when the function value of the comprehensive loss function reaches the preset loss threshold, the training is stopped and the gas recognition model at this time is saved, and the construction of the gas recognition model is completed.
2. According to claim 1, an infrared gas sensor online upgrade system, It is characterized in that The construction method of the anomaly detection model includes: Defining an infrastructure of an anomaly detection model, the infrastructure comprising a feature extraction layer, a feature aggregation layer, an isolation tree generation layer, a threshold layer, and an outlier removal layer; The feature extraction layer first performs automatic feature extraction on the preliminary concentration data of each gas through a 1D convolutional layer to obtain the high-order feature vector of each gas concentration data; The feature aggregation layer concatenates the high-order feature vectors of all gases to form a joint vector of anomaly scores; The isolation tree generation layer is used to generate the isolation forest; the isolation forest is used to divide the anomaly score joint vector into outliers; For each preliminary gas data , get its anomaly score joint vector , starting from the root node along each isolation tree, it is routed to a leaf node according to the size relationship of the eigenvalues; statistics The number of nodes passed by is recorded as the path length ; Through predefined functions The path length Convert to anomaly score ,in, is the total number of nodes in the isolation tree; Predefined functions ;in, yes The expected path length on a given isolation tree; The anomaly scores calculated for all isolation trees are averaged to form the isolation forest pair The final anomaly score of The threshold layer introduces the Gaussian mixture model method to fit the probability density distribution of the joint vector of anomaly scores; Integrate the probability density distribution to the threshold corresponding to the set confidence level as the discrimination threshold for the current anomaly detection; The outlier removal layer marks the corresponding data points whose final anomaly scores are greater than or equal to the discrimination threshold as outliers; for the preliminary concentration data of each gas, those data points marked as outliers are removed to obtain the gas concentration data of the gas.
3. According to claim 2, an infrared gas sensor online upgrade system, It is characterized in that The generation method of the isolation forest includes: Step 1: Collect f groups of preliminary gas data in the historical process, and manually remove abnormal values from the preliminary gas data to form normal data samples; initialize the root node of each isolation tree in the isolation forest, and the root node contains all normal data samples; Step 2: For the non-leaf nodes of the current isolation tree, randomly select a feature dimension q, which is a dimension in the joint vector of anomaly scores; Step 3: For the selected feature dimension q, randomly sample a split point p from the value distribution of the feature dimension; use the split point p to divide the normal data sample of the current node into two parts according to the size of the feature value; the feature value is the value corresponding to each component in the anomaly score joint vector; Step 4: divide the normal data samples of the current node into a left child node and a right child node according to the split point, the left child node contains normal data samples whose value of feature dimension q is less than the split point p; the right child node contains normal data samples whose value of feature dimension q is greater than or equal to the split point p; Step 5: For the newly generated left child node and right child node, repeat steps 2-4 and continue to recursively split the child nodes until all normal data samples in the child nodes have exactly the same values in all feature dimensions; Step 6: Repeat steps 2-5 until a complete isolation tree is constructed; then repeat steps 1-6 to generate an isolation forest consisting of t isolation trees.
4. According to claim 3, an infrared gas sensor online upgrade system, It is characterized in that The training preprocessing method includes: Analyze the distribution of infrared gas sensor data and identify abnormal values that are significantly deviated from the normal range; set a corresponding abnormal value threshold for each gas type, and mark the concentration value of the corresponding gas type that is greater than the abnormal value threshold as an abnormal value; For outliers, directly remove them from the infrared gas sensor data or replace them with the average or median of adjacent data points; Perform sliding window averaging on the retained infrared gas sensor data, and replace each concentration value of the corresponding gas type with the average value of a fixed number of concentration values around it to obtain the averaged data; Randomly translate the substitution data to obtain translation data; Normalize the translation data; directly use the encoded gas types; use the normalized translation data and the corresponding encoded gas types as model training data; sort and encode the model training data according to the collected time sequence to obtain gas concentration time series data; The input data of the gas input layer is gas concentration time series data, and the input data is divided according to the time step to form a three-dimensional tensor; Define the input dimension and output dimension of the first gas GRU layer and the second gas GRU layer; used to output the gas hidden state; The gas attention layer takes the hidden state as the query, key, and value; it generates attention weights by calculating the similarity between the query and the key, and applies them to the value to get the weighted sum result; The gas pooling layer is used to perform a pooling operation on the weighted sum of the outputs of the gas attention layer. The pooling operation is maximum pooling or average pooling, which compresses the features in the time dimension into a vector of a fixed length, which is the overall feature. The overall features output by the gas pooling layer are passed through one or T feature fully connected layers to perform feature transformation and dimension adjustment to obtain fully connected features; The gated output layer uses the Softmax activation function to convert the fully connected features output by the fully connected layer into the probability distribution of gas types and their corresponding concentration values.
