Contrast learning-based unsupervised field adaptive time sequence classification method and system

By adopting a comparative learning framework and constraints in the unsupervised field adaptive method, the problem of negative samples on selection dependence in the prior art is solved, and feature representation and domain alignment are achieved without relying on negative pairs, which improves the accuracy and stability of time series classification tasks.

CN119903376APending Publication Date: 2025-04-29FUJIAN UNIV OF TECH +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411969087.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-04-29

AI Technical Summary

Technical Problem

In the prior art, the comparative adaptive methods rely heavily on the selection of negative sample pairs, resulting in poor feature characterization effect and prone to model crash problems in the absence of negative samples.

Method used

The unsupervised domain adaptive method based on contrast learning is adopted, and the comparison loss is calculated without relying on negative pairs through the intra-domain and inter-domain contrast learning framework, and the variance, invariant variance and covariance constraints are introduced to enhance the model's domain adaptive learning ability.

Benefits of technology

The difference in feature distribution between the source domain and the target domain is effectively reduced, domain alignment is achieved, and the accuracy and stability of the model in time series classification tasks are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119903376A_ABST
    Figure CN119903376A_ABST
Patent Text Reader

Abstract

The invention discloses an unsupervised domain adaptive time sequence classification method and system based on comparative learning, and the method comprises the steps: obtaining time sequences corresponding to a source domain and a target domain, and generating corresponding enhanced views through data enhancement; respectively inputting the original input data of the source domain and the target domain and the respective enhanced views into respective domain feature extractors to generate corresponding feature representations; obtaining intra-domain comparison loss of the source domain and the target domain through projectors in respective fields of the feature representations of the source domain and the target domain; creating a cross-source domain and a target domain, and calculating to obtain inter-domain comparison learning loss of the source domain and the target domain; the embedded features of the source domain and the target domain are distributed in an aligned mode, domain classification loss is obtained through calculation, an overall loss function is constructed, adversarial classification training is conducted by minimizing the overall loss function, and a final behavior classification result is obtained. According to the method, the characteristics of the data can be learned more effectively, and the performance is remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of classification technology, and in particular to an unsupervised domain adaptive time series classification method and system based on contrastive learning. Background Art

[0002] Unsupervised domain adaptation has been widely studied in the field of computer vision. On the one hand, minimizing the statistical distribution difference has been used as a paradigm to solve the domain shift problem. On the other hand, adversarial methods have been proposed to reduce the feature distribution difference between domains. In adversarial training, the domain discriminator is trained to maximize the discriminator loss, forcing the feature extractor to generate features that the domain discriminator cannot distinguish whether it is from the source domain or the target domain. In this way, the feature distribution difference between the source domain and the target domain is reduced. Although many effective unsupervised domain adaptation paradigms have emerged, the research on unsupervised domain adaptation for time series is still limited.

[0003] In the prior art, CoDATS is an unsupervised domain adaptation method for time series. It uses CNN as a feature extraction network and uses adversarial training to reduce the domain gap between the source domain and the target domain. DANN (Domain-Adversarial Neural Networks) uses adversarial training to map domains with different feature distributions into the same feature space. The extracted features are input into the domain discriminator through the gradient reversal layer to align the features from the source domain and the target domain to achieve knowledge transfer.

[0004] Most current contrastive adaptation methods rely heavily on the selection of negative pairs, which significantly affects feature representation. On the one hand, if the selected negative pairs are too simple, the model will not be able to learn meaningful features. On the other hand, if the selected negative pairs are too complex, the model may have difficulty distinguishing them, resulting in decreased accuracy. Summary of the invention

[0005] The purpose of the present invention is to provide an unsupervised domain adaptive time series classification method and system based on contrastive learning.

[0006] The technical solution adopted by the present invention is:

[0007] An unsupervised domain adaptive time series classification method based on contrastive learning is applied to human behavior recognition and is implemented by a computer device, the computer device comprising a memory and a processor, wherein: the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory. The method comprises the following steps:

[0008] S1, source domain and target domain data acquisition: obtain the time series input x corresponding to the source domain and target domains and x t , respectively generate enhanced views corresponding to the original input samples through data enhancement and

[0009] S2, source domain and target domain feature extraction: The original input data x s and enhanced views Input to the feature extractor F(x), and generate the corresponding feature representations as e s and The original input data x of the target domain t and enhanced views Input feature extractor F(x) to generate corresponding feature representations as e t and

[0010] S3, intra-domain contrastive learning: The source domain and target domain feature representations obtained from the feature extractor are calculated through the projectors P(e) in their respective fields to obtain the intra-domain contrastive losses of the source domain and target domain;

[0011] Specifically, the intra-domain contrastive learning stage uses contrastive learning to learn feature-invariant representations between the source and target domains; contrastive learning is particularly effective in learning feature representations because it focuses on maximizing the similarity between positive pairs while minimizing the similarity between negative pairs. This approach enhances the model's ability to capture meaningful feature representations.

[0012] S4, inter-domain contrastive learning: create positive pairs across source and target domains, and add them to the queue after the input source domain original time series branch. s , in preparation for comparative learning; Represented as the feature representation generated by augmented view data of the target domain The i-th feature in represents the recognition from the source domain The nearest neighbor of Bundle As Calculate the inter-domain contrast learning loss between the source domain and the target domain.

[0013] Specifically, inter-domain contrastive learning is used to align the feature representations of time series between different domains.

[0014] S5, adversarial training: Use the gradient reversal layer to align the feature representations of the source domain and the target domain, and calculate the domain classification loss; use the intra-domain contrast loss, inter-domain contrast learning loss and domain classification loss to construct the overall loss function, and perform adversarial classification training by minimizing the overall loss function to obtain the final behavior classification result.

[0015] Furthermore, the specific steps of calculating the intra-domain contrast loss are as follows:

[0016] S3-1, obtain the source domain and target domain feature representation Z of the two branches corresponding to the comparison architecture = {z 1 ,z 2 ,...,z n}and Where n represents the number of input samples, and each batch consists of n vectors of dimension d;

[0017] S3-2, respectively calculate the function of obtaining the standard deviation of the source domain and target domain feature representation as the variance regularization term V(Z) and Furthermore, the function expression of the standard deviation of the source domain embedding feature representation in S3-2 is as follows:

[0018]

[0019] Among them, z j is represented as a vector consisting of the j-th dimension values ​​of all vectors in z; α is a fixed value used to calculate the standard deviation; ε is a scalar used to prevent numerical instability; s(z j ,ε) represents z j The regularized standard deviation of

[0020] Similarly, the function expression of the standard deviation of the target domain feature representation in S3-2 is as follows:

[0021]

[0022] in, Expressed as is a vector composed of the j-th dimension values ​​of all vectors in ; α is a fixed value used to calculate the standard deviation; ε represents a scalar used to prevent numerical instability; express The regularized standard deviation of Specifically, as a feasible implementation, α is set to 1. Specifically, by increasing the variance, the present invention enhances the difference between embeddings and prevents the model from collapsing when there are no negative samples.

[0023] S3-3, respectively, obtain the covariance regularization terms of the source domain and target domain through the covariance matrices of the embedded feature representation, that is, the covariance C(Z) of the source domain feature representation and the covariance of the target domain feature representation The expression of the covariance matrix c(Z) of the source domain feature representation in S3-3 is as follows:

[0024]

[0025] Among them, z i is the i-th eigenvector in the feature representation Z,

[0026] The covariance regularization term, that is, the calculation expression of the covariance C(Z) represented by the source domain features is as follows:

[0027]

[0028] Among them, the standard function is scaled to a dimension-dependent function by a factor of 1 / d;

[0029] Similarly, the covariance matrix of the target domain feature representation in S3-3 is The expression is as follows:

[0030]

[0031] Get the covariance regularization term, that is, the covariance of the target domain feature representation The calculation expression is as follows:

[0032]

[0033] Among them, the standard function is scaled to a dimension-dependent function by a factor of 1 / d;

[0034] Specifically, covariance is another component of contrast loss. The present invention expects the off-diagonal elements of c(Z) to approach zero, reducing the correlation between different dimensions of the vector, thereby ensuring that each dimension of the vector remains independent and has different meanings. Decorrelation at the embedding level ultimately leads to a decorrelation effect at the representation level.

[0035] S3-4, use MSE loss to constrain Z and The invariance between is used as the invariant variance of the contrast loss The corresponding expressions are as follows:

[0036]

[0037] Specifically, the last component of the contrastive loss is the invariance term, which aims to maximize the similarity between positive sample pairs, thereby training the feature extractor to learn invariant representations of features and enhancing the domain adaptive learning ability of the model.

[0038] S3-5, the variance, invariant variance and covariance are combined to obtain the overall intra-domain contrastive learning loss:

[0039]

[0040] in, represents the intra-domain contrast loss; the hyperparameter λ s , v , c These correspond to the effects of the individual components of the adjusted invariant variance, variance, and covariance, respectively.

[0041] Specifically, as a feasible implementation mode, the present invention sets λ s =λ v >1 and λ c =1.

[0042] Furthermore, the inter-domain contrastive learning loss expression is as follows:

[0043]

[0044] Represents the corresponding feature representation generated by the original time series data of the target domain The i-th feature representation in .

[0045] Represents the feature representation generated by the enhanced view of the target domain The i-th feature representation in .

[0046] Represents the corresponding feature representation generated by the original time series data of the source domain The j-th feature representation in .

[0047] N s and N t Represent the total number of samples in the source domain and the target domain respectively.

[0048] Among them, τ>0 is a scaling parameter, and NN(·) retrieves the branch of the original sample from the source domain input The nearest neighbor predicts a data sample as the most similar neighbor category.

[0049] Furthermore, the domain classification loss is expressed as:

[0050]

[0051] Where D(·) is the domain discriminator, F(·) is the feature extractor, R(·) is the gradient reversal layer, and are the domain labels of the source domain and the target domain respectively, is the cross entropy loss function, N s and N t Represent the total number of samples in the source domain and the target domain respectively.

[0052] Furthermore, adversarial training minimizes domain differences through the domain discriminator. The feature extractor is trained to generate features that the discriminator cannot distinguish whether they are from the source domain or the target domain, thereby aligning their distributions. This is achieved using the gradient reversal layer, and the corresponding expression is as follows:

[0053] R(x)=x, (11)

[0054]

[0055] Where I is the identity matrix.

[0056] Furthermore, the overall loss function expression is as follows

[0057]

[0058] in, is the inter-domain contrastive learning loss, is the domain classification loss, and They are the intra-domain contrastive learning of the source domain and the target domain respectively; the hyperparameter μ D , μ CL , μ RECL The contribution of each loss component is controlled; is the classification loss, which is the cross entropy loss function.

[0059] An unsupervised domain adaptive time series classification system based on contrastive learning is applied to human activity recognition and is implemented by a computer device, the computer device comprising a memory and a processor, wherein: the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory. The system comprises:

[0060] Data acquisition module, used to obtain the time series input x corresponding to the source domain and the target domain s and x t , and generate enhanced views corresponding to the original input samples through data enhancement and

[0061] The feature extraction module is used to transform the original input data x s and enhanced views Input to the feature extractor F(x), and generate the corresponding feature representations as e s and The original input data x of the target domain t and enhanced views Input feature extractor F(x) to generate corresponding feature representations as e t and

[0062] The intra-domain contrast learning module is used to obtain the source domain and target domain feature representations from the feature extractor and calculate the intra-domain contrast loss of the source domain and the target domain through the projectors P(e) in their respective fields;

[0063] The inter-domain contrastive learning module is used to create positive pairs across the source domain and the target domain, and is added to the queue storage after the branch of the input source domain original time series. s , in preparation for comparative learning; Represented as the feature representation generated by augmented view data of the target domain The i-th feature in represents the recognition from the source domain The nearest neighbor of Bundle As Calculate the inter-domain contrast learning loss between the source domain and the target domain.

[0064] The adversarial training module is used to align the distribution of the embedded feature representations of the source domain and the target domain using the gradient reversal layer, and calculate the domain classification loss; the overall loss function is constructed using the intra-domain contrast loss, inter-domain contrast learning loss, and domain classification loss, and adversarial classification training is performed by minimizing the overall loss function to obtain the final behavior classification result.

[0065] The present invention adopts the above technical solution, and the unsupervised domain adaptation model based on contrastive learning, whose intra-domain contrastive learning framework can calculate the contrast loss without relying on negative pairs in the process of learning feature representation. The present invention introduces constraints to prevent the model collapse problem in the absence of negative samples. In addition, the present invention further aligns the feature distribution between the source domain and the target domain through inter-domain contrastive learning. Different from the previous method, the present invention adopts a symmetrical intra-domain contrast structure, and captures the invariant representation of features through intra-domain and inter-domain contrastive learning, thereby reducing the feature distribution difference between the source domain and the target domain, and realizing domain alignment. BRIEF DESCRIPTION OF THE DRAWINGS

[0066] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments;

[0067] Figure 1 It is a schematic diagram of the model structure of the unsupervised domain adaptive time series classification method and system based on contrastive learning of the present invention. DETAILED DESCRIPTION

[0068] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.

[0069] like Figure 1As shown, the present invention discloses an unsupervised domain adaptive time series classification method based on contrastive learning, which is applied to human behavior recognition and is implemented by a computer device, wherein the computer device includes a memory and a processor, wherein: the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, and the method includes the following steps:

[0070] S1, source domain and target domain data acquisition: obtain the time series input x corresponding to the source domain and target domain s and x t , respectively generate enhanced views corresponding to the original input samples through data enhancement and

[0071] S2, source domain and target domain feature extraction: The original input data x s and enhanced views Input to the feature extractor F(x), and generate the corresponding feature representations as e s and The original input data x of the target domain t and enhanced views Input feature extractor F(x) to generate corresponding feature representations as e t and

[0072] S3, intra-domain contrastive learning: The source domain and target feature representations obtained from the feature extractor are respectively calculated through the projectors P(e) in their respective fields to obtain the intra-domain contrastive loss of the source domain and the target domain; further, the specific steps for calculating the intra-domain contrastive loss are as follows:

[0073] S3-1, obtain the source domain and target domain feature representation Z of the two branches corresponding to the comparison architecture = {z 1 ,z 2 ,...,z n}and Where n represents the number of input samples, and each batch consists of n vectors of dimension d;

[0074] S3-2, respectively calculate the function of obtaining the standard deviation of the source domain and target domain feature representation as the variance regularization term V(Z) and Furthermore, the function expression of the standard deviation of the source domain embedding feature representation in S3-2 is as follows:

[0075]

[0076] Among them, z jis represented as a vector consisting of the j-th dimension values ​​of all vectors in z; α is a fixed value used to calculate the standard deviation; ε is a scalar used to prevent numerical instability; s(z j ,ε) represents z j The regularized standard deviation of

[0077] Similarly, the function expression of the standard deviation of the target domain feature representation in S3-2 is as follows:

[0078]

[0079] in, Expressed as is a vector composed of the j-th dimension values ​​of all vectors in ; α is a fixed value used to calculate the standard deviation; ε represents a scalar used to prevent numerical instability; express The regularized standard deviation of Specifically, as a feasible implementation, α is set to 1. Specifically, by increasing the variance, the present invention enhances the difference between embeddings and prevents the model from collapsing when there are no negative samples.

[0080] S3-3, respectively, obtain the covariance regularization terms of the source domain and target domain embedded feature representation covariance matrices, that is, the covariance C(Z) of the source domain embedded feature representation and the covariance of the target domain embedded feature representation The expression of the covariance matrix c(Z) of the source domain embedding feature representation in S3-3 is as follows:

[0081]

[0082] z i is the i-th eigenvector in the feature representation Z,

[0083] The covariance regularization term, that is, the calculation expression of the covariance C(Z) of the source domain embedding feature representation is as follows:

[0084]

[0085] Among them, the standard function is scaled to a dimension-dependent function by a factor of 1 / d;

[0086] Similarly, the covariance matrix of the target domain embedding feature representation in S3-3 is The expression is as follows:

[0087]

[0088] Get the covariance regularization term, that is, the covariance of the target domain embedding feature representation The calculation expression is as follows:

[0089]

[0090] Among them, the standard function is scaled to a dimension-dependent function by a factor of 1 / d;

[0091] Specifically, covariance is another component of contrast loss. The present invention expects the off-diagonal elements of c(Z) to approach zero, reducing the correlation between different dimensions of the vector, thereby ensuring that each dimension of the vector remains independent and has different meanings. Decorrelation at the embedding level ultimately leads to a decorrelation effect at the representation level.

[0092] S3-4, use MSE loss to constrain Z and The invariance between is used as the invariant variance of the contrast loss The corresponding expressions are as follows:

[0093]

[0094] Specifically, the last component of the contrastive loss is the invariance term, which aims to maximize the similarity between positive sample pairs, thereby training the feature extractor to learn invariant representations of features and enhancing the domain adaptive learning ability of the model.

[0095] S3-5, the variance, invariant variance and covariance are combined to obtain the overall intra-domain contrastive learning loss:

[0096]

[0097] in, represents the intra-domain contrast loss; the hyperparameter λ s , v , c These correspond to the effects of the individual components of the adjusted invariant variance, variance, and covariance, respectively.

[0098] Specifically, as a feasible implementation mode, the present invention sets λ s =λ v >1 and λ c =1.

[0099] Specifically, the intra-domain contrastive learning stage uses contrastive learning to learn feature-invariant representations between the source and target domains; contrastive learning is particularly effective in learning feature representations because it focuses on maximizing the similarity between positive pairs while minimizing the similarity between negative pairs. This approach enhances the model's ability to capture meaningful feature representations.

[0100] S4, inter-domain contrastive learning: create positive pairs across source and target domains, and add them to the queue after the input source domain original time series branch. s , in preparation for comparative learning; Represented as the feature representation generated by augmented view data of the target domain The i-th feature in represents the recognition from the source domain The nearest neighbor of Bundle As The inter-domain contrastive learning loss of the source domain and the target domain is calculated. Specifically, inter-domain contrastive learning is used to align the feature representations of time series between different domains. The inter-domain contrastive learning loss expression is as follows:

[0101]

[0102] Represents the corresponding feature representation generated by the original time series data of the target domain The i-th feature representation in .

[0103] Represents the feature representation generated by the enhanced view of the target domain The i-th feature representation in .

[0104] Represents the corresponding feature representation generated by the original time series data of the source domain The j-th feature representation in .

[0105] N s and N t Represent the total number of samples in the source domain and the target domain respectively.

[0106] Among them, τ>0 is a scaling parameter, and NN(·) retrieves the branch of the original sample from the source domain input The nearest neighbor predicts a data sample as the most similar neighbor category.

[0107] S5, adversarial training: Use the gradient reversal layer to align the distribution of the embedded feature representations of the source domain and the target domain, and calculate the domain classification loss; use the intra-domain contrast loss, inter-domain contrast learning loss and domain classification loss to construct the overall loss function, and perform adversarial classification training by minimizing the overall loss function to obtain the final behavior classification result.

[0108] Furthermore, adversarial training minimizes domain differences through the domain discriminator. The feature extractor is trained to generate features that the discriminator cannot distinguish whether they are from the source domain or the target domain, thereby aligning their distributions. This is achieved using the gradient reversal layer, and the corresponding expression is as follows:

[0109] R(x)=x, (10)

[0110]

[0111] Where I is the identity matrix.

[0112] In summary, the domain classification loss of the present invention is expressed as:

[0113]

[0114] Where D(·) is the domain discriminator, F(·) is the feature extractor, R(·) is the gradient reversal layer, and are the domain labels of the source domain and the target domain respectively, is the cross entropy loss function, N s and N t Represent the total number of samples in the source domain and the target domain respectively.

[0115] Furthermore, the overall loss function expression is as follows

[0116]

[0117] is the inter-domain contrastive learning loss above, is the domain classification loss above, and are the intra-domain contrastive learning of the source domain and the target domain respectively. The hyperparameter μ D , μ CL , μ RECL Controls the contribution of each loss component, is the classification loss, which is the cross entropy loss function.

[0118] The present invention also discloses an unsupervised domain adaptive time series classification system based on contrastive learning, which is applied to human activity recognition and is implemented by a computer device, wherein the computer device includes a memory and a processor, wherein: the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory. The system includes:

[0119] Data acquisition module, used to obtain the time series input x corresponding to the source domain and the target domain s and x t , and generate enhanced views corresponding to the original input samples through data enhancement and

[0120] The feature extraction module is used to transform the original input data x s and enhanced views Input to the feature extractor F(x), and generate the corresponding feature representations as e s and The original input data x of the target domain t and enhanced views Input feature extractor F(x) to generate corresponding feature representations as e t and

[0121] The intra-domain contrast learning module is used to obtain the embedded feature representations of the source domain and the target domain from the feature extractor and calculate the intra-domain contrast loss of the source domain and the target domain through the projectors P(e) in their respective fields;

[0122] The inter-domain contrastive learning module is used to create positive pairs across the source domain and the target domain, and is added to the queue storage after the branch of the input source domain original time series. s , in preparation for comparative learning; Represented as the feature representation generated by augmented view data of the target domain The i-th feature in represents the recognition from the source domain The nearest neighbor of Bundle As Calculate the inter-domain contrast learning loss between the source domain and the target domain.

[0123] The adversarial training module is used to align the distribution of the embedded feature representations of the source domain and the target domain using the gradient reversal layer, and calculate the domain classification loss; the overall loss function is constructed using the intra-domain contrast loss, inter-domain contrast learning loss, and domain classification loss, and adversarial classification training is performed by minimizing the overall loss function to obtain the final behavior classification result.

[0124] The principle of the present invention is described in detail below: The present invention mainly includes intra-domain contrast learning, inter-domain contrast learning and adversarial training, specifically:

[0125] Intra-domain contrastive learning: This paper uses contrastive learning to learn feature-invariant representations between source and target domains. Contrastive learning is particularly effective in learning feature representations because it focuses on maximizing the similarity between positive pairs while minimizing the similarity between negative pairs. This approach enhances the model's ability to capture meaningful feature representations.

[0126] Given a time series input x from the source domain (or target domain) s (or x t ), which generates an enhanced view of the original input sample through data augmentation (or ). The original input data and its enhanced views are fed into the feature extractors F(x) of their respective domains to generate the corresponding embeddings es and (or e t and ). Subsequently, the feature representations obtained from the feature extractor are passed through a projector P(e) to compute the contrastive loss in each domain.

[0127] The present invention defines the embedding of the two branches of the contrast architecture as Z = {z 1 ,z 2 ,...,z n}and Where n represents the number of input samples, and each batch consists of n vectors with a dimension of d. j is represented as a vector of the jth dimension values ​​of all vectors in z. The contrastive loss function of the model consists of variance, invariant variance, and covariance. Specifically, the variance regularization term V is defined as a function of the standard deviation of the embedding:

[0128]

[0129] Where α is a fixed value used to calculate the standard deviation. In the experiment of the present invention, α=1 is set, and ε is a small scalar to prevent numerical instability. s(·,·) is the regularized standard deviation, which is defined as:

[0130]

[0131] By increasing the variance, the present invention enhances the differences between embeddings and prevents the model from collapsing in the absence of negative samples.

[0132] Covariance is another component of contrast loss. The present invention defines the covariance matrix of Z as follows:

[0133]

[0134] From the covariance matrix, the present invention can obtain a covariance regularization term, whose factor 1 / d scales the standard as a function of the dimension:

[0135]

[0136] The present invention expects the off-diagonal elements of c(Z) to approach zero, reducing the correlation between different dimensions of the vector, thereby ensuring that each dimension of the vector remains independent and has different meanings. The decorrelation at the embedding level ultimately leads to the decorrelation effect at the representation level.

[0137] The last component of the contrast loss is the invariance term, which aims to maximize the similarity between positive sample pairs, thereby training the feature extractor to learn the invariant representation of features and enhancing the domain adaptive learning ability of the model. The MSE loss is used to constrain Z and The invariance between:

[0138]

[0139] The overall contrastive learning loss is a combination of three terms: variance, invariant variance, and covariance:

[0140]

[0141] Among them, the hyperparameter λ s ,λ v ,λ c Adjust the influence of each individual component. The present invention sets λ s =λ v >1 and λ c =1.

[0142] Inter-domain contrastive learning: In addition to capturing the semantic information of samples within a domain through contrastive learning, the method of the present invention further aligns the feature representations of time series between different domains. Specifically, the present invention creates positive pairs across the source domain and the target domain. After the branch of the original time series of the input source domain is added to the queue storage s , in preparation for contrastive learning. The present invention identifies The nearest neighbor of Then the present invention takes it as The inter-domain contrastive learning loss of the present invention is defined as follows:

[0143]

[0144] Where τ>0 is a scaling parameter. NN(·) retrieves the branch of the original sample from the source domain The nearest neighbor of .

[0145] Adversarial training: The purpose of using adversarial training is to address the feature distribution gap between the source and target domains. By minimizing the domain difference through the domain discriminator, the feature extractor is trained to generate features that the discriminator cannot distinguish whether it is from the source domain or the target domain, thereby aligning their distributions. This is achieved using a gradient reversal layer:

[0146] R(x)=x, (8)

[0147]

[0148] Where I is the identity matrix.

[0149] In summary, the domain classification loss of the present invention is expressed as:

[0150]

[0151] Where D(·) is the domain discriminator, F(·) is the feature extractor, R(·) is the gradient reversal layer, and are the domain labels of the source domain and the target domain respectively, is the cross entropy loss function, N s and N t Represent the total number of samples in the source domain and the target domain respectively.

[0152] For the proposed model, the training goal of the present invention is to minimize the following loss function:

[0153]

[0154] Among them, the hyperparameter μ D , μ CL , μ RECL The contribution of each loss component is controlled; is the classification loss, which is the cross entropy loss function.

[0155] To verify the effectiveness of the method of the present invention, the present invention uses WISDM and HAR, two benchmark datasets for unsupervised domain adaptation of time series, to evaluate the proposed model. The dataset WISDM contains data from 36 subjects collected using accelerometer sensors. Due to the imbalance of categories, this human activity recognition dataset is challenging because data from different subjects may only cover a subset of all activity categories. The dataset HAR includes data from 30 participants collected using three different sensors. This dataset also focuses on human activity recognition. Each dataset contains a variety of cross-domain migration scenarios. In the experiment, the present invention randomly selected several groups for cross-domain migration tasks. In the present invention, a commonly used evaluation indicator for classification algorithms, namely accuracy, is selected. Generally, the higher the accuracy, the better the performance of the model. The definition of accuracy is as follows:

[0156]

[0157] Among them, TP stands for true positive, which means that the model successfully predicts a positive sample as a positive sample. FP stands for false positive, which means that the model incorrectly predicts a positive sample as a negative sample. TN stands for true negative, which means that the model successfully predicts a negative sample as a negative sample. FN stands for false negative, which means that the model incorrectly predicts a negative sample as a positive sample.

[0158] Quantitative analysis: Table 1 shows the experimental results of 8 methods on WISDM and HAR datasets, which is used to prove the effectiveness of the improved model UDATS of the present invention. Among them, DSAN, AdvSKM, CAN, CoDATS, DeepCORAL, DDC, and HoMM are all commonly used neural network models in unsupervised domain adaptation tasks.

[0159] Table 1 Comparison of the accuracy of eight different unsupervised domain adaptation methods in different cross-domain migration scenarios

[0160]

[0161]

[0162] In the experiment, the present invention uses the accuracy index to evaluate the effectiveness of the model and compares it with the performance of other excellent unsupervised domain adaptation models. The results are shown in Table 1. UDATS achieves excellent unsupervised domain adaptation task performance on two classic datasets, and is significantly higher than other excellent methods in most cross-domain scenario tasks, making significant improvements for time series domain adaptation. For example, in the "9 to 18" domain migration scenario of the HAR dataset, most models perform poorly and can only achieve poor migration effects. The accuracy of UDATS in this scenario reaches 0.927, which is 14.5% higher than the suboptimal CoDATS. Although the accuracy on the two datasets can generally achieve the best performance, it will also show slightly poor performance in migration tasks in some cross-domain scenarios. For example, the HoMM method shows better performance in the "28 to 20" task of the WISDM dataset.

[0163] In general, the UDATS model has shown excellent performance in most cross-domain migration scenarios. It can be seen that this has met certain requirements of real-world applications and can more accurately achieve the classification task of time series data in an environment lacking label information. The neural network model proposed in the present invention uses time series data as the input of the model, and realizes the data classification process through the learning ability of the neural network, and finally achieves good results on two time series benchmark data sets.

[0164] The present invention adopts the above technical solution, and the unsupervised domain adaptation model based on contrastive learning, whose intra-domain contrastive learning framework can calculate the contrast loss without relying on negative pairs in the process of learning feature representation. The present invention introduces constraints to prevent the model collapse problem in the absence of negative samples. In addition, the present invention further aligns the feature distribution between the source domain and the target domain through inter-domain contrastive learning. Different from the previous method, the present invention adopts a symmetrical intra-domain contrast structure, and captures the invariant representation of features through intra-domain and inter-domain contrastive learning, thereby reducing the feature distribution difference between the source domain and the target domain, and realizing domain alignment.

[0165] Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be combined with each other. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the detailed description of the embodiments of the present application is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians of the art without making creative work are within the scope of protection of the present application.

Claims

1. Unsupervised domain adaptive time series classification method based on contrastive learning, characterized by: The method is applied to human behavior recognition and implemented by a computer device, wherein the computer device includes a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory. The method includes the following steps: S1 Source domain and target domain data acquisition: Get the time series input x corresponding to the source domain and target domain s and x t , respectively generate enhanced views corresponding to the original input samples through data enhancement and S2 Source domain and target domain feature extraction: The original input data and enhanced view of the source domain are input into the feature extractor F(x) to generate the corresponding feature representations e s and The original input data and enhanced view of the target domain are input into the feature extractor F(x) to generate the corresponding feature representations e t and S3 Intra-domain contrastive learning: The source domain and target domain feature representations obtained from the feature extractor are calculated through the projectors P(e) in their respective fields to obtain the intra-domain contrastive losses of the source domain and target domain; S4 inter-domain contrastive learning: Create positive pairs across source and target domains, and add them to the queue after the branch of the input source domain original time series. s , prepare for contrastive learning; identify The nearest neighbor of Bundle As Calculate the inter-domain contrast learning loss between the source domain and the target domain. Represents the feature representation generated by the enhanced view of the target domain The i-th feature representation in ; S5 adversarial training: Use the gradient reversal layer to align the distribution of the embedded feature representations of the source domain and the target domain, and calculate the domain classification loss; use the intra-domain contrast loss, inter-domain contrast learning loss, and domain classification loss to construct the overall loss function, and perform adversarial classification training by minimizing the overall loss function to obtain the final behavior classification result.

2. The unsupervised domain adaptive time series classification method based on contrastive learning according to claim 1, characterized in that: The specific steps for calculating the contrast loss in the domain in S3 are as follows: S3-1, obtain the source domain and target domain embedding feature representation Z = {z1,z2,...,z n }and Where n represents the number of input samples, and each batch consists of n vectors of dimension d; S3-2, respectively calculate the function of obtaining the standard deviation of the source domain and target domain embedding feature representation as the variance regularization term V(Z) and S3-3, respectively, obtain the covariance regularization terms of the source domain and target domain embedded feature representation covariance matrices, that is, the covariance C(Z) of the source domain embedded feature representation and the covariance of the target domain embedded feature representation S3-4, use MSE loss to constrain Z and The invariance between is used as the invariant variance of the contrast loss The corresponding expressions are as follows: S3-5, the variance, invariant variance and covariance are combined to obtain the overall intra-domain contrastive learning loss: in, represents the intra-domain contrast loss; the hyperparameter λ s , v , c These correspond to the effects of the individual components of the adjusted invariant variance, variance, and covariance, respectively.

3. The unsupervised domain adaptive time series classification method based on contrastive learning according to claim 2, characterized in that: The expression of the function of the standard deviation of the source domain embedding feature representation in S3-2 is as follows: Among them, z j is represented as a vector consisting of the j-th dimension values ​​of all vectors in z; α is a fixed value used to calculate the standard deviation; ε is a scalar used to prevent numerical instability; s(z j ,ε) represents z j The regularized standard deviation of Similarly, the expression of the function of the standard deviation of the target domain embedding feature representation in S3-2 is as follows: in, Expressed as is a vector composed of the j-th dimension values ​​of all vectors in ; α is a fixed value used to calculate the standard deviation; ε represents a scalar used to prevent numerical instability; express The regularized standard deviation of 4. The unsupervised domain adaptive time series classification method based on contrastive learning according to claim 2, characterized in that: The expression of the covariance matrix c(Z) of the source domain embedding feature representation in S3-3 is as follows: Among them, z i is the i-th eigenvector in the feature representation Z, The covariance regularization term, that is, the calculation expression of the covariance C(Z) represented by the source domain features is as follows: Among them, the standard function is scaled to a function related to the dimension by a factor of 1 / d; Similarly, the covariance matrix of the target domain feature representation in S3-3 is The expression is as follows: Get the covariance regularization term, that is, the covariance of the target domain embedding feature representation The calculation expression is as follows: Here, the standard function is scaled to a dimension-dependent function using a factor of 1 / d.

5. The unsupervised domain adaptive time series classification method based on contrastive learning according to claim 2, characterized in that: Set λ in S3-5 s =λ v >1 and λ c =1.

6. The unsupervised domain adaptive time series classification method based on contrastive learning according to claim 1, characterized in that: The inter-domain contrastive learning loss expression is as follows: in, Represents the corresponding feature representation generated by the original time series data of the target domain The i-th feature representation in ; Represents the feature representation generated by augmented view data of the target domain The i-th feature representation in ; Represents the corresponding feature representation generated by the original time series data of the source domain The jth feature representation in N s and N t denotes the total number of samples in the source domain and the target domain respectively; τ>0 is a scaling parameter, and NN(·) retrieves the branch of the original sample from the source domain. The nearest neighbor predicts a data sample as the most similar neighbor category.

7. The unsupervised domain adaptive time series classification method based on contrastive learning according to claim 1, characterized in that: In S5, the gradient reversal layer is used to align the feature representations of the source domain and the target domain. The corresponding expression is as follows: R(x)=x, (8) Where I is the identity matrix.

8. The unsupervised domain adaptive time series classification method based on contrastive learning according to claim 1 or 7, characterized in that: The domain classification loss is expressed as: Where D(·) is the domain discriminator, F(·) is the feature extractor, R(·) is the gradient reversal layer, and are the domain labels of the source domain and the target domain respectively, is the cross entropy loss function, N s and N t Represent the total number of samples in the source domain and the target domain respectively.

9. The unsupervised domain adaptive time series classification method based on contrastive learning according to claim 1, characterized in that: The overall loss function expression is as follows in, is the inter-domain contrastive learning loss, is the domain classification loss, and They are the intra-domain contrastive learning of the source domain and the target domain respectively; the hyperparameter μ D , μ CL , μ RECL The contribution of each loss component is controlled; is the classification loss, which is the cross entropy loss function.

10. An unsupervised domain adaptive time series classification system based on contrastive learning, which adopts the unsupervised domain adaptive time series classification method based on contrastive learning according to any one of claims 1 to 9, characterized in that: Applied to human activity recognition, it is implemented by a computer device, the computer device includes a memory and a processor, wherein: the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory. The system includes: Data acquisition module, used to obtain the time series input x corresponding to the source domain and the target domain s and x t , and generate enhanced views corresponding to the original input samples through data enhancement and The feature extraction module is used to input the original input data of the source domain and the target domain and their respective enhanced views into the feature extractors F(x) of their respective fields to generate the corresponding feature representations e s and and e t and The intra-domain contrast learning module is used to obtain the source domain and target domain feature representations from the feature extractor and calculate the intra-domain contrast loss of the source domain and the target domain through the projectors P(e) in their respective fields; The inter-domain contrastive learning module is used to create positive pairs across the source domain and the target domain, and is added to the queue storage after the branch of the input source domain original time series. s , prepare for contrastive learning; identify The nearest neighbor of Bundle As Calculate the inter-domain contrast learning loss between the source domain and the target domain. Represents the feature representation generated by augmented view data of the target domain The i-th feature representation in ; The adversarial training module is used to align the feature representations of the source domain and the target domain using the gradient reversal layer and calculate the domain classification loss. The overall loss function is constructed using the intra-domain contrast loss, inter-domain contrast learning loss, and domain classification loss. The adversarial classification training is performed by minimizing the overall loss function to obtain the final behavior classification result.

Citation Information

Cited By

  • Neural image analysis model training method and device, equipment and storage medium

    CN120318601A