Time sequence decomposition feature nearest neighbor search method based on locality sensitive hash

Through the timing decomposition feature nearest neighbor search method based on locally sensitive hash, the problems of information loss and excessive model complexity in deep learning when processing timing data are solved, and more efficient and accurate feature extraction and data processing are achieved.

CN119494038APending Publication Date: 2025-02-21NANTONG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411572939.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-06
Publication Date
2025-02-21

AI Technical Summary

Technical Problem

Existing deep learning methods have problems such as information loss and excessive model complexity when processing time series data, which affect the accuracy and efficiency of the results.

Method used

The nearest neighbor search method for time-series decomposition feature based on locally sensitive hash is used to decompose the time series into similar and non-similar information through the time-series decomposition network layer, and the nearest neighbor search is performed in high-dimensional space using locally sensitive hash, and optimized by weighted loss function. Model.

Benefits of technology

It effectively reduces the complexity of the model, improves feature extraction capabilities, reduces information loss, and improves the accuracy and efficiency of time-series data processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119494038A_ABST
    Figure CN119494038A_ABST
Patent Text Reader

Abstract

The invention provides a time sequence decomposition feature nearest neighbor search method based on locality sensitive hash, belongs to the technical field of deep learning, and solves the technical problem that a training result and a test result are different due to different data distribution. According to the technical scheme, stacking decomposition network time series data is decomposed into channel similar items and non-similar items, local sensitive hash achieves nearest neighbor search compression of a self-attention matrix in a high-dimensional space, and a triple loss function reduces data distribution differences of a source domain and a target domain. The beneficial effects of the invention are that compared with some existing deep learning methods, the method provided by the invention has higher recognition accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of deep learning, and in particular relates to a time series decomposition feature nearest neighbor search method based on local sensitive hashing. Background Art

[0002] Deep learning has revolutionized time series feature extraction, making it possible to automatically extract complex features from raw sensor data. Traditional methods usually rely on manual feature extraction, which has limitations in terms of the complexity of time series features. Deep learning models, such as convolutional neural networks (CNNs) and recurrent neural networks (RNNs), excel in learning discriminative representations directly from data. These representations are able to encode spatial and temporal dependencies. In addition, the popularity of sensor devices provides a rich source of data for training these models, further improving their performance in real-world applications. Therefore, feature extraction based on deep learning has been widely used in fields such as health monitoring and intelligent environmental control, marking an important progress in this field.

[0003] Recently, deep learning architectures based on time series decomposition have been widely used to deconstruct and reconstruct time series patterns from complex time series data and enhance the model's ability to model long-term and short-term dependencies. These studies usually use multi-scale convolution to decompose time series data into trend terms and seasonal terms to capture significant features. Others have proposed a time series decomposition architecture based on Fourier transform, which decomposes time series data into different periodic patterns through the main frequency results.

[0004] Since its introduction in 2017, the Transformer model has become a core architecture in the field of natural language processing, inspiring time series researchers to develop models based on the TS Transformer. However, when applying NLP Transformers to time series tasks, they mainly face the problem of quadratic time and memory complexity. To address this issue, several computationally aware time series Transformer models have been proposed, such as Informer, Autoformer, Pyraformer, and FEDformer, which achieve L or Llog(L) complexity by modifying the self-attention mechanism.

[0005] At the same time, locality sensitive hashing (LSH) has also been widely used in the HAR field. LSH is a technology used for approximate nearest neighbor search of high-dimensional data. Its core idea is to map similar data points into the same or similar buckets, thereby increasing the collision probability of similar data points in the hash table. Compared with traditional linear search methods, LSH can significantly reduce the search complexity when processing large-scale data sets.

[0006] Despite significant progress in this field, the processing of time series data remains problematic. Typically, feature maps generated by convolutional layers from raw sensor data are simply vectorized and fed into a recurrent network. However, this approach can result in information loss and fail to fully utilize the deep features of time series data, which can affect the accuracy of the results. In addition, although Transformer-based deep learning frameworks have shown great potential in processing multi-channel time series data, they still face challenges in balancing accuracy and complexity. High accuracy is often accompanied by increased model complexity, so how to optimize model complexity while maintaining high performance is a key issue that needs further exploration in this field. Summary of the invention

[0007] In view of the technical problems existing in the deep learning methods in the above-mentioned prior art, the present invention proposes a time series decomposition feature nearest neighbor search method based on local sensitive hashing, and designs a low-complexity self-attention deep learning model. The model first decomposes the time series into similar information and dissimilar information through a time series decomposition network layer, aligns the decomposed features with the prototype pool samples through an alignment network to make the distribution of training data and test data converge, and then obtains features in different hash spaces through stackable network layers, distributes the features in each hash space to different hash buckets through a random rotation matrix, and then, aggregates features with the same hash code through sorting, calculates attention weights for features with the same hash code, and finally trains the model by maximizing the distance between prototype pool classes and adding a cross entropy loss function.

[0008] The inventive idea of ​​the present invention is: the present invention decomposes time series data into channel similar items and dissimilar items through a stacked decomposition network, uses similar items to achieve distribution alignment, and uses dissimilar items to search for similar time step features; secondly, a hash process is designed to distribute the decomposed features to different hash buckets, and the attention matrix is ​​only performed within the same hash code. Then, a triple loss function is designed to control the alignment of data distribution, and finally realize the recognition of human daily activities.

[0009] In order to achieve the above-mentioned invention object, the technical scheme adopted by the present invention is as follows: a method for nearest neighbor search of time series decomposition features based on local sensitive hash, comprising the following steps:

[0010] S1. Decomposition of time series data by the time series decomposition network layer: Initialize n prototype samples to build a prototype sample pool P. The number of n is determined by the downstream task. If it is a time series classification task, it is determined by the number of classifications. If it is a time series prediction task, it is determined by the number of multivariate channels. Then, the channel similarity feature x is extracted through the decomposition network. sim , p sim ; Use the original input data xinput and the prototype sample P, respectively, minus the similar features captured by each, and we get the non-similar features x no_sim , p no_sim ;

[0011] S2. Align the feature distribution of prototype features with the input data to improve generalization ability: Taking the data after the first layer of decomposition as an example, receiving the x after the time series decomposition layer sim , p sim and x no_sim , p no_sim , is x sim Find the closest p in the prototype pool sim Prototype, in the training phase, by obtaining the label of the input data, directly find the prototype sample with the corresponding label to achieve feature alignment between the two; in the test phase, since the test data has unknown labels, the measurement x sim The Euclidean distance with the n prototype samples in the prototype pool is used to complete the feature alignment. sim , the corresponding prototype sample After that, firstly convert x sim and The encoder is passed in. The encoder consists of batch normalization, multi-layer convolution and activation function. sim and The input feature alignment network, during the training phase, the two need to be aligned with each other, because p sim It is an initialized trainable sample, which does not have the data distribution of the input sample. The training data features also need to be aligned because it is easier to make the distribution of both training data and test data similar to the prototype data than to make the training distribution towards the test data. Through the linear layer and sigmoid function, learning and The gap weight, and The result is multiplied by the weight and added to x sim and To achieve feature interaction, however, in the test phase, since the prototype pool has been trained, feature alignment is one-way, and the prototype samples do not need to be aligned with the test data, and the test data can be aligned with the prototype samples. Finally, the aligned results are aligned with x no_sim , p no_sim Add them together and pass them to the next decomposition layer to complete feature alignment at different decomposition levels;

[0012] S3, local sensitive hashing to achieve nearest neighbor search in high-dimensional space: receiving the decomposition layer x no_sim , p no_sim , if there are m decomposition layers, there are m groups of x no_sim , pno_sim , m-layer decomposition layer is equivalent to m hash functions, which map the time series features to different hash spaces. Similar time series features still have similarity in different hash spaces, so set the same number of random matrices m*R as the number of decomposition layers, multiply the features in each hash space by a random matrix R of the corresponding layer, and then twist the features into k hash buckets. k is the number of hash buckets, which is a hyperparameter set artificially. After all the features in the m hash spaces are assigned to the hash buckets of this layer, the hash code is constructed according to the bucket number. Since each time series feature is encoded into m hash spaces, each hash space has k hash buckets, so each data feature has k1k2k3...k m So the hash code of length m, k m Indicates the kth bucket number in the mth space. Therefore, each time series feature has its own unique hash code. Then use sort to reorder the features with the same hash code and put them together to complete the nearest neighbor search in the high-dimensional space. Finally, only the self-attention matrix is ​​calculated for the features with the same hash code, compressing the quadratic complexity to O(LlogL).

[0013] S4, weighted loss function: The extracted features are used to complete downstream tasks: classification or prediction through the cross entropy loss function. Then, the inter-class distance in the prototype sample pool is maximized to make each prototype sample clearer. These two items constitute a complete loss function, which helps the model have better accuracy and robustness.

[0014] As a further preferred solution of the time series decomposition feature nearest neighbor search method based on local sensitive hash provided by the present invention, the S1 specifically includes the following steps:

[0015] First, the channel similarity feature x is extracted by decomposing the network sim , using the original input data x input The similar features captured are the non-similar features x no_sim :

[0016] x sim =sigmod(fc(AvgPool2D(Conv2D(x input )))*x input (1)

[0017] x no_sim =x input -x sim (2)

[0018] Among them, x input is the initialization data, x simis the extracted channel similarity data, x no_sin is the extracted channel non-similar data, fc is the linear layer, AvgPool2D represents the pooling operation, and Cinv2D represents the convolution operation;

[0019] Then initialize the prototype sample pool P, and use the same method to extract channel similarity features p through the decomposition network sim , p no_sim :

[0020] P=Embeding(N,H,T,E) (3)

[0021] P sim =sigmod(fc(AvgPool2D(Conv2D(P)))*P (4)

[0022] P no_sim =PP sim (5)

[0023] Among them, P is the initialization data, P sim is the extracted channel similarity data, P no_sim is the extracted channel non-similar data, Eebeding is the initialized trainable data, N, H, T, E represent the number of prototype pool samples, the number of attention heads, the time series length and the embedding size respectively;

[0024] As a further preferred solution of the time series decomposition feature nearest neighbor search method based on local sensitive hash provided by the present invention, S2 specifically includes the following steps:

[0025] First, x sim Find the closest p sim Prototype, in the training phase, by obtaining the label of the input data, directly find the prototype sample with the corresponding label; in the testing phase, the test data label is unknown, and the measurement x sim The Euclidean distance from the n prototype samples in the prototype pool to find the optimal prototype sample:

[0026]

[0027]

[0028] in, Represents x sim For the selected data of the same category, argmin represents finding the minimum value, and dist represents Euclidean distance calculation;

[0029] Then x sim and Perform feature encoding to facilitate subsequent feature alignment operations, and learn through linear layers and sigmoid functions and The gap weight, and The result is multiplied by the weight and added to x sim and Go to realize the interaction of features:

[0030]

[0031]

[0032] Among them, X ali and represents the features that interact with each other after alignment, w represents the trainable parameters, bias represents the bias term, and encoder represents the encoder consisting of a normalization layer, a convolutional layer, and an activation function;

[0033] Finally, the aligned results are respectively compared with x no_sim , p no_sim Add and pass to the next decomposition layer:

[0034] x input =x no_sim +x ali (10)

[0035]

[0036] Among them, x input and p i Now let's show the features after the alignment is completed;

[0037] As a further preferred solution of the time series decomposition feature nearest neighbor search method based on local sensitive hash provided by the present invention, S3 specifically includes the following steps:

[0038] Set x in each hash space no_sim The features are multiplied by a random matrix R of the corresponding layer, so as to twist the features into k hash buckets, where k is the number of hash buckets, a manually set hyperparameter:

[0039] bucket k =x no_sim *R (12)

[0040] Among them, R represents the random rotation matrix corresponding to the hash space of this layer; bucket k Represents the kth hash bucket of the hash space at this layer;

[0041] After allocating the features in the m hash spaces to the hash buckets of this layer, the hash code is constructed according to the bucket number. Since each time series feature is encoded in m hash spaces, each hash space has k hash buckets, so each data feature has k1k2k3...k m The hash code of length m is:

[0042] buckets_and_p kj =seqlen×buckets kj +(ticker kj %seqlen) (13)

[0043] Among them, buckets_and_p kj is a unique composite identifier generated for each time series feature, buckets kj Indicates the jth data in the kth bucket, ticker kj is the index of the sequence position;

[0044] Then use sort to reorder the features with the same hash code and put them together to complete the nearest neighbor search in the high-dimensional space:

[0045] sbuckets_and_p, sticker=sort(buckets_and_p, ticker) (14)

[0046] Among them, sbuckets_and_p is the sort combination identifier, and sticker is the original index after sorting.

[0047] Finally, the self-attention matrix is ​​calculated only for features with the same hash code:

[0048] st=sticker%seqlen (15)

[0049] queries sq =index select(queries q ,st) (16)

[0050]

[0051] Among them, st is the index in the bucket, queries q The original time series features are regarded as the original query set in self-attention. sq It is a new query set after reordering the features with the same hash code according to the index. i , k jand v i Respectively represent the q, k, and v values ​​of the same hash code after rearrangement, z(i; P i ) represents the normalization term in softmax, o i Represents the i-th temporal feature, aggregating the attention features with the same hash code.

[0052] As a further preferred solution of the time series decomposition feature nearest neighbor search method based on local sensitive hash provided by the present invention, the S4 specifically includes the following steps:

[0053] The extracted features are used to complete downstream tasks: classification or prediction through the cross entropy loss function. Then, the inter-class distance in the prototype sample pool is maximized to make each prototype sample more distinct. These two items constitute a complete loss function, which helps the model have better accuracy and robustness. Take the classification task as an example:

[0054]

[0055]

[0056] loss = αL class +βL class (20)

[0057] Among them, α and β are hyperparameters after normalization of weights, which are used to control the network's bias towards extracting periodic features or seasonal features; Indicates the probability of belonging to the i-th category calculated by feature o, L class represents the cross entropy loss function, L margin Represents the maximization of inter-class loss.

[0058] Compared with the existing technology, it has the following technical effects:

[0059] (1) The present invention creates deep learning-based hash functions by constructing m layers of time series decomposition layers and random rotation matrices. These hash functions have better feature extraction capabilities and can transform time series data into m hash spaces. By allocating time series data to m hash buckets in m hash spaces, the probability of allocation errors is reduced, and attention calculation is performed on time series features with the same hash code, reducing the complexity of 0(L^2) to 0(LlogL).

[0060] (2) The present invention designs a solution to alleviate the degradation of model performance caused by the different distributions of training data and test data. By constructing a prototype sample pool and a decomposition network, data from different domains are aligned at different decomposition levels, thereby reducing the data difference between the target domain and the source domain.

[0061] (3) The present invention designs a weighted loss function. For the created prototype sample pool, since it is necessary to find the closest prototype sample for the input data, maximizing the inter-class loss of the prototype samples can help achieve this goal. At the same time, the cross entropy loss function is added to form a complete weighted loss training stable and robust model. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] The accompanying drawings are used to provide further understanding of the present invention and constitute a part of the specification. They are used to explain the present invention together with the embodiments of the present invention and do not constitute a limitation of the present invention.

[0063] Figure 1 The overall flow chart of the nearest neighbor search method for time series decomposition features based on local sensitive hashing provided by the present invention.

[0064] Figure 2 This is a curve chart of the decomposition results on the UCIHAR dataset in the present invention.

[0065] Figure 3 This is a schematic diagram of the attention visualization results on the UCIHAR dataset in the present invention.

[0066] Figure 4 This is a schematic diagram of the classification confusion matrix after testing on the SHAR dataset in the present invention. DETAILED DESCRIPTION

[0067] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. Of course, the specific embodiments described here are only used to explain the present invention and are not used to limit the present invention.

[0068] Example 1

[0069] See also Figures 1 to 4 In this embodiment, a nearest neighbor search method based on local sensitive hashing for decomposition of time series features in high-dimensional space is proposed. In this embodiment, the experiment of this embodiment is carried out on pytorch, and the network training and testing are carried out on NVIDIA 3050TiGPU. During the experiment, the model is trained and evaluated on the UCIHAR and SHAR public datasets. This dataset is used for comparison with other methods.

[0070] A nearest neighbor search method for decomposed time series features in high-dimensional space based on local sensitive hashing includes the following steps:

[0071] S1. Decomposition of time series data by the time series decomposition network layer: Initialize n prototype samples to build a prototype sample pool P. The number of n is determined by the downstream task. If it is a time series classification task, it is determined by the number of classifications. If it is a time series prediction task, it is determined by the number of multivariate channels. Then, the channel similarity feature x is extracted through the decomposition network. sim , p sim ; Use the original input data x input and the prototype sample P, respectively, minus the similar features captured by each, and we get the non-similar features x no_sim , p no_sim ;

[0072] S2. Align the feature distribution of prototype features with the input data to improve generalization ability: Taking the data after the first layer of decomposition as an example, receiving the x after the time series decomposition layer sim , p sim and x no_sim , p no_sim , is x sim Find the closest p in the prototype pool sim Prototype, in the training phase, by obtaining the label of the input data, directly find the prototype sample with the corresponding label to achieve feature alignment between the two; in the test phase, since the test data has unknown labels, we measure x sim The Euclidean distance with the n prototype samples in the prototype pool is used to complete the feature alignment. sim , the corresponding prototype sample After that, firstly convert x sim and The encoder is passed in. The encoder consists of batch normalization, multi-layer convolution and activation function. sim and The input feature alignment network, during the training phase, the two need to be aligned with each other, because p sim It is an initialized trainable sample, which does not have the data distribution of the input sample. The training data features also need to be aligned because it is easier to make the distribution of both training data and test data similar to the prototype data than to make the training distribution towards the test data. Through the linear layer and sigmoid function, learning and The gap weight, and The result is multiplied by the weight and added to x sim and To achieve feature interaction, however, in the test phase, since the prototype pool has been trained, feature alignment is one-way, and the prototype samples do not need to be aligned with the test data, and the test data can be aligned with the prototype samples. Finally, the aligned results are aligned with x no_sin , p no_simAdd them together and pass them to the next decomposition layer to complete feature alignment at different decomposition levels;

[0073] S3, local sensitive hashing to achieve nearest neighbor search in high-dimensional space: receiving the decomposition layer x no_sim , p no_sim , if there are m decomposition layers, there are m groups of x no_sim , p no_sim, The m-layer decomposition layer is equivalent to m hash functions, which map the time series features to different hash spaces. Similar time series features still have similarity in different hash spaces, so we set the same number of random matrices m*R as the number of decomposition layers, and multiply the features in each hash space by a random matrix R of the corresponding layer, so as to twist the features into k hash buckets. k is the number of hash buckets, which is a hyperparameter set artificially. After all the features in the m hash spaces are assigned to the hash buckets of this layer, the hash code is constructed according to the bucket number. Since each time series feature is encoded into m hash spaces, each hash space has k hash buckets, so each data feature has k1k2k3…k m So the hash code of length m, k m Indicates the kth bucket number in the mth space. Therefore, each time series feature has its own unique hash code. Then use sort to reorder the features with the same hash code and put them together to complete the nearest neighbor search in the high-dimensional space. Finally, only the self-attention matrix is ​​calculated for the features with the same hash code, compressing the quadratic complexity to O(LlogL).

[0074] S4, weighted loss function: The extracted features are used to complete downstream tasks: classification or prediction through the cross entropy loss function. Then, the inter-class distance in the prototype sample pool is maximized to make each prototype sample clearer. These two items constitute a complete loss function, which helps the model have better accuracy and robustness.

[0075] Specifically, the step S1 comprises the following steps:

[0076] First, the channel similarity feature x is extracted by decomposing the network sim , using the original input data x input The similar features captured are the non-similar features x no_sim :

[0077] x sim =sigmod(fc(AvgPool2D(Conv2D(x input )))*x input (1)

[0078] xno_sim =x input -x sim (2)

[0079] Among them, x input is the initialization data, x sim is the extracted channel similarity data, x no_sim is the extracted channel non-similar data, fc is the linear layer, AvgPool2D represents the pooling operation, and Conv2D represents the convolution operation;

[0080] Then initialize the prototype sample pool P, and use the same method to extract channel similarity features p through the decomposition network sim , p no_sim :

[0081] P=Embeding(N,H,T,E) (3)

[0082] P sim =sigmod(fc(AvgPool2D(Conv2D(P)))*P (4)

[0083] P no_sim =PP sim (5)

[0084] Among them, P is the initialization data, P sim is the extracted channel similarity data, P no_sim is the extracted channel non-similar data, Eebeding is the initialized trainable data, N, H, T, E represent the number of prototype pool samples, the number of attention heads, the time series length and the embedding size respectively;

[0085] Specifically, the step S2 comprises the following steps:

[0086] First, x sim Find the closest p sim Prototype, in the training phase, by obtaining the label of the input data, directly find the prototype sample with the corresponding label; in the testing phase, the test data label is unknown, and the measurement x sim The Euclidean distance from the n prototype samples in the prototype pool to find the optimal prototype sample:

[0087]

[0088]

[0089] in, Represents x sim For the selected data of the same category, argmin represents finding the minimum value, and dist represents Euclidean distance calculation;

[0090] Then x sim and Perform feature encoding to facilitate subsequent feature alignment operations, and learn through linear layers and sigmoid functions and The gap weight, and The result is multiplied by the weight and added to x sim and Go to realize the interaction of features:

[0091]

[0092]

[0093] Among them, x ali and represents the features that interact with each other after alignment, w represents the trainable parameters, bias represents the bias term, and encoder represents the encoder consisting of a normalization layer, a convolutional layer, and an activation function;

[0094] Finally, the aligned results are respectively compared with x no_sim , p no_sim Add and pass to the next decomposition layer:

[0095] x input =x no_sim +x ali (10)

[0096]

[0097] Among them, x input and p i Now let's show the features after the alignment is completed;

[0098] Specifically, the step S3 specifically includes the following steps: calculating the time proportion of each activity according to the prediction result:

[0099] Set x in each hash space no_sim The features are multiplied by a random matrix R of the corresponding layer, so as to twist the features into k hash buckets, where k is the number of hash buckets, a manually set hyperparameter:

[0100] bucket k =x no_sim *R (12)

[0101] Among them, R represents the random rotation matrix corresponding to the hash space of this layer; bucket k Represents the kth hash bucket of the hash space at this layer;

[0102] After allocating the features in the m hash spaces to the hash buckets of this layer, the hash code is constructed according to the bucket number. Since each time series feature is encoded in m hash spaces, each hash space has k hash buckets, so each data feature has k1k2k3…k m The hash code of length m is:

[0103] buckets_and_p kj =seqlen×buckets kj +(ticker kj %seqlen) (13)

[0104] Among them, buckets_and_p kj is a unique composite identifier generated for each time series feature, buckets kj Indicates the jth data in the kth bucket, ticker kj is the index of the sequence position;

[0105] Then use sort to reorder the features with the same hash code and put them together to complete the nearest neighbor search in the high-dimensional space:

[0106] sbuckets_and_p, sticker=sort(buckets_and_p, ticker) (14)

[0107] Among them, sbuckets_and_p is the sort combination identifier, and sticker is the original index after sorting.

[0108] Finally, the self-attention matrix is ​​calculated only for features with the same hash code:

[0109] st=sticker%seqlen (15)

[0110] queries sq =index select(queries q ,st) (16)

[0111]

[0112] Among them, st is the index in the bucket, queries q The original time series features are regarded as the original query set in self-attention. sq It is a new query set after reordering the features with the same hash code according to the index. i , k j and vi Respectively represent the q, k, and v values ​​of the same hash code after rearrangement, z(i; P i ) represents the normalization term in softmax, o i Represents the i-th temporal feature, aggregating the attention features with the same hash code.

[0113] Specifically, the step S4 comprises the following steps:

[0114] The extracted features are used to complete downstream tasks: classification or prediction through the cross entropy loss function. Then, the inter-class distance in the prototype sample pool is maximized to make each prototype sample more distinct. These two items constitute a complete loss function, which helps the model have better accuracy and robustness. Take the classification task as an example:

[0115]

[0116]

[0117] loss = αL class +βL class (20)

[0118] Among them, α and β are hyperparameters after normalization of weights, which are used to control the network's bias towards extracting periodic features or seasonal features; Indicates the probability of belonging to the i-th category calculated by feature o, L class represents the cross entropy loss function, L margin Represents the maximization of inter-class loss.

[0119] Comparative experiment:

[0120] UCI-HAR dataset. Collected from 30 volunteers who strapped their smartphones to their waists and performed one of 6 standard activities, with motion data recorded by developed mobile software. The motion data recorded are x, y and z accelerometer data (linear acceleration) and gyroscope data (angular velocity) from the smartphone (specifically Samsung Galaxy S II). Each volunteer performed the activity sequence twice, the first time with the device on the left side of the waist, and the second time with the smartphone placed by the user according to their preference.

[0121] pass Figure 2 It can be seen that this embodiment can decompose the time series data very well. Figure 3 It can be seen that this embodiment has excellent classification ability.

[0122] Example 2

[0123] Based on Example 1, the same operating steps are implemented to test the SHAR dataset of Example 2. The UniMiB-SHAR (University of Milan-Bicocca Smart Home Activity Recognition) dataset is used to recognize human activities through mobile phone sensor data, especially in action recognition tasks. The dataset collects data from the accelerometer and gyroscope of the smartphone with a sampling frequency of 50Hz, recording 50 data points per second. The dataset covers 12 common activities in daily life, including sleeping, sitting, standing, walking, running, going upstairs, going downstairs, riding a bicycle, making phone calls, watching TV, doing housework and reading. The data is stored in the form of time windows, each window contains time series data of a fixed length, and records multi-dimensional measurements of the accelerometer and gyroscope. Figure 4 As shown, the confusion matrix of the WISDM dataset test results is plotted.

[0124] This embodiment provides a method for nearest neighbor search in high-dimensional space based on local sensitive hashing of decomposed time series features, including the following steps: stacking decomposition networks to decompose time series data, constructing prototype sample pools to reduce the data distribution differences between source domains and target domains, constructing hash codes of m-layer hash space features to realize high-dimensional space nearest neighbor search, and low-complexity attention matrix calculation. The beneficial effects of this embodiment are: this embodiment decomposes time series data into similar information and non-similar information through neural networks, and after multi-layer decomposition network blocks, completes feature alignment under the degree of indecomposition; secondly, the search for similar features in the m-layer hash space and the hash code constructed by hash bucket allocation reduce the probability of search errors, and then the attention matrix calculation is performed in the features with the same hash code, which reduces the complexity. Finally, through experiments, it is verified that the method of this embodiment has excellent performance in decomposing and identifying time series data.

[0125] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A time series decomposition feature nearest neighbor search method based on local sensitive hashing, characterized in that: The following steps are involved: S1. Decomposition of time series data by the time series decomposition network layer: Initialize n prototype samples to build a prototype sample pool P. The number of n is determined by the downstream task. If it is a time series classification task, it is determined by the number of classifications. If it is a time series prediction task, it is determined by the number of multivariate channels. Then, the channel similarity feature x is extracted through the decomposition network. sim , p sim ; Use the original input data x input and the prototype sample P, respectively, minus the similar features captured by each, and we get the non-similar features x no_sim , p no_sim ; S2. Align the feature distribution of prototype features with the input data to improve generalization ability: The feature alignment mechanism is used to make the prototype features consistent with the feature distribution of the input data. Taking the data after the first layer of decomposition as an example, the data x after the time series decomposition layer is received. sim , p sim and x no_sim , p no_sim , during the training phase, the label is matched to x sim Find the corresponding p sim Prototype samples, feature alignment; In the test phase, by calculating x sim The Euclidean distance to the n prototypes in the prototype pool, select the closest prototype sample Select x sim and the corresponding After that, the two are passed into the encoder composed of batch normalization, multi-layer convolution and activation function, and then input into the feature alignment network. In the training phase, the gap weights are learned to align x sim and Perform bidirectional alignment; In the test phase, since the prototype pool has been trained, feature alignment only needs to be performed in one direction. The results after alignment are respectively compared with x no_sin and p no_sim Add them together and input them into the next decomposition layer to complete the feature alignment of each layer; S3. Local sensitive hashing realizes nearest neighbor search in high-dimensional space: Use m layers of decomposition as m hash functions to map time series features into different hash spaces. Multiply each layer of features by a random matrix R and map them into k hash buckets to generate exclusive hash codes. Reorder and concentrate features with the same hash code to realize nearest neighbor search in high-dimensional space. Calculate self-attention for features with the same hash code and compress the complexity to O(LlogL). S4. Weighted loss function: The extracted features are used through the cross entropy loss function to complete the downstream task: classification or prediction. Then, the inter-class distance in the prototype sample pool is maximized to make each prototype sample distinct.

2. According to claim 1, the method for nearest neighbor search of time series decomposition features based on local sensitive hashing is characterized in that: The step S1 comprises the following steps: S11. Extract channel similarity features x by decomposing the network sim , using the original input data x input Capture similar features and obtain non-similar features x no_sim : x sim =sigmod(fc(AvgPool2D(Conv2D(x input )))*x input (1) x no_sim =x imput -x sim (2) Among them, x input is the initialization data, x sim is the extracted channel similarity data, x no_sim is the extracted channel non-similar data, fc is the linear layer, AvgPool2D represents the pooling operation, and Conv2D represents the convolution operation; S12, initialize the prototype sample pool P, and extract channel similarity features p through the decomposition network sim , p no_sim : P=Embeding(N,H,T,E) (3) P sim =sjgmod(fc(AvgPool2D(Conv2D(P)))*P (4) P no_sim =P-P sim (5) Among them, P is the initialization data, P sim is the extracted channel similarity data, P no_sim is the extracted channel non-similar data, Eebeding is the initialized trainable data, N, H, T, E represent the number of prototype pool samples, the number of attention heads, the time series length and the embedding size respectively.

3. The method for nearest neighbor search based on local sensitive hashing for time series decomposition according to claim 2 is characterized in that: The step S2 comprises the following steps: S21, first for x sim Find the closest p sim Prototype, in the training phase, by obtaining the label of the input data, find the prototype sample with the corresponding label; in the testing phase, the test data label is unknown, and the measurement x sim The Euclidean distance from the n prototype samples in the prototype pool to find the optimal prototype sample: in, Represents x sim For the selected data of the same category, argmin represents finding the minimum value, and dist represents Euclidean distance calculation; S22, x sim and Perform feature encoding and subsequent feature alignment operations, learn through linear layers and sigmoid functions and The gap weight, and The result is multiplied by the weight and added to x sim and Go to realize the interaction of features: Among them, x ali and represents the features that interact with each other after alignment, w represents the trainable parameters, bias represents the bias term, and encoder represents the encoder consisting of a normalization layer, a convolutional layer, and an activation function; S23, compare the aligned results with x no_sim , p no_sim Add and pass to the next decomposition layer: x input =x no_sim +x ali (10) Among them, x input and p i Indicates the features after the alignment is completed.

4. The method for nearest neighbor search of time series decomposition features based on local sensitive hashing according to claim 3 is characterized in that: The step S3 comprises the following steps: S31. Set x in each hash space no_sim The features are multiplied by a random matrix R of the corresponding layer to twist the features into k hash buckets, where k is the number of hash buckets, a manually set hyperparameter: bucket k =x no_sim *R (12) Among them, R represents the random rotation matrix corresponding to the hash space of this layer; bucket k Represents the kth hash bucket of the hash space at this layer; S32. After allocating the features in the m hash spaces to the hash buckets of this layer, a hash code is constructed according to the bucket number. Since each time series feature is encoded into m hash spaces, each hash space has k hash buckets, so each data feature has k1k2k3…k m The hash code of length m is: buckets_and_p kj =seqlen×buckets kj +(ticker kj %seqlen) (13) Among them, buckets_and_p kj is a unique composite identifier generated for each time series feature, buckets kj Indicates the jth data in the kth bucket, ticker kj is the index of the sequence position; S33, then use sort to reorder the features with the same hash code, put them together, and complete the nearest neighbor search in the high-dimensional space: sbuckets_and_p, sticker=sort(buckets_and_p, ticker) (14) Among them, sbuckets_and_p is the sort combination identifier, and sticker is the original index after sorting; S34. Calculate the self-attention matrix for features with the same hash code: st=sticker%seqlen (15) queries sq =index select(queries q ,st) (16) Among them, st is the index in the bucket, queries q The original time series features are regarded as the original query set in self-attention. sq It is a new query set after reordering the features with the same hash code according to the index. i , k j and v i Respectively represent the q, k, and v values ​​of the same hash code after rearrangement, z(i; P i ) represents the normalization term in softmax, o i Represents the i-th temporal feature, aggregating the attention features with the same hash code.

5. The method for nearest neighbor search based on local sensitive hashing for time series decomposition according to claim 4 is characterized in that: The step S4 comprises the following steps: S41, the extracted features are used to complete downstream tasks: classification or prediction, S42, maximize the distance between classes in the prototype sample pool, so that each prototype sample is clear. These two items constitute a complete loss function. The classification task is as follows: loss=αL class +βL class (20) Among them, α and β are hyperparameters after normalization of weights, which are used to control the network's bias towards extracting periodic features or seasonal features; Indicates the probability of belonging to the i-th category calculated by feature o, L class represents the cross entropy loss function, L margin Represents the maximization of inter-class loss.