Electronic nose cross-domain recognition and drift compensation method based on contrastive variational autoencoder

By employing a cross-domain recognition and drift compensation method based on a contrastive variational autoencoder, the sensor drift problem of the electronic nose system is solved, achieving efficient feature extraction and cross-domain recognition, improving detection accuracy and stability, and making it suitable for electronic nose systems in industrial scenarios.

CN122241322APending Publication Date: 2026-06-19CHINA UNIV OF MINING & TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHINA UNIV OF MINING & TECH
Filing Date
2026-05-20
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

Existing electronic nose systems suffer from sensor drift issues during long-term use, leading to a decrease in detection accuracy. Current technologies struggle to effectively address nonlinear drift problems, have insufficient feature extraction capabilities, lack precise cross-domain category alignment, and fail to adequately simulate domain drift through data augmentation.

Method used

A cross-domain recognition and drift compensation method based on contrastive variational autoencoder (C-VAE) is adopted. Through source domain supervised pre-training and target domain unsupervised representation learning, combined with cross-domain joint domain adaptation training, a joint loss function is constructed for multi-dimensional optimization to achieve deep alignment and feature extraction in the latent space.

Benefits of technology

It improves the detection stability and accuracy of the electronic nose system, enables highly robust cross-domain gas recognition in the target domain, reduces labeling costs, and adapts to online recognition needs in industrial scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122241322A_ABST
    Figure CN122241322A_ABST
Patent Text Reader

Abstract

A cross-domain recognition and drift compensation method for electronic noses based on contrastive variational autoencoders (CVAEs) is proposed, belonging to the interdisciplinary field of electronic nose systems and artificial intelligence. The method involves constructing a labeled dataset, building an initial C-VAE network and establishing a basic loss function, connecting the initial C-VAE network with a classifier to form a joint learning network, introducing a classification loss function to construct a combined C-VAE loss function, and training to obtain an initial model. A target domain dataset is then constructed and input into the initial model to obtain the latent space vector of the target domain. Mean-variance transformation is used to achieve style transfer and data augmentation of source domain features. The latent feature structure of the target domain is optimized through various constraints. A joint training set is constructed, and the depth alignment of features between the source and target domains is achieved by constraining the distribution differences of features between the two domains. Training is performed under the joint loss function, and progressive scheduling is applied to obtain a cross-domain gas recognition model. This method effectively solves the nonlinear drift problem of electronic nose sensors.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of interdisciplinary technology of electronic nose systems and artificial intelligence, specifically involving a cross-domain recognition and drift compensation method for electronic noses based on a contrastive variational autoencoder. Background Technology

[0002] Electronic noses (E-nose), as an artificial intelligence detection device that simulates the biological olfactory system, have been widely used in environmental monitoring, food safety, medical diagnosis, industrial safety and other fields due to their core advantages of high sensitivity, low cost and real-time detection. They have become a key technology for odor and component detection in complex scenarios.

[0003] However, the long-term stable deployment and large-scale promotion of electronic nose systems have always been limited by a core technological bottleneck—sensor drift. Sensor drift refers to the unexpected changes in the response characteristics of the electronic nose's sensor array to the target object over time or in different scenarios due to factors such as sensor material aging, environmental temperature and humidity fluctuations, and batch differences in sensors (i.e., "domain" shift). This drift phenomenon causes a significant difference in probability distribution between the source domain data used in the model training phase and the target domain data in the actual application phase. This results in a performance "collapse" of the recognition model trained on the source domain in the target domain, with a sharp drop in detection accuracy, severely restricting the reliable application of electronic noses in long-term continuous monitoring scenarios.

[0004] To address the sensor drift problem, researchers have conducted extensive research at both the hardware and algorithm levels, but all of these approaches have significant limitations. At the hardware level, early solutions focused on optimizing sensor manufacturing processes, improving sensitive materials, or performing periodic physical recalibration of the sensors. However, such methods not only lead to a significant increase in equipment development and maintenance costs, but also the calibration process is time-consuming and laborious, severely impacting detection efficiency. At the same time, due to limitations in current manufacturing processes, producing absolutely stable, drift-free sensors remains extremely challenging and cannot fundamentally solve the drift problem. At the algorithm level: (1) Multivariate correction analysis method: Early algorithms were based on the assumption that "drift is a separable specific component" and attempted to remove the drift effect from the original signal through methods such as principal component analysis. However, its core flaw lies in its reliance on the "linear drift" assumption, which makes it difficult to cope with complex nonlinear drift in real-world scenarios. Furthermore, the effect is highly dependent on the preset "drift direction." If the assumption does not match the actual drift characteristics, the correction will completely fail. (2) Traditional machine learning algorithms: Subsequent researchers have adopted algorithms with stronger nonlinear modeling capabilities, such as support vector machine (SVM) classifier ensemble and random forest, which have improved the model's robustness against drift to some extent. However, such methods require manual feature selection, which is complex and time-consuming; if the selected features are themselves sensitive to drift, the classifier performance is difficult to guarantee, and the problem of cross-domain distribution differences cannot be solved at its root. (3) Domain adaptation technology based on deep learning: In recent years, transfer learning and domain adaptation have been introduced into sensor drift solutions. The core idea is to learn "domain-invariant features" through the powerful nonlinear feature extraction capabilities of deep neural networks (such as CNN and LSTM) to eliminate the data distribution differences between the source and target domains, which has become the mainstream direction for solving the nonlinear drift of electronic noses. However, existing domain adaptation methods based on deep learning still have technical defects such as insufficient feature representation capabilities, insufficient cross-domain category alignment accuracy, and insufficient data augmentation simulation of domain drift scenarios, which have led to the failure of the anti-drift effect to meet the ideal requirements of practical applications.

[0005] In summary, existing technologies have not yet been able to effectively solve the nonlinear drift problem of electronic nose sensors. Therefore, there is an urgent need to provide a technical solution with stronger feature extraction capabilities and more accurate cross-domain alignment. Summary of the Invention

[0006] To address the problems existing in the prior art, this invention provides an electronic nose cross-domain recognition and drift compensation method based on a contrastive variational autoencoder. This method can effectively solve the nonlinear drift problem of electronic nose sensors, capture the distribution pattern of gas features more comprehensively, improve the robustness of feature extraction, and effectively improve the detection stability and accuracy of the electronic nose system in the target domain.

[0007] To achieve the above objectives, this invention provides a method for cross-domain recognition and drift compensation of an electronic nose based on a contrastive variational autoencoder, comprising the following steps:

[0008] S1: Source domain supervised pre-training to build the initial C-VAE feature learning and classification model;

[0009] Building a labeled dataset An initial C-VAE network containing an encoder, reparameterized sampling, and a decoder was constructed, and the basic loss function was established. The initial C-VAE network is connected to the classifier to form a joint learning network, and a classification loss function is introduced. Constructing the combined C-VAE loss function The initial model is obtained through training. Then, introduce contrastive loss constraints and add a contrastive loss function. Construct a joint optimization total loss function Perform secondary training to obtain an initial model with class alignment. ;

[0010] S2: Unsupervised representation learning of the target domain to achieve latent spatial distribution alignment and structural optimization;

[0011] Construct target domain dataset And input the initial model with category alignment. The latent space vector of the target domain is obtained through encoder and reconstruction parameterized sampling. ; Calculate the mean and standard deviation statistics of the source and target domains in the latent space; Achieve style transfer and data augmentation of source domain features through mean-variance transformation; Optimize the latent feature structure of the target domain through various constraint methods;

[0012] S3: Cross-domain joint domain adaptation training to build a cross-domain gas recognition model and perform online recognition;

[0013] Merging source domain optimized latent vectors after style transfer and data augmentation With the latent features optimized from the target domain after latent space optimization Constructing a joint training set By constraining the distribution differences of features between the source and target domains, depth alignment of features between the two domains is achieved; for the joint training set Training is performed under a joint loss function, and the weights of each loss term are asymptotically scheduled to obtain a cross-domain gas recognition model. Real-time acquisition of target domain data, input into cross-domain gas recognition model. Complete online identification and output gas category prediction results.

[0014] This invention provides an uncertainty-aware semi-supervised domain adaptation method based on contrastive variational autoencoders (C-VAE) to address drift compensation and cross-domain recognition issues in gas sensors. First, a C-VAE probabilistic feature extractor is constructed based on labeled source domain data. A joint learning network is built by combining this with a classifier. Initial model training is completed through joint optimization of the C-VAE base loss and classification loss. Contrastive loss constraints are introduced to optimize the class alignment of the C-VAE latent space. Cross-domain class-level alignment is achieved through these constraints, enhancing the inter-class separability and intra-class aggregation of latent features. This constructs a probabilistic latent space, strengthening anti-drift capabilities and effectively solving the problems of insufficient robustness in feature extraction and class discriminability of latent features. This lays a high-quality model foundation for subsequent cross-domain adaptation. Next, unsupervised representation learning was conducted on unlabeled data in the target domain. The C-VAE encoder of the initial model was used to extract latent features in the target domain. Core statistics of the latent spaces in both the source and target domains were calculated, and mean-variance transformation was employed to achieve style transfer and data augmentation of the latent space. Style transfer enhancement of the latent space simulated real-world drift, achieving initial distribution alignment across domains. Furthermore, the latent feature structure of the target domain was jointly optimized using multiple approaches. This addressed the feature distribution shift between the source and target domains caused by instrument / batch / time differences, while primarily using unlabeled data and allowing for the inclusion of a small amount of labeled target domain data. This approach balanced efficiency and practicality in cross-domain adaptation. Subsequently, the style-transfer-optimized latent features of the source domain and the structure-optimized latent features of the target domain were fused to construct a cross-domain joint training set. Multi-strategy domain adaptation techniques were then employed to achieve deep alignment of cross-domain features and extraction of domain-invariant features. By fusing multi-dimensional losses to construct a joint loss function and combining it with asymptotic weight scheduling to optimize the cross-domain joint loss, and dynamically balancing the strength of each loss constraint, a robust cross-domain gas recognition model with both source domain classification capability and target domain adaptation capability is constructed. This solves the problems of deep fusion of cross-domain features and insufficient model generalization. Finally, this model is used to directly interface with real-time collected unlabeled data of the target domain to achieve online, rapid, and accurate identification of gas categories. Thus, this invention effectively solves three key technical problems in existing electronic nose cross-domain classification and drift compensation methods: insufficient feature representation capability, insufficient cross-domain category alignment, and insufficient data augmentation for domain drift simulation. It forms a highly robust drift compensation algorithm that can be deployed in electronic nose systems.

[0015] This invention aims to provide a semi-supervised domain adaptation algorithm that integrates probabilistic modeling capabilities, cross-domain category-level alignment capabilities, and domain style simulation capabilities to improve the drift compensation performance and recognition robustness of electronic noses in practical deployments. Compared with existing technologies, this invention has the following advantages:

[0016] 1. Probabilistic and Robust Feature Extraction: Based on C-VAE, probabilistic modeling of gas features is achieved, which is adapted to the randomness and volatility of electronic nose sensor data. Compared with deterministic feature extraction methods, it can capture the distribution pattern of gas features more comprehensively, fundamentally solving the problem of insufficient feature representation capability of deterministic models, further consolidating the construction effect of probabilistic latent space, strengthening anti-drift capability, and significantly improving the robustness of feature extraction.

[0017] 2. High discriminative power of the source domain model: Through triple-supervised training involving C-VAE, classifier, and domain discriminator, a collaborative optimization process of feature reconstruction, classification task, and class alignment is achieved. This fully leverages the role of contrastive learning in cross-domain class-level alignment, strengthens the intra-class aggregation and inter-class separability of latent features, solves the problem of insufficient class alignment in traditional cross-domain methods, and enables the initial model to learn more discriminative gas features, laying a high-quality foundation for cross-domain adaptation.

[0018] 3. Low-cost cross-domain adaptation: The target domain learning phase only requires unlabeled data, eliminating the need for manual labeling of target domain data from different instruments / batch / time periods. This significantly reduces labeling and labor costs in industrial scenarios and adapts to working conditions where target domain labeled data is difficult to obtain in practical applications.

[0019] 4. Quantification and Precision of Cross-Domain Alignment: By calculating the mean and standard deviation of the latent spaces of the source and target domains, the degree of distribution shift is quantified, providing a quantitative basis for subsequent mean-variance transformation style transfer and providing precise support for simulating real drift in latent space style transfer. Compared with traditional empirical alignment methods, this makes cross-domain distribution alignment more targeted and precise.

[0020] 5. Hierarchical optimization of feature space: A hierarchical cross-domain optimization strategy is adopted, which includes initial distribution alignment, joint structural optimization, and deep domain adaptation. First, the core statistical offset between the source domain and the target domain is eliminated. Then, the structural integrity and separability of the target domain features are guaranteed. Finally, domain-invariant features are extracted. The cross-domain feature offset problem is solved step by step, and the optimization effect is more significant.

[0021] 6. Dynamic and rational model training: In the cross-domain joint training stage, the progressive weight scheduling is used to adjust the loss weights and the strength of the loss constraint is dynamically optimized according to the training process. This avoids the training imbalance caused by a single weight, making the model training process more stable and significantly improving the generalization and robustness of the final model.

[0022] 7. End-to-end collaborative optimization: The solution adopts end-to-end joint network construction and training in multiple stages (such as the joint construction of C-VAE and classifier, and the joint construction of cross-domain feature fusion and domain adaptation), which avoids the problem of feature and task disconnect in the traditional two-step process. It enables the features learned by the model to better fit the task requirements of gas classification, while simplifying the training process and improving the training efficiency of the model.

[0023] 8. Integration of Data Augmentation and Cross-Domain Adaptation: While achieving cross-domain distribution alignment through style transfer in the latent space, source domain data augmentation is also completed, further enhancing the simulation effect of latent space style transfer on real drift. This method can accurately simulate the complex domain drift characteristics of real sensors, solving the problem of insufficient domain drift simulation by traditional data augmentation, expanding the diversity of training data, enabling the model to learn more generalized cross-domain feature patterns, and further improving the model's adaptability to the target domain distribution.

[0024] This method can effectively solve the nonlinear drift problem of electronic nose sensors, capture the distribution pattern of gas features more comprehensively, improve the robustness of feature extraction, effectively improve the detection stability and accuracy of electronic nose systems in the target domain, adapt to the cross-domain online recognition needs of electronic noses in industrial scenarios, and can be directly deployed in electronic nose systems, which helps to promote the large-scale application of electronic nose technology in long-term continuous monitoring scenarios.

[0025] Furthermore, in order to enable the model to learn gas features that are both complete and highly discriminative, thus laying a solid foundation for high-quality models in subsequent cross-domain adaptations, the process of constructing the initial C-VAE feature learning and classification model in S1 is as follows:

[0026] S11: Source Domain Dataset Construction; Collect electronic nose data from the same instrument or batch and construct a labeled dataset. ;

[0027] S12: Construct a C-VAE probabilistic feature extractor; construct an initial C-VAE network including an encoder, reparameterized sampling, and a decoder, and construct the basic loss function of the initial C-VAE network. ;

[0028] S13: Construct a joint network of the initial C-VAE network and the classifier; connect the classifier to the output of the initial C-VAE network to build a joint learning network;

[0029] S14: Joint supervised training of the joint learning network; in the basic loss function Based on this, add a classification loss function Construct the combined C-VAE loss function Training is performed on labeled source domain data, the weights of each loss term are progressively adjusted, and the combined C-VAE loss function is minimized. The initial model is obtained after training. ;

[0030] S15: Class alignment of contrastive variational autoencoders; introducing contrastive loss constraints to optimize class alignment in the C-VAE latent space, enhancing the inter-class separability and intra-class aggregation of latent features, and combining the C-VAE loss function. Based on this, add a contrastive loss function Construct a joint optimization total loss function Based on joint optimization of the total loss function The joint learning network is trained under secondary supervision, and the optimized initial model with class alignment is obtained. .

[0031] Furthermore, in order to efficiently achieve cross-domain latent spatial distribution alignment and multi-dimensional optimization of feature structure, while balancing adaptation efficiency and feature quality, the process of latent spatial distribution alignment and structure optimization in S2 is as follows:

[0032] S21: Acquisition of unlabeled data in the target domain; acquisition of unlabeled data in the target domain collected by different instruments / batch / time. Construct the target domain dataset ;

[0033] S22: Latent feature extraction of the target domain; extracting unlabeled data from the target domain. Input class aligned initial model Unsupervised encoding is performed using the C-VAE encoder of the model, and the latent space vector of the target domain is obtained through reparameterized sampling. ;

[0034] S23: Calculation of latent statistics for the source and target domains; calculate the mean and standard deviation of the source and target domains in the latent space respectively, and obtain two sets of core statistics: latent statistics for the source domain and latent statistics for the target domain;

[0035] S24: Style transfer data augmentation based on latent space; The mean-variance transformation is used to perform style transfer on the latent features of the source domain to achieve preliminary distribution alignment across the latent space, and data augmentation is performed based on the transferred features.

[0036] S25: Multi-technology joint optimization of the latent space structure of the target domain; based on distribution alignment, the latent feature structure of the target domain is optimized to ensure the separability, feature integrity and distribution rationality of the latent space of the target domain.

[0037] Furthermore, to ensure both the adaptability and accuracy of the cross-domain model and the efficiency and convenience of engineering implementation, the process of constructing a cross-domain gas recognition model and performing online recognition in S3 is as follows:

[0038] S31: Cross-domain feature integration and multi-policy domain alignment training; optimizing the latent vectors of the source domain after style transfer and data augmentation. With the latent features optimized from the target domain after latent space optimization Merge them to build a cross-domain joint training set. By constraining the distribution differences of features between the source and target domains, depth alignment of features between the two domains is achieved, enabling domain-invariant feature extraction.

[0039] S32: Cross-domain joint loss optimization and final model generation; optimization of the cross-domain joint training set. Training is performed under the constraint of the joint loss function, and the loss weights are adjusted using asymptotic weight scheduling to finally obtain the cross-domain gas recognition model. ;

[0040] S33: Online identification; real-time acquisition of unlabeled data in the target domain. As input data, a cross-domain gas identification model is used. Perform online identification and output gas category prediction results.

[0041] As a preferred option, in S11 of S1, the labeled dataset is constructed according to formula (1). In S1 of S1, the basic loss function of C-VAE is constructed according to formula (2). In S14 of S1, the combined C-VAE loss function is constructed according to formula (3);

[0042] (1);

[0043] In the formula, , indicating the first Time-series signals of sensor arrays from a source domain sample, For the set of real numbers, In terms of time dimension, Spatial dimension; , indicating the first Gas category labels corresponding to each source domain sample This represents the total number of gas categories. This represents the total number of samples in the source domain.

[0044] (2);

[0045] In the formula, To rebuild the losses, , For the first Source domain samples The reconstructed signal after encoder reconstruction; For divergence loss, , For the first Source domain samples After encoder mapping, the mean of the Gaussian distribution of the latent space is obtained. For the first Source domain samples The standard deviation of the Gaussian distribution in the latent space obtained after encoder mapping; The basic harmonic parameters for reconstructing the loss; The basic harmonic parameters for divergence loss;

[0046] (3);

[0047] In the formula, The harmonic parameters are used for the classification loss.

[0048] Furthermore, in order to accurately achieve intra-class aggregation and inter-class separation of C-VAE latent space features and effectively enhance the class discriminativeness of features, the class alignment process of the variational autoencoder is compared in S15 of S1 as follows:

[0049] S15-1: Extract the mean of the C-VAE latent distribution As a stable feature representation of data;

[0050] S15-2: Construct a similarity matrix of latent features based on source domain data;

[0051] S15-3: Based on gas category label Construct a positive and negative sample mask, defining samples of the same class as positive samples and samples of different classes as negative samples;

[0052] S15-4: Introducing the InfoNCE Contrast Loss Function This enables features within a class to be brought closer together and features between classes to be pushed further apart.

[0053] S15-5: Construct the joint optimization total loss function according to formula (4) ;

[0054] (4);

[0055] In the formula, Harmonic parameters for comparison loss.

[0056] As a preferred option, in S21 of S2, the target domain dataset is constructed according to formula (5). In S2 of S2, the target domain potential vector is obtained according to formula (6). In S23 of S2, the global mean of the source domain is obtained according to formulas (7) and (8) respectively. and global standard deviation The global mean of the target domain is obtained according to formulas (9) and (10) respectively. and global standard deviation ;

[0057] (5);

[0058] In the formula, , indicating the first Time-series input signals of sensor arrays for each target domain sample; The total number of samples in the target domain;

[0059] (6);

[0060] In the formula, The mean of the potential distribution; For standard normally distributed noise, ; is the logarithmic vector of the variance of the potential distribution.

[0061] (7);

[0062] (8);

[0063] (9);

[0064] (10);

[0065] In the formula, For the first Target domain samples The output latent space has a Gaussian distribution mean after unsupervised encoding by the encoder.

[0066] Furthermore, in order to achieve accurate distribution alignment across the latent space and decode and generate source domain augmented samples with the style of the target domain, and to effectively improve cross-domain data diversity and distribution alignment without annotation costs, the style transfer data augmentation process based on the latent space in S24 of S2 is as follows:

[0067] S24-1: Obtain the source domain latent feature normalization result according to formula (11) ;

[0068] (11);

[0069] In the formula, For the first Source domain samples The original source domain latent space vector obtained after encoder encoding and reparameterized sampling;

[0070] S24-2: Normalization results of latent features in the source domain using mean-variance transformation Perform style transfer in the target domain and obtain the intermediate product of the source domain latent vector after style transfer according to formula (12). ;

[0071] (12);

[0072] S24-3: Intermediate product of source domain latent vectors after style transfer The input decoder generates source domain augmented samples with a style consistent with the target domain. Based on the decoded source domain augmented samples, the source domain latent vector intermediate product is optimized in reverse. The feature completeness and discriminativeness are improved, and finally, the source domain optimized latent vectors are obtained after style transfer and data augmentation. .

[0073] As a preferred option, in S31 of S3, a joint training set is constructed according to formula (13). ;

[0074] (13).

[0075] Furthermore, in order to effectively improve the robustness and target domain adaptability of the cross-domain gas recognition model by constraining the model from multiple dimensions such as classification tasks, cross-domain distribution alignment, and feature reconstruction, the process of cross-domain joint loss optimization and final model generation in S32 of S3 is as follows:

[0076] S32-1: Construct the pseudo-label classification loss function according to formula (14) Based on formula (15), construct the entropy minimization loss function. Based on formula (16), the maximum mean difference loss of source and target domain features is constructed. ;

[0077] (14);

[0078] (15);

[0079] (16);

[0080] In the formula, For the first in the target domain The predicted probability distribution of each sample; For the first in the target domain The sample belongs to the first The predicted probability values ​​for each category; For the first The source domain optimized latent vector of each sample; For the first Potential features of the target domain after optimization for each sample;

[0081] S32-2: Construct the joint loss function according to formula (17) By combining progressive weight scheduling for joint training, a cross-domain gas recognition model is finally obtained. ;

[0082] (17);

[0083] In the formula, For task classification loss function of labeled data in the source domain; The adversarial loss function for the domain discriminator; For cross-domain contrastive loss function; , , , , , , These are the asymptotic harmonic parameters for the cross-domain stage task classification loss function, pseudo-label classification loss function, entropy minimization loss function, maximum mean difference loss, adversarial loss function, the basic loss function of C-VAE, and the cross-domain contrastive loss function, respectively. Attached Figure Description

[0084] Figure 1 This is a structural block diagram of the C-VAE in this invention;

[0085] Figure 2 This is a schematic diagram illustrating the comparative learning of latent space alignment in this invention;

[0086] Figure 3 This is a flowchart of the style transfer data enhancement process in this invention;

[0087] Figure 4 This is a flowchart of the entire invention;

[0088] Figure 5 The diagram shows the performance comparison of each model configuration in this invention; where (a) is the classification accuracy of each model on the target task; (b) is the curve of the change in test accuracy during training; (c) is the percentage improvement in performance relative to the baseline model; and (d) is the change in reconstruction loss of each model with training rounds.

[0089] Figure 6 This is a schematic diagram of the feature space distribution of different models. Detailed Implementation

[0090] The invention will now be further described with reference to the accompanying drawings.

[0091] like Figures 1 to 6 As shown, this invention provides a cross-domain recognition and drift compensation method for electronic noses based on a contrastive variational autoencoder, comprising the following steps:

[0092] S1: Source domain supervised pre-training to build the initial C-VAE feature learning and classification model; constructing the labeled dataset. An initial C-VAE network containing an encoder, reparameterized sampling, and a decoder was constructed, and the basic loss function was established. The initial C-VAE network is connected to the classifier to form a joint learning network, and a classification loss function is introduced. Constructing the combined C-VAE loss function The initial model is obtained through training. Then, introduce contrastive loss constraints and add a contrastive loss function. Construct a joint optimization total loss function Perform secondary training to obtain an initial model with class alignment. In order to enable the model to learn gas features that are both complete and highly discriminative, and to lay a solid foundation for a high-quality model for subsequent cross-domain adaptation, the specific process is as follows:

[0093] S11: Source Domain Dataset Construction; Collect electronic nose data from the same instrument or batch and construct a labeled dataset. ;

[0094] As a preferred method, the labeled dataset is constructed according to formula (1). ;

[0095] (1);

[0096] In the formula, , indicating the first Time-series signals of sensor arrays from a source domain sample, For the set of real numbers, In terms of time dimension, Spatial dimension; , indicating the first Gas category labels corresponding to each source domain sample This represents the total number of gas categories. This represents the total number of samples in the source domain.

[0097] S12: Construct a C-VAE probabilistic feature extractor; construct an initial C-VAE network including an encoder, reparameterized sampling, and a decoder, and construct the basic loss function of the initial C-VAE network. ;

[0098] The encoder employs a combined network structure of three one-dimensional convolutional layers and pooling layers to process time-series signals from the sensor array. As input, local features are extracted through three layers of one-dimensional convolution and pooling layers, and the latent distribution parameters are output. and (Latent distribution mean vector) The logarithmic vector of the variance of the potential distribution Reparameterized sampling is based on introduced random noise. Generate latent vectors The decoder employs a three-layer deconvolutional network structure (recovering the time series dimension layer by layer) to obtain the latent spatial vector. As input, the reconstructed signal is reconstructed through three deconvolutional layers. The classifier is used to classify the latent space vectors. As input, and output the gas category prediction probability. To achieve gas category discrimination based on latent vectors;

[0099] As a preferred option, the basic loss function of C-VAE is constructed according to formula (2). ;

[0100] (2);

[0101] In the formula, To rebuild the losses, , The core of C-VAE reconstruction constraints is to use a decoder to reconstruct the input signal, minimizing the reconstruction error while preserving no features. For the first Source domain samples The reconstructed signal after encoder reconstruction; For divergence loss, , Corresponding to the KL divergence constraint, its core function is to maintain good continuity and controllability of the latent distribution, and to avoid chaotic distribution of latent features. For the first Source domain samples After encoder mapping, the mean of the Gaussian distribution of the latent space is obtained. For the first Source domain samples The standard deviation of the Gaussian distribution in the latent space obtained after encoder mapping; The basic harmonic parameters for reconstructing the loss; The basic harmonic parameters for divergence loss;

[0102] S13: Construct a joint network of the initial C-VAE network and the classifier; connect the classifier to the output of the initial C-VAE network to build a joint learning network; in this way, after the initial C-VAE network outputs the latent features, the features are then input into the classifier to predict the gas category, laying the structural foundation for subsequent joint training.

[0103] S14: Joint supervised training of the joint learning network; in the basic loss function Based on this, add a classification loss function Construct the combined C-VAE loss function Training is performed on labeled source domain data, the weights of each loss term are progressively adjusted, and the combined C-VAE loss function is minimized. The initial model is obtained after training. Initial model It has the ability to stably identify gases under source region conditions, while ensuring the continuity and controllability of potential spatial distribution;

[0104] As a preferred option, a combined C-VAE loss function is constructed according to formula (3);

[0105] (3);

[0106] In the formula, The harmonic parameters are used for the classification loss.

[0107] S15: Class alignment in contrastive variational autoencoders; introducing contrastive loss constraints to optimize class alignment in the C-VAE latent space. The core logic of contrastive learning is to construct positive and negative sample pairs, bringing latent features of similar structures (samples of the same class) closer together and pushing latent features of different distributions (samples of different classes) further apart, thereby strengthening the inter-class separability and intra-class aggregation of latent features, and combining this with the C-VAE loss function. Based on this, add a contrastive loss function Construct a joint optimization total loss function Based on joint optimization of the total loss function The joint learning network is trained under secondary supervision, and the optimized initial model with class alignment is obtained. To align latent representations with category labels; to introduce contrastive learning on top of C-VAE to enhance the discriminative power of category-level features; and to construct a label-based positive and negative sample mask.

[0108] To accurately achieve intra-class aggregation and inter-class separation of C-VAE latent space features and effectively enhance the class discriminativeness of features, the class alignment process compared to variational autoencoders is as follows:

[0109] S15-1: Extract the mean of the C-VAE latent distribution As a stable feature representation of data;

[0110] S15-2: Construct a similarity matrix of latent features based on source domain data;

[0111] S15-3: Based on gas category label Construct a positive and negative sample mask, defining samples of the same class as positive samples and samples of different classes as negative samples;

[0112] S15-4: Introducing the InfoNCE Contrast Loss Function This enables features within a class to be brought closer together and features between classes to be pushed further apart.

[0113] S15-5: Construct the joint optimization total loss function according to formula (4) ;

[0114] (4);

[0115] In the formula, Harmonic parameters for comparison loss.

[0116] S2: Unsupervised representation learning of the target domain to achieve latent spatial distribution alignment and structural optimization;

[0117] Construct target domain dataset And input the initial model with category alignment. The latent space vector of the target domain is obtained through encoder and reconstruction parameterized sampling. The process involves calculating the mean and standard deviation statistics of the source and target domains in the latent space; performing source domain feature style transfer and data augmentation through mean-variance transformation; optimizing the latent feature structure of the target domain through various constraints to ensure its separability, integrity, and reasonable distribution; and, to efficiently achieve cross-domain latent space distribution alignment and multi-dimensional optimization of feature structure, balancing adaptation efficiency and feature quality, the specific steps are as follows:

[0118] S21: Acquisition of unlabeled data in the target domain; acquisition of unlabeled data in the target domain collected by different instruments / batch / time. Construct the target domain dataset ;

[0119] As a preferred option, the target domain dataset is constructed according to formula (5). ;

[0120] (5);

[0121] In the formula, , indicating the first Time-series input signals of sensor arrays for each target domain sample; The total number of samples in the target domain;

[0122] S22: Latent feature extraction of the target domain; extracting unlabeled data from the target domain. Input class aligned initial model Unsupervised encoding is performed using the C-VAE encoder of the model, and the latent space vector of the target domain is obtained through reparameterized sampling. ;

[0123] As a preferred option, the latent vector of the target domain is obtained according to formula (6). ;

[0124] (6);

[0125] In the formula, The mean of the potential distribution; For standard normally distributed noise, ; is the logarithmic vector of the variance of the potential distribution.

[0126] S23: Calculation of latent statistics for the source and target domains; calculate the mean and standard deviation of the source and target domains in the latent space respectively, and obtain two sets of core statistics: source domain latent statistics ( , ) and target domain latent statistics ( , This provides a data foundation for subsequent distribution alignment;

[0127] As a preferred option, the global mean of the source domain is obtained according to formulas (7) and (8), respectively. and global standard deviation The global mean of the target domain is obtained according to formulas (9) and (10) respectively. and global standard deviation ;

[0128] (7);

[0129] (8);

[0130] (9);

[0131] (10);

[0132] In the formula, For the first Target domain samples The output latent space has a Gaussian distribution mean after unsupervised encoding by the encoder.

[0133] S24: Style transfer data augmentation based on latent space; The mean-variance transformation is used to perform style transfer on the latent features of the source domain, so that the latent features of the source domain move closer to the feature distribution of the target domain, simulate the feature distribution style of the target domain, achieve preliminary distribution alignment across the latent space, and perform data augmentation based on the transferred features.

[0134] The core of style transfer is to transform the distribution features (mean / variance) of the latent features in the source domain into the distribution features of the target domain, thereby achieving initial alignment across the latent space. At the same time, the generated enhanced samples can enrich the dataset for subsequent cross-domain training.

[0135] To achieve accurate distribution alignment across latent spaces and decode and generate source-domain augmented samples with target-domain styles, and to effectively improve cross-domain data diversity and distribution alignment without annotation costs, the style transfer data augmentation process based on latent spaces is as follows:

[0136] S24-1: Obtain the source domain latent feature normalization result according to formula (11) ;

[0137] (11);

[0138] In the formula, For the first Source domain samples The original source domain latent space vector obtained after encoder encoding and reparameterized sampling;

[0139] S24-2: Normalization results of latent features in the source domain using mean-variance transformation Perform style transfer in the target domain and obtain the intermediate product of the source domain latent vector after style transfer according to formula (12). ;

[0140] (12);

[0141] S24-3: Intermediate product of source domain latent vectors after style transfer The input decoder generates source domain augmented samples with a style consistent with the target domain. Based on the decoded source domain augmented samples, the source domain latent vector intermediate product is optimized in reverse. The feature completeness and discriminativeness are improved, and finally, the source domain optimized latent vectors are obtained after style transfer and data augmentation. .

[0142] As a preferred option, in S31 of S3, a joint training set is constructed according to formula (13). ;

[0143] (13).

[0144] S25: Multi-technical joint optimization of the latent space structure of the target domain; Based on distribution alignment, the latent feature structure of the target domain is optimized. By combining the separability enhancement of contrast loss constraint, the feature integrity guarantee of C-VAE reconstruction constraint, and the distribution controllability constraint of KL divergence constraint, the distribution of target domain samples in the latent space is made more regular, ensuring the separability, feature integrity and distribution rationality of the latent space of the target domain.

[0145] Techniques such as feature smoothing and structure regularization can be used to analyze the latent features of the target domain. Optimization is performed to obtain the optimized latent features of the target domain. This provides high-quality features for subsequent cross-domain joint training and makes up for the omissions in the original result definition.

[0146] S3: Cross-domain joint domain adaptation training to build a cross-domain gas recognition model and perform online recognition;

[0147] Merging source domain optimized latent vectors after style transfer and data augmentation With the latent features optimized from the target domain after latent space optimization Constructing a joint training set By constraining the distribution differences of features between the source and target domains, depth alignment of features between the two domains is achieved; for the joint training set Training is performed under a joint loss function, with asymptotic scheduling of the weights of each loss term. The focus is on optimizing the classification loss (including the classification loss for labeled samples in the target domain), while also considering the distributional differences between the source and target domain features. After joint optimization, a cross-domain gas recognition model is obtained. Real-time acquisition of target domain data, input into cross-domain gas recognition model. Complete online identification and output of gas category prediction results; to ensure both the adaptability and accuracy of cross-domain models and the efficiency and convenience of engineering implementation, the specific process is as follows:

[0148] S31: Cross-domain feature integration and multi-policy domain alignment training; optimizing the latent vectors of the source domain after style transfer and data augmentation. With the latent features optimized from the target domain after latent space optimization Merge them to build a cross-domain joint training set. Domain adaptation techniques (such as domain adversarial techniques and MMD alignment) are employed to deeply align the features of the source and target domains in the latent space, thereby achieving domain-invariant feature extraction.

[0149] The alignment process includes:

[0150] Adversarial domain classifier (domain alignment loss): Domain-invariant feature learning is achieved through adversarial training that minimizes the classifier loss and maximizes the domain discrimination loss;

[0151] Maximum Mean Difference (MMD) Alignment: Calculate the mean of features of the source and target domains in a high-dimensional kernel space, and minimize the MMD distance to make the means of the two domains closer;

[0152] Class center alignment: Calculate the center of each latent feature of the source domain, minimize the distance between the class center of the source domain and the latent features of the same class in the target domain, and achieve class-level alignment;

[0153] Contrastive learning alignment: Constructing positive and negative sample relationships between cross-domain samples to optimize the potential spatial structure of inter-class separability and intra-class clustering;

[0154] S32: Cross-domain joint loss optimization and final model generation; optimization of the cross-domain joint training set. Training is performed under the constraint of the joint loss function, and the loss weights are adjusted using asymptotic weight scheduling to finally obtain the cross-domain gas recognition model. ;

[0155] To effectively improve the robustness and target domain adaptability of the cross-domain gas recognition model by constraining the model from multiple dimensions such as classification tasks, cross-domain distribution alignment, and feature reconstruction, the process of cross-domain joint loss optimization and final model generation is as follows:

[0156] S32-1: Construct the pseudo-label classification loss function according to formula (14) Based on formula (15), construct the entropy minimization loss function. Based on formula (16), the maximum mean difference loss of source and target domain features is constructed. ;

[0157] (14);

[0158] (15);

[0159] (16);

[0160] The core function of the maximum mean difference (MMD) alignment technique is to make the mean values ​​of the features of the source and target domains close in high-dimensional space, thereby achieving the initial alignment of the potential features of the two domains.

[0161] In the formula, For the first in the target domain The predicted probability distribution of each sample; For the first in the target domain The sample belongs to the first The predicted probability values ​​for each category; For the first The source domain optimized latent vector of each sample; For the first Potential features of the target domain after optimization for each sample;

[0162] S32-2: Construct the joint loss function according to formula (17) By combining progressive weight scheduling for joint training, a cross-domain gas recognition model is finally obtained. Cross-domain gas identification model It can be directly applied to gas identification tasks in the target domain, and can complete target domain identification under the condition that the target domain is mainly unlabeled data;

[0163] (17);

[0164] In the formula, For task classification loss function of labeled data in the source domain; For the adversarial loss function of the domain discriminator, corresponding to the adversarial domain classifier, the core is to achieve domain feature confusion and improve domain invariance by minimizing the classifier loss and maximizing the domain discriminant loss; For cross-domain contrastive loss function, corresponding to contrastive loss constraint alignment, the core is to build positive and negative sample relationships between cross-domain samples, to realize the potential structure of inter-class separability and intra-class clustering; , , , , , , These are the asymptotic harmonic parameters for the cross-domain stage task classification loss function, pseudo-label classification loss function, entropy minimization loss function, maximum mean difference loss, adversarial loss function, the basic loss function of C-VAE, and the cross-domain contrastive loss function. The weights are asymptotically adjusted during training iterations (e.g., the domain adversarial loss weights are gradually increased). This achieves deep domain alignment of features between the source and target domains while maintaining the model's gas classification accuracy.

[0165] S33: Online identification; real-time acquisition of unlabeled data in the target domain. As input data, a cross-domain gas identification model is used. Perform online gas identification and output gas category prediction results. Input data is processed by a cross-domain gas identification model. After the C-VAE encoder extracts domain-invariant latent features, it inputs the classifier to directly output the gas category prediction result, completing end-to-end online recognition. The robustness of the model stems from two aspects: firstly, the synergistic effect of multiple domain alignment techniques such as adversarial domain classifiers and MMD alignment, which achieves deep alignment of features between the source and target domains; secondly, the synergistic optimization of contrastive loss constraints, C-VAE reconstruction constraints, and KL divergence constraints (C-VAE representation enhancement), which prevents feature collapse and ensures the normalization of the latent space of the target domain. At the same time, the cross-domain category alignment effect can be further enhanced through class center alignment (calculating the center of each feature and minimizing the distance).

[0166] Experiments were conducted using the method of this invention, and the results are shown in Table 1. Simultaneously, the feature space distribution of the method of this invention was compared with that of traditional methods through experiments, as shown below. Figure 6 As shown, the feature vectors output by the model are visualized by dimensionality reduction. Different colored points represent different gas categories. The figure includes the feature distribution of CNN, AE, VAE, VAE+Global Contrast and C-VAE models on the same dataset, which can effectively illustrate the differences in sample separability and cluster structure of each model in the latent space.

[0167] Table 1: Comparison of gas identification accuracy (%) of different methods on various target domain tasks

[0168]

[0169] To address the core issues of nonlinear drift and cross-domain gas recognition in electronic nose sensors, existing technologies suffer from three major drawbacks: First, deterministic feature extractors cannot effectively describe differences in data distribution, and cross-domain drift can easily cause model feature distribution collapse, leading to a significant decrease in classification accuracy. Second, traditional domain alignment methods only achieve global distribution alignment, making it difficult to achieve fine alignment at the category level. Similar features are not effectively brought closer together, and dissimilar features are not sufficiently pushed apart, resulting in blurred category boundaries and poor target domain recognition performance. Third, conventional data augmentation methods cannot accurately simulate real sensor drift scenarios, causing a deviation between the model training distribution and the actual usage distribution, resulting in weak generalization ability. To address the aforementioned issues, this invention provides an uncertainty-aware semi-supervised domain adaptation method based on a contrastive variational autoencoder (C-VAE) to solve drift compensation and cross-domain recognition problems in gas sensors. First, a C-VAE probabilistic feature extractor is constructed based on labeled source domain data. A joint learning network is built by combining this with a classifier. Initial model training is completed through joint optimization of the C-VAE base loss and classification loss. A contrastive loss constraint is introduced to optimize the class alignment of the C-VAE latent space. This constraint achieves cross-domain class-level alignment, enhancing the inter-class separability and intra-class aggregation of latent features. The construction of the probabilistic latent space strengthens the anti-drift capability and effectively solves the problems of insufficient robustness in feature extraction and class discriminability of latent features, laying a high-quality model foundation for subsequent cross-domain adaptation. Next, unsupervised representation learning was conducted on unlabeled data in the target domain. The C-VAE encoder of the initial model was used to extract latent features in the target domain. Core statistics of the latent spaces in both the source and target domains were calculated, and mean-variance transformation was employed to achieve style transfer and data augmentation of the latent space. Style transfer enhancement of the latent space simulated real-world drift, achieving initial distribution alignment across domains. Furthermore, the latent feature structure of the target domain was jointly optimized using multiple approaches. This addressed the feature distribution shift between the source and target domains caused by instrument / batch / time differences, while primarily using unlabeled data and allowing for the inclusion of a small amount of labeled target domain data. This approach balanced efficiency and practicality in cross-domain adaptation. Subsequently, the style-transfer-optimized latent features of the source domain and the structure-optimized latent features of the target domain were fused to construct a cross-domain joint training set. Multi-strategy domain adaptation techniques were then employed to achieve deep alignment of cross-domain features and extraction of domain-invariant features. By fusing multi-dimensional losses to construct a joint loss function and combining it with asymptotic weight scheduling to optimize the cross-domain joint loss, and dynamically balancing the strength of each loss constraint, a robust cross-domain gas recognition model with both source domain classification capability and target domain adaptation capability is constructed. This solves the problems of deep fusion of cross-domain features and insufficient model generalization. Finally, this model is used to directly connect to real-time collected unlabeled data in the target domain to achieve online, fast and accurate identification of gas categories.Therefore, this invention effectively solves three key technical problems in existing electronic nose cross-domain classification and drift compensation methods: insufficient feature representation capability (traditional deterministic feature extraction models such as CNN and AE cannot describe the probability distribution of gas signals, resulting in unstable model performance under strong drift conditions and easy "collapse" of feature distribution), insufficient cross-domain category alignment (most existing methods (such as DANN) only perform global distribution alignment, which results in the inability to effectively bring samples of the same class in the source and target domains closer in the latent space, and samples of different classes are not pushed apart, resulting in blurred class boundaries, especially poor recognition performance on difficult samples), and insufficient data augmentation to simulate domain drift (ordinary noise augmentation and other methods are difficult to simulate the complex distribution drift caused by aging, poisoning or environmental changes of real sensors, resulting in inconsistent model training distribution and real usage distribution, and weak generalization ability).

[0170] This method can effectively solve the nonlinear drift problem of electronic nose sensors, capture the distribution pattern of gas features more comprehensively, improve the robustness of feature extraction, effectively improve the detection stability and accuracy of electronic nose systems in the target domain, adapt to the cross-domain online recognition needs of electronic noses in industrial scenarios, and can be directly deployed in electronic nose systems, which helps to promote the large-scale application of electronic nose technology in long-term continuous monitoring scenarios.

Claims

1. A method for cross-domain recognition and drift compensation of electronic nose based on contrastive variational autoencoders, characterized in that, Includes the following steps: S1: Source domain supervised pre-training to build the initial C-VAE feature learning and classification model; Building a labeled dataset An initial C-VAE network containing an encoder, reparameterized sampling, and a decoder was constructed, and the basic loss function was established. The initial C-VAE network is connected to the classifier to form a joint learning network, and a classification loss function is introduced. Constructing the combined C-VAE loss function The initial model is obtained through training. Then, introduce contrastive loss constraints and add a contrastive loss function. Construct a joint optimization total loss function Perform secondary training to obtain an initial model with class alignment. ; S2: Unsupervised representation learning of the target domain to achieve latent spatial distribution alignment and structural optimization; Construct the target domain dataset and input the initial model with class alignment , and obtain the target domain latent space vector through the encoder and reconstruction parameterized sampling ; calculate the mean and standard deviation statistics of the source domain and the target domain in the latent space; achieve source domain feature style transfer and data augmentation through mean-variance transformation; optimize the target domain latent feature structure through multiple constraint methods; S3: Cross-domain joint domain adaptation training to build a cross-domain gas recognition model and perform online recognition; Merging source domain optimized latent vectors after style transfer and data augmentation With the latent features optimized from the target domain after latent space optimization Constructing a joint training set By constraining the distribution differences of features between the source and target domains, depth alignment of features between the two domains is achieved; for the joint training set Training is performed under a joint loss function, and the weights of each loss term are asymptotically scheduled to obtain a cross-domain gas recognition model. ; Real-time acquisition of target domain data, input into cross-domain gas recognition model Complete online identification and output gas category prediction results.

2. The electronic nose cross-domain recognition and drift compensation method based on a contrastive variational autoencoder according to claim 1, characterized in that, In S1, the process of constructing the initial C-VAE feature learning and classification model is as follows: S11: Source Domain Dataset Construction; Collect electronic nose data from the same instrument or batch and construct a labeled dataset. ; S12: Construct a C-VAE probabilistic feature extractor; construct an initial C-VAE network including an encoder, reparameterized sampling, and a decoder, and construct the basic loss function of the initial C-VAE network. ; S13: Construct a joint network of the initial C-VAE network and the classifier; connect the classifier to the output of the initial C-VAE network to build a joint learning network; S14: Joint supervised training of the joint learning network; in the basic loss function Based on this, add a classification loss function Construct the combined C-VAE loss function Training is performed on labeled source domain data, the weights of each loss term are progressively adjusted, and the combined C-VAE loss function is minimized. The initial model is obtained after training. ; S15: Class alignment of contrastive variational autoencoders; introducing contrastive loss constraints to optimize class alignment in the C-VAE latent space, enhancing the inter-class separability and intra-class aggregation of latent features, and combining the C-VAE loss function. Based on this, add a contrastive loss function Construct a joint optimization total loss function Based on joint optimization of the total loss function The joint learning network is trained under secondary supervision, and the optimized initial model with class alignment is obtained. .

3. The electronic nose cross-domain recognition and drift compensation method based on a contrastive variational autoencoder according to claim 1, characterized in that, In S2, the process of achieving potential spatial distribution alignment and structural optimization is as follows: S21: Acquisition of unlabeled data in the target domain; acquisition of unlabeled data in the target domain collected by different instruments / batch / time. Construct the target domain dataset ; S22: Latent feature extraction of the target domain; extracting unlabeled data from the target domain. Input class aligned initial model Unsupervised encoding is performed using the C-VAE encoder of the model, and the latent space vector of the target domain is obtained through reparameterized sampling. ; S23: Calculation of latent statistics for the source and target domains; calculate the mean and standard deviation of the source and target domains in the latent space respectively, and obtain two sets of core statistics: latent statistics for the source domain and latent statistics for the target domain; S24: Style transfer data augmentation based on latent space; We employ mean-variance transformation to perform style transfer on latent features in the source domain, achieving preliminary distribution alignment across the latent space. Simultaneously, we perform data augmentation based on the transferred features. S25: Multi-technology joint optimization of the latent space structure of the target domain; based on distribution alignment, the latent feature structure of the target domain is optimized to ensure the separability, feature integrity and distribution rationality of the latent space of the target domain.

4. The electronic nose cross-domain recognition and drift compensation method based on a contrastive variational autoencoder according to claim 1, characterized in that, In S3, the process of constructing a cross-domain gas identification model and performing online identification is as follows: S31: Cross-domain feature integration and multi-policy domain alignment training; optimizing the latent vectors of the source domain after style transfer and data augmentation. With the latent features optimized from the target domain after latent space optimization Merge them to build a cross-domain joint training set. By constraining the distribution differences of features between the source and target domains, depth alignment of features between the two domains is achieved, enabling domain-invariant feature extraction. S32: Cross-domain joint loss optimization and final model generation; optimization of the cross-domain joint training set. Training is performed under the constraint of the joint loss function, and the loss weights are adjusted using asymptotic weight scheduling to finally obtain the cross-domain gas recognition model. ; S33: Online recognition; Real-time acquisition of unlabeled data in the target domain As input data, a cross-domain gas identification model is used. Perform online identification and output gas category prediction results.

5. The electronic nose cross-domain recognition and drift compensation method based on a contrastive variational autoencoder according to claim 2, characterized in that, In S11, the labeled dataset is constructed according to formula (1). In S12, the basic loss function of C-VAE is constructed according to formula (2). In S14, the combined C-VAE loss function is constructed according to formula (3); (1); In the formula, , indicating the first Time-series signals of sensor arrays from a source domain sample, For the set of real numbers, In terms of time dimension, Spatial dimension; , indicating the first Gas category labels corresponding to each source domain sample This represents the total number of gas categories. This represents the total number of samples in the source domain. (2); In the formula, To rebuild the losses, , For the first Source domain samples The reconstructed signal after encoder reconstruction; For divergence loss, , For the first The latent mean of a source domain sample For the first The potential distribution standard deviation of each source domain sample; The basic harmonic parameters for reconstructing the loss; The basic harmonic parameters for divergence loss; (3); In the formula, The harmonic parameters are used for the classification loss.

6. The electronic nose cross-domain recognition and drift compensation method based on a contrastive variational autoencoder according to claim 2, characterized in that, In S15 of S1, the process of class alignment for the contrastive autoencoder is as follows: S15-1: Extract the mean of the C-VAE latent distribution As a stable feature representation of data; S15-2: Construct a similarity matrix of latent features based on source domain data; S15-3: Based on gas category label Construct a positive and negative sample mask, defining samples of the same class as positive samples and samples of different classes as negative samples; S15-4: Introducing the InfoNCE Contrast Loss Function This enables features within a class to be brought closer together and features between classes to be pushed further apart. S15-5: Construct the joint optimization total loss function according to formula (4) ; (4); In the formula, Harmonic parameters for comparison loss.

7. The electronic nose cross-domain recognition and drift compensation method based on a contrastive variational autoencoder according to claim 3, characterized in that, In S21 of S2, the target domain dataset is constructed according to formula (5). In S2 of S2, the target domain potential vector is obtained according to formula (6). In S23 of S2, the global mean of the source domain is obtained according to formulas (7) and (8) respectively. and global standard deviation The global mean of the target domain is obtained according to formulas (9) and (10) respectively. and global standard deviation ; (5); In the formula, , indicating the first Time-series input signals of sensor arrays for each target domain sample; The total number of samples in the target domain; (6); In the formula, The mean of the potential distribution; For standard normally distributed noise, ; Let be the logarithmic vector of the variance of the latent distribution; (7); (8); (9); (10); In the formula, For the first Target domain samples The output latent space has a Gaussian distribution mean after unsupervised encoding by the encoder.

8. The electronic nose cross-domain recognition and drift compensation method based on a contrastive variational autoencoder according to claim 3, characterized in that, In S24 of S2, the process of style transfer data augmentation based on the latent space is as follows: S24-1: Obtain the source domain latent feature normalization result according to formula (11) ; (11); In the formula, For the first Source domain samples The original source domain latent space vector obtained after encoder encoding and reparameterized sampling; S24-2: Normalization results of latent features in the source domain using mean-variance transformation Perform style transfer in the target domain and obtain the intermediate product of the source domain latent vector after style transfer according to formula (12). ; (12); S24-3: Intermediate product of source domain latent vectors after style transfer The input decoder generates source domain augmented samples with a style consistent with the target domain. Based on the decoded source domain augmented samples, the source domain latent vector intermediate product is optimized in reverse. The feature completeness and discriminativeness are improved, and finally, the source domain optimized latent vectors are obtained after style transfer and data augmentation. .

9. The electronic nose cross-domain recognition and drift compensation method based on a contrastive variational autoencoder according to claim 4, characterized in that, In S31 of S3, a joint training set is constructed according to formula (13). ; (13)。 10. The electronic nose cross-domain recognition and drift compensation method based on a contrastive variational autoencoder according to claim 4, characterized in that, In S32 of S3, the process of cross-domain joint loss optimization and final model generation is as follows: S32-1: Construct the pseudo-label classification loss function according to formula (14) Based on formula (15), construct the entropy minimization loss function. Based on formula (16), the maximum mean difference loss of source and target domain features is constructed. ; (14); (15); (16); In the formula, For the first in the target domain The predicted probability distribution of each sample; For the first in the target domain The sample belongs to the first The predicted probability values ​​for each category; For the first The source domain optimized latent vector of each sample; For the first Potential features of the target domain after optimization for each sample; S32-2: Construct the joint loss function according to formula (17) By combining progressive weight scheduling for joint training, a cross-domain gas recognition model is finally obtained. ; (17); In the formula, For task classification loss function of labeled data in the source domain; The adversarial loss function for the domain discriminator; For cross-domain contrastive loss function; , , , , , , These are the asymptotic harmonic parameters for the cross-domain stage task classification loss function, pseudo-label classification loss function, entropy minimization loss function, maximum mean difference loss, adversarial loss function, the basic loss function of C-VAE, and the cross-domain contrastive loss function, respectively.