1. Introduction
With the rapid development of new energy vehicles and energy storage systems, safety accidents caused by lithium-ion battery (LIB) thermal runaway have become a critical concern in the industry [
1]. Compared with traditional schemes such as temperature, voltage, or impedance monitoring, monitoring characteristic gases (e.g., H
2, CO) released during the early stages of thermal runaway offers significant advantages [
2,
3,
4]. Studies indicate that the rapid detection of characteristic gas signals can secure precious early-warning time for safe evacuation and fault disposal [
5]. Among numerous gas detection technologies, metal-oxide semiconductor (MOS) sensors—characterized by high sensitivity [
6], rapid response, low cost, and ease of integration—are more suitable for long-term online monitoring than electrochemical or optical sensors [
7,
8]. Because the gases generated during thermal runaway are complex mixtures, a single sensor struggles to identify them accurately. Therefore, constructing a sensor array to simulate a biological olfactory system [
9,
10], thereby generating multidimensional response signals, has become an inevitable choice for precisely identifying characteristic gases in complex environments.
However, the inherent cross-sensitivity of MOS sensors presents a significant difficulty for the early and accurate identification of distinctive gases from battery thermal runaway [
11,
12]. The cross-sensitivity behavior of MOS gas sensors mainly originates from the competitive adsorption and surface reaction processes of different gas molecules on the sensing materials. During lithium-ion battery thermal runaway, multiple gases such as H
2, CO, and hydrocarbons are released simultaneously, and these gases may interact with the same active sites on the sensor surface, resulting in overlapping response patterns and reduced selectivity. In addition, the sensing characteristics of MOS sensors are strongly affected by environmental factors, including humidity, ambient temperature fluctuation, and long-term sensor aging. Variations in humidity can alter the adsorption state of oxygen species on the sensor surface, while temperature fluctuations may influence reaction kinetics and carrier transport behavior. Moreover, prolonged operation may gradually change the surface morphology and catalytic activity of sensing materials, causing response drift and degradation of sensor stability. These factors further increase the complexity of early thermal runaway gas detection and highlight the necessity of developing robust intelligent recognition algorithms for practical applications. Multiple components (such as H
2, CO, and hydrocarbon gases) are released concurrently during the thermal runaway process, and their signals strongly overlap on the sensors. This causes ambiguity in both the quantitative concentration analysis and the qualitative classification of various thermal runaway stages. Effective pattern-recognition algorithms are essential to overcoming this obstacle and achieving quick early warning [
13]. In order to effectively extract the compositional and concentration information of the distinctive gases amid complicated background interference, these algorithms must thoroughly mine the high-dimensional nonlinear data produced by the array [
14].
Initially, researchers relied on classic machine learning techniques like random forest (RF) and support vector machine (SVM) to solve static response feature extraction and simple gas categorization problems for sensor arrays [
15]. Although these models are resilient in small-sample tasks [
16,
17,
18], they fail to reflect the complex, dynamic evolutionary linkages in multi-sensor sequences when confronted with transitory response signals during the early phases of lithium-ion battery thermal runaway [
19]. Deep learning, on the other hand, has more significant algorithmic advantages, allowing for the accurate resolution of transient development patterns in the early stages of thermal runaway [
20].
Through gated recurrent units (GRUs), Long Short-Term Memory (LSTM) networks capture long-term temporal trends in characteristic gas generation, allowing the model to precisely detect the continuous accumulation patterns of gas concentrations under difficult settings [
21,
22]. In the meantime, the Self-Attention (SA) mechanism greatly improves identification sensitivity by allowing the model to precisely focus on the important gas features that contribute most to early warning amid the nonlinear signals resulting from multi-sensor cross-sensitivity through dynamic weight allocation [
23,
24]. In order to achieve highly sensitive identification of nine representative volatile organic compounds (VOCs) with a classification accuracy of 98.89%, Mao et al. [
25] proposed a nanoconfined-structure sensor array based on atomic layer deposition (ALD) technology and combined it with a CNN-LSTM-Attention hybrid deep learning model. By building a heterogeneous sensor array, Li et al. [
26] successfully eliminated H
2 interference and accomplished continuous monitoring of mixed gases (H
2, SO
2, CO) using a CNN-Transformer-LSTM model based on Time2Vec encoding. Its mean
for quantitative concentration prediction was 97.6%, while its qualitative identification accuracy was 97.0% In order to provide a wide receptive field and capture local mutation features produced by the sensor array during the violent reaction stage of thermal runaway, Temporal Convolutional Networks (TCNs) employ dilated convolutions. In order to obtain second-level early warnings, it is essential to capture the sudden spikes in the concentrations of distinctive gases like CO and H
2 [
27,
28]. By adding temporal attention and gating methods, Jia et al. [
29] suggested an enhanced attention-gated temporal convolutional network (AGT-TCN) to improve long-term prediction performance. Its root mean square error (RMSE) for predicting CO and CH
4 concentrations was as low as 0.138 and 0.170, respectively, according to experiments, greatly surpassing conventional TCN models. In order to accomplish high-precision monitoring of CO, ethylene, and methane mixtures, Liu et al. [
30] presented a LoRA-TCN pre-training/fine-tuning paradigm using low-rank adaptation technology. In the gas identification challenge, its classification accuracy was 98.24%, and the RMSE of its concentration prediction was as low as 0.113 A multi-head attention temporal convolutional network based on the PReLU activation function (PMH-TCN) was proposed by Zhuo et al. [
31] to predict mixed gas concentrations. According to the experimental data, the model’s prediction accuracy for CO and C
2H
4 was 98.71% and 98.81%, respectively, with a very high prediction speed. A progressive prediction algorithm (PPA) that combines a TCN-GRU multi-task learning network with temporal correction and multi-interval data sampling was proposed by Fu et al. [
32]. This achieved quick qualitative identification (99.3% accuracy) and quantitative concentration prediction (
of 0.927) for gases like CO, NH
3, NO
2, and toluene during the early stages of sensor response, resolving the problem of existing models struggling to balance detection accuracy and response speed.
Nevertheless, current research continues to demonstrate inadequacies in meeting the urgent response demands associated with lithium-ion battery thermal runaway. In practical gas-sensing scenarios, gas classification and concentration prediction are inherently correlated rather than completely independent tasks. The gas category determines the overall response pattern of the sensor array, while the gas concentration further affects the dynamic amplitude and temporal evolution characteristics of the response signals. Therefore, both tasks share substantial low-level temporal and spatial feature representations. Traditional single-task learning frameworks usually optimize each task independently, which may lead to redundant feature extraction, insufficient use of shared information, and reduced generalization under limited-sample conditions [
32,
33]. In contrast, the multi-task learning framework enables multiple tasks to collaboratively optimize the shared backbone network, allowing the model to learn more discriminative and robust feature representations. Moreover, the shared-parameter mechanism introduces an implicit regularization effect, which can effectively alleviate overfitting and improve the robustness of the model under noisy environments. [
34,
35]. Also, parallel multi-task processing cuts down on the amount of computing power needed for repetitive feature extraction by a huge amount, which ensures that the detection system responds quickly in real time. Based on this backdrop, this study presents a new deep learning network framework that combines ISA-LSTM-TCN.
The primary innovations of this study are as follows: First, an improved Self-Attention (ISA) module is proposed to achieve the efficient extraction of complex gas features. Unlike image data with relatively stable spatial distributions, MOS gas-sensing signals usually exhibit strong temporal fluctuation, response drift, and noise interference caused by environmental variation and sensor cross-sensitivity. Therefore, directly applying conventional self-attention mechanisms may lead to unstable feature extraction and reduced robustness under limited-sample conditions. To address these issues, the proposed ISA module introduces residual-enhanced feature propagation and cosine-similarity-based attention calculation to improve temporal feature discrimination while reducing sensitivity to amplitude variations and noise disturbance. In addition, normalization operations are incorporated to stabilize the feature distribution during training, thereby enhancing convergence stability and improving the robustness of temporal representation learning for gas-sensing applications. Second, TCN and LSTM are integrated to synergistically capture the multi-scale spatiotemporal features of the data. Finally, an ISA-LSTM-TCN multi-task learning (MTL-ILT) model is constructed using a hard parameter-sharing mechanism, aiming to achieve parallel outputs for gas classification and concentration regression via the task-complementary effect of the shared feature layer.
2. Algorithm Model and Theory
The overall logical structure of the model is illustrated in
Figure 1a. Using a parallel architecture based on a hard parameter-sharing mechanism, the suggested model uses the synergistic operation of LSTM and TCN to deeply mine the multi-scale spatiotemporal aspects of the gas-sensing signals. In particular, the LSTM branch employs its recurrent structure to mimic long-term temporal trends in the response curves, whereas the TCN branch uses dilated convolutions to precisely capture local transient distortions in the signals. To ensure the compatibility of features from heterogeneous architectures, a 1 × 1 convolutional projection layer is employed to map the outputs of both LSTM and TCN into a unified feature dimension. In the feature integration stage, a Gated Fusion mechanism is designed. After concatenating the projected features, a learnable gating weight is computed to adaptively adjust the contribution ratios of each branch. This mechanism enables the model to dynamically balance global sequence context and local transient information, achieving a complementary fusion that enhances the overall representation capability of the network.
Based on this, the model incorporates the ISA module, which is improved by a residual multiplication method. This module improves feature-screening accuracy, convergence speed, and noise robustness by recalibrating the channel using cosine similarity. This study thoroughly validates the high performance and superiority of the suggested architecture in complex gas pattern recognition tasks from the perspectives of module design, feature mining, and model robustness through multi-dimensional ablation experiments on gas classification and concentration detection.
2.1. Temporal Modeling Networks
The LSTM network is frequently used in temporal modeling tasks and uses gating techniques to selectively store important information.
Figure 1b shows the usual structure of an LSTM cell. To increase the receptive field while rigorously maintaining temporal causality, the TCN architecture combines causal convolutions with dilated convolutions, as seen in
Figure 1c. This architecture has several benefits, including parallel computing and structural stability, and makes it possible to handle long-term dependencies in time-series data well.
2.2. Improved Self-Attention Mechanism
To enhance the representational capacity of the network and enable the model to better learn the mapping relationships between features and output labels, a novel improved self-attention (ISA) mechanism is proposed in this study, building upon the standard self-attention (SA) and residual self-attention (RSA) mechanisms, as depicted in
Figure 1d.
Deep learning technologies, such as attention mechanisms, are frequently employed in sequential data domains (e.g., natural language processing, time-series analysis, and computer vision). By dynamically designating weights, they allow the model to concentrate on data segments that make a substantial contribution to the output, while selectively discarding trivial redundant information [
36]. In the context of multi-sensor time-series data, the SA mechanism can also be implemented to quantify the correlation information between various gas components and concentrations, thereby extracting the high self-attention values present in the gas temporal data [
37].
The SA mechanism, a prominent variety of attention mechanisms, converts its input matrix
into three components—Query (
), Key (
), and Value (
)—through weighted linear projections. The Query identifies the target items of focus, the Key is employed to calculate similarity relative to the Query, and the Value signifies the actual information to be consolidated.
Here,
,
,
represent the weight matrices, while
denote the Query, Key, and Value matrices, respectively. The dot product of
and
is computed to generate a similarity matrix, which is then divided by a scaling factor and transformed into a probability distribution via the softmax function. Finally, the dot product between this probability distribution and the V is calculated to yield the final output, SA.
However, despite its effectiveness in modeling long-range temporal dependencies, the conventional SA mechanism still exhibits certain limitations when processing heterogeneous MOS gas-sensing sequences. Specifically, the attention score in standard SA is computed based on dot-product similarity, making the attention distribution highly sensitive to feature magnitude variations. In practical gas-sensing scenarios, sensor responses are often influenced by concentration fluctuation, environmental disturbance, sensor drift, and cross-sensitivity effects, which may lead to substantial amplitude inconsistency among temporal features. Under such conditions, high-magnitude responses may dominate the attention weights, while weak but informative transient features can be suppressed.
RSA mechanisms partially alleviate gradient degradation by introducing residual pathways. However, in most RSA structures, the residual connection is applied only after the attention aggregation stage, while the attention score itself still relies on conventional dot-product similarity. Consequently, the sensitivity of attention weights to feature magnitude remains fundamentally unchanged.
Motivated by these limitations, the proposed ISA mechanism introduces cosine-similarity-based attention together with residual-enhanced feature interaction, aiming to improve scale robustness and stabilize temporal feature propagation under complex multi-sensor gas-sensing conditions.
Expanding on the conventional SA, the ISA mechanism incorporates a new connecting pathway that multiplies the input data and the self-attention output element-wise. With this design, we hope to emphasize important characteristics even more while dampening the noise of less important ones. Effectively suppressing noise and boosting the model’s overall robustness, this multiplicative operation compresses or amplifies the input signals, smoothing the model’s response to specific features and mitigating needless oscillations. The risk of numerical instability is something to keep in mind when performing multiplication operations. This problem is solved by applying batch normalization (BN) to the data just after the multiplicative connection, which gives rise to the final ISA form.
Compared with conventional dot-product self-attention mechanisms, the proposed cosine-similarity-based attention calculation focuses more on the directional consistency between temporal feature vectors rather than absolute magnitude differences. This characteristic is particularly suitable for MOS gas-sensing signals, whose response amplitudes may vary significantly due to gas concentration fluctuation, environmental disturbance, and sensor drift. Meanwhile, the residual-enhanced structure facilitates stable gradient propagation and alleviates feature degradation in deep temporal feature extraction. Consequently, the proposed ISA module can effectively improve noise robustness and temporal feature representation capability under complex gas-sensing conditions.
Specifically, the adoption of cosine similarity instead of the classical scaled dot-product is a deliberate design choice for two reasons. First, from a mathematical perspective, normalizing Q and K vectors constrains similarity scores to a bounded interval, and cosine similarity further enforces this by restricting the scores within a fixed range ([−1, 1]), thereby avoiding the “vanishing gradient” problem caused by softmax saturation when processing high-dimensional feature vectors. This ensures a more stable convergence rate and reliable weight distribution during multi-task optimization. Second, from a computational perspective, the normalization process introduces only a marginal linear increase in FLOPs, which does not alter the model’s overall complexity class. This modification allows the ISA module to prioritize directional correlations in sensor transients, making the network inherently more robust to baseline drift common in MOS sensors.
2.3. Model Principles and Multi-Task Learning Mechanism
In this study, the classification and concentration regression tasks share training data within a multi-task learning (MTL) framework that employs a hard parameter-sharing mechanism. By jointly learning classification and regression tasks within a unified framework, the model can exploit the intrinsic correlation between gas category information and concentration-dependent temporal characteristics, thereby improving feature utilization efficiency and enhancing the overall representation capability of the network. Let
denote the input sequence, where
represents the sensor response vector at the
-th time step. The shared feature extraction layer consists of parallel LSTM and TCN branches, which are designed to simultaneously capture the long-term dependencies and multi-scale dynamic features of the sequences. In the LSTM branch, the hidden state is updated as follows:
Here, denotes the hidden state at time step i, represents the cell state at the previous time step, and are the input gate, forget gate, and output gate, respectively. Additionally, stands for the candidate cell state, and the symbol denotes element-wise multiplication. These gating mechanisms ensure that the network can effectively retain crucial historical information within the sequence.
Meanwhile, the TCN branch extracts local dynamic features through dilated causal convolutions and expands the receptive field to capture long-term temporal dependencies. Given an input sequence
and a convolutional filter
of size
, the convolution output at position s is expressed as follows:
Here, denotes the dilation factor, which dictates the sampling interval of the convolution. As the network depth increases, the receptive field expands exponentially, thereby facilitating the modeling of long-term temporal features.
Upon extracting the feature representations from both branches, they are concatenated and adaptively fused via a gating mechanism, which is expressed as follows:
Here, and denote the feature representations extracted by the two branches, respectively. The operator [;] represents feature concatenation, and is the sigmoid activation function. This mechanism dynamically adjusts the contribution ratio of both information sources based on feature importance, thereby achieving the highly efficient fusion of sequential features. Subsequently, the integrated features are fed into the ISA module.
Within the multi-task learning framework, the model simultaneously performs the gas classification and concentration prediction tasks, sharing an identical feature representation .
For the concentration prediction task, a linear regression layer is employed to obtain the continuous output, which is formulated as follows:
Here, and denote the weight matrix and bias vector of the regression layer, respectively.
For the gas classification task, a softmax function is applied to yield the class probability distribution, which is expressed as follows:
Here, and denote the weight matrix and bias vector of the classification layer, respectively.
To achieve the synergistic optimization of both tasks, a weighted multi-task loss function is employed for joint training, and
regularization is incorporated to enhance the generalization capability of the model.
Here, and denote the mean squared error (MSE) loss for the regression task and the cross-entropy loss for the classification task, respectively. and are the task weight coefficients, is the regularization coefficient, and represents all learnable parameters of the model. By jointly optimizing the aforementioned loss function, concentration prediction performance can be improved while maintaining classification accuracy, thereby mitigating model overfitting.
To determine the optimal balance between the gas classification task and the concentration regression task, a sensitivity analysis of the loss function coefficients
and
was performed. As summarized in
Table 1, various combinations of weights were evaluated using the validation set. It is observed that the model performance is sensitive to these parameters; an excessive weight on the classification task (
> 0.6) leads to a decline in
for CO concentration, while prioritizing regression (
> 0.8) results in a slight drop in classification accuracy. The optimal performance was achieved at
= 0.4 and
= 0.6, yielding a classification accuracy of 99.23% and
values of 0.9510 and 0.8400 for H
2 and CO, respectively. This configuration ensures that the ISA-LSTM-TCN model extracts features that are robust for both gas identification and precise concentration quantification.
3. Data Acquisition and Processing
3.1. Construction of Self-Tested Dataset
Because MOS gas sensors generally have a selectivity problem, it is hard for one sensor to accurately identify mixed gases. This work builds a sensor array out of three commercial MOS sensors—HGS1000, HGS1001, and HGS1002, all purchased from Micro-Nano Sensing Co., Ltd. (Hefei, China)—and then combines them with a data-processing model to recognize different gases.
Table 2 shows the target gases and detection ranges for each sensor. The research focused on H
2, CO, and their mixes, with different concentration combinations set up for testing (see
Table 3 for further information).
Moreover, the dataset was divided into training and testing subsets prior to data augmentation to avoid information leakage between different subsets. Unlike conventional fixed-pattern gas classification datasets, the constructed dataset contains multiple concentration gradients for each gas category. Consequently, the model is required to simultaneously capture gas-type-dependent response patterns and concentration-related temporal evolution characteristics. This multi-concentration setting increases the complexity of the recognition task and improves the evaluation of the model’s generalization capability under varying gas-response conditions.
For the single-gas conditions, hydrogen concentrations were set to 20, 50, 100, 150, and 200 ppm, while carbon monoxide concentrations were set to 2, 5, 10, 15, and 20 ppm. For mixed-gas conditions (CO, H
2), the concentration pairs were configured as (18 ppm, 200 ppm), (10 ppm, 1000 ppm), and (2 ppm, 1800 ppm). The experimental dataset used in this study was adopted from our previously published work in Ref. [
15]. Specifically, each gas concentration level was independently tested ten times to improve experimental repeatability and reduce random measurement fluctuations, resulting in 130 temporal response samples covering multiple gas categories and concentration gradients. The present study mainly focuses on the development and validation of the proposed ISA-LSTM-TCN framework for simultaneous gas classification and concentration regression based on the existing dataset.
Although the nominal detection range of the employed sensors is 0–500 ppm, higher gas concentrations were intentionally introduced to simulate severe thermal runaway scenarios, in which characteristic gas emissions may exceed conventional sensing limits. Meanwhile, narrow-range sensors were selected to ensure high sensitivity toward trace gas detection at the early warning stage. Accordingly, the concentration range of this dataset was designed to cover the wide range of evolution processes of gas release during thermal runaway, spanning from early-stage leakage to extreme runaway conditions.
While partial saturation can occur at elevated concentrations, the sensor signals still preserve rich transient dynamic information, including response and recovery kinetics, which can be effectively exploited by the deep learning model. Therefore, these partially saturated responses not only represent realistic extreme operating conditions but also do not compromise the reliability of the dataset for model training and evaluation. This design enables robust model assessment under both normal sensing conditions and safety-critical extreme scenarios.
During the thermal runaway process of lithium-ion batteries, a variety of gases are generated, including H
2, CO
2, CO, CH
4, and HF [
5]. However, not all gas species are equally suitable for early-warning applications. Previous studies have demonstrated that H
2 and CO are generated at relatively early stages of thermal runaway and exhibit a strong correlation with the onset of critical reactions [
38]. In particular, these gases can reach detectable concentrations prior to full thermal runaway, making them effective indicators for early-stage fault detection.
In contrast, although CO
2 is often the dominant component, it lacks specificity as it can be produced under non-critical conditions, while hydrocarbons and other byproducts are typically associated with more advanced stages of decomposition. Therefore, focusing on H
2 and CO enables reliable and efficient early-warning monitoring while maintaining low system complexity and cost. This strategy is also consistent with existing studies on thermal runaway diagnosis and gas evolution behavior [
14].
This study used a feature-alignment and zero-padding technique for labeling raw signals in the development of the multi-task learning architecture: a single-component gas is regarded as a distinct mixed state with the concentration of the other component at 0 ppm. This method maps both H2 and CO concentration regression tasks at the same time in a single feature space. The trials were performed at room temperature, atmospheric pressure, and a relative humidity of (60 ± 10)%. Although the experiments were conducted under controlled laboratory conditions to ensure measurement consistency, practical battery operating environments may involve more complex humidity fluctuations, temperature variations, and long-term sensor drift effects, which will be further investigated in future studies. At a sampling frequency of 10 Hz, the sensor array’s temporal response signals were captured.
Figure 2 shows that the sensor response and recovery processes show that the array has strong response characteristics and different cross-sensitivity levels for all three gases. This provides a solid dataset for employing pattern recognition methods to classify and identify gases subsequently.
3.2. Data Augmentation
Data augmentation is used to enhance the model’s generalization capability and prevent overfitting. This work employs the same data augmentation as proposed by Wang et al. [
39], based on sample weighting, to expand the training set. Based on the self-tested dataset, an arbitrary initial sample
is selected as the object for augmentation, where c denotes the class index, 0 represents the initial state, and
is the number of sensors in the E-nose array. For all samples
within the same class, the Euclidean distance between the time-series data of each sensor in the current sample and the corresponding sensor in sample
is calculated. The average of these sensor-level distances is then defined as the overall distance between the two samples.
Here, represents the sensor index, denotes the -th sample within the same class as the initial sample, and signifies the total number of samples in that class.
The samples are ranked according to their distances from the initial sample, and the five nearest neighbors are selected. A new sample is then constructed by assigning weights to each: the weight of the initial sample is set to 0.5, two randomly selected samples are assigned a weight of 0.15 each, and the remaining three samples share a combined weight of 0.2. The final augmented sample is obtained by a weighted calculation using these assigned values. Consequently, each original sample can yield new samples. In this study, the deep learning model is trained and evaluated based on these augmented samples. Meanwhile, to prevent model overfitting induced by an excessive volume of augmented data, the weighting scheme of this method is adjusted and reallocated. Specifically, the initial sample is assigned a weight of 0.5, one randomly selected sample is assigned a weight of 0.2, and the remaining three samples are each assigned a weight of 0.1. Under this configuration, each original sample yields new augmented samples.
To further improve the robustness of model training under limited-sample conditions, data augmentation techniques were applied exclusively to the training dataset after the training-testing split procedure, thereby avoiding information leakage between the training and testing subsets. After augmentation, the total number of training samples was expanded to 650. It should be noted that the testing dataset remained completely independent and was not involved in any augmentation process. This strategy ensures that the evaluation results more accurately reflect the generalization capability of the proposed framework rather than potential memorization caused by duplicated or highly correlated samples.
Furthermore, due to the multi-concentration dynamic response characteristics of the dataset, the proposed framework is required to simultaneously learn gas-category-related response patterns and concentration-dependent temporal evolution features, which substantially increases the complexity of the recognition task and reduces the likelihood of simple memorization-based overfitting.
3.3. Model Training and Evaluation Metrics
To comprehensively evaluate the model’s performance within the multi-task learning framework, specific evaluation metrics are defined for both the classification and regression sub-tasks in this study. For the gas classification task, accuracy is selected as a performance metric to comprehensively assess the model’s precision and stability in class identification. For the concentration prediction (regression) task, RMSE and are used for evaluation. Specifically, RMSE is used to quantify the deviation between predicted and true values, while is used to characterize the model’s goodness-of-fit to the underlying data fluctuation patterns.
To achieve synergistic learning between the classification and regression tasks, this study adopts a joint optimization strategy. By linearly weighting and combining the classification loss and the regression loss, the overall loss function is defined as follows:
For the gas classification task, the cross-entropy loss function is employed, which is formulated as follows:
Here, denotes the total number of samples, represents the number of classes, is the ground-truth label, and signifies the predicted probability of the model.
For the concentration regression task, a mask matrix
is introduced to filter out invalid labels, ensuring that the mean squared error is computed exclusively at valid positions. This regression loss is defined as follows:
To ensure the model evaluation’s objectivity and impartiality, the original dataset is rigorously divided into a training set and an independent test set at an 8:2 ratio. During the entire process of developing the model, the test set is kept fully separate and is only used to see how well the model can generalize. During the hyperparameter optimization step, the training set is tested five times using cross-validation. The best setup is the one that gives the best results on the validation set when multiple parameter combinations are used. We calculate the classification cross-entropy loss and the regression mean squared error (MSE) loss for each batch of data during training. The regression loss has a masking technique that makes sure it is only calculated for genuine observations. To balance the training goals of both the classification and regression tasks, these two loss components are merged in a linear way using weight coefficients. To stop the gradient from exploding, gradient clipping is also used on the model parameters during training.
Since the classification task tends to reach its limit early in training, the model selection criterion mainly leverages for H2 and CO concentration predictions as the main parameter, putting more weight on regression accuracy. During the hyperparameter optimization phase, we ran a search for critical parameters, including lstm_hidden_size, tcn_channel, tcn_kernel_size, and tcn_dropout, for 200 iterations. The AdamW optimizer is used to change the weights, and both the learning rate and weight decay coefficient are set at 0.001. After finding the best combination of hyperparameters, the model is trained again on the whole training set. Also, a cosine annealing approach is used in the last 250 epochs to improve the quality of convergence. The model’s capacity to generalize across both regression and classification tasks is conclusively validated by its extensive performance on the independent test set.
The key hyperparameter settings of the proposed ISA-LSTM-TCN framework are summarized in
Table 4, including the LSTM hidden dimension, TCN kernel size, channel configuration, dropout ratio, feature projection dimension, batch size, and learning rate.
To further evaluate the computational efficiency of the proposed framework, the model complexity and inference latency are summarized in
Table 5. The proposed model achieves relatively lightweight computational characteristics while maintaining high recognition and regression performance. The proposed model contains 647.68 K parameters and has a model size of 2.47 MB while achieving inference latencies of 1.0 ms on GPU and 18.6 ms on CPU, respectively. These results indicate that the proposed ISA-LSTM-TCN framework has relatively low computational overhead compared with conventional deep temporal learning architectures.
4. Results and Discussion
4.1. Results of MTL-ILT on Self-Made Dataset
To verify the practical efficacy of the proposed ISA-LSTM-TCN multi-task learning model in detecting characteristic gases of lithium-ion battery thermal runaway, the model is systematically evaluated using the constructed self-collected dataset. The experimental results demonstrate that the model exhibits outstanding performance in the lithium-ion battery safety early-warning task (
Figure 3). In the classification task, the model achieves an accuracy of 99.23%, providing a reliable criterion for triggering the rapid early-warning logic. In the concentration regression task, the
for the H
2 and CO predictions reach as high as 0.9510 and 0.8400, respectively. Regarding the error analysis, the RMSE for H
2 and CO are 129.404 ppm and 2.641 ppm, respectively. Although the absolute error value for H
2 is relatively high, this is primarily attributed to the discrepancy in the experimental gas concentration ranges: the detection concentration of H
2 covers a broad span of 0–2000 ppm, whereas the detection range for CO is merely 0–100 ppm.
The loss curves show that both the training loss and the test loss drop quickly from a high value of about 450,000 during the first 50 epochs of training. The test loss changes a lot at first, but as training goes on, the size of these changes becomes smaller. The two trends tend to level off and come together around 50 to 100 epochs. After 100 epochs, they pretty much stay the same at a low level close to 0, and the training and test losses are very close to each other, which shows that there is no overfitting.
The prediction accuracies for both gases are still very high when it comes to relative error and goodness of fit. The scatter plots (
Figure 3d) show that the observation points are very close to the
identity line. This shows that the model has very high prediction fidelity, even in the high-concentration intervals that happen when thermal runaway causes a lot of gas to be generated. By using inter-task information complementarity, this hard parameter-sharing design greatly improves generalization and stops overfitting. Experimental results show that this approach strikes the best balance between accuracy in monitoring and timeliness in giving warnings. It is an efficient and reliable way to keep an eye on lithium-ion battery thermal runaway online.
To further evaluate the robustness and reproducibility of the proposed framework, repeated experiments under multiple random seeds were conducted. The statistical comparison results are summarized in
Table 6. In addition to the performance metrics obtained under different random seeds, the mean and standard deviation (Std) values of all evaluation metrics are also provided to quantitatively assess the stability of the proposed framework. The results show that the proposed model achieves relatively small performance fluctuations across different random seeds, particularly for the regression
R2 metrics, whose standard deviations remain below 0.01. Although slight variations exist due to stochastic parameter initialization and optimization processes, the overall classification and regression performances remain relatively consistent, indicating good training stability and generalization capability.
Figure 4 illustrates the representative convergence behavior of the proposed ISA-LSTM-TCN framework under the selected experimental random seed (Seed = 3407). Both the classification accuracy and regression
curves exhibit stable convergence trends without obvious oscillation divergence or severe performance degradation. Combined with the statistical results obtained under multiple random seeds, these observations further indicate that the proposed framework possesses good training stability and does not suffer from significant overfitting under the current experimental conditions.
To further evaluate the generalization capability of the proposed model and investigate the potential risk of overfitting under limited data conditions, a five-fold cross-validation experiment was conducted on the original dataset. Specifically, the dataset was first randomly shuffled and divided into five equally sized subsets (folds). For each iteration, four folds were used for model training, while the remaining fold was used for testing. This process was repeated five times until each fold had been used once as the test set. The evaluation metrics included classification accuracy as well as the for H2 and CO concentration regression tasks.
The fold-wise experimental results are presented in
Figure 5. It can be observed that the proposed model maintains highly consistent performance across different data partitions, with only minor fluctuations in all evaluation metrics. No significant degradation was observed in any individual fold, indicating that the model does not depend on a specific training-validation split and exhibits stable predictive capability under different sampling conditions.
Furthermore, the standard deviations of classification accuracy, H2 , and CO across the five folds are only 0.00688, 0.03183, and 0.00612, respectively. Such low variances further demonstrate the stability and robustness of the proposed framework. The cross-validation results indicate that the model complexity is well matched to the current dataset scale and that no noticeable overfitting phenomenon is observed.
To further verify the superiority of the model, its performance on both the classification and regression tasks is quantitatively evaluated against various mainstream algorithms (
Table 7). The results indicate that the ISA-LSTM-TCN model exhibits a prominent leading advantage across all evaluation dimensions. This performance enhancement fully demonstrates the innovativeness of the proposed model: by introducing the ISA module to precisely capture key feature weights and integrating the dual advantages of LSTM and TCN in long-term temporal modeling and parallel feature extraction, the model successfully overcomes the inherent drawback of insufficient accuracy in conventional models during mixed gas prediction.
This provides a solid dataset for employing pattern recognition methods to classify and identify gases subsequently.
4.2. Results of MTL-LT of Different SA Units
First, using LSTM-TCN as the backbone architecture, this section investigates the impact of various attention mechanisms on the model’s representational capacity. As shown in
Table 8, although the standard self-attention (SA) and residual self-attention (RSA) mechanisms exhibit certain feature-extraction capabilities for processing multi-sensor sequences, the proposed ISA-LSTM-TCN achieves an average
of 0.8955, significantly outperforming the traditional architectures. In specific task evaluations, the model initially achieves a remarkable leap in classification performance. Its gas-component recognition accuracy increases significantly from 77.69% (with the backbone architecture) to 99.23%, greatly enhancing the discriminative reliability of the early-warning system. In the concentration regression task, the model also demonstrates exceedingly high prediction accuracy: for H
2 detection, its
reaches as high as 0.9510—an improvement of approximately 9.7% compared to the backbone architecture—with the RMSE decreasing to 129.404 ppm; for CO detection, its
reaches 0.8400, with an RMSE of merely 2.641 ppm.
This confirms that the ISA module can better boost important characteristics while reducing noise over time by multiplying input signals and attention weights. The ISA module also works better with BN, which makes predictions more accurate and stable while keeping the number of parameters minimal.
Upon establishing the ISA as the optimal attention module, the second phase of the ablation study aims to verify the necessity of the synergistic operation among the ISA, LSTM, and TCN modules.
Table 9 compares the performance of various component combinations in terms of classification accuracy and multi-task regression for H
2 and CO. It is noteworthy that the LSTM-TCN model exhibits slightly lower classification accuracy compared to the standalone TCN in the ablation experiments. This architectural behavior can be attributed to the feature distribution mismatch between the two branches. While the TCN is adept at extracting high-frequency local transient features from sensor signals, the LSTM focuses on long-term global trends. In the absence of the ISA and Gated Fusion modules, the simple integration of these heterogeneous features leads to increased dimensionality and potential feature redundancy. Without the selective weighting provided by the ISA module, the less discriminative global features from the LSTM branch may act as noise, interfering with the precise local features captured by the TCN, thus complicating the optimization process and resulting in a performance dip. This result further highlights the critical role of the ISA module and Gated Fusion mechanism in synergizing multi-scale temporal information and suppressing inter-branch interference. Furthermore, the five-fold cross-validation error plots for the models are shown in
Figure 6. The results in
Figure 6 demonstrate that the MTL-ILT model exhibits exceptional predictive stability across multiple cross-validation folds. Its error distribution interval is significantly narrower than those of other comparative architectures, demonstrating that the proposed model design exhibits strong robustness to sample fluctuations. This further confirms the reliability of the proposed architecture for lithium-ion battery thermal-runaway monitoring.
With the introduction of ISA enhancement, ISA-TCN significantly outperforms the baseline TCN. Notably, in the CO regression task, the increased from 0.6555 to 0.7390, demonstrating the critical role of ISA in local feature mining. A comparison between ISA-TCN and ISA-LSTM reveals that the convolution-based TCN structure has superior feature-mapping capabilities compared to a standalone LSTM when processing such gaseous temporal data. Although LSTM-TCN combines long-term memory with local feature extraction, its performance remains inferior to the full model due to the lack of dynamic enhancement for key features. The MTL-ILT model proposed in this study achieved a classification accuracy of 99.23% after integrating the ISA module and reached the highest (0.9510) for H2 prediction.
Experimental data show that MTL-ILT achieves the best results in multi-task learning by combining the global temporal modeling capacity of LSTM, the parallel feature-extraction benefits of TCN, and the dynamic feature-enhancement features of ISA. These components collaborate to ensure the model operates effectively and accurately, especially in the presence of complex sensor data.
4.3. Results of MTL-ILT Using Public Datasets
While ablation experiments have confirmed the effectiveness of the proposed modules on the self-tested dataset, verifying the model’s adaptability across different sensor arrays and varying environments is crucial for evaluating its robustness. Therefore, this section introduces the widely recognized UCI Twin Gas Sensor Arrays dataset for cross-scenario validation. The objective is to quantitatively evaluate the generalization capability and prediction accuracy of the ISA-LSTM-TCN model when processing other sensor data. The gas response curves of this dataset are illustrated in
Figure 7.
To further verify the generalization capability of the proposed ISA-LSTM-TCN framework, the public Twin Gas Sensor Array dataset from the UCI repository was additionally employed for external validation. To adapt the dataset for the multi-task learning framework, several preprocessing procedures were conducted.
First, the original 100 Hz sensor signals were downsampled to 20 Hz to reduce temporal redundancy and suppress high-frequency noise interference while preserving the primary dynamic response characteristics. Subsequently, a 40 s effective response segment after gas injection was extracted from each sample to ensure temporal consistency during model training and evaluation. Considering that the original dataset contains only 16 samples for each gas category, data augmentation techniques were further applied to alleviate the small-sample limitation. Finally, normalization and Z-score standardization were performed to minimize the influence of baseline drift and unit discrepancies among different sensor arrays, thereby improving the robustness and generalization capability of the proposed framework.
Compared with our proprietary dataset, the UCI dataset presents greater challenges due to differences in sensor types and concentration distributions, thereby providing a more rigorous evaluation of the architectural stability and cross-dataset robustness of the proposed model.
Figure 8 illustrates the fitting results of the model for the concentration prediction of four gases: CO, ethanol, ethylene, and methane. The experimental results demonstrate that the model exhibits exceptional generalization performance in multi-component gas concentration prediction. Specifically, the
values for all target gases exceeded 0.97 (with CO and methane reaching as high as 0.9804 and 0.9818, respectively), proving that the model possesses superior linear fitting precision. Meanwhile, the extremely low RMSE metrics (e.g., only 5.440 ppm for ethanol) and the prediction points closely distributed along both sides of the diagonal line strongly validate the effectiveness of the ISA module. Through its element-wise multiplication mechanism, the ISA module performs smoothing on input signals, which effectively suppresses sensor noise and accurately captures the nonlinear evolutionary characteristics of gas concentrations.
4.4. Noise Robustness and Time Window Investigation
Even though the ISA-LSTM-TCN model does a great job of generalizing on public datasets, real-world uses of lithium-ion battery thermal-runaway detection need better real-time early-warning and anti-interference features. Sensors always make random noise in complicated surroundings, and the length of the detection window directly affects how quickly the warning system responds.
To further evaluate the reliability of the model in real-world environments, this section first conducts a robustness analysis against noise to verify its detection stability under varying signal-to-noise ratios (SNRs). As summarized in
Table 10, the MTL-ILT model exhibits significant anti-noise advantages across various interference levels. Compared to the baseline architectures, the proposed model shows the minimum performance degradation under different SNR environments, maintaining high levels of both classification accuracy and regression goodness-of-fit. This is primarily attributed to the ISA module, which performs precise recalibration of feature channels using cosine similarity. Combined with the deep extraction of multi-scale temporal features by TCN and LSTM, the model effectively filters out the random fluctuations of noise signals.
Subsequently, this study conducted comparative experiments to investigate the influence of different sampling window lengths (5 s, 10 s, 20 s, and 40 s) on detection performance, aiming to explore the model’s potential for rapid detection response. As summarized in
Table 11, the experimental results demonstrate a significant advantage in early warning speed: even when the detection window is shortened to 10 s, the model maintains a classification accuracy of 96.15%, with
values for H
2 and CO regression reaching as high as 0.9226 and 0.8288, respectively. It should be noted that a longer temporal window does not necessarily guarantee higher prediction accuracy for MOS gas-sensing signals. In the proposed task, the early transient response stage of the sensor contains rich dynamic kinetic information related to gas adsorption and reaction processes, which provides strong discriminative features for concentration prediction. As the response gradually approaches a steady state, the temporal variation becomes weaker, while redundant information, baseline drift, and accumulated noise may increase. Consequently, excessively long temporal windows may introduce additional interference and slightly reduce regression stability under limited-sample conditions. Furthermore, the relatively high prediction performance achieved under short temporal windows demonstrates the capability of the proposed framework for rapid thermal runaway early-warning applications.
Figure 9 illustrates the performance evaluation comparison under various time windows. These results strongly validate the capability of the ISA-LSTM-TCN architecture to capture the initial characteristics of thermal-runaway gases within an extremely short time frame. This not only ensures high detection precision but also significantly reduces response latency, securing critical “golden time” for the early suppression of lithium-ion battery fires.
4.5. Error Analysis and Discussion of Potential Failure Cases
Although the proposed ISA-LSTM-TCN framework achieves high overall classification and regression performance, several error characteristics and practical limitations should still be discussed.
According to the confusion matrix results, a small number of misclassification cases can still be observed between H2 and CO samples. Specifically, approximately 2% of CO samples are incorrectly recognized as H2. This phenomenon is mainly attributed to the intrinsic cross-sensitivity characteristics of MOS gas sensors and the partial overlap of transient response features under low-concentration conditions. Nevertheless, the overall classification accuracy remains above 98%, indicating that the proposed framework can still effectively distinguish the major gas categories.
For concentration regression tasks, the proposed framework still exhibits non-negligible prediction deviations, particularly in the H2 regression task (RMSE = 129.404 ppm). Larger prediction errors are mainly concentrated in high-concentration regions, which may be related to sensor response nonlinearity, uneven sample distribution, and stochastic optimization sensitivity. In comparison, the CO regression task achieves relatively smaller prediction errors due to its narrower concentration range and lower response variance.
Furthermore, the multi-task optimization process also affects the error characteristics of the proposed framework. Sensitivity analysis of the loss coefficients and indicates that the balance between classification and regression objectives significantly influences model performance. Excessively emphasizing the classification task improves category discrimination capability but increases concentration prediction errors, particularly for the CO regression task. In contrast, assigning overly large weights to the regression task slightly weakens classification accuracy and feature separability. These observations suggest that improper task balancing may lead to optimization bias and unstable feature learning, thereby affecting the overall robustness of the framework. Therefore, appropriate selection of the multi-task loss coefficients is essential for maintaining stable classification and concentration prediction performance simultaneously.
In addition, although missing and invalid samples were removed during data preprocessing, the overall dataset scale remains relatively limited for deep learning-based regression tasks. Environmental noise, sensor baseline drift, and temporal fluctuations may also introduce uncertainties into feature extraction and concentration prediction. Repeated experiments under multiple random seeds further demonstrate that the proposed framework maintains relatively stable convergence behavior and consistent overall performance, although the regression task remains more sensitive to initialization conditions and noise perturbations than the classification task.
Overall, these results indicate that the proposed ISA-LSTM-TCN framework possesses good robustness and generalization capability for early-stage gas detection applications, while further improvements in dataset scale, noise suppression, and sensor selectivity may help reduce prediction uncertainty in future work.