Method and system for detecting toxic gas based on Reformer

The improved Reformer model enables efficient fusion and accurate identification of gas data, solving the problems of high computational load and time consumption in high-dimensional data processing of traditional models, and is suitable for gas identification and prediction.

CN119293548APending Publication Date: 2025-01-10ELECTRIC POWER RES INST OF GUANGXI POWER GRID CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411243480.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-05
Publication Date
2025-01-10

AI Technical Summary

Technical Problem

Traditional machine learning models struggle to handle complex, high-dimensional data, making it difficult to accurately and completely extract effective information, and they are computationally intensive and time-consuming.

Method used

An improved Reformer model is used for gas concentration prediction. The Reformer algorithm is used to fuse gas data of different long sequences. The reversible module is used to reduce the dependence of the network model and the memory footprint. The segmented fully connected approach is used to reduce memory space. The locality-sensitive hash attention mechanism is combined to reduce the computational complexity of the matrix.

Benefits of technology

It improves the accuracy of gas identification and prediction, reduces computational complexity and memory requirements, is suitable for operation in resource-constrained environments, and is applicable to classification and regression tasks in gas identification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119293548A_ABST
    Figure CN119293548A_ABST
Patent Text Reader

Abstract

The invention discloses a Reformer-based toxic gas detection method, which comprises the following steps: acquiring gas data, storing the gas data, and preprocessing by using weighted recursive average filtering to obtain first gas data; performing forward calculation on the first gas data to obtain a loss function of the neural network model, and performing backward calculation by using a reversible network layer; feature extraction is carried out, different feature vectors are sorted according to the hash values, the same feature vectors are stacked, and a first gas data sequence is obtained; the first gas data sequence is partitioned through segmented full connection, the length of each block of sequence is calculated, and a first neural network model is obtained; and inputting the first gas data into the first neural network model, outputting the gas information, predicting gas classification for the gas information by using the first activation function to obtain a gas prediction result, performing regression prediction on the gas prediction result by using the second activation function to obtain an actual gas detection result, and improving the performance of the whole system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of identification and quantitative analysis of mixed gas molecules, and in particular to a method and system for detecting poisonous gases based on a Reformer. Background Art

[0002] With the rapid development of new energy vehicles, the safety of new energy batteries has received great attention. Batteries will release huge heat during thermal runaway, and will release a variety of gases in the early stage of thermal runaway, including hydrogen, carbon dioxide, carbon monoxide, ethylene, etc. There is an urgent need for a method that can accurately predict gas concentrations in order to safely manage and control thermal runaway phenomena in advance. In recent years, with the rapid development of artificial intelligence and deep learning, the use of intelligent models to predict gas concentrations has become a research hotspot. Existing models for gas prediction include support vector machines, convolutional neural networks (CNNs), recurrent neural networks (RNNs), long short-term memory networks (LSTMs), transformers, and ensemble learning methods. Traditional machine learning models are often difficult to process complex high-dimensional data. The current mainstream time series prediction methods mostly use LSTM and transformer related models. When the sequence length is too long, the LSTM model makes it difficult to accurately and completely extract effective information. Although the Transformer model can process ultra-long time series, its calculation amount is huge and very time-consuming. To address this problem, this paper uses the improved Reformer model to predict gas concentration, which improves the ability to process high-dimensional complex data while reducing model complexity and increasing calculation speed.

[0003] In view of the problems existing in the existing gas concentration prediction, the present invention proposes a gas detection method based on the Reformer model. The device has the following characteristics: the Reformer algorithm is used to realize the fusion of gas data of different long sequences, and the accurate identification of unknown mixed gases is realized, thereby improving the accuracy of gas identification and prediction. By adopting the reversible module method, the dependence on each layer of data in the network model calculation process is reduced, and the occupation of video memory is reduced. On the other hand, the segmented full connection method is adopted to connect all networks, so that the network occupies a smaller memory space. Using local sensitive hashing attention, through the hash value mapping method, more operations are performed in matrices with higher similarity, reducing the complexity of matrix calculation, thereby improving the running speed. Summary of the invention

[0004] In view of the above-mentioned problems, the present invention is proposed.

[0005] Therefore, the technical problem solved by the present invention is: the present invention solves the problem that traditional machine learning models are difficult to process complex high-dimensional data, traditional machine learning models are difficult to accurately and completely extract effective information, and the calculation amount is huge and very time-consuming.

[0006] In order to solve the above technical problems, the present invention provides the following technical solutions:

[0007] In a first aspect, the present invention provides a method for detecting poisonous gases based on Reformer, comprising:

[0008] Acquire gas data, store the gas data, and preprocess the stored gas data using weighted recursive average filtering to obtain first gas data;

[0009] Performing forward calculation on the first gas data to obtain a loss function of the neural network model, calculating the gradient of the loss function, performing backward calculation using a reversible network layer, and updating parameters of the neural network model;

[0010] Extract features from the first gas data, sort different feature vectors according to hash values ​​through a local sensitive hashing attention mechanism, and stack the feature vectors with the same feature to obtain a first gas data sequence;

[0011] Divide the first gas data sequence into blocks using segmented full connection, calculate the length of each block of the sequence, and obtain a first neural network model;

[0012] The first gas data is input into a first neural network model, gas information is output, gas classification is predicted for the gas information using a first activation function to obtain a gas prediction result, and regression prediction is performed on the gas prediction result using a second activation function to obtain an actual gas detection result.

[0013] As a preferred solution of the method for detecting poisonous gases based on Reformer described in the present invention, the preprocessing of the stored gas data by weighted recursive average filtering includes:

[0014] Initialize the initial state of the filter, take the value of the first data point as the initial filtering result, and filter the gas data of each data point starting from the first data point;

[0015] For each data point, the gas data of the current data point is multiplied by the weight of the current gas data in the filtering result plus the filtering coefficient multiplied by the previous filtering result of the previous data point to obtain the filtered result of the current data point;

[0016] The filtered result is standardized, and the average value of the filtered result is subtracted from the filtered result before standardization and divided by the standard deviation of the filtered result to obtain the gas data of the standardized filtered result as the first gas data.

[0017] As a preferred solution of the method for detecting poisonous gases based on Reformer described in the present invention, the forward calculation includes:

[0018] By utilizing the reversible characteristics of the Reformer model network layer, a shallow network is used to calculate the activation value of a deep network during forward calculation, and a deep network is used to calculate the activation value of a shallow network during backward calculation.

[0019] The forward calculation is represented by the first input Reformer model feature plus the second input Reformer model feature after local sensitive hashing attention processing to obtain the first output label;

[0020] The second output label is the feature of the second input Reformer model plus the first output label after feedforward network processing.

[0021] As a preferred solution of the method for detecting poisonous gases based on Reformer described in the present invention, the backward calculation includes:

[0022] The second output label minus the first output label after feedforward network processing obtains the updated value of the second input Reformer model feature;

[0023] The updated value of the second input Reformer model feature after the local sensitive hashing attention processing is subtracted from the first output label to obtain the updated value of the first input Reformer model feature.

[0024] As a preferred solution of the method for detecting poisonous gases based on Reformer described in the present invention, the local sensitive hashing attention mechanism includes:

[0025] Sort different feature vectors according to the hash value, and the local sensitive hash value is expressed as:

[0026]

[0027] in, For vector u and vector v h The dot product operation, t h is the bias term, T is a fixed value, t h ∈[0,T];

[0028] For any two eigenvectors of the same dimension that satisfy Pr h[h(p)=h(q)]≈s(p,q), where Pr h is the probability, s(·) is the similarity function, h(p) and h(q) are the hash values ​​of feature vectors p and q respectively;

[0029] Feature vectors are arranged according to the similarity of their hash values, and feature vectors with the same hash value are stacked together.

[0030] As a preferred solution of the method for detecting poisonous gases based on Reformer described in the present invention, the segmented full connection includes:

[0031] In the Reformer model, the first gas data sequence is divided into blocks using segmented full connection as follows:

[0032]

[0033] in, is the value of input X2 for the i-th element in the sequence, FFN(Y1) (i) is the value of the feedforward network applied to the i-th element in the Y1 sequence, is the Y2 value of the i-th element in the Y2 sequence.

[0034] As a preferred solution of the method for detecting poisonous gases based on Reformer described in the present invention, wherein: using the first activation function to predict the gas classification of the gas information to obtain the gas prediction result, and using the second activation function to regress and predict the gas prediction result to obtain the actual gas detection result includes:

[0035] Using the Softmax activation function, the last hidden layer output vector of the Reformer network is transformed into a vector with each element corresponding to each gas category. The output of the hidden layer is converted through the Softmax activation function to obtain the probability of each category, and the category with the highest probability is selected as the prediction result.

[0036] The prediction result is converted through the tanh activation function, the positive exponent and negative exponent of the prediction result are calculated, the positive exponent is subtracted from the negative exponent to obtain the difference, the positive exponent is added to the negative exponent to obtain the sum, and the difference is divided by the sum to obtain the actual gas detection result.

[0037] In a second aspect, the present invention provides a system for detecting poisonous gases based on Reformer, comprising:

[0038] A preprocessing module, used for acquiring gas data, storing the gas data, and preprocessing the stored gas data by using weighted recursive average filtering to obtain first gas data;

[0039] A calculation module, used for performing forward calculation on the first gas data to obtain a loss function of the neural network model, calculating the gradient of the loss function, performing backward calculation using a reversible network layer, and updating parameters of the neural network model;

[0040] A sorting module, used to extract features from the first gas data, sort different feature vectors according to hash values ​​through a local sensitive hashing attention mechanism, and stack the feature vectors with the same feature to obtain a first gas data sequence;

[0041] A block module, used to block the first gas data sequence using segmented full connection, calculate the length of each block sequence, and obtain a first neural network model;

[0042] The classification module is used to input the first gas data into the first neural network model, output gas information, use the first activation function to predict gas classification of the gas information to obtain a gas prediction result, and use the second activation function to regress and predict the gas prediction result to obtain an actual gas detection result.

[0043] In a third aspect, the present invention provides a computing device, comprising:

[0044] Memory and processor;

[0045] The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions. When the computer executable instructions are executed by the processor, the steps of the Reformer-based method for detecting toxic gases are implemented.

[0046] In a fourth aspect, the present invention provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the steps of the Reformer-based method for detecting toxic gases.

[0047] Beneficial effects of the present invention: The Reformer-based method for detecting toxic gases proposed in the present invention adopts the Reformer algorithm to realize the fusion of gas data of different long sequences, adopts the local sensitive hash attention mechanism and the reversible residual network, reduces the computational and memory burden, and adopts the Reformer algorithm to effectively process long sequences. Since gas data is usually time series data, it can maintain computational efficiency when processing high-resolution or long-span data. At the same time, it is also very useful for collecting very long data from multiple gas sensors. The local sensitive hash attention technology greatly reduces the memory requirement. It can be run in a resource-constrained environment, which is very important for gas identification applications in embedded systems or in edge devices. The algorithm can adapt to the previous signal processing method and feature extraction method to improve the performance of the entire system. This method is suitable for classification and regression tasks in gas identification, and can detect the presence or absence of specific gases and predict the change of gas concentration over time. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. Among them:

[0049] Figure 1 An overall flow chart of a method for detecting poisonous gases based on Reformer provided by the present invention. DETAILED DESCRIPTION

[0050] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the drawings of the specification. Obviously, the described embodiments are part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary persons in the art without creative work should fall within the scope of protection of the present invention.

[0051] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.

[0052] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The term "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive with other embodiments.

[0053] The present invention is described in detail with reference to schematic diagrams. When describing the embodiments of the present invention, for the sake of convenience, the cross-sectional diagrams showing the device structure will not be partially enlarged according to the general scale, and the schematic diagrams are only examples, which should not limit the scope of protection of the present invention. In addition, in actual production, the three-dimensional dimensions of length, width and depth should be included.

[0054] At the same time, in the description of the present invention, it should be noted that the directions or positional relationships indicated by the terms "upper, lower, inner and outer" are based on the directions or positional relationships shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific direction, be constructed and operated in a specific direction, and therefore cannot be understood as limiting the present invention. In addition, the terms "first, second or third" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance.

[0055] In the present invention, unless otherwise clearly specified and limited, the terms "install, connect, connect" should be understood in a broad sense, for example: it can be a fixed connection, a detachable connection or an integral connection; it can also be a mechanical connection, an electrical connection or a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0056] Example 1

[0057] Reference Figure 1 , as an embodiment of the present invention, provides a method for detecting poisonous gas based on Reformer, comprising:

[0058] S100: Acquire gas data, store the gas data, and pre-process the stored gas data using weighted recursive average filtering to obtain first gas data;

[0059] In the embodiment of the present application, the initial state of the filter is initialized, the value of the first data point is used as the initial filtering result, and the gas data of each data point is filtered starting from the first data point;

[0060] For each data point, the gas data of the current data point is multiplied by the weight of the current gas data in the filtering result plus the filtering coefficient multiplied by the previous filtering result of the previous data point to obtain the filtered result of the current data point;

[0061] The filtered result is standardized, and the average value of the filtered result is subtracted from the filtered result before standardization and divided by the standard deviation of the filtered result to obtain the gas data of the standardized filtered result as the first gas data.

[0062] Specifically, in the process of collecting data in the actual environment, data is collected at regular intervals according to a preset time interval, and the sample data is stored in the data storage module. The time interval is set according to the frequency of the collected signal. If the collected signal is 10Hz, the time interval is 30s. The sample data is a digital signal, and a timestamp will be added when it is stored in the storage module.

[0063] The data in the data storage module contains a variety of signals, such as Class A gas, Class B gas, temperature and humidity signals. When a certain gas signal is actually to be detected, only the gas signal needs to be processed later. If all gas information is needed, all data will be allocated and the saved data in the data storage module will be distributed to the preprocessing module.

[0064] Specifically, the current filtered result depends on the previous filtered result. The weighted recursive average filtering method is expressed as: y(n) = (1-a)*x(n) + a*y(n-1), where y(n) is the current filtered result, y(n-1) is the previous filtered result, a is the filter coefficient, and x(n) is the weight of the current gas data in the filter result. The filter coefficient a ranges from 0.8 to 1. Data normalization is then used to divide the preprocessed data into training set, validation set, and test set in a ratio of 8:1:1. During the training process, the training set is sent to the model for training, and the validation set is used to verify the effectiveness of the model training process to avoid problems such as overfitting of the model. Finally, the model is tested with the test set to obtain an effective prediction model;

[0065] The present invention preferably uses weighted recursive average filtering to preprocess the data, and can also use moving average filtering, median filtering, Gaussian filtering, etc.

[0066] It should be noted that the weighted recursive average filtering method only needs to select the previous filtering result during operation, so it requires less storage space in the microprocessor and is better used in resource-constrained embedded devices. The moving average filter can cause signal distortion, especially for situations involving rapidly changing or pulse signals; the median filter can effectively overcome the fluctuation interference caused by accidental factors, but it will cause the image features to be less prominent; the Gaussian filter is not selective, that is, it may blur the edges and details of the image while reducing noise, which is not conducive to applications that need to retain edge information.

[0067] S200: performing forward calculation on the first gas data to obtain a loss function of the neural network model, calculating the gradient of the loss function, performing backward calculation using a reversible network layer, and updating parameters of the neural network model;

[0068] In the embodiment of the present application, the reversible characteristics of the Reformer model network layer are utilized, and the activation value of the deep network is calculated by using the shallow network in the forward calculation, and the activation value of the shallow network is calculated by the deep network in the backward calculation;

[0069] The forward calculation is represented by the first input Reformer model feature plus the second input Reformer model feature after local sensitive hashing attention processing to obtain the first output label;

[0070] The second output label is the feature of the second input Reformer model plus the first output label after feedforward network processing.

[0071] Specifically, the forward calculation of the Reformer model is expressed as:

[0072]

[0073] Among them, x1 and x2 are the features of the first and second input Reformer model, LSHAttention(·) is the local sensitive hashing attention, FeedForward(·) is the feedforward network, y1 is the first output label, and y2 is the second output label.

[0074] In the embodiment of the present application, the second output label minus the first output label after the feedforward network processing obtains the updated value of the second input Reformer model feature;

[0075] The updated value of the second input Reformer model feature after the local sensitive hashing attention processing is subtracted from the first output label to obtain the updated value of the first input Reformer model feature.

[0076] Specifically, the backward calculation of the Reformer model is expressed as:

[0077]

[0078] Through this process, due to the reversible characteristics of the network layer, a shallow network can be used to calculate the activation value of a deep network during forward calculation. Similarly, a deep network can be used to calculate the activation value of a shallow network during backward calculation, thereby saving computing memory space.

[0079] The present invention preferably uses Reformer, and can also use convolutional neural networks and long short-term memory networks.

[0080] It should be noted that Reformer is the most efficient transformer model in the field of long sequence modeling to date. It can train 500,000 tokens on 8GB of memory. Reformer minimizes memory requirements and avoids performance degradation while reducing memory requirements. Convolutional neural networks perform well in specific situations, but may not be able to process long sequence data. Long short-term memory networks are suitable for time series prediction, but face the problems of large computational complexity and difficulty in processing ultra-long sequences. The Reformer model was chosen because of its improved features, such as reversible modules and local sensitive hashing attention mechanisms. These features help improve the ability to process high-dimensional complex data, reduce model complexity, and increase computing speed.

[0081] S300: extracting features from the first gas data, sorting different feature vectors according to hash values ​​through a local sensitive hashing attention mechanism, and stacking feature vectors with the same feature to obtain a first gas data sequence;

[0082] In the embodiment of the present application, different feature vectors are sorted according to the hash value, and the local sensitive hash value is expressed as:

[0083]

[0084] in, For vector u and vector v h The dot product operation, t h is the bias term, T is a fixed value, t h ∈[0,T];

[0085] For any two eigenvectors of the same dimension that satisfy Pr h [h(p)=h(q)]≈s(p,q), where Pr h is the probability, s(·) is the similarity function, h(p) and h(q) are the hash values ​​of feature vectors p and q respectively;

[0086] Feature vectors are arranged according to the similarity of their hash values, and feature vectors with the same hash value are stacked together.

[0087] Specifically, the local sensitive hashing attention is to sort different feature vectors according to the hash values, stack the feature vectors with the same hash value together, and calculate the local sensitive hash value, where

[0088] All feature hash values ​​are arranged in order according to their similarity, thus enabling effective sorting;

[0089] It should be noted that the traditional attention mechanism needs to compare all feature vectors in the sequence, which will result in huge computational complexity on large-scale datasets. Locality-sensitive hashing reduces the number of feature vector pairs that need to be compared by mapping vectors with similar features into the same hash bucket, thereby reducing computational complexity. Locality-sensitive hashing attention indirectly reduces memory usage by reducing the number of feature vector pairs involved in the calculation.

[0090] S400: Divide the first gas data sequence into blocks using segmented full connection, calculate the length of each block of the sequence, and obtain a first neural network model;

[0091] In the embodiment of the present application, the first gas data sequence is divided into blocks and represented by segmented full connection in the Reformer model as follows:

[0092]

[0093] in, is the value of input X2 for the i-th element in the sequence, FFN(Y1) (i) is the value of the feedforward network applied to the i-th element in the Y1 sequence, is the Y2 value of the i-th element in the Y2 sequence.

[0094] It should be noted that Reformer uses segmented full-connection operations, that is, block-based calculations, which occupies less video memory. Perform separate calculations and split a complete sequence into several continuous blocks to save video memory and reduce space requirements.

[0095] S500: inputting the first gas data into the first neural network model, outputting the gas information, using the first activation function to predict the gas classification of the gas information to obtain the gas prediction result, and using the second activation function to regress and predict the gas prediction result to obtain the actual gas detection result;

[0096] In the embodiment of the present application, the last hidden layer of the Reformer network is output as a vector using the Softmax activation function, each element of which corresponds to each gas category. The output of the hidden layer is converted through the Softmax activation function to obtain the probability of each category, and the category with the highest probability is selected as the prediction result;

[0097] The prediction result is converted through the tanh activation function, the positive exponent and negative exponent of the prediction result are calculated, the positive exponent is subtracted from the negative exponent to obtain the difference, the positive exponent is added to the negative exponent to obtain the sum, and the difference is divided by the sum to obtain the actual gas detection result.

[0098] Specifically, the Softmax function is the most commonly used activation function when processing multi-classification tasks, and is used to accurately predict the gas category. Compared with other activation functions, the tanh function has a graph that is symmetrical about the origin and an output range of [-1, 1], so it works better when the feature difference is obvious. The present invention preferably uses the Softmax activation function and the tanh activation function, and can also use the Sigmoid activation function and the ReLU activation function;

[0099] It should be noted that the Sigmoid activation function has the problem of gradient disappearance, which affects the training of deep networks and reduces learning efficiency; the ReLU activation function will cause instability in the learning process; and Softmax is the first choice for dealing with multi-classification problems. It can map a sample to the probability distribution of multiple categories. The output range of the tanh function is [-1, 1] and is symmetric about the origin, which helps the mean of the data approach 0, thereby improving learning efficiency.

[0100] The above is a schematic scheme of a method for detecting toxic gases based on Reformer in this embodiment. It should be noted that the technical scheme of the device for detecting toxic gases based on Reformer and the technical scheme of the method for detecting toxic gases based on Reformer mentioned above belong to the same concept. For details not described in detail in the technical scheme of the device for detecting toxic gases based on Reformer in this embodiment, please refer to the description of the technical scheme of the method for detecting toxic gases based on Reformer mentioned above.

[0101] The device for detecting poisonous gas based on Reformer in this embodiment includes:

[0102] A preprocessing module, used for acquiring gas data, storing the gas data, and preprocessing the stored gas data by using weighted recursive average filtering to obtain first gas data;

[0103] A calculation module, used for performing forward calculation on the first gas data to obtain a loss function of the neural network model, calculating the gradient of the loss function, performing backward calculation using a reversible network layer, and updating parameters of the neural network model;

[0104] A sorting module, used to extract features from the first gas data, sort different feature vectors according to hash values ​​through a local sensitive hashing attention mechanism, and stack the feature vectors with the same feature to obtain a first gas data sequence;

[0105] A block module, used to block the first gas data sequence using segmented full connection, calculate the length of each block sequence, and obtain a first neural network model;

[0106] The classification module is used to input the first gas data into the first neural network model, output gas information, use the first activation function to predict gas classification of the gas information to obtain a gas prediction result, and use the second activation function to regress and predict the gas prediction result to obtain an actual gas detection result.

[0107] This embodiment further provides a computing device, which is suitable for detecting poisonous gas conditions based on Reformer, including:

[0108] Memory and processor; the memory is used to store computer executable instructions, and the processor is used to execute computer executable instructions to implement the method for detecting toxic gases based on Reformer as proposed in the above embodiment.

[0109] This embodiment further provides a storage medium on which a computer program is stored. When the program is executed by a processor, the method for detecting poisonous gases based on Reformer as proposed in the above embodiment is implemented.

[0110] The storage medium proposed in this embodiment and the method for detecting toxic gases based on Reformer proposed in the above embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be found in the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.

[0111] Through the above description of the implementation methods, the technicians in the relevant field can clearly understand that the present invention can be implemented by means of software and necessary general hardware, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ReadOnly, Memory, ROM), random access memory (RandomAccess Memory, RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform the methods of various embodiments of the present invention.

[0112] Example 2

[0113] This embodiment is different from the first embodiment in that it provides a verification test of a method for detecting poisonous gases based on Reformer, in order to verify and illustrate the technical effects adopted in this method.

[0114] Taking a chemical plant monitoring ammonia (NH3) and hydrogen sulfide (H2S) as an example, multiple ammonia and hydrogen sulfide detection sensors are deployed inside the plant to collect gas concentration data every 1 minute.

[0115] Assume that the raw data collected by the sensor is:

[0116] Ammonia concentration: [5.2, 5.4, 5.6, 5.8, 6.0, 6.2, 6.4, 6.6, 6.8, 7.0] ppm

[0117] Hydrogen sulfide concentration: [2.1, 2.3, 2.5, 2.7, 2.9, 3.1, 3.3, 3.5, 3.7, 3.9] ppm

[0118] The raw gas data were preprocessed using a weighted recursive average filter, and the weight coefficient of the filter was set to: α = 0.8;

[0119] After filtering, the first gas data is obtained:

[0120] Ammonia concentration: [5.2, 5.32, 5.46, 5.61, 5.77, 5.93, 6.10, 6.26, 6.43, 6.60] ppm

[0121] Hydrogen sulfide concentration: [2.1, 2.24, 2.39, 2.54, 2.70, 2.86, 3.02, 3.18, 3.34, 3.50] ppm;

[0122] Input the first gas data into the Reformer model and perform forward calculation to obtain the loss function L.

[0123] Calculate the gradient of the loss function L, use the reversible network layer for backward calculation, and update the parameters of the Reformer model.

[0124] The first gas data is subjected to feature extraction, and the feature vectors [f1, f2, ..., fn] are sorted according to the hash values ​​using the local sensitive hashing attention mechanism to obtain a feature vector sequence [f(1), f(2), ..., f(n)].

[0125] The same feature vectors are stacked to obtain the first gas data sequence.

[0126] The first gas data sequence is divided into blocks using segmented full connection, with the length of each block set to 64, to obtain the first neural network model.

[0127] Input the first gas data into the trained first neural network model and output the gas information [g1, g2].

[0128] The Softmax activation function is used to classify and predict the gas information [g1, g2] to obtain the gas prediction results:

[0129] Ammonia prediction probability: P(NH3)=0.85;

[0130] Hydrogen sulfide prediction probability: P(H2S)=0.92;

[0131] The tanh activation function is used to regress the gas prediction results to obtain the final gas concentration detection results:

[0132] Ammonia concentration: 6.55ppm;

[0133] Hydrogen sulfide concentration: 3.45ppm;

[0134] A weighted recursive average filter is used to preprocess the raw gas data, which effectively reduces noise interference. The Reformer model is used for feature extraction and sequence modeling to better capture the temporal characteristics of gas concentration changes. The local sensitive hashing attention mechanism is used to improve the model's ability to learn key features. Finally, through the combination of classification and regression, accurate detection of gas types and concentrations is achieved.

[0135] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.

Claims

1. A method for detecting poisonous gases based on Reformer, characterized in that: include: Acquire gas data, store the gas data, and preprocess the stored gas data using weighted recursive average filtering to obtain first gas data; Performing forward calculation on the first gas data to obtain a loss function of the neural network model, calculating the gradient of the loss function, performing backward calculation using a reversible network layer, and updating parameters of the neural network model; Extract features from the first gas data, sort different feature vectors according to hash values ​​through a local sensitive hashing attention mechanism, and stack the feature vectors with the same feature to obtain a first gas data sequence; Divide the first gas data sequence into blocks using segmented full connection, calculate the length of each block of the sequence, and obtain a first neural network model; The first gas data is input into a first neural network model, gas information is output, gas classification is predicted for the gas information using a first activation function to obtain a gas prediction result, and regression prediction is performed on the gas prediction result using a second activation function to obtain an actual gas detection result.

2. The method for detecting poisonous gas based on Reformer as claimed in claim 1, characterized in that: Preprocessing the stored gas data using weighted recursive average filtering includes: Initialize the initial state of the filter, take the value of the first data point as the initial filtering result, and filter the gas data of each data point starting from the first data point; For each data point, the gas data of the current data point is multiplied by the weight of the current gas data in the filtering result plus the filtering coefficient multiplied by the previous filtering result of the previous data point to obtain the filtered result of the current data point; The filtered result is standardized, and the average value of the filtered result is subtracted from the filtered result before standardization and divided by the standard deviation of the filtered result to obtain the gas data of the standardized filtered result as the first gas data.

3. The method for detecting poisonous gas based on Reformer as claimed in claim 1 or 2, characterized in that: The forward calculation includes: By utilizing the reversible characteristics of the Reformer model network layer, a shallow network is used to calculate the activation value of a deep network during forward calculation, and a deep network is used to calculate the activation value of a shallow network during backward calculation. The forward calculation is represented by the first input Reformer model feature plus the second input Reformer model feature after local sensitive hashing attention processing to obtain the first output label; The second output label is the feature of the second input Reformer model plus the first output label after feedforward network processing.

4. The method for detecting poisonous gas based on Reformer as claimed in claim 3, characterized in that: The backward calculation includes: The second output label minus the first output label after feedforward network processing obtains the updated value of the second input Reformer model feature; The updated value of the second input Reformer model feature after the local sensitive hashing attention processing is subtracted from the first output label to obtain the updated value of the first input Reformer model feature.

5. The method for detecting poisonous gas based on Reformer as claimed in claim 4, characterized in that: The locality-sensitive hashing attention mechanism includes: Sort different feature vectors according to the hash value, and the local sensitive hash value is expressed as: in, For vector u and vector v h The dot product operation, t h is the bias term, T is a fixed value, t h ∈[0,T]; For any two eigenvectors of the same dimension that satisfy Pr h [h(p)=h(q)]≈s(p,q), where Pr h is the probability, s(·) is the similarity function, h(p) and h(q) are the hash values ​​of feature vectors p and q respectively; Feature vectors are arranged according to the similarity of their hash values, and feature vectors with the same hash value are stacked together.

6. The method for detecting poisonous gas based on Reformer as claimed in claim 5, characterized in that: Segmented full connection includes: In the Reformer model, the first gas data sequence is divided into blocks using segmented full connection as follows: in, is the value of input X2 for the i-th element in the sequence, FFN(Y1) (i) is the value of the feedforward network applied to the i-th element in the Y1 sequence, is the Y2 value of the i-th element in the Y2 sequence.

7. The method for detecting poisonous gas based on Reformer as claimed in claim 6, characterized in that: The gas classification is predicted by using the first activation function to obtain a gas prediction result, and the gas prediction result is regressed and predicted by using the second activation function to obtain an actual gas detection result, including: Using the Softmax activation function, the last hidden layer output vector of the Reformer network is transformed into a vector with each element corresponding to each gas category. The output of the hidden layer is converted through the Softmax activation function to obtain the probability of each category, and the category with the highest probability is selected as the prediction result. The prediction result is converted through the tanh activation function, the positive exponent and negative exponent of the prediction result are calculated, the positive exponent is subtracted from the negative exponent to obtain the difference, the positive exponent is added to the negative exponent to obtain the sum, and the difference is divided by the sum to obtain the actual gas detection result.

8. A system for detecting poisonous gases based on Reformer, characterized in that: include: A preprocessing module, used for acquiring gas data, storing the gas data, and preprocessing the stored gas data by using weighted recursive average filtering to obtain first gas data; A calculation module, used for performing forward calculation on the first gas data to obtain a loss function of the neural network model, calculating the gradient of the loss function, performing backward calculation using a reversible network layer, and updating parameters of the neural network model; A sorting module, used to extract features from the first gas data, sort different feature vectors according to hash values ​​through a local sensitive hashing attention mechanism, and stack the feature vectors with the same feature to obtain a first gas data sequence; A block module, used to block the first gas data sequence using segmented full connection, calculate the length of each block sequence, and obtain a first neural network model; The classification module is used to input the first gas data into the first neural network model, output gas information, use the first activation function to predict gas classification of the gas information to obtain a gas prediction result, and use the second activation function to regress and predict the gas prediction result to obtain an actual gas detection result.

9. An electronic device, characterized in that: The device comprises: processor; a memory for storing processor-executable instructions; The processor is configured to call the instructions stored in the memory to execute the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Detection and identification method for multiple types of industrial toxic gases

    CN120892797A