Time sequence cross-domain adaptive classification method and device based on task attention potential alignment

Through the method of potential alignment of task attention, the dynamic graph encoder and self-attention mechanism are used, combined with dual contrast learning, the problems of information confusion and structural differences in time series cross-domain adaptation are solved, and classification and clustering performance are improved.

CN120277525APending Publication Date: 2025-07-08NANJING UNIV
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510343773.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-22
Publication Date
2025-07-08

AI Technical Summary

Technical Problem

The existing time series cross-domain adaptation methods have problems such as information confounding and neglecting variable structure differences in domain alignment and classification tasks, resulting in degradation of classification performance.

Method used

Using a method based on the potential alignment of task attention, features are extracted through dynamic graph encoder and time convolution network, combined with self-attention mechanism and dual contrast learning, the task-related information is captured and the variable structure is aligned, and multiple loss functions are constructed for model training.

Benefits of technology

It improves the accuracy and robustness of transfer learning, enhances the adaptability and generalization ability of cross-domain transfer, and reduces the impact of task heterogeneity on model performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120277525A_ABST
    Figure CN120277525A_ABST
Patent Text Reader

Abstract

The invention discloses a time sequence cross-domain adaptive classification method and device based on task attention potential alignment. The method comprises the following steps: preprocessing input time sequences of a source domain and a target domain, inputting a graph encoder of a dynamic timestamp to perform feature extraction, and capturing dynamic feature representation across time steps; by utilizing a task attention potential alignment module, task related information is obtained according to a label weight, and the domain difference recognition capability of the model is enhanced; a task-oriented correlation fusion module is used for learning multivariable structures of different labels, source domain data is used for guiding alignment of the multivariable structures in a target domain, and specific disturbance of the domain is effectively filtered; in combination with a double-contrast learning method based on an attention mechanism, task related information is captured in a source domain and a cross-domain, and learning of domain invariant representation is promoted. By aligning task-related information and task-related structures for a cross-domain time sequence, the cross-domain classification capability and robustness of the model are effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of time series processing, and particularly to a time series cross-domain adaptation classification method and device based on task attention potential alignment. Background Art

[0002] Time series data is a very common type of data in daily production and life. For example, in human activity fields such as industry, environment, finance, healthcare, aerospace, and network, time series data is being generated all the time. Specifically: in the industrial field, time series data can involve various indicators in the production process, such as temperature, humidity, production line output, quality control data, etc., which are usually generated from production equipment, sensors, and monitoring systems; in the environmental field, time series data involves environmental monitoring data, such as meteorological data, air quality data, soil detection data, etc., which are collected through devices such as weather stations and meteorological satellites; in the financial field, time series data includes financial market data such as stock prices, exchange rates, bond yields, trading volumes, etc., which come from exchanges, financial institutions, etc.; in the healthcare field, time series data includes patient monitoring data, data on drug dosage changes over time, patient physiological parameter data, etc., which are usually generated by various medical monitoring devices in hospitals; in the aerospace field, time series data includes spacecraft status, flight trajectory, fuel consumption data, etc., which are usually generated by various devices and sensors in the spacecraft; in the network field, time series data includes network traffic, network performance indicators, fault logs, user activities, etc., which are usually generated by network devices, servers, network monitoring systems, etc.

[0003] A time series is a sequence of data points recorded in chronological order. The core characteristic of time series data lies in its temporal correlation, that is, past observations affect future observations. This unique property makes time series analysis an important research direction in data science, statistics, and artificial intelligence. In recent years, with the improvement of computing power and the expansion of data scale, time series analysis methods have evolved from traditional statistical models to deep learning models. Traditional methods such as autoregressive integrated moving average (ARIMA), exponential smoothing (ETS), wavelet transform, etc., although performing well in specific scenarios, have certain limitations in dealing with non-linear, long-term dependence, and high-dimensional data. The wide application of deep learning methods, such as recurrent neural networks (RNNs), convolutional neural networks (CNNs), graph neural networks (GNNs), and the Transformer architecture, has provided new ideas and breakthroughs for time series modeling.

[0004] Time series domain adaptation refers to training a machine learning model based on a source domain time series data set with rich labels and then applying it to a different but related task in a target domain without labels. In recent years, time series domain adaptation has been widely applied in fields such as healthcare, medical assistance, and financial analysis. For example, in sensor-based human activity recognition applications, the task is to learn a classification model through time series sensor data to identify human activities (such as walking, running, falling, going up stairs, cycling, etc.). A classifier can be trained on a labeled young people data set and then used to identify the activities of unlabeled elderly people, completing the process of transfer learning, so as to better track the actions of the elderly. However, due to the domain shift problem, adapting a pre-trained model to an unseen target domain is a challenging task.

[0005] Existing research on unsupervised domain adaptation of multivariate time series (MTS-UDA) has two limitations. First, the domain alignment and classification tasks are carried out simultaneously, that is, directly aligning the representations learned from the source domain and the target domain. This method may introduce task-irrelevant information into the features, thus weakening the performance of the classification task. Second, existing methods mainly focus on directly aligning the multivariate structures across domains while ignoring the differences in the correlation structures between different variables under different classification labels. Therefore, these methods fail to capture the variable-interaction structures that can effectively guide the domain adaptation task. Summary of the Invention

[0006] Object of the Invention: To solve the problems in the above-mentioned prior art, the present invention proposes a time series cross-domain adaptation classification method and device based on task attention latent alignment, which improves the accuracy and robustness of transfer learning and the final classification and clustering performance.

[0007] In order to achieve the above object of the invention, the technical solution of the present invention is as follows:

[0008] A time series cross-domain adaptation classification method based on task attention latent alignment, comprising the following steps:

[0009] Preprocess the input time series instances to extract the local information of univariate time series. The time series local information corresponding to the preprocessed original data of the source domain and the target domain is h s and h t ;

[0010] According to the preprocessed features h s and h t of the source domain and the target domain, use a dynamic graph encoder for feature enhancement, including: using a graph convolutional neural network based on time steps to extract the temporal features g of the source domain and the target domain respectivelys and g t , using a temporal convolutional network, respectively extract temporal features f s and f t ;

[0011] According to the temporal features f s and f t perform feature classification and cross-domain discrimination, and obtain task-related information according to the label weights of the feature classification, and align the feature categories with the task-related information to construct a classification loss and a discrimination loss and

[0012] Use the self-attention mechanism to design a label structure encoder to learn the structural features A s and A t under different labels in the source domain and the target domain, and construct a task structure classification loss and a label alignment loss

[0013] Perform contrastive learning within the domain and across domains. For within-domain contrastive learning, respectively mask the task-related segments and task-unrelated segments in the sequence. The features f s + extracted from the task-related segments and the features f s - extracted from the task-unrelated segments are respectively combined with f s to form positive and negative sample pairs; for cross-domain contrastive learning, the task-related features f′ s and f′ t across domains but of the same category are used as positive sample pairs, and the task-related features f′ s and f″ t across domains and of different categories are used as negative sample pairs; calculate the above two contrastive learning losses and and sum them up as the total contrastive loss

[0014] According to the classification loss the discrimination loss the task structure classification loss the label alignment loss and the total contrastive loss Construct a total loss function to perform the training process of the model. Finally, preprocess the data without labels in the target domain, and obtain the time series classification results of the target domain through the dynamic graph encoder and the classification head.

[0015] Furthermore, the implementation of the dynamic graph encoder based on time steps includes:

[0016] The pre - processed features of the source domain and the target domain are divided into P segments through the Patchify layer. P learnable adjacency matrices are used to capture the multivariate relationships in each time segment, and graph learning is performed separately in each domain, where each adjacency matrix represents the relationship between multiple time slices within a specified time;

[0017] After obtaining the multivariate graph representation, it is input into the temporal convolutional layer, and the temporal dependence features are learned through a two - layer dilated convolutional architecture to obtain f s and f t 。

[0018] Further, the loss for classification of f s is as follows:

[0019]

[0020] where y s is the true label of the labeled source - domain samples, is the prediction result of the classifier, and N s is the number of source - domain samples.

[0021] Further, the calculation method of the discriminative loss after aligning the task - related attention is as follows:

[0022]

[0023] where f s and f t are the extraction results of the graph encoders of the source domain and the target domain respectively, is the label weight of the linear classification head, β is a learnable parameter, f′ s is the representation after mapping of f s , N is the number of samples, and D represents the discriminator.

[0024] Further, using the self - attention mechanism, a label - structure encoder is designed to learn the structural features A s and A t under different labels in the source domain and the target domain, including: transposing the pre - processed results h s and h t , regarding each dimension of the sequence as a feature representing a variable, and then extracting information through a learnable self - attention mechanism to obtain a weight matrix, which represents the task - related structural relationships A s and A t 。

[0025] Further, the calculation methods of the task - structure classification loss and the label - alignment loss are as follows:

[0026]

[0027] where N s is the number of source domain samples, and y s is the true label of the labeled source domain samples. The features are input into a linear layer to obtain two normalized distributions: D t = BN(C cls (f t )), D' t = BN(C task (A t )); By aligning the label distributions of the target domain, the variable correlation structures of the target domain and the source domain are guided to align. The label alignment loss is calculated as follows:

[0028]

[0029] where k l (u, v) represents the value of the l-th Gaussian kernel function, and β l is the weight coefficient of this kernel, and L represents the total number of kernels. means taking one sample u and v from each of the two distributions respectively and calculating the expected value of the kernel similarity between them.

[0030] Furthermore, the loss calculation formula for in-domain contrastive learning is as follows:

[0031]

[0032] where E represents the cosine similarity, and {f s + , f s} is regarded as a positive sample pair for in-domain contrastive learning, while {f s - , f s} is regarded as a negative sample pair for in-domain contrastive learning;

[0033] The loss calculation formula for cross-domain contrastive learning is as follows:

[0034]

[0035] where {f' s , f' t} is used as a positive sample pair for cross-domain contrastive learning, and {f' s , f'' t} is used as a negative sample pair for cross-domain contrastive learning.

[0036] A time series cross-domain adaptation classification device based on task attention potential alignment includes:

[0037] A data preprocessing module, which is used to preprocess the input time series instances, extract the local information of the univariate time series, and the local information of the time series corresponding to the original data of the source domain and the target domain after preprocessing are h s and h t ;

[0038] A dynamic graph encoder module, which is used to enhance the features using a dynamic graph encoder according to the preprocessed features h s and h t , including: using a graph convolutional neural network based on time steps to extract the temporal features g s and g t of the source domain and the target domain respectively, and using a temporal convolutional network to extract the temporal features f s and f t through dilated convolution respectively;

[0039] A task attention potential alignment module, which is used to perform feature classification and cross-domain discrimination according to the temporal features f s and f t , obtain task-related information according to the label weights of the feature classification, align the feature categories with the task-related information, and construct a classification loss and a discrimination loss

[0040] A task-oriented relationship fusion module, which is used to use the self-attention mechanism to design a label structure encoder to learn the structural features A s and A t under different labels of the source domain and the target domain, and construct a task structure classification loss and a label alignment loss

[0041] A dual contrast learning module, which is used to perform contrast learning within the domain and across domains. For within-domain contrast learning, the task-related segments and task-unrelated segments in the sequence are respectively masked, and the features f s + extracted from the task-related segments and the features f s - extracted from the task-unrelated segments are respectively paired with f s to form positive and negative sample pairs; for cross-domain contrast learning, the task-related features f′ s and f′ t across domains but of the same category are used as positive sample pairs, and the task-related features f′ s and f″ t across domains and of different categories are used as negative sample pairs; calculate the above two contrast learning losses and and sum them up as the total contrast loss

[0042] A training and inference module, for according to the classification loss discriminative loss task structure classification loss label alignment loss and the total contrast loss Construct a total loss function to perform the training process of the model. Finally, preprocess the data without labels in the target domain, and obtain the time series classification result of the target domain through the dynamic graph encoder and the classification head.

[0043] The present invention also provides an electronic device, including: one or more processors; a memory; and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors. When the program is executed by the processor, the steps of the above-mentioned time series cross-domain adaptation classification method based on task attention potential alignment are implemented.

[0044] The present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned time series cross-domain adaptation classification method based on task attention potential alignment are implemented.

[0045] Compared with the prior art, the present invention has the following beneficial effects:

[0046] (1) By introducing a task-related attention mechanism, it is possible to dynamically capture task-related information during the cross-domain adaptation of multivariate time series, thereby improving the effectiveness of transfer learning. (2) Through the task-oriented relationship fusion module, the dependency structure between variables is retained during the transfer process, making the variable relationship in the target domain closer to that in the source domain, thereby improving the accuracy of cross-domain transfer. (3) Conduct contrastive learning in the time dimension and variable dimension respectively, and combine a unified contrastive learning framework to maintain the consistency of data features between different domains, improving the generalization ability and robustness. (4) Through task-related alignment and variable relationship maintenance, the transfer between different tasks is smoother, reducing the impact of task heterogeneity on the model performance and improving the cross-task adaptation ability. (5) By introducing task-related structure learning and contrastive loss, it is still possible to maintain a high transfer effect when processing data in different domains and different task types, improving the stability and robustness of the model. Description of the Drawings

[0047] Figure 1 is a flowchart of a time series domain adaptation method based on task attention potential alignment and double contrastive learning;

[0048] Figure 2Schematic diagram of a time series domain adaptation model based on task attention latent alignment and dual contrast learning. Specific implementation manners

[0049] To make the objectives, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Meanwhile, it should be understood that these embodiments are only used to illustrate the present invention and not to limit the scope of the present invention. After reading the present invention, those skilled in the art's various equivalent modifications of the present invention all fall within the scope defined by the appended claims of this application.

[0050] In the first embodiment of the present invention, a time series cross-domain adaptation classification method based on task attention latent alignment is provided. A data preprocessing module, a task attention latent alignment module, a task-oriented relationship fusion module, and a dual contrast learning module are used to perform transfer learning on cross-domain multivariate time series and perform cross-domain classification. Refer to Figure 1 and Figure 2 , the method includes the following steps:

[0051] (1) Data preprocessing step: For a time series instance, first perform preprocessing on it to extract local time series information.

[0052] (2) Task attention latent alignment step: Use a dynamic graph encoder to further enhance the time series information, calculate the classification loss for the source domain data after extracting features, and obtain task-related information through label weights to align the categories and task-related information;

[0053] (3) Task-oriented relationship fusion step: A multi-head self-attention mechanism is proposed to effectively learn task-related structural information. Calculate the classification loss of the task and align the cross-domain label distribution.

[0054] (4) Dual contrast learning step: To further learn domain-invariant information, a dual contrast learning mechanism is proposed, which performs contrast learning within the domain and across domains. This enables the model to capture key intra-domain features and enhance its transfer generalization ability.

[0055] (5) Training and inference step: Construct a total loss function for model training and use the trained model for task inference in the target domain.

[0056] The specific implementation manners of each step are described below.

[0057] Data preprocessing step According to an embodiment of the present invention, time series data is preprocessed by extracting local time series information. When generating features from time series, context information, relationships between variables, and time dependence (i.e., the current value depends on previous observations) are usually considered. Assume that there are N s labeled samples in the source domain and N t unlabeled samples in the target domain where N s and N t represent the number of samples in the source domain and the target domain respectively. The source domain and the target domain share the same label space where K is the number of classes. Each sample represents a multivariate time series, where T is the time length and M is the number of variables. Here, j ∈ {1, 2, …, M} represents the index of different variables. For simplicity of representation, the subscript i will be omitted in the subsequent parts of this article, and x s or x t will be used to represent source domain or target domain samples. As Figure 2 shown, the time series of each channel is preprocessed independently, and feature extraction is performed using E pre . E pre includes a one-dimensional convolutional layer Conv1D, an activation function Relu, and a max pooling layer MaxPool for extracting local context information. It is expressed as:

[0058] E pre (x) = MaxPool(Relu(Conv1D(x)))

[0059] h s = E pre (x s ), h t = E pre (x t )

[0060] where h s , h t represent the local information extracted from the source domain and the target domain respectively.

[0061] Task attention potential alignment step

[0062] According to an embodiment of the present invention, the purpose of the task attention potential alignment step is to capture task-related information in the sequence to enhance the discriminative ability of the samples and guide the target domain to extract this task-related information. In the context of the present invention, domain and field have the same meaning, and source domain and source field can be used interchangeably, and target domain or target field can be used interchangeably. Domain adaptation is equivalent to domain transfer, cross-domain transfer, etc. In a specific implementation, first, graph-based representation learning is performed on the multivariate time series to capture the dynamic sequence features. Subsequently, the attention weights derived from the source domain labels are used to extract task-related information, thereby improving the discriminative ability of the model.

[0063] In the present invention, the graph-based representation learning of the multivariate time series is implemented by using a dynamic graph encoder based on time steps. Specifically, after preprocessing, h is divided into P segments through a Patchify layer (chunking layer, used to segment a long sequence). s and h t This step aims to reduce the complexity of processing long sequence data. Each segment represents a period of time and consists of M time slices. Delays or offsets usually occur when time series data crosses domains, but the relationships between multiple variables within the same time segment should remain stable. Traditional CNN methods usually assume that the relationships between variables are fixed or consistent and cannot reflect the dynamic changes between time steps. Inspired by the graph convolutional network, the present invention uses P learnable adjacency matrices to capture the multivariate relationships in each time segment and performs graph learning separately in each domain. Each adjacency matrix reflects the relationships between multiple time slices within a period of time.

[0064] g s = σ(D -1 / 2 (A s + I)D -1 / 2 H s W s )

[0065] g t = σ(D -1 / 2 (A t + I)D -1 / 2 H t W t )

[0066] where A s and A t represent the multivariate adjacency matrices of each time step in the source domain and the target domain respectively; D represents the corresponding degree matrix. σ is the activation function, and w s and w t are the dynamic graph learnable parameter matrices of the source domain and the target domain respectively, and I is the identity matrix.

[0067] After obtaining the multivariate graph representation, it is input into a temporal convolutional layer E tcn (Temporal Convolutional Layer), and the temporal dependence features are learned through a two-layer dilated convolutional architecture.

[0068] f s = E tcn (g s ), f t = E tcn (g t )

[0069] The dynamic graph encoder captures the multivariate relationships within each time step, focuses on the task-related variable features through the local graph structure, and ignores the local noise.

[0070] In the present invention, the attention weights derived from the source domain labels are used to extract task-related information for aligning task-related attention. As Figure 2 shown, f s is input into the shared feature classification head C cls , f s and f t are input into the cross-domain discriminator D. The classification head is a linear layer that outputs the predicted class That is The cross-entropy loss is used to optimize the classification task, and the classification loss is expressed as:

[0071]

[0072] where y s is the true label of the labeled source domain sample, is the prediction result of the classifier, and N s is the number of source domain samples.

[0073] Let represent the output of the source domain sample on its true class c, and the weight of the fully connected layer corresponding to class c is The label weight of the classification head is the key parameter that defines the decision boundary. By aligning the sample feature f s with , the sample feature can be remapped to the direction consistent with its correct class weight.

[0074]

[0075] where β is a learnable parameter, and f' s is the representation after mapping f s .

[0076] Domain adversarial learning differentiates the domain of given samples by training a domain discriminator D. Since C cls and the optimization directions of D are adversarial, a Gradient Reversal Layer (GRL) is usually introduced to achieve adversarial training. This loss guides the alignment of the target domain features with the task attention features of the source domain, prompting the encoder to pay more attention to task-related information. The discriminant loss calculation formula is expressed as follows:

[0077]

[0078] where N is the number of samples (N s and N t ).

[0079] Task-oriented relationship fusion step

[0080] According to the embodiments of the present invention, in the task-oriented relationship fusion step, task-related structural information is effectively learned to align the task-related structures across domains. Thereby filtering out domain-specific noises and ensuring the cross-domain consistency of the multi-variable structures of the same category. Specifically, traditional methods regard the multi-variable relationship as a unified structure for cross-domain alignment, which may result in the same multi-variable relationship under different labels, which is obviously an undesirable result. To solve this problem, the present invention proposes a multi-head self-attention mechanism to effectively learn such information.

[0081] The multi-head self-attention mechanism captures global context information by calculating the dependencies between each element in the sequence and all other elements. To intuitively learn the relationships between variables, the present invention transposes the learned representations h s and h t , regards each dimension of the sequence as a feature representing a variable, and then extracts information through three learnable matrices. Among them, W Q and W K are the shared projection matrices for queries and keys; because with domain transfer, the relationships of some variable structures may change slightly, W V is used to adjust the structure of the target domain, The output is:

[0082] Q s = h s W Q , Q t = h t W Q , K s = h s W K , K t = h t W K , V t= h t W V

[0083]

[0084] where m represents the number of heads, and the present invention trains m groups of W simultaneously Q 、W K 、W V to obtain To learn the structural relationships related to different categories, the present invention employs a fully connected layer classifier C task , to capture the unique relationships of specific tasks and be used for optimizing the classification tasks based on variable structures. The calculation method of the task structure classification loss is as follows:

[0085]

[0086] So far, different variable structures A s and A t have been learned based on the categories of the source domain through the multi-attention mechanism. However, since the labels of the target domain are unknown, the corresponding relationship between the source domain and target domain categories cannot be directly determined. To solve this problem, the present invention proposes a label distribution alignment method.

[0087] Specifically, A t represents the output of the multi-variable structure encoder learned based on the source domain labels on the target domain samples, while f t represents the high-dimensional feature information extracted from the target domain samples. The label distributions (probability distributions belonging to a certain category) of the same sample output should be consistent. Inputting the above features into the linear layer to obtain two normalized distributions: D t = BN(C cls (f t )), D' t = BN(C task (A t ))). C cls 、C task are the two classifiers introduced above. By aligning the label distributions of the target domain, the variable-related structures of the target domain and the source domain are guided to align. The label alignment loss is calculated as follows:

[0088]

[0089] where k l (u, v) represents the value of the l-th Gaussian kernel function, β l is the weight coefficient of the kernel, and L represents the total number of kernels. Where k l(u, v) represents the value of the l-th Gaussian kernel function, defined as σ l represents the bandwidth parameter of the l-th Gaussian kernel function. represents taking one sample u and v from each of the two distributions respectively, and calculating the expected value of the kernel similarity between them. This loss function distinguishes the multivariate structures corresponding to different labels, while aligning the label distributions across domains. It filters out domain-specific noises and ensures the cross-domain consistency of the multivariate structures of the same category.

[0090] Dual contrast learning step

[0091] Task-related segments play an active role in classification. To further learn domain-invariant information, the present invention proposes a dual contrast learning mechanism, which performs contrast learning within the domain and across domains. This enables the model to capture key intra-domain features and enhance its transfer generalization ability. Specifically, it is divided into intra-domain contrast learning based on gradient TCN and cross-domain contrast learning based on task awareness.

[0092] (I) Intra-domain contrast learning based on gradient TCN

[0093] To strengthen the learning of task-related features, first, through backpropagation based on the source domain labels, a multi-channel attention heatmap is generated from the TCN encoder to mine the segment information that the model pays more attention to in the time series. Then, according to the activation weight values that the model focuses on, the task-related segments and task-unrelated segments in the sequence are respectively masked, so as to form positive sample pairs and negative sample pairs for contrast learning.

[0094] Calculate the gradient with respect to the input feature map:

[0095]

[0096] where F e represents the feature of the e-th activation channel in the final TCN layer; i, j represent a point in the channel feature, and Z is the length of one channel. By multiplying the gradient with the weight obtained by global average pooling and applying the activation function, an attention map is generated:

[0097]

[0098] Mask the 20% segments with the lowest weights, because these segments have the least impact on the training of the model and may contain noise information. On the contrary, masking the 30% segments with the highest weights will remove key information. These two masked segments are input into the frozen TCN encoder to obtain f s + and f s - . The calculation formula of the contrast loss is as follows:

[0099]

[0100] Among them, E represents the cosine similarity, and {f s 6 , f s} is regarded as a positive sample pair, while {f s - , f s} is regarded as a negative sample pair.

[0101] (2) Task-Aware Cross-Domain Contrastive Learning

[0102] Cross-domain contrastive learning focuses on domain alignment and difference modeling. While optimizing the distribution alignment, discriminative information is retained to reduce the risk of negative transfer. Since the target domain lacks labels, the category with the highest classification score is selected as the pseudo-label for the target domain Then, according to the classifier weights, the task-related features of the target domain are calculated.

[0103]

[0104] To encourage the model to better learn cross-domain features in the feature space, the task-related information extracted from samples of the same category c in different domains should be consistent, while the sample information of different categories should be distinguished as much as possible. Denote the samples of different categories across domains as f″ t , and the samples of the same category as f′ t . The contrast loss is expressed as:

[0105]

[0106] Among them, {f′ s , f′ t} is used as a positive sample pair, and {f′ s , f″ t} is used as a negative sample pair.

[0107] Combining the two losses, the final total contrast loss consists of the intra-domain contrast loss and the cross-domain contrast loss.

[0108]

[0109] Training and Inference Steps

[0110] The final loss function consists of multiple parts, including classification loss, relationship learning loss, adversarial loss, label alignment loss, and contrastive learning loss. All hyperparameter values are determined through grid search.

[0111]

[0112] Among them, λ1, λ2, and λ3 are weight coefficients.

[0113] The classification loss, adversarial loss, and contrastive loss are used to train the task attention potential alignment module, while the relation learning loss and label alignment loss are used to train the task-oriented relation fusion module. All losses jointly train the preprocessing convolutional layer.

[0114] In the inference stage, the time series of the target domain is input into the preprocessing module, graph encoder, and feature classification network for classification, thus achieving cross-domain adaptation.

[0115] During the model training process, the gradient of the loss function with respect to the entire model is calculated through the backpropagation algorithm. Then, according to the gradient information, the gradient descent optimization algorithm is used to update each parameter in the model. Through continuous iterative training, the encoding ability of the model is improved, and thus the features most helpful for cross-domain classification are encoded, improving the domain adaptation effect.

[0116] In practical implementation, common deep learning frameworks such as TensorFlow and PyTorch can be used to implement the method of the present invention.

[0117] The present invention discloses a method for cross-domain adaptation of time series scenarios based on task attention potential alignment. After preprocessing the input multivariate time series of the source domain and target domain, it is input into a graph encoder with dynamic timestamps for feature extraction, thereby capturing the dynamic feature representation across time steps. Subsequently, a task attention potential alignment module is introduced to obtain task-related information according to label weights, thereby enhancing the model's ability to identify domain differences. In addition, a task-oriented correlation fusion module is proposed, which learns the multivariate structure of different labels and uses the source domain data to guide the alignment of the multivariate structure in the target domain, effectively filtering out domain-specific perturbations. Finally, combined with a dual contrast learning method based on the attention mechanism, task-related information is captured within the source domain and cross-domain, thereby promoting the learning of domain-invariant representations. By aligning task-related information and task-related structures for cross-domain time series, compared with conventional methods, the present invention effectively improves the cross-domain classification ability and robustness of the model.

[0118] Based on the same technical concept as the above method embodiment, the present invention also provides a time series cross-domain adaptation classification device based on task attention potential alignment, including:

[0119] A data preprocessing module for preprocessing the input time series instances and extracting the local information of the univariate time series. The local information of the time series corresponding to the preprocessed original data of the source domain and target domain is h s and h t ;

[0120] A dynamic graph encoder module for enhancing features using a dynamic graph encoder based on the preprocessed features h of the source domain and the target domain, including: separately extracting the temporal features g of the source domain and the target domain using a graph convolutional neural network based on time steps s and h t ; using a temporal convolutional network to separately extract the temporal features f s and g t through dilated convolutions s and f t ;

[0121] A task attention potential alignment module for feature classification and cross-domain discrimination based on the temporal features f s and f t , obtaining task-related information according to the label weights of feature classification, aligning the feature categories with the task-related information, and constructing a classification loss and a discrimination loss ;

[0122] A task-oriented relationship fusion module for designing a label structure encoder to learn the structural features A s and A t under different labels of the source domain and the target domain using a self-attention mechanism, constructing a task structure classification loss and a label alignment loss

[0123] A dual contrast learning module for performing contrast learning within the domain and across domains. For within-domain contrast learning, the task-related segments and task-unrelated segments in the sequence are separately masked, and the features f s + extracted from the task-related segments and the features f s - extracted from the task-unrelated segments are respectively combined with f s to form positive and negative sample pairs; for cross-domain contrast learning, the task-related features f′ s and f′ t across domains but of the same category are used as positive sample pairs, and the task-related features f′ s and f″ t across domains and of different categories are used as negative sample pairs; calculating the above two contrast learning losses and and summing them up to the total contrast loss

[0124] A training and inference module for training and inferring according to the classification loss the discrimination loss the task structure classification loss the label alignment loss and the total contrast loss Construct the total loss function and carry out the training process of the model. Finally, the unlabeled data in the target domain, after being preprocessed, passes through the dynamic graph encoder and the classification head to obtain the time series classification result of the target domain.

[0125] It should be understood that the time series cross-domain adaptation classification device based on task attention potential alignment in the embodiments of the present invention can implement all the technical solutions in the above method embodiments. The functions of its respective functional modules can be specifically implemented according to the methods in the above method embodiments. The specific implementation process can refer to the relevant descriptions in the above embodiments and will not be elaborated here.

[0126] The present invention also provides an electronic device, including: one or more processors; a memory; and one or more programs, where the one or more programs are stored in the memory and are configured to be executed by the one or more processors. When the program is executed by the processor, it implements the steps of the time series cross-domain adaptation classification method based on task attention potential alignment as described above.

[0127] The present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the steps of the time series cross-domain adaptation classification method based on task attention potential alignment as described above.

[0128] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a device, a computer device, or a computer program product. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) containing computer-usable program code.

[0129] The present invention is described with reference to the flowchart of the method according to the embodiments of the present invention. It should be understood that each process in the flowchart and the combination of processes in the flowchart can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for implementing the functions specified in one Figure 1 process or multiple processes. These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing devices to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured product including an instruction device, and the instruction device implements the process Figure 1functions specified in one or more processes. These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide for implementing in the process Figure 1 steps of functions specified in one or more processes.

Claims

1. A time series cross-domain adaptation classification method based on task attention potential alignment, characterized in that Including the following steps: The input time series instance is preprocessed to extract the local information of the univariate time series. The local information of the time series corresponding to the original data of the source domain and the target domain after preprocessing is h s and h t ; According to the pre - processed features h of the source domain and the target domain s and h t , feature enhancement is performed using a dynamic graph encoder, including: using a graph convolutional neural network based on time steps to extract the temporal features g of the source domain and the target domain respectively s and g t , using a temporal convolutional network to extract the temporal features f through dilated convolution respectively s and f t ; According to the timing feature f s and f t perform feature classification and cross-domain discrimination, and obtain task-related information according to the label weights of the feature classification align the feature categories with the task-related information, and construct a classification loss and a discrimination loss Using the self-attention mechanism, design a label structure encoder to learn the structural features A under different labels in the source domain and the target domain s and A t , construct the task structure classification loss and the label alignment loss Perform contrastive learning within a domain and across domains. For within-domain contrastive learning, mask the task-related segments and task-unrelated segments in the sequence respectively. The features extracted from the task-related segments and the features extracted from the task-unrelated segments are respectively paired with f s to form positive and negative sample pairs; for cross-domain contrastive learning, the task-related features f s ′ and f t ′ across domains but of the same category are used as positive sample pairs, and the task-related features f s ′ and f t ′′ across domains and of different categories are used as negative sample pairs; calculate the above two contrastive learning losses and and sum them up to get the total contrastive loss According to the classification loss Discriminative loss Task structure classification loss Label alignment loss And the total contrastive loss Construct the total loss function and conduct the training process of the model. Finally, the unlabeled data in the target domain is preprocessed and passed through the dynamic graph encoder and the classification head to obtain the time series classification results in the target domain.

2. The method according to claim 1, wherein The implementation of the dynamic graph encoder based on time steps includes: Dividing the preprocessed features of the source domain and the target domain into P segments through the Patchify layer, using P learnable adjacency matrices to capture the multivariate relationships in each time segment, and performing graph learning separately in each domain, where each adjacency matrix represents the relationship between multiple time slices within a specified time; After obtaining the multivariate graph representation, it is input into the temporal convolutional layer, and the temporal dependence features are learned through a two-layer dilated convolutional architecture to obtain f s and f t .

3. The method according to claim 1, wherein f s The loss for classification is as follows: where y s is the true label of the labeled source domain samples, is the prediction result of the classifier, and N s is the number of source domain samples.

4. The method according to claim 1, characterized in that The calculation method of the discriminant loss after aligning the task-related attention is as follows: Among them, f s and f t are the extraction results of the graph encoders in the source domain and the target domain respectively, is the label weight of the linear classification head, β is a learnable parameter, f s ′ is the representation after f s is mapped, N is the number of samples, and D represents the discriminator.

5. The method according to claim 1, wherein Using the self-attention mechanism, design a label structure encoder to learn the structural features A under different labels in the source domain and the target domain s and A t , including: transposing the results h s and h t , regarding each dimension of the sequence as a feature representing a variable, and then extracting information through a learnable self-attention mechanism to obtain a weight matrix, which represents the task-related structural relationship A between variables in different domains s and A t .

6. The method according to claim 1, wherein Task structure classification loss and label alignment loss The calculation method is as follows: Among them N s is the number of source domain samples, and y s is the true label of the labeled source domain samples. The features are input into the linear layer to obtain two normalized distributions: D t = BN(C cls (f t )), D t ′ = BN(C task (A t )); By aligning the label distributions of the target domain, the variable correlation structures of the target domain and the source domain are guided to align. The label alignment loss is calculated as follows: where k l (u, v) represents the value of the l-th Gaussian kernel function, and β l is the weight coefficient of this kernel, L represents the total number of kernels, means taking one sample u and v from each of the two distributions respectively, and calculating the expected value of the kernel similarity between them.

7. The method according to claim 1, wherein The calculation formula of the loss for intra-domain contrast learning is as follows: where E represents the cosine similarity, is regarded as a positive sample pair for in-domain contrastive learning, while is regarded as a negative sample pair for in-domain contrastive learning; The calculation formula of the loss for cross-domain contrast learning is as follows: Among them, {f′ s , f′ t} is used as the positive sample pair for cross-domain contrastive learning, and {f′ s , f″ t} is used as the negative sample pair for cross-domain contrastive learning.

8. A time series cross-domain adaptation classification device based on task attention potential alignment, characterized in that, Including: A data preprocessing module for preprocessing the input time series instances and extracting the local information of the univariate time series. The local information of the time series corresponding to the original data of the source domain and the target domain after preprocessing are h s and h t ; A dynamic graph encoder module, which is used to perform feature enhancement on the preprocessed features h of the source domain and the target domain using a dynamic graph encoder, including: using a time-step based graph convolutional neural network to extract the temporal features g s and h t of the source domain and the target domain respectively, and using a temporal convolutional network to extract the temporal features f s and g t of the source domain and the target domain respectively through dilated convolutions, and using a temporal convolutional network to extract the temporal features f s and f t ; A task attention potential alignment module, which is used to perform feature classification and cross-domain discrimination according to the temporal features f s and f t obtain task-related information according to the label weights of the feature classification, align the feature categories with the task-related information, and construct a classification loss and a discrimination loss and a discrimination loss A task-oriented relationship fusion module, which is used to design a label structure encoder using the self-attention mechanism to learn the structural features A under different labels in the source domain and the target domain s and A t , construct a task structure classification loss and a label alignment loss A dual contrastive learning module for performing contrastive learning within a domain and across domains. For within-domain contrastive learning, the task-related segments and task-unrelated segments in the sequence are respectively masked, and the features extracted from the task-related segments and the features extracted from the task-unrelated segments are respectively paired with f s to form positive and negative sample pairs; for cross-domain contrastive learning, the task-related features f′ s and f′ t from across domains but of the same class are used as positive sample pairs, and the task-related features f′ s and f″ t from across domains and of different classes are used as negative sample pairs; calculate the above two contrastive learning losses and and sum them up to obtain the total contrastive loss Training and inference modules for constructing a total loss function according to the classification loss discriminative loss task structure classification loss label alignment loss and the total contrastive loss During the training process of the model, finally, the unlabeled data in the target domain is preprocessed and passed through the dynamic graph encoder and the classification head to obtain the time series classification results of the target domain.

9. An electronic device, characterized in that, Including: One or more processors; A memory; And one or more programs, where the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and when the program is executed by the processor, it implements the steps of the time series cross-domain adaptation classification method based on task attention potential alignment as described in any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the time series cross-domain adaptation classification method based on task attention potential alignment as described in any one of claims 1-7.

Citation Information

Cited By

  • Encrypted traffic classification method and system based on cross-modal comparative learning, and medium

    CN121727866A