Gas recognition method based on multi-task learning time convolution network and bidirectional cross attention network and training method of gas recognition model
Through the multi-task learning time convolution network and the two-way cross attention network, the problem of inefficiency caused by independent gas component recognition and concentration recognition tasks is solved, and efficient and accurate gas detection is achieved.
Patent Information
- Application Number
- CN202510581823.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-07
- Publication Date
- 2025-08-08
AI Technical Summary
In the prior art, the gas component identification and gas concentration identification tasks are carried out independently, resulting in low recognition efficiency and low characteristic parameter utilization efficiency, and the inability to efficiently conduct gas detection.
Multi-task learning time convolution network and bidirectional cross attention network are used to extract common features through the shared feature extraction layer, combine the concentration recognition task output layer and the component recognition task output layer, and use the bidirectional cross attention network to update the feature matrix to achieve gas concentration and component recognition.
The synergistic effect and parameter utilization efficiency of gas recognition are improved, the accuracy of gas component recognition and concentration recognition accuracy are enhanced, and accurate gas component and concentration recognition are achieved.
Smart Images

Figure CN120452608A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of gas detection technology, and in particular to a gas identification method, apparatus, computer equipment, storage medium and computer program product based on a multi-task learning temporal convolutional network and a bidirectional cross attention network. Background Art
[0002] In the industrial sector, landfill leachate treatment processes are a significant source of volatile organic compounds (VOCs). Their physical and chemical properties can pose varying degrees of harm to human health. Furthermore, VOCs can participate in atmospheric chemical reactions, generating secondary pollutants (e.g., secondary organic aerosols (SOAs)), which can indirectly impact the environment and human health.
[0003] Currently, when detecting indoor gases, each recognition task is often performed independently. However, this approach results in a large number of independent calculations, resulting in low overall detection efficiency. Furthermore, when performing gas component and gas concentration recognition, since the gas component and gas concentration recognition tasks are separate recognition tasks, the different feature information under different recognition tasks is independent of each other, resulting in low efficiency in the utilization of feature parameters between different recognition tasks, low synergy between different recognition tasks, and limited recognition speed.
[0004] Therefore, there is a problem in conventional technologies that gases cannot be detected efficiently. Summary of the Invention
[0005] Based on this, it is necessary to provide a gas identification method, device, computer equipment, computer-readable storage medium and computer program product based on multi-task learning temporal convolutional network and bidirectional cross attention network, which can efficiently detect gas in response to the above technical problems.
[0006] A gas recognition method based on multi-task learning temporal convolutional network and bidirectional cross attention network, including:
[0007] Obtaining a gas response curve output by the gas sensor for the gas to be detected, and generating a response characteristic time series based on the gas response curve; the response characteristic time series includes the gas response characteristics of the gas response curve in each response segment;
[0008] The response feature time series is input into the shared feature extraction layer of the temporal convolutional network of the gas recognition model. The shared feature extraction layer extracts common features based on the response feature time series. The common features represent the common information between the response segments.
[0009] The common features are respectively input into the concentration recognition task output layer and the component recognition task output layer in the temporal convolutional network, and the concentration recognition task output layer outputs a first feature matrix based on the common features, and the component recognition task output layer outputs a second feature matrix based on the common features;
[0010] Inputting the first feature matrix and the second feature matrix into the bidirectional cross attention network of the gas recognition model, the bidirectional cross attention network updates the first feature matrix and the second feature matrix based on the bidirectional cross attention mechanism to obtain updated feature matrices corresponding to the first feature matrix and the second feature matrix respectively;
[0011] Based on the updated characteristic matrix corresponding to the first characteristic matrix, a gas concentration identification result for the gas to be detected is determined, and based on the updated characteristic matrix corresponding to the second characteristic matrix, a gas component identification result for the gas to be detected is determined.
[0012] In an exemplary embodiment, generating a response characteristic time series according to a gas response curve includes:
[0013] The gas response curve is segmented to obtain the curve corresponding to each response segment;
[0014] For any response segment, determine the ratio of the data change in each time window in the response segment to the time window length based on the curve corresponding to the response segment, and use the curve data corresponding to the time window with the largest ratio as the characteristic data of the response segment;
[0015] A response characteristic time series corresponding to the gas response curve is generated according to the characteristic data of each response segment.
[0016] In an exemplary embodiment, the gas response curve is segmented to obtain curves corresponding to the response segments, including:
[0017] Using the peak detection rule, the index of each local peak point in the gas response curve is determined;
[0018] Generate an index set based on the index of each local peak point;
[0019] Determine the distance between the indexes of two adjacent local peak points in the index set, and generate a distance set according to the index distance between the indexes of the two adjacent local peak points in the index set;
[0020] Obtaining a distance threshold for the distance set, grouping the index distances in the distance set according to the distance threshold to obtain a local peak point grouping result; the local peak point grouping result includes at least one local peak point set; and the index distance between the indexes of two adjacent local peak points in the same local peak point set is less than the distance threshold;
[0021] Determine the maximum local peak point index in each local peak point set, and generate a maximum local peak point index set based on the maximum local peak point index in each local peak point set;
[0022] For any maximum local peak point index, determine the index range of each response segment according to the preset left offset and the preset right offset corresponding to the maximum local peak point index;
[0023] According to the index range of each response segment, a curve corresponding to each response segment is extracted from the gas response curve.
[0024] A gas recognition model training method, comprising:
[0025] Acquire a gas response curve sample set; the gas response curve sample set includes multiple gas response curve sample subsets; different gas response curve sample subsets correspond to gas response curve test data sets of different gases; the gas response curve test data set corresponding to any gas includes multiple gas response test curves obtained after performing response tests on the gas at various gas concentrations;
[0026] Inputting the response characteristic time series corresponding to the gas response test curve of any gas at any gas concentration into the gas recognition model to be trained to obtain the gas concentration recognition result and gas component recognition result for the gas; the response characteristic time series includes the gas response characteristics of the gas response test curve in each response segment;
[0027] Determine loss information based on the gas concentration identification result and the gas component identification result of any gas;
[0028] Based on the loss information, the gas recognition model to be trained is trained.
[0029] In an exemplary embodiment, a gas identification model to be trained includes a temporal convolutional network to be trained and a bidirectional cross-attention network to be trained. The temporal convolutional network to be trained includes a shared feature extraction layer to be trained, a concentration identification task output layer to be trained, and a component identification task output layer to be trained. A response feature time series corresponding to a gas response test curve of any gas at any gas concentration is input into the gas identification model to be trained, and a gas concentration identification result and a gas component identification result for the gas are obtained, including:
[0030] The response feature time series corresponding to the gas response test curve of any gas at any gas concentration is input into the shared feature extraction layer to be trained. The shared feature extraction layer to be trained extracts common features based on the response feature time series; the common features represent the common information between the response segments;
[0031] The common features are respectively inputted into the concentration identification task output layer to be trained and the component identification task output layer to be trained, and the concentration identification task output layer to be trained outputs a first feature matrix based on the common features, and the component identification task output layer to be trained outputs a second feature matrix based on the common features;
[0032] Inputting the first feature matrix and the second feature matrix into the bidirectional cross attention network to be trained, and updating the first feature matrix and the second feature matrix based on the bidirectional cross attention mechanism by the bidirectional cross attention network to be trained to obtain updated feature matrices corresponding to the first feature matrix and the second feature matrix respectively;
[0033] A gas concentration identification result for the gas is determined based on the updated characteristic matrix corresponding to the first characteristic matrix, and a gas component identification result for the gas is determined based on the updated characteristic matrix corresponding to the second characteristic matrix.
[0034] In an exemplary embodiment, determining loss information based on a gas concentration identification result and a gas component identification result of any gas includes:
[0035] Determining mean square error loss information based on a gas concentration identification result of any gas, and determining cross entropy loss information based on a gas component identification result of any gas;
[0036] The mean square error loss information and the cross entropy loss information are weighted to obtain the loss information.
[0037] A gas recognition device based on multi-task learning temporal convolutional network and bidirectional cross attention network, comprising:
[0038] An acquisition module is used to acquire a gas response curve output by the gas sensor for the gas to be detected, and generate a response characteristic time series corresponding to the gas response curve based on the gas response curve; the response characteristic time series includes the gas response characteristics of the gas response curve in each response segment;
[0039] An extraction module is configured to input the response feature time series into a shared feature extraction layer in the temporal convolutional network of the gas recognition model, and extract common features based on the response feature time series through the shared feature extraction layer; the common features represent the common information between the response segments of the gas response curve;
[0040] An output module, configured to input the common features into a concentration identification task output layer and a component identification task output layer in the temporal convolutional network, respectively, and output a first feature matrix based on the common features through the concentration identification task output layer, and output a second feature matrix based on the common features through the component identification task output layer;
[0041] An updating module is configured to input the first feature matrix and the second feature matrix into a bidirectional cross attention network of a gas recognition model, and update the first feature matrix and the second feature matrix based on a bidirectional cross attention mechanism through the bidirectional cross attention network to obtain updated feature matrices corresponding to the first feature matrix and the second feature matrix respectively;
[0042] The determination module is used to determine the gas concentration identification result for the gas to be detected based on the updated characteristic matrix corresponding to the first characteristic matrix, and to determine the gas component identification result for the gas to be detected based on the updated characteristic matrix corresponding to the second characteristic matrix.
[0043] A computer device includes a memory and a processor, wherein the memory stores a computer program and the processor implements the steps of the above method when executing the computer program.
[0044] A computer-readable storage medium stores a computer program, which implements the steps of the above method when executed by a processor.
[0045] A computer program product comprises a computer program, which implements the steps of the above method when executed by a processor.
[0046] The above-mentioned gas identification method, device, computer equipment, storage medium and computer program product based on multi-task learning temporal convolutional network and bidirectional cross attention network obtains the gas response curve output by the gas sensor for the gas to be detected, and generates a response feature time series according to the gas response curve; the response feature time series includes the gas response features of the gas response curve in each response segment; the response feature time series is input into the shared feature extraction layer in the temporal convolutional network of the gas identification model, and the shared feature extraction layer extracts the common features based on the response feature time series; the common features characterize the common information between each response segment; the common features are respectively input into the concentration identification task output layer and the component identification task output layer in the temporal convolutional network, and the concentration identification task output layer outputs a first feature matrix based on the common features, and the component identification task output layer outputs a second feature matrix based on the common features; the first feature matrix and the second feature matrix are input into the bidirectional cross attention network of the gas identification model, and the bidirectional cross attention network performs the bidirectional cross attention mechanism on the first feature matrix. The matrix and the second feature matrix are updated to obtain updated feature matrices corresponding to the first feature matrix and the second feature matrix respectively; based on the updated feature matrix corresponding to the first feature matrix, the gas concentration recognition result for the gas to be detected is determined, and, based on the updated feature matrix corresponding to the second feature matrix, the gas component recognition result for the gas to be detected is determined; in this way, firstly, based on the temporal modeling capability of the temporal convolutional network, the gas time characteristics can be accurately extracted, wherein, through the shared feature extraction layer of the temporal convolutional network, information sharing and parameter sharing between different tasks are realized, further enhancing the task synergy effect, through the concentration recognition task output layer and the component recognition task output layer of the temporal convolutional network, while realizing the sharing of underlying features, it is realized to provide an exclusive output layer for each recognition task, thereby improving the parameter utilization efficiency, and then, through the bidirectional cross attention network, the bidirectional cross attention mechanism is introduced to enhance the information interaction between the first feature matrix and the second feature matrix, thereby improving the component recognition accuracy and concentration recognition accuracy, and being able to perform accurate component recognition and concentration recognition of the gas to be detected. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0048] Figure 1 FIG2 is an application environment diagram of a gas recognition method based on a multi-task learning temporal convolutional network and a bidirectional cross attention network in one embodiment;
[0049] Figure 2 1 is a flow chart of a gas recognition method based on multi-task learning temporal convolutional network and bidirectional cross attention network in one embodiment;
[0050] Figure 3 Schematic diagram of a flow chart of a gas recognition method based on multi-task learning temporal convolutional network and bidirectional cross attention network in another embodiment;
[0051] Figure 4 A flow chart of a method for training a gas recognition model in one embodiment;
[0052] Figure 5 is a schematic diagram of a time-response curve of a gas sensor array according to an embodiment;
[0053] Figure 6 is a schematic diagram of a data preprocessing process for a gas response curve sample set in one embodiment;
[0054] Figure 7 is a schematic diagram of a model architecture of a gas identification model in one embodiment;
[0055] Figure 8 Schematic diagram of loss curves and evaluation indicators for different model training methods in one embodiment;
[0056] Figure 9 A schematic diagram of performance analysis results of a gas identification model in one embodiment;
[0057] Figure 10 A schematic diagram comparing the classification accuracy and regression prediction accuracy of a gas identification model and other basic models in one embodiment;
[0058] Figure 11 Schematic diagram showing a comparison of the regression performance and classification performance of two models under different data lengths in one embodiment;
[0059] Figure 12 is a flow chart of a method for training a gas recognition model in another embodiment;
[0060] Figure 13 1 is a structural block diagram of a gas identification device based on a multi-task learning temporal convolutional network and a bidirectional cross attention network in one embodiment;
[0061] Figure 14 is a structural block diagram of a training device for a gas identification model in one embodiment;
[0062] Figure 15 FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0063] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0064] The gas recognition method based on multi-task learning time convolutional network and bidirectional cross attention network provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The server 104 obtains the gas response curve output by the gas sensor for the gas to be detected, and generates a response feature time series based on the gas response curve; the response feature time series includes the gas response characteristics of the gas response curve in each response segment; the server 104 inputs the response feature time series into the shared feature extraction layer in the time convolution network of the gas recognition model, and extracts common features based on the response feature time series through the shared feature extraction layer; the common features represent the common information between each response segment; the server 104 inputs the common features into the concentration recognition task output layer and the component recognition task output layer in the time convolution network, and the concentration recognition task output layer extracts the common features based on the common features. The first feature matrix is output by the component identification task output layer, and a second feature matrix is output based on the common features. The server 104 inputs the first and second feature matrices into the bidirectional cross-attention network of the gas identification model. The bidirectional cross-attention network updates the first and second feature matrices based on the bidirectional cross-attention mechanism, obtaining updated feature matrices corresponding to the first and second feature matrices, respectively. The server 104 determines a gas concentration identification result for the gas to be detected based on the updated feature matrix corresponding to the first feature matrix, and determines a gas component identification result for the gas to be detected based on the updated feature matrix corresponding to the second feature matrix. The terminal 102 may be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices may include smart speakers, smart TVs, smart air conditioners, smart car devices, etc. Portable wearable devices may include smart watches, smart bracelets, head-mounted devices, etc. The server 104 may be implemented as a standalone server or a server cluster consisting of multiple servers.
[0065] In an exemplary embodiment, Figure 2As shown in the figure, a gas recognition method based on multi-task learning temporal convolutional network and bidirectional cross attention network is provided. Figure 1 The server 104 in the example is used for explanation, and the steps include the following steps S202 to S210.
[0066] in:
[0067] Step S202 , obtaining a gas response curve output by the gas sensor for the gas to be detected, and generating a response characteristic time series based on the gas response curve; the response characteristic time series includes the gas response characteristics of the gas response curve in each response segment.
[0068] The gas to be detected may refer to a gas with unknown gas composition and unknown gas concentration, and the gas may contain volatile organic compounds (VOCs).
[0069] The gas response curve may describe the response process of the gas sensor to changes in gas concentration.
[0070] Among them, the response characteristic time series includes the gas response characteristics of the gas response curve in each response segment. The response characteristic time series can be a series of response characteristic values corresponding to key time points arranged in chronological order during the response process of the gas sensor to changes in gas concentration. These key time points can correspond to each response segment, and these response characteristic values can correspond to the gas response characteristics.
[0071] Each response segment of the gas response curve can only be obtained after segmenting the gas response segment.
[0072] Optionally, the server obtains a gas response curve output by the gas sensor for the gas to be detected, and generates a response characteristic time series corresponding to the gas response curve based on the gas response curve.
[0073] In step S204, the response feature time series is input into the shared feature extraction layer in the temporal convolutional network of the gas recognition model. The shared feature extraction layer extracts common features based on the response feature time series. The common features represent the common information between the response segments.
[0074] Among them, the gas recognition model can refer to a model composed of a multi-task temporal convolutional network and a bidirectional cross attention mechanism.
[0075] In practical applications, the multi-task temporal convolutional network can adopt the TCN (Temporal Convolutional Network) network. The TCN (Temporal Convolutional Network) network can include multiple TCN-blocks. The TCN-block is also called the residual block, which is the core module of the TCN network.
[0076] Among them, the temporal convolutional network can include a shared feature extraction layer, a concentration identification task output layer and a component identification task output layer. The shared feature extraction layer, the concentration identification task output layer and the component identification task output layer can be constructed by one or more temporal convolutional network blocks respectively.
[0077] Among them, the shared feature extraction layer is the part of the temporal convolutional network used to extract common features from the response feature time series. The shared feature extraction layer will perform a series of convolution operations on the input response feature time series to extract common features that are useful for sequence modeling. The shared feature extraction layer is usually composed of multiple one-dimensional convolution operations and may be combined with technologies such as dilated convolution and weight normalization to enhance the network's ability to capture long-term dependencies in time series.
[0078] In practical applications, the shared feature extraction layer can be composed of multiple temporal convolutional network blocks.
[0079] The aforementioned temporal convolutional network (TCN) block is the core component of the TCN and consists of one-dimensional causal atrous convolution, batch normalization, a ReLU nonlinear activation function, and a residual structure. The computational flow of the TCN block is as follows: y = ReLU(BatchNorm(Conv1D(x))) + x; where x is a multidimensional feature matrix, and after passing through the TCN block, the output matrix y is obtained.
[0080] The temporal convolutional network block of this application introduces a one-dimensional causal dilated convolution to ensure that the output of the current time step t depends only on the current and previous inputs, avoiding future information leakage. The dilation rate is expanded layer by layer to effectively increase the receptive field, enabling the model to capture dependencies over a longer time range. At the same time, due to the scarcity of gas sensor data samples and the limited sample length, this application does not use the Dropout operation, but instead normalizes the input data by introducing batch normalization (BatchNorm) to stabilize the model training process and improve generalization capabilities. The nonlinear activation function ReLU is used to enhance the expressive power of the model and improve the nonlinear transformation capability of features. The residual connection alleviates the gradient vanishing problem through cross-layer jump connections, and improves the training effect of deep networks while deepening the number of network layers. Overall, the temporal convolutional network block is mainly used to process time series data, modeling long-term dependencies through causal convolution and dilated convolution, and combining residual connections and normalization mechanisms to improve the stability of training. The hyperparameter settings of the temporal convolutional network block of this application are shown in Table 1. The settings of the hyperparameters in Table 1 can be set according to the model running direction.
[0081] Table 1
[0082]
[0083] Among them, common features can refer to general features extracted from the response feature time series that can reflect the essential laws, patterns or attributes of the sequence. Common features are features that can be shared and utilized by multiple different recognition tasks after being extracted by the shared feature extraction layer. Common features will be further processed by subsequent network layers (such as the concentration recognition task output layer and the component recognition task output layer). Common features provide a common, preliminarily processed feature representation for downstream tasks, enabling the network to better understand and learn the laws in the sequence data, thereby achieving good performance in various sequence-related tasks.
[0084] Optionally, the server inputs the response feature time series into a shared feature extraction layer in a temporal convolutional network of the gas recognition model, and extracts common features from the response feature time series through the shared feature extraction layer.
[0085] In step S206, the common features are respectively input into the concentration recognition task output layer and the component recognition task output layer in the temporal convolutional network, and the first feature matrix is output based on the common features through the concentration recognition task output layer, and the second feature matrix is output based on the common features through the component recognition task output layer.
[0086] The concentration identification task output layer may be a neural network layer having the function of identifying the gas concentration of the gas to be detected.
[0087] The component identification task output layer may be a neural network layer having the function of identifying the gas components of the gas to be detected.
[0088] In practical applications, the output layer of the concentration recognition task and the output layer of the component recognition task can be constructed using one temporal convolutional network block respectively, or multiple ones can be used. There is no limit on the number of temporal convolutional network blocks used for the two.
[0089] The first feature matrix can refer to the feature matrix output by the concentration recognition task output layer after processing the common features, which can be expressed as T A .
[0090] The second feature matrix can refer to the feature matrix output by the component recognition task output layer after processing the common features, which can be expressed as T B .
[0091] Optionally, the server inputs the common features into the concentration recognition task output layer and the component recognition task output layer in the temporal convolutional network respectively, and outputs the first feature matrix T based on the common features through the concentration recognition task output layer. A , the second feature matrix T is output based on the common features through the component recognition task output layer B .
[0092] In step S208, the first feature matrix and the second feature matrix are input into the bidirectional cross attention network of the gas recognition model. The bidirectional cross attention network updates the first feature matrix and the second feature matrix based on the bidirectional cross attention mechanism to obtain updated feature matrices corresponding to the first feature matrix and the second feature matrix respectively.
[0093] Among them, the bidirectional cross attention network can be a neural network architecture that utilizes the bidirectional cross attention mechanism. The bidirectional cross attention network allows the two feature matrices to interact with each other and affect each other's feature extraction process. By calculating the mutual attention weights between the two feature matrices, it can capture the correlation and mutual dependence of the elements in the two feature matrices, thereby improving the model's understanding and processing capabilities of input data in multiple tasks.
[0094] The bidirectional cross-attention mechanism is an improved attention mechanism that enhances information interaction and fusion between two different feature spaces. This mechanism achieves bidirectional information flow by calculating the cross-attention weights of the two input feature matrices, thereby improving the model's ability to model complex correlated features.
[0095] Among them, the updated feature matrix corresponding to the first feature matrix can be expressed as
[0096] Among them, the updated feature matrix corresponding to the second feature matrix can be expressed as
[0097] Optionally, the server inputs the first feature matrix and the second feature matrix into the bidirectional cross attention network of the gas recognition model, and updates the first feature matrix and the second feature matrix based on the bidirectional cross attention mechanism through the bidirectional cross attention network to obtain the updated feature matrix corresponding to the first feature matrix The updated feature matrix corresponding to the second feature matrix
[0098] To facilitate understanding by those skilled in the art, step S208 is specifically expanded below. The specific calculation process of step S208 is as follows:
[0099] First, the first feature matrix T of the input is processed through the fully connected layer A and the second characteristic matrix T B Mapping is performed to obtain Query, Key and Value:
[0100] Q A =T A W Q ,K B =T B W K ,V B =T B W V ,
[0101] Q B =T B W Q ,K A =T A W K ,V A =T A W V ,
[0102] Where, T A , T B is the output of the gas concentration recognition task and the gas component recognition task, respectively. Q , W K , W V There are three learnable parameter matrices used to map the output of each task layer to obtain the corresponding Query, Key, and Value.
[0103] Then, cross attention is calculated for each task separately. Each calculation uses the query of one task and the key and value of another task to achieve information interaction. The cross attention calculation process is as follows:
[0104]
[0105] T′ A =Atten A V B ;
[0106] Where, Atten A Indicates T A How to focus on T at each time step B Each time step, and then through Atten A Dot product V B Get the fused task feature T′ A .
[0107] Finally, a residual connection is made to alleviate the vanishing gradient and improve model performance:
[0108]
[0109] You can follow the above T A The processing flow of T B to be processed.
[0110] The bidirectional cross-attention mechanism proposed in this application differs from traditional attention mechanisms in that traditional attention mechanisms typically perform weighted calculations only within the same feature domain, while the bidirectional cross-attention mechanism allows information to be transferred between two feature domains, enabling the model to capture the dependencies between different task features. This mechanism can effectively calculate the correlation between input features, allowing information to flow between different inputs, enhancing the ability to align different feature spaces, and is particularly suitable for multi-task learning scenarios.
[0111] Step S210 , determining a gas concentration identification result for the gas to be detected based on the updated characteristic matrix corresponding to the first characteristic matrix, and determining a gas component identification result for the gas to be detected based on the updated characteristic matrix corresponding to the second characteristic matrix.
[0112] The gas concentration identification result may include the gas concentration of each gas type in the gas to be detected.
[0113] The gas component identification result may include the gas component of the gas to be detected, that is, the gas type of the gas to be detected.
[0114] Optionally, the server is based on the updated feature matrix corresponding to the first feature matrix Determine the gas concentration in the gas to be detected, and the server updates the characteristic matrix corresponding to the second characteristic matrix Determine the gas composition of the gas to be detected.
[0115] In the above-mentioned gas identification method based on multi-task learning temporal convolutional network and bidirectional cross attention network, a response feature time series is generated according to the gas response curve by obtaining the gas response curve output by the gas sensor for the gas to be detected; the response feature time series includes the gas response features of the gas response curve in each response segment; the response feature time series is input into the shared feature extraction layer in the temporal convolutional network of the gas identification model, and the shared feature extraction layer is used to extract common features based on the response feature time series; the common features characterize the common information between each response segment; the common features are respectively input into the concentration identification task output layer and the component identification task output layer in the temporal convolutional network, and the concentration identification task output layer outputs a first feature matrix based on the common features, and the component identification task output layer outputs a second feature matrix based on the common features; the first feature matrix and the second feature matrix are input into the bidirectional cross attention network of the gas identification model, and the bidirectional cross attention network is used to process the first feature matrix and the second feature matrix based on the bidirectional cross attention mechanism. Update to obtain updated feature matrices corresponding to the first feature matrix and the second feature matrix respectively; based on the updated feature matrix corresponding to the first feature matrix, determine the gas concentration recognition result for the gas to be detected, and, based on the updated feature matrix corresponding to the second feature matrix, determine the gas component recognition result for the gas to be detected; in this way, first, based on the temporal modeling capability of the temporal convolutional network, the gas time characteristics can be accurately extracted, wherein, through the shared feature extraction layer of the temporal convolutional network, information sharing and parameter sharing between different tasks are realized, further enhancing the task synergy effect, through the concentration recognition task output layer and the component recognition task output layer of the temporal convolutional network, while realizing the sharing of underlying features, it is realized that an exclusive output layer is provided for each recognition task, thereby improving the parameter utilization efficiency, and then, through the bidirectional cross attention network, a bidirectional cross attention mechanism is introduced to enhance the information interaction between the first feature matrix and the second feature matrix, thereby improving the component recognition accuracy and concentration recognition accuracy, and being able to perform accurate component recognition and concentration recognition of the gas to be detected.
[0116] In an exemplary embodiment, a response characteristic time series is generated based on a gas response curve, including: segmenting the gas response curve to obtain curves corresponding to each response segment; for any response segment, determining, based on the curve corresponding to the response segment, the ratio of the data change within each time window in the response segment to the time window length, and using the curve data corresponding to the time window with the largest ratio as characteristic data of the response segment; and generating a response characteristic time series corresponding to the gas response curve based on the characteristic data of each response segment.
[0117] The time windows in the response segment may be obtained by dividing the response segment into time windows according to a preset step size and a preset window shift. In practical applications, the preset step size may be set to 0.5s.
[0118] The characteristic data of the response segment may correspond to the curve data of any time window in the response segment, and the most representative time window curve data may be used as the characteristic data of the response segment.
[0119] Optionally, the server segments the gas response curve to obtain curves corresponding to each response segment. For any response segment, the server determines the ratio of the data change within each time window in the response segment to the time window length based on the curve corresponding to the response segment, and selects the curve data corresponding to the time window with the largest ratio as the characteristic data of the response segment. The server generates a response characteristic time series corresponding to the gas response curve based on the characteristic data of each response segment.
[0120] To facilitate understanding by those skilled in the art, the following provides a method for determining characteristic data of a response segment. The specific process can be expressed as follows:
[0121]
[0122] Where t is the starting position of the time window, Δy t Indicates the total change of the response within the time window when the starting position is t, and w is the width of the time window. t The ratio of the total data change in the time window to the window width when the starting position is t. The starting position of the time window with the largest ratio is t max , the final feature data segment is expressed as:
[0123]
[0124] In this embodiment, the gas response curve is segmented to obtain curves corresponding to each response segment. For any response segment, the ratio of the data change within each time window in the response segment to the time window length is determined based on the curve corresponding to the response segment, and the curve data corresponding to the time window with the largest ratio is used as the characteristic data of the response segment. Based on the characteristic data of each response segment, a response characteristic time series corresponding to the gas response curve is generated. In this way, the response characteristic data of each response segment of the gas response curve can be accurately extracted, thereby generating a response characteristic time series that can represent the gas response curve.
[0125] In an exemplary embodiment, a gas response curve is segmented to obtain curves corresponding to each response segment, including: using a peak detection rule to determine the index of each local peak point in the gas response curve; generating an index set based on the index of each local peak point; determining the distance between the indexes of two adjacent local peak points in the index set, and generating a distance set based on the index distance between the indexes of two adjacent local peak points in the index set; obtaining a distance threshold for the distance set, and grouping each index distance in the distance set based on the distance threshold to obtain a local peak point grouping result; the local peak point grouping result includes at least one local peak point set; the index distance between the indexes of two adjacent local peak points in the same local peak point set is less than the distance threshold; determining the maximum local peak point index in each local peak point set, and generating a maximum local peak point index set based on the maximum local peak point index in each local peak point set; for any maximum local peak point index, determining the index range of each response segment based on a preset left offset and a preset right offset corresponding to the maximum local peak point index; and extracting the curve corresponding to each response segment from the gas response curve based on the index range of each response segment.
[0126] The peak detection rule may refer to a detection rule corresponding to a peak detection algorithm (find_peaks).
[0127] The local peak point may refer to a point in the gas response curve that is higher than its left and right adjacent points.
[0128] The index of the local peak point may refer to a position identifier of the local peak point in the gas response curve.
[0129] The index set includes the index of each local peak point, and the index set can be expressed as P = {p1, p2, ..., p n}, where each p j satisfy:
[0130] and
[0131] The distance between the indices of two adjacent local peak points in the index set can represent the appearance time difference between any two local peak points in the index set in the gas response curve.
[0132] The distance set includes the distance between the indexes of any two adjacent local peak points in the index set. The distance set can be expressed as D = {d1, d2, ..., d n-1},in:
[0133] d=p j+1 -p j , j∈[1,n-1].
[0134] Among them, the distance threshold can be expressed as d threshold ,The distance threshold is determined by the gas sampling frequency and the response recovery time of the gas sensor (the descending stage of the response curve).
[0135] The local peak point grouping result may include multiple local peak point sets, and the index distance between two adjacent local peak points in each local peak point set is less than the distance threshold d threshold , the grouping set G can be used to represent the local peak point grouping results:
[0136] G={g1,g2,…,g m},g={p k1 ,p k2 ,…,p kl},k∈[1,m];
[0137] It can be seen that the local peak points are divided into m groups (ie, m local peak point sets), each group includes l local peak points, and the number l of local peak points in each group can be different.
[0138] The maximum local peak point index in the local peak point set may refer to the index corresponding to the local peak point with the largest peak point among all the local peak points in the local peak point set. For example, for a local peak point set g, its corresponding maximum peak index p may be determined. max :
[0139]
[0140] The maximum local peak point index set may be a set consisting of the indexes of the maximum local peak points in each local peak point set, which can be expressed as
[0141] Among them, the preset left offset can be expressed as l offset , used to determine the left boundary of the response segment, the preset right offset can be expressed as r offset , used to determine the right boundary of the response fragment.
[0142] The index range of the response segment may refer to the position interval of the response segment in the gas response curve.
[0143] Optionally, the server finds the gas response data y through a peak detection algorithm (find_peaks) i The index of all local peak points, index set P = {p1, p2, ..., p n}, where each p j satisfy:
[0144] and
[0145] Then, the distance set D between the indexes of adjacent peak points is calculated = {d1, d2, ..., d n-1},in:
[0146] d=p j+1 -p j ,j∈[1,n-1];
[0147] Set the distance threshold d threshold , which is determined by the gas sampling frequency and the response recovery time of the gas sensor (the descending stage of the response curve), can be set to 600, which will satisfy d<d threshold Adjacent peaks are grouped into the same group, and the final grouping set G is:
[0148] G={g1,g2,…,g m},g={p k1 ,p k2 ,…,p kl},k∈[1,m];
[0149] Then, for each group g, find its corresponding maximum peak index p max :
[0150]
[0151] Generate maximum peak set
[0152] Then, the index p of each maximum peak point is max As a reference, set the left offset l offset With right offset r offset , determine the index range of each response fragment: [p max -l offset , p max +r offset ]; parameter l offset With r offset The determination strategy is: after determining the maximum peak point, its left side corresponds to the gas response phase, and the right side corresponds to the recovery phase. In this application, the response phase of the gas sensor lasts for 5 minutes (i.e., 600 sampling points). Because the data in the response phase will be fully used for feature extraction, in order to ensure the integrity of the data, offset Set to 700. At the beginning of the recovery phase, it is assumed that there is a "numerical feature" because the final response values of gases with different concentration ratios at the end of the response will be different. Therefore, r offset Set to 400;
[0153] Finally, the response fragment set S = {s1, s2, ..., s m}.
[0154] In this embodiment, the index of each local peak point in the gas response curve is determined by adopting a peak detection rule; an index set is generated based on the index of each local peak point; the distance between the indexes of two adjacent local peak points in the index set is determined, and a distance set is generated based on the index distance between the indexes of two adjacent local peak points in the index set; a distance threshold for the distance set is obtained, and each index distance in the distance set is grouped according to the distance threshold to obtain a local peak point grouping result; the local peak point grouping result includes at least one local peak point set; the index distance between the indexes of two adjacent local peak points in the same local peak point set is less than the distance threshold; the maximum value in each local peak point set is determined The local peak point index generates a maximum local peak point index set based on the maximum local peak point index in each local peak point set; for any maximum local peak point index, the index range of each response segment is determined based on the preset left offset and preset right offset corresponding to the maximum local peak point index; according to the index range of each response segment, the curve corresponding to each response segment is intercepted from the gas response curve; in this way, the local peak characteristics of the gas response data can be used in the data preprocessing stage to automatically segment the gas response curve, and feature data in a unified format can be generated in combination with the time window, which is conducive to extracting the typical features of the gas response curve of the gas to be detected and is conducive to accurate identification by the subsequent gas recognition model.
[0155] In another embodiment, Figure 3 As shown in the figure, a gas recognition method based on multi-task learning temporal convolutional network and bidirectional cross attention network is provided. Figure 1 Taking the server 104 in the example as an example, the following steps are included:
[0156] Step S302: obtaining a gas response curve output by the gas sensor for the gas to be detected.
[0157] Step S304: using a peak detection rule to determine the index of each local peak point in the gas response curve.
[0158] Step S306: Generate an index set based on the index of each local peak point.
[0159] Step S308 : determining the distance between the indexes of two adjacent local peak points in the index set, and generating a distance set according to the index distance between the indexes of two adjacent local peak points in the index set.
[0160] Step S310: Obtain a distance threshold for a distance set, group the index distances in the distance set according to the distance threshold, and obtain a local peak point grouping result; the local peak point grouping result includes at least one local peak point set; and the index distance between the indexes of two adjacent local peak points in the same local peak point set is less than the distance threshold.
[0161] Step S312 : determining the maximum local peak point index in each local peak point set, and generating a maximum local peak point index set according to the maximum local peak point index in each local peak point set.
[0162] Step S314 : For any maximum local peak point index, determine the index range of each response segment according to the preset left offset and the preset right offset corresponding to the maximum local peak point index.
[0163] Step S316 : extracting a curve corresponding to each response segment from the gas response curve according to the index range of each response segment.
[0164] Step S318: For any response segment, determine the ratio of the data variation within each time window in the response segment to the time window length based on the curve corresponding to the response segment, and use the curve data corresponding to the time window with the largest ratio as the feature data of the response segment.
[0165] Step S320 : generating a response characteristic time series corresponding to the gas response curve according to the characteristic data of each response segment; the response characteristic time series includes the gas response characteristics of the gas response curve in each response segment.
[0166] In step S322, the response feature time series is input into the shared feature extraction layer in the temporal convolutional network of the gas recognition model. The shared feature extraction layer extracts common features based on the response feature time series; the common features represent the common information between the response segments.
[0167] In step S324, the common features are respectively input into the concentration recognition task output layer and the component recognition task output layer in the temporal convolutional network, and the first feature matrix is output based on the common features through the concentration recognition task output layer, and the second feature matrix is output based on the common features through the component recognition task output layer.
[0168] In step S326, the first feature matrix and the second feature matrix are input into the bidirectional cross attention network of the gas recognition model. The bidirectional cross attention network updates the first feature matrix and the second feature matrix based on the bidirectional cross attention mechanism to obtain updated feature matrices corresponding to the first feature matrix and the second feature matrix respectively.
[0169] Step S328 : determining a gas concentration identification result for the gas to be detected based on the updated characteristic matrix corresponding to the first characteristic matrix, and determining a gas component identification result for the gas to be detected based on the updated characteristic matrix corresponding to the second characteristic matrix.
[0170] It should be noted that the specific limitations of the above steps can be found in the specific limitations of a gas recognition method based on a multi-task learning temporal convolutional network and a bidirectional cross attention network.
[0171] In an exemplary embodiment, Figure 4 As shown, a training method for a gas recognition model is provided, comprising:
[0172] Step S402, obtaining a gas response curve sample set; the gas response curve sample set includes multiple gas response curve sample subsets; different gas response curve sample subsets correspond to gas response curve test data sets of different gases; the gas response curve test data set corresponding to any gas includes multiple gas response test curves obtained after response testing of the gas at various gas concentrations.
[0173] Among them, the gas response curve sample set includes multiple gas response curve sample subsets, each gas response curve sample subset corresponds to a gas response curve test data set of a different gas, and the gas response curve test data set corresponding to each gas is a plurality of gas response test curves obtained after response testing of the gas at different gas concentrations.
[0174] In this application, a gas sensor is used to collect a gas response curve sample set. The material of the gas sensor used is SnO2. For specific sensor models and corresponding response gases, see Table 2. This application conducts gas response tests on 12 volatile organic compounds (VOCs), including acetone, methanol, ethanol, isopropanol, n-propanol, ethyl acetate, butyl acetate, ethylene glycol, toluene, xylene, benzaldehyde and ethane, to obtain a gas response curve sample set. The 12 volatile organic compounds (VOCs) correspond to 12 groups of gas experiments. In each group of experiments, only one gas is measured, and 10 concentration gradients are set from 10ppm (parts per million) to 100ppm, with a step size of 10ppm, to obtain 10 sensing responses. Each group of experiments is repeated at least 5 times, for a total of 600 gas sensing response data. In each group of experimental gas concentration gradient cyclic response tests, the gas sensor is exposed to the target gas for 5 minutes, and then recovered in the air for 5 minutes. The gas sampling frequency is 2Hz. In the gas experiment, the time-response curve of the gas sensor array is as follows Figure 5 shown. Figure 5(a)-(l) correspond to acetone, methanol, ethanol, isopropanol, n-propanol, ethyl acetate, butyl acetate, ethylene glycol, toluene, xylene, benzaldehyde and ethane, respectively. Figure 5 In the figure, the labels Sen.1-Sen.8 represent the gas response curves output by different types of sensors, the horizontal axis Time represents the time, and the vertical axis Response represents the response value s. The calculation formula for the response value s in the gas response curve is: R0 is the resistance of the gas sensor in air, and R is the resistance of the gas sensor in the measured gas.
[0175] Table 2
[0176]
[0177] Optionally, a gas response curve sample set is obtained by repeatedly performing experiments on 12 experimental gases using a gas sensor.
[0178] In the data preprocessing stage, this application automatically segments the continuous gas samples by utilizing the local peak characteristics of the gas response data, and generates sample data in a unified format by combining the time window. The data preprocessing process of the gas response curve sample set can be referred to Figure 6 , including the following four stages: response segment segmentation, feature selection, feature dimensionality reduction, and feature matrix normalization.
[0179] In the process of response segmentation, first, all local peaks of the gas response data need to be calculated and "classified" (peak indexes within the set threshold are grouped together); then, in each group of peak points, the peak with the largest index is selected as the benchmark based on the peak index size, and the left and right offsets are set to divide the response segments. The specific process is as follows: The gas response data y is found through the peak detection algorithm (find_peaks) i The index of all local peak points, index set P = {p1, p2, ..., p n}, where each p j satisfy: and Calculate the distance set D between adjacent peak indices = {d1, d2, ..., d n-1}, where: d = p j+1 -p j , j∈[1,n-1]; set the threshold d threshold (where d thresholdThe gas sampling frequency and the response recovery time of the gas sensor, i.e., the descending phase of the response curve, are determined by the gas sampling frequency. In the single-component VOCs gas dataset used in this application, the response recovery time of the gas sensor is 5 minutes, which is equivalent to 600 sampling points. Therefore, in each set of gas sensor responses, the distance between the indexes of the peak points should be less than 600), which will satisfy d<d threshold The adjacent peaks are grouped into the same group, and the final grouping set G is: G = {g1, g2, ..., g m}, g={p k1 , p k2 ,…,p kl}, k∈[1,m]; for each group g, find its corresponding maximum peak index p max : Maximum peak set Take the index p of each maximum peak point max As a reference, set the left offset l offset With right offset r offset , determine the index range of each response fragment: [p max -l offset , p max +r offset Finally, the response fragment set S = {s1, s2, ..., s m}, where parameter l offset With r offset The determination strategy is as follows: After determining the maximum peak point, its left side corresponds to the gas response phase, and the right side corresponds to the recovery phase. In the acquisition strategy of the application data set, the response phase of the gas sensor lasts for 5 minutes (i.e., 600 sampling points). Because the data in the response phase will be fully used for feature extraction, in order to ensure the integrity of the data, offset is set to 700. At the beginning of the recovery phase, we assume that there is a “numerical feature” because the final response values of gases with different concentration ratios will be different at the end of the response. Therefore, r offset Set to 400.
[0180] During the feature selection process, a time window with a step size of 0.5 seconds is used to slide along the time axis for the segmented response fragments. The time window feature selection logic is: calculate the ratio of the data change in the time window to the window width, and select the fragment with the largest ratio as the feature data. The time window width is set as a square term (such as n 2 The specific process is as follows: Among them, t is the starting position of the time window, Δy t It represents the total change of the response within the time window when the starting position is t, w is the width of the time window, R tThe ratio of the total data change in the time window to the window width when the starting position is t. The starting position of the time window with the largest ratio is t max The final feature data segment is: y tmax ={yi|t max ≤i<t max +w}.
[0181] During feature dimensionality reduction, since the gas sensor array consists of eight sensors, the acquired gas response data is an eight-dimensional time matrix. To improve model training efficiency and enhance feature representation, this application uses a multi-layer perceptron (MLP) to perform feature dimensionality reduction on the gas response data. The specific structure and parameter settings of the MLP are detailed in Table 3. After feature dimensionality reduction, the original eight-dimensional time matrix is compressed to six dimensions.
[0182] Table 3
[0183]
[0184] During the normalization of the feature matrix, the response fragment after dimensionality reduction Normalization is performed using the minimum-maximum method, and the formula is: Finally, the 600 samples were divided into five folds, each containing 120 samples. One fold was used as the test set, and the other four folds were used as the training set, with a training set to test set ratio of 4:1.
[0185] In step S404, the response characteristic time series corresponding to the gas response test curve of any gas at any gas concentration is input into the gas recognition model to be trained to obtain the gas concentration recognition result and the gas component recognition result for the gas; the response characteristic time series includes the gas response characteristics of the gas response test curve in each response segment.
[0186] Among them, the response characteristic time series corresponding to the gas response test curve of any gas at any gas concentration can be generated based on the gas response test curve of the gas at the gas concentration. The specific process is: segmenting the gas response test curve to obtain the curves corresponding to each response segment; for any response segment, based on the curve corresponding to the response segment, determining the ratio of the window data change amount of each time window in the response segment to the time window length, and taking the curve data corresponding to the time window with the largest ratio as the characteristic data of the response segment; based on the characteristic data of each response segment, generating the response characteristic time series corresponding to the gas response test curve. Among them, the specific process of segmenting the gas response test curve to obtain the curves corresponding to each response segment can refer to the specific process of "segmenting the gas response curve to obtain the curves corresponding to each response segment" in the previous embodiment.
[0187] The gas concentration recognition result may refer to the gas concentration of each gas component obtained by identifying the response characteristic time series of the gas response test curve of the gas by the gas recognition model to be trained.
[0188] The gas component identification result may refer to the gas component identified by the gas identification model to be trained based on the response characteristic time series of the gas response test curve of the gas.
[0189] Optionally, the server inputs the response characteristic time series corresponding to the gas response test curve of any gas at any gas concentration into the gas recognition model to be trained to obtain the gas component recognition result and the gas component recognition result for the gas.
[0190] Step S406: Determine loss information based on the gas concentration identification result and the gas component identification result of any gas.
[0191] The loss information may refer to a loss value determined based on the gas concentration recognition result and the gas component recognition result using the loss function of the gas recognition model to be trained.
[0192] Optionally, the server determines the loss information based on a difference between a gas component identification result of any gas and an actual gas component, and based on a difference between a gas concentration identification result of any gas and an actual gas concentration.
[0193] Step S408: training the gas recognition model to be trained based on the loss information.
[0194] Optionally, the server trains the gas recognition model to be trained based on the loss information until the model converges.
[0195] The training method of the above-mentioned gas recognition model obtains a gas response curve sample set; the gas response curve sample set includes multiple gas response curve sample subsets; different gas response curve sample subsets correspond to gas response curve test data sets of different gases; the gas response curve test data set corresponding to any gas includes multiple gas response test curves obtained after response testing of the gas at various gas concentrations; the response feature time series corresponding to the gas response test curve of any gas at any gas concentration is input into the gas recognition model to be trained to obtain the gas concentration recognition result and gas component recognition result for the gas; the response feature time series includes the gas response feature of the gas response test curve in each response segment; based on the gas concentration recognition result and gas component recognition result of any gas, the loss information is determined; based on the loss information, the gas recognition model to be trained is trained; in this way, a gas recognition model that accurately recognizes the component and concentration of the gas can be trained.
[0196] In an exemplary embodiment, the gas recognition model to be trained includes a time convolutional network to be trained and a bidirectional cross-attention network to be trained, the time convolutional network to be trained includes a shared feature extraction layer to be trained, a concentration recognition task output layer to be trained, and a component recognition task output layer to be trained, the response feature time series corresponding to the gas response test curve of any gas at any gas concentration is input into the gas recognition model to be trained, and the gas concentration recognition result and the gas component recognition result for the gas are obtained, including: inputting the response feature time series corresponding to the gas response test curve of any gas at any gas concentration into the shared feature extraction layer to be trained, extracting common features based on the response feature time series through the shared feature extraction layer to be trained; the common features represent the common information between each response segment. information; the common features are respectively input into the concentration recognition task output layer to be trained and the component recognition task output layer to be trained, and the concentration recognition task output layer to be trained outputs a first feature matrix based on the common features, and the component recognition task output layer to be trained outputs a second feature matrix based on the common features; the first feature matrix and the second feature matrix are input into the bidirectional cross attention network to be trained, and the bidirectional cross attention network to be trained updates the first feature matrix and the second feature matrix based on the bidirectional cross attention mechanism to obtain updated feature matrices corresponding to the first feature matrix and the second feature matrix respectively; based on the updated feature matrix corresponding to the first feature matrix, the gas concentration recognition result for the gas is determined, and based on the updated feature matrix corresponding to the second feature matrix, the gas component recognition result for the gas is determined.
[0197] The gas recognition model to be trained includes a time convolutional network to be trained and a bidirectional cross attention network to be trained. The time convolutional network to be trained includes a shared feature extraction layer to be trained, a concentration recognition task output layer to be trained, and a component recognition task output layer to be trained. For the model architecture of the gas recognition model, please refer to Figure 7 , Figure 7 (a) is the overall architecture of the gas identification model (MTL-TCBANet model). Figure 7 (b) is the specific structure of the temporal convolutional network block. Figure 7 (c) is a schematic diagram of the cross-attention mechanism. Figure 7 The gas recognition model shown in (a) includes a temporal convolutional network and a bidirectional cross-attention network. The temporal convolutional network includes a shared feature extraction layer (including three temporal convolutional network blocks TCN-Block), a concentration recognition task output layer (a temporal convolutional network block TCN-Block) and a component recognition task output layer (a temporal convolutional network block TCN-Block). Figure 7 The temporal convolutional network block shown in (b) consists of an input layer, a convolutional layer, a batch normalization layer, an activation layer, and an output layer. Figure 7 The input of the bidirectional cross attention mechanism shown in (c) is the first feature matrix T A and the second characteristic matrix T B , the output is the updated first feature matrix And the updated second characteristic matrix
[0198] In this application, the model backbone network hyperparameters of the gas recognition model are shown in Table 4, and the batch size is set to 20. In Table 4, C in Represents the number of features of the input matrix in the convolution operation; K represents the convolution kernel size; S represents the convolution step size; P represents the number of paddings for features during convolution. To maintain causality, only the input feature vector is left-padded, and the number of paddings is calculated based on the convolution kernel size and the dilation factor. This ensures that when performing convolution, the output only depends on the current moment and the previous moment, avoiding future information leakage; T A With T B They represent the outputs of the gas concentration identification task and the gas component identification task respectively.
[0199] Table 4
[0200]
[0201] Optionally, the server inputs the response feature time series corresponding to the gas response test curve of any gas at any gas concentration into the gas identification model to be trained. First, the response feature time series is input into the shared feature extraction layer to be trained. The shared feature extraction layer to be trained extracts common features based on the response feature time series to extract the common information between each response segment. Then, the server inputs the common features into the concentration identification task output layer to be trained and the component identification task output layer to be trained respectively. The concentration identification task output layer to be trained outputs a first feature matrix T based on the common features. A , the component recognition task output layer to be trained outputs the second feature matrix T based on the common features B , the server will first feature matrix T A and the second characteristic matrix T B Input to the bidirectional cross attention network to be trained, and the bidirectional cross attention network to be trained is based on the bidirectional cross attention mechanism to perform the first feature matrix T A and the second characteristic matrix T B Update to obtain the updated feature matrix corresponding to the first feature matrix The updated feature matrix corresponding to the second feature matrix The server is based on the updated feature matrix corresponding to the first feature matrix Determine the gas concentration identification result Gas Concentration for the gas, and the updated feature matrix corresponding to the second feature matrix Determine the gas component identification result Gas Component for the gas.
[0202] In this embodiment, the response feature time series corresponding to the gas response test curve of any gas at any gas concentration is input into the shared feature extraction layer to be trained, and the shared feature extraction layer to be trained is used to extract common features based on the response feature time series; the common features characterize the common information between each response segment; the common features are respectively input into the concentration recognition task output layer to be trained and the component recognition task output layer to be trained, and the concentration recognition task output layer to be trained outputs a first feature matrix based on the common features, and the component recognition task output layer to be trained outputs a second feature matrix based on the common features; the first feature matrix and the second feature matrix are input into the bidirectional cross attention network to be trained, and the bidirectional cross attention network to be trained is used to update the first feature matrix and the second feature matrix based on the bidirectional cross attention mechanism to obtain the updated feature matrices corresponding to the first feature matrix and the second feature matrix. feature matrix; based on the updated feature matrix corresponding to the first feature matrix, the gas concentration recognition result for the gas is determined, and, based on the updated feature matrix corresponding to the second feature matrix, the gas component recognition result for the gas is determined; in this way, during the training process, efficient information exchange is carried out between the gas component recognition task and the gas concentration recognition task, and the learning effect of the gas time characteristics is improved through the temporal modeling capability of the temporal convolutional network. The information interaction between different features is enhanced through the bidirectional cross-attention mechanism, thereby improving the gas component recognition accuracy and gas concentration prediction performance. In addition, the bidirectional cross-attention network further enhances the task synergy effect through information sharing and parameter sharing between tasks. In addition, a dedicated network layer is designed for each recognition task after the shared feature extraction layer of the temporal convolutional network, which improves the parameter utilization efficiency and provides an efficient and reliable solution for scenarios with limited resources and the need for rapid recognition.
[0203] In an exemplary embodiment, loss information is determined based on the gas concentration identification result and the gas component identification result of any gas, including: determining mean square error loss information based on the gas concentration identification result of any gas, and determining cross entropy loss information based on the gas component identification result of any gas; and weighting the mean square error loss information and the cross entropy loss information to obtain loss information.
[0204] The cross entropy loss information may be a loss value determined by using a cross entropy loss function in the classification task of the gas component identification task.
[0205] The mean square error loss information may be a loss value determined by using a mean square error loss function in the regression task of the gas concentration identification task.
[0206] Optionally, the server determines a mean square error loss value based on the gas concentration identification result of any gas, and determines a cross entropy loss value based on the gas component identification result of any gas. The server weights the mean square error loss information and the cross entropy loss information to obtain loss information.
[0207] In this application, all experimental results are the average values after 5-fold cross validation. The gas component identification task is a 12-classification task, while the gas concentration identification task is a single-output regression task. Different tasks correspond to different loss functions. For the gas component identification task, cross entropy is used as the training loss; for the gas concentration identification task, mean square error is selected as the training loss. Since the value of the cross entropy loss is between [0,1] and the mean square error has no upper limit, the numerical difference between the two is large, and direct addition will make the cross entropy loss have little effect on the final loss. Therefore, this application introduces a learnable parameter to dynamically weight the losses of each part to balance the numerical differences between different loss functions. Specifically, two learnable parameters are defined: the learnable parameter σ for the classification task ci and the learnable parameters σ for the regression task crp These parameters can be dynamically optimized using the gradient descent method of the neural network, and the final total loss function is defined as follows:
[0208] TotalLoss=σ ci Loss ci +σ crp Loss crp ;
[0209] Where TotalLoss is the final total loss of the gas identification model, Loss ci is the training loss of the classification task, Loss crp is the training loss for the regression task. This adaptive mechanism solves the problem of large differences in the values of different loss values, allowing all tasks to be effectively optimized during training and ensuring the stability of the model. Figure 8 The loss curves and evaluation indicators during training and verification using the dynamic weighted loss function (Dynamic Weight) and directly superimposing the losses of each part (Directly Overlaid) are shown. Figure 8 (a) shows the mean square error loss MSELoss of the concentration prediction task during training. Figure 8 (b) shows the R of the concentration prediction task during the validation process. 2 Fraction, Figure 8(c) is the cross entropy loss CrossEntropyLoss of the component recognition task during training. Figure 8 (d) shows the accuracy of the component identification task during the verification process. Figure 8 In (a) and (b), although the model using the loss function of directly superimposing the losses of each part converges faster in the early stage, its R 2 The score is lower than that of using a dynamically weighted loss function. Figure 8 In Figures (b) and (d), both the convergence speed during training and the classification performance of the model in the validation phase show that the model using the dynamic weighted loss function has a higher accuracy rate in the component identification task and a higher R score in the concentration prediction task. 2 Specifically, the dynamic weighted loss function is better than the loss function that directly adds the losses of each part. 2 The score increased by 2 percentage points and the accuracy increased by 2 percentage points.
[0210] In this embodiment, the mean square error loss information is determined based on the gas concentration identification result of any gas, and the cross entropy loss information is determined based on the gas component identification result of any gas; the mean square error loss information and the cross entropy loss information are weighted to obtain loss information; in this way, the loss information of each part can be dynamically weighted to balance the numerical differences between different loss functions, which is conducive to accurately training the gas recognition model and obtaining a gas recognition model that can accurately identify gas components and gas concentrations.
[0211] To facilitate the understanding of those skilled in the art, the following provides the performance analysis results of the gas identification model of this application. The experimental results include two parts: gas component identification (classification task) and gas concentration prediction (regression task), such as Figure 9 After 5-fold cross-validation, the model showed excellent recognition performance on these two tasks, with an accuracy of 95.50% for the classification task and R of 95.50% for the regression task. 2 The score is 0.93. Table 5 records the four main evaluation indicators of classification and regression tasks and their corresponding standard errors.
[0212] Table 5
[0213]
[0214] The following shows the performance comparison between the gas identification model of this application and the basic model:
[0215] First, a systematic comparison is made between the gas identification model of this application and the basic model. Specifically, a systematic comparison is made between a variety of mainstream machine learning and deep learning models, covering traditional machine learning methods (such as KNN nearest neighbor algorithm, support vector machine SVM, random forest RF) and deep neural networks (such as RNN, LSTM, CNN and TF, TF stands for Transformer model). The experimental results show that the gas identification model of this application is superior to other basic models in terms of classification accuracy and regression prediction accuracy. The experimental results are shown in Figure 10 ,The specific performance of each model is shown in Table 6.
[0216] Table 6
[0217]
[0218] Secondly, to verify the advantages of multi-task learning over single-task learning in simultaneously performing gas component identification and gas concentration identification, the TCBANet model was improved by removing the cross-fusion module and splitting the network into two parts: TCBA-C and TCBA-R, which independently perform gas component identification and gas concentration identification, respectively. The performance comparison of the three models is shown in Table 7.
[0219] Table 7
[0220]
[0221] The experimental results show that the multi-task model performs better than the single-task model in terms of overall performance. 2 The score increased by 2 percentage points; in the classification task, the accuracy of the multi-task model increased by 1 percentage point.
[0222] In addition, when determining the training samples, this application sets different time window widths, including the square of 11, 12, 13, 14, 15, 16, 17, 19, 21, 23, 25, and 27, in order to determine the optimal training sample length, and conducts comparative experiments with convolutional neural networks (CBCANet) and TCBANet. The results show that when the sample length is 192 (ie, 361 sample points), the performance of the model is equivalent to that when the sample length is 272 (ie, 729 sample points). This shows that appropriately shortening the sample length will not only not significantly reduce the prediction accuracy of the model, but can significantly improve the operating efficiency of the model. The experimental results are as follows Figure 11 shown. Figure 11 (a) shows the regression performance of the two models under different data lengths. Figure 11 (b) shows the classification performance of the two models under different data lengths.
[0223] Finally, to verify whether the temporal convolutional network block, dynamic weighted loss function, and bidirectional cross-attention mechanism in MTL-TCBANet improve model performance, a series of ablation experiments were conducted, as shown in Table 8. By replacing the temporal convolutional network block with a standard one-dimensional convolution (no TCNBlock), the experiment verified the temporal convolutional network block's effectiveness in capturing long-term dependencies; replacing the dynamic weighted loss function with a direct summation of the losses (no loss) to test the effectiveness of the dynamic weighting mechanism in balancing the numerical differences in losses across different tasks; and removing the bidirectional cross-attention mechanism (no attention) to verify its improved information flow and capture of cross-task dependencies. These ablation experiments provide a comprehensive understanding of the contribution of each component mechanism to the model and further confirm the impact of each improvement method on performance.
[0224] Table 8
[0225]
[0226] Ablation experiments show that when the temporal convolutional network block is removed, the model's regression performance and classification accuracy both decrease, indicating that the temporal convolutional network block plays an important role in capturing long-term dependencies. After replacing the dynamic weighted loss function with a direct summation of the losses, the model's regression performance and classification accuracy both decrease, verifying the importance of the dynamic weighted loss function in balancing the difference in loss values between tasks. When the bidirectional cross-attention mechanism is removed, the model's regression performance decreases significantly, indicating that this mechanism plays a significant role in promoting information flow and improving the ability to capture cross-task dependencies. Ablation experiments show that adding the temporal convolutional network block, the dynamic weighted loss function, and the bidirectional cross-attention mechanism have a significant effect on improving model performance.
[0227] In another embodiment, Figure 12 As shown in the figure, a gas recognition method based on multi-task learning temporal convolutional network and bidirectional cross attention network is provided. Figure 1 Taking the server 104 in the example as an example, the following steps are included:
[0228] Step S1202, obtaining a gas response curve sample set; the gas response curve sample set includes multiple gas response curve sample subsets; different gas response curve sample subsets correspond to gas response curve test data sets of different gases; the gas response curve test data set corresponding to any gas includes multiple gas response test curves obtained after response testing of the gas at various gas concentrations.
[0229] In step S1204, the response feature time series corresponding to the gas response test curve of any gas at any gas concentration is input into the shared feature extraction layer to be trained, and the shared feature extraction layer to be trained extracts common features based on the response feature time series; the common features represent the common information between each response segment; the response feature time series includes the gas response features of the gas response test curve in each response segment.
[0230] In step S1206, the common features are respectively input into the concentration recognition task output layer to be trained and the component recognition task output layer to be trained, and the concentration recognition task output layer to be trained outputs a first feature matrix based on the common features, and the component recognition task output layer to be trained outputs a second feature matrix based on the common features.
[0231] In step S1208, the first feature matrix and the second feature matrix are input into the bidirectional cross-attention network to be trained. The bidirectional cross-attention network to be trained updates the first feature matrix and the second feature matrix based on the bidirectional cross-attention mechanism to obtain updated feature matrices corresponding to the first feature matrix and the second feature matrix respectively.
[0232] Step S1210 : determining a gas concentration identification result for the gas based on the updated characteristic matrix corresponding to the first characteristic matrix, and determining a gas component identification result for the gas based on the updated characteristic matrix corresponding to the second characteristic matrix.
[0233] Step S1212: Determine loss information based on the gas concentration identification result and the gas component identification result of any gas.
[0234] Step S1214: training the gas recognition model to be trained based on the loss information.
[0235] It should be noted that the specific limitations of the above steps can be found in the specific limitations of a gas recognition method based on a multi-task learning temporal convolutional network and a bidirectional cross attention network.
[0236] It should be understood that, although the various steps in the flowcharts involved in the various embodiments described above are displayed in sequence according to the instructions of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the various embodiments described above can include multiple steps or multiple stages, and these steps or stages are not necessarily executed and completed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of steps or stages in other steps.
[0237] Based on the same inventive concept, an embodiment of the present application also provides a gas identification device based on a multi-task learning temporal convolutional network and a bidirectional cross-attention network for implementing the above-mentioned gas identification method based on a multi-task learning temporal convolutional network and a bidirectional cross-attention network. The implementation solution provided by the device to solve the problem is similar to the implementation solution described in the above-mentioned method. Therefore, the specific limitations of one or more embodiments of the gas identification device based on a multi-task learning temporal convolutional network and a bidirectional cross-attention network provided below can be referred to the limitations of the gas identification method based on a multi-task learning temporal convolutional network and a bidirectional cross-attention network above, and will not be repeated here.
[0238] In an exemplary embodiment, Figure 13 As shown, a gas identification device based on a multi-task learning temporal convolutional network and a bidirectional cross attention network is provided, comprising: an acquisition module 1302, an extraction module 1304, an output module 1306, an update module 1308 and a determination module 1310, wherein:
[0239] An acquisition module 1302 is configured to acquire a gas response curve output by the gas sensor for the gas to be detected, and generate a response characteristic time series corresponding to the gas response curve based on the gas response curve; the response characteristic time series includes the gas response characteristics of each response segment of the gas response curve;
[0240] Extraction module 1304 is configured to input the response feature time series into a shared feature extraction layer in the temporal convolutional network of the gas recognition model, and extract common features based on the response feature time series through the shared feature extraction layer; the common features represent the common information between the response segments of the gas response curve;
[0241] Output module 1306, configured to input the common features into the concentration identification task output layer and the component identification task output layer in the temporal convolutional network, respectively, and output a first feature matrix based on the common features through the concentration identification task output layer, and output a second feature matrix based on the common features through the component identification task output layer;
[0242] An updating module 1308 is configured to input the first feature matrix and the second feature matrix into a bidirectional cross attention network of a gas recognition model, and update the first feature matrix and the second feature matrix through the bidirectional cross attention network based on a bidirectional cross attention mechanism to obtain updated feature matrices corresponding to the first feature matrix and the second feature matrix respectively.
[0243] The determination module 1310 is configured to determine a gas concentration identification result for the gas to be detected based on the updated characteristic matrix corresponding to the first characteristic matrix, and to determine a gas component identification result for the gas to be detected based on the updated characteristic matrix corresponding to the second characteristic matrix.
[0244] In an exemplary embodiment, the acquisition module 1302 is used to segment the gas response curve to obtain curves corresponding to each response segment; for any response segment, based on the curve corresponding to the response segment, the ratio of the data change within each time window in the response segment to the time window length is determined, and the curve data corresponding to the time window with the largest ratio is used as the characteristic data of the response segment; based on the characteristic data of each response segment, a response characteristic time series corresponding to the gas response curve is generated.
[0245] In an exemplary embodiment, the acquisition module 1302 is used to determine the index of each local peak point in the gas response curve using a peak detection rule; generate an index set based on the index of each local peak point; determine the distance between the indexes of two adjacent local peak points in the index set, and generate a distance set based on the index distance between the indexes of two adjacent local peak points in the index set; obtain a distance threshold for the distance set, and group each index distance in the distance set based on the distance threshold to obtain a local peak point grouping result; the local peak point grouping result includes at least one local peak point set; the index distance between the indexes of two adjacent local peak points in the same local peak point set is less than the distance threshold; determine the maximum local peak point index in each local peak point set, and generate a maximum local peak point index set based on the maximum local peak point index in each local peak point set; for any maximum local peak point index, determine the index range of each response segment based on a preset left offset and a preset right offset corresponding to the maximum local peak point index; and extract the curve corresponding to each response segment from the gas response curve based on the index range of each response segment.
[0246] Each module in the aforementioned gas identification device based on a multi-task learning temporal convolutional network and a bidirectional cross-attention network can be implemented in whole or in part through software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in hardware form, or stored in a computer device memory in software form, so that the processor can call and execute the corresponding operations of each module.
[0247] Based on the same inventive concept, embodiments of the present application also provide a gas recognition model training device for implementing the aforementioned gas recognition model training method. The solution provided by this device is similar to the solution described in the aforementioned method. Therefore, the specific limitations of the one or more gas recognition model training device embodiments provided below can be found in the limitations of the gas recognition model training method described above and will not be further elaborated here.
[0248] In an exemplary embodiment, Figure 14 As shown, a training device for a gas identification model is provided, comprising: a sample acquisition module 1402, a sample input module 1404, a loss information determination module 1406 and a model training module 1408, wherein:
[0249] Sample acquisition module 1402 is configured to acquire a gas response curve sample set; the gas response curve sample set includes multiple gas response curve sample subsets; different gas response curve sample subsets correspond to gas response curve test data sets for different gases; the gas response curve test data set corresponding to any gas includes multiple gas response test curves obtained after response testing of the gas at various gas concentrations;
[0250] The sample input module 1404 is configured to input a response feature time series corresponding to a gas response test curve of any gas at any gas concentration into the gas recognition model to be trained, thereby obtaining a gas concentration recognition result and a gas component recognition result for the gas; the response feature time series includes the gas response feature of each response segment of the gas response test curve;
[0251] a loss information determination module 1406 for determining loss information based on a gas concentration identification result and a gas component identification result of any gas;
[0252] The model training module 1408 is used to train the gas recognition model to be trained based on the loss information.
[0253] In an exemplary embodiment, the gas identification model to be trained includes a time convolutional network to be trained and a bidirectional cross-attention network to be trained. The time convolutional network to be trained includes a shared feature extraction layer to be trained, a concentration identification task output layer to be trained, and a component identification task output layer to be trained. The sample input module 1404 is specifically used to input the response feature time series corresponding to the gas response test curve of any gas at any gas concentration into the shared feature extraction layer to be trained, and extract common features based on the response feature time series through the shared feature extraction layer to be trained; the common features represent the common information between each response segment; the common features are respectively input into the concentration identification task output layer to be trained and the component identification task output layer to be trained. The component identification task output layer outputs a first feature matrix based on the common features through the concentration identification task output layer to be trained, and outputs a second feature matrix based on the common features through the component identification task output layer to be trained; the first feature matrix and the second feature matrix are input into the bidirectional cross-attention network to be trained, and the first feature matrix and the second feature matrix are updated based on the bidirectional cross-attention mechanism through the bidirectional cross-attention network to be trained to obtain updated feature matrices corresponding to the first feature matrix and the second feature matrix respectively; based on the updated feature matrix corresponding to the first feature matrix, the gas concentration identification result for the gas is determined, and based on the updated feature matrix corresponding to the second feature matrix, the gas component identification result for the gas is determined.
[0254] In an exemplary embodiment, the loss information determination module 1406 is specifically used to determine the mean square error loss information based on the gas concentration identification result of any gas, and to determine the cross entropy loss information based on the gas component identification result of any gas; and to perform weighted processing on the mean square error loss information and the cross entropy loss information to obtain the loss information.
[0255] Each module in the aforementioned gas recognition model training device can be implemented in whole or in part through software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor within a computer device in hardware form, or can be stored in a computer device memory in software form, so that the processor can call and execute the corresponding operations of each module.
[0256] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Figure 15As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O) and a communication interface. The processor, memory and input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The database of the computer device is used to store gas recognition data based on a multi-task learning time convolutional network and a bidirectional cross attention network, and training data of a gas recognition model. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a gas recognition method based on a multi-task learning time convolutional network and a bidirectional cross attention network and a training method of a gas recognition model are implemented.
[0257] Those skilled in the art will understand that Figure 15 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0258] In one embodiment, a computer device is provided, comprising a memory and a processor. The memory stores a computer program. When the computer program is executed by the processor, the processor performs the steps of the aforementioned method for gas identification based on multi-task learning of a temporal convolutional network and a bidirectional cross-attention network, and the method for training a gas identification model. The steps of the method for gas identification based on multi-task learning of a temporal convolutional network and a bidirectional cross-attention network, and the method for training a gas identification model may be the steps of the method for gas identification based on multi-task learning of a temporal convolutional network and a bidirectional cross-attention network, and the method for training a gas identification model in each of the aforementioned embodiments.
[0259] In one embodiment, a computer-readable storage medium is provided, storing a computer program. When executed by a processor, the computer program causes the processor to perform the steps of the aforementioned method for gas identification based on multi-task learning of a temporal convolutional network and a bidirectional cross-attention network, and the method for training a gas identification model. The steps of the method for gas identification based on multi-task learning of a temporal convolutional network and a bidirectional cross-attention network, and the method for training a gas identification model may be the steps of the method for gas identification based on multi-task learning of a temporal convolutional network and a bidirectional cross-attention network, and the method for training a gas identification model in each of the aforementioned embodiments.
[0260] In one embodiment, a computer program product is provided, comprising a computer program. When executed by a processor, the computer program causes the processor to perform the steps of the aforementioned method for gas identification based on multi-task learning of a temporal convolutional network and a bidirectional cross-attention network, and the method for training a gas identification model. The steps of the method for gas identification based on multi-task learning of a temporal convolutional network and a bidirectional cross-attention network, and the method for training a gas identification model may be the steps of the method for gas identification based on multi-task learning of a temporal convolutional network and a bidirectional cross-attention network, and the method for training a gas identification model in each of the aforementioned embodiments.
[0261] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory may include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processor involved in the various embodiments provided herein may be, but are not limited to, a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, and the like.
[0262] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0263] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.
Claims
1. A gas recognition method based on multi-task learning temporal convolutional network and bidirectional cross attention network, characterized in that: The method comprises: Obtaining a gas response curve output by the gas sensor for the gas to be detected, and generating a response characteristic time series based on the gas response curve; the response characteristic time series includes the gas response characteristics of each response segment of the gas response curve; Inputting the response feature time series into a shared feature extraction layer in a temporal convolutional network of a gas recognition model, and extracting common features based on the response feature time series through the shared feature extraction layer; the common features represent common information between the response segments; Inputting the common features into the concentration identification task output layer and the component identification task output layer in the temporal convolutional network respectively, outputting a first feature matrix based on the common features through the concentration identification task output layer, and outputting a second feature matrix based on the common features through the component identification task output layer; Inputting the first feature matrix and the second feature matrix into a bidirectional cross attention network of the gas recognition model, and updating the first feature matrix and the second feature matrix through the bidirectional cross attention network based on a bidirectional cross attention mechanism to obtain updated feature matrices corresponding to the first feature matrix and the second feature matrix respectively; Based on the updated characteristic matrix corresponding to the first characteristic matrix, a gas concentration identification result for the gas to be detected is determined; and based on the updated characteristic matrix corresponding to the second characteristic matrix, a gas component identification result for the gas to be detected is determined.
2. The method according to claim 1, characterized in that Generating a response characteristic time series according to the gas response curve includes: Slicing the gas response curve to obtain curves corresponding to each response segment; For any of the response segments, determining the ratio of the data variation within each time window in the response segment to the time window length based on the curve corresponding to the response segment, and using the curve data corresponding to the time window with the largest ratio as the characteristic data of the response segment; A response characteristic time series corresponding to the gas response curve is generated according to the characteristic data of each response segment.
3. The method according to claim 2, characterized in that The gas response curve is segmented to obtain curves corresponding to the response segments, including: Using a peak detection rule, determining the index of each local peak point in the gas response curve; Generate an index set according to the index of each local peak point; Determine the distance between the indexes of two adjacent local peak points in the index set, and generate a distance set according to the index distance between the indexes of the two adjacent local peak points in the index set; Obtaining a distance threshold for the distance set, and grouping the index distances in the distance set according to the distance threshold to obtain a local peak point grouping result; the local peak point grouping result includes at least one local peak point set; and an index distance between indexes of two adjacent local peak points in the same local peak point set is less than the distance threshold; Determining a maximum local peak point index in each of the local peak point sets, and generating a maximum local peak point index set according to the maximum local peak point index in each of the local peak point sets; For any of the maximum local peak point indexes, determining an index range of each of the response segments according to a preset left offset and a preset right offset corresponding to the maximum local peak point index; According to the index range of each response segment, a curve corresponding to each response segment is extracted from the gas response curve.
4. A method for training a gas recognition model, characterized in that: The method comprises: Acquire a gas response curve sample set; the gas response curve sample set includes a plurality of gas response curve sample subsets; different gas response curve sample subsets correspond to gas response curve test data sets of different gases; the gas response curve test data set corresponding to any of the gases includes a plurality of gas response test curves obtained after response testing of the gas at various gas concentrations; Inputting a response characteristic time series corresponding to a gas response test curve of any of the gases at any of the gas concentrations into a gas recognition model to be trained to obtain a gas concentration recognition result and a gas component recognition result for the gas; the response characteristic time series includes the gas response characteristics of the gas response test curve at each response segment; determining loss information based on a gas concentration identification result and a gas component identification result of any of the gases; The gas recognition model to be trained is trained based on the loss information.
5. The method according to claim 4, characterized in that The gas identification model to be trained includes a time convolutional network to be trained and a bidirectional cross attention network to be trained. The time convolutional network to be trained includes a shared feature extraction layer to be trained, a concentration identification task output layer to be trained, and a component identification task output layer to be trained. The response feature time series corresponding to the gas response test curve of any of the gases at any of the gas concentrations is input into the gas identification model to be trained to obtain a gas concentration identification result and a gas component identification result for the gas, including: Inputting a response feature time series corresponding to a gas response test curve of any of the gases at any of the gas concentrations into the shared feature extraction layer to be trained, and extracting common features based on the response feature time series by the shared feature extraction layer to be trained; the common features represent common information between the response segments; Inputting the common features into the concentration identification task output layer to be trained and the component identification task output layer to be trained, respectively, outputting a first feature matrix based on the common features through the concentration identification task output layer to be trained, and outputting a second feature matrix based on the common features through the component identification task output layer to be trained; Inputting the first feature matrix and the second feature matrix into the bidirectional cross attention network to be trained, and updating the first feature matrix and the second feature matrix based on the bidirectional cross attention mechanism by the bidirectional cross attention network to be trained to obtain updated feature matrices corresponding to the first feature matrix and the second feature matrix respectively; A gas concentration identification result for the gas is determined based on the updated feature matrix corresponding to the first feature matrix, and a gas component identification result for the gas is determined based on the updated feature matrix corresponding to the second feature matrix.
6. The method according to claim 4, characterized in that The determining of loss information based on the gas concentration identification result and the gas component identification result of any of the gases includes: Determining mean square error loss information based on a gas concentration identification result of any of the gases, and determining cross entropy loss information based on a gas component identification result of any of the gases; The mean square error loss information and the cross entropy loss information are weighted to obtain the loss information.
7. A gas identification device based on multi-task learning temporal convolutional network and bidirectional cross attention network, characterized in that: The device comprises: an acquisition module, configured to acquire a gas response curve output by the gas sensor for a gas to be detected, and generate a response characteristic time series corresponding to the gas response curve based on the gas response curve; the response characteristic time series includes the gas response characteristics of each response segment of the gas response curve; an extraction module, configured to input the response feature time series into a shared feature extraction layer in a temporal convolutional network of a gas recognition model, and extract common features based on the response feature time series through the shared feature extraction layer; the common features represent common information between the response segments of the gas response curve; An output module, configured to input the common features into a concentration identification task output layer and a component identification task output layer in the temporal convolutional network, respectively, and output a first feature matrix based on the common features through the concentration identification task output layer, and output a second feature matrix based on the common features through the component identification task output layer; an updating module, configured to input the first feature matrix and the second feature matrix into a bidirectional cross attention network of the gas recognition model, and update the first feature matrix and the second feature matrix through the bidirectional cross attention network based on a bidirectional cross attention mechanism to obtain updated feature matrices corresponding to the first feature matrix and the second feature matrix respectively; A determination module is used to determine a gas concentration identification result for the gas to be detected based on the updated feature matrix corresponding to the first feature matrix, and to determine a gas component identification result for the gas to be detected based on the updated feature matrix corresponding to the second feature matrix.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Wind turbine generator fault early warning method, device and equipment and storage medium
CN118484655A
Video quality evaluation method and device, electronic equipment, storage medium, system and computer program product
CN118660151A
Method and apparatus for training a computer-implemented machine-learning model
EP4372617A1
Activity recognition method of LRF large-kernel attention convolution network based on large receptive field
US11989935B1