Efficient deep learning method for constructing prototype features to carry out human activity recognition
By constructing prototype features and Prototype Pool technology, combined with the low-complexity Transformer model, the problem of inconsistent feature extraction and distribution in human activity recognition is solved, efficient feature extraction and recognition accuracy are achieved, and the generalization ability and robustness of the model are improved. Great sex.
Patent Information
- Application Number
- CN202410729231.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-06
- Publication Date
- 2024-09-06
AI Technical Summary
Existing human activity recognition methods based on deep learning are difficult to extract features efficiently and face the problem of inconsistent distribution between the training domain and the test domain. Moreover, the complexity of the Transformer-based model is high and it is difficult to process large-scale data.
By constructing prototype features, using Prototype Pool to maintain the prototype sample pool, dynamically updating and maintaining prototype samples, designing a low-complexity Transformer feature extractor, and constructing an attention matrix based on the distance between QK features and mean features to separate attention and non-attention information. And enhance the generalization ability of the model by maximizing the loss of positive and negative sample pairs and the cross-entropy loss function.
It improves the training efficiency and generalization ability of the model, reduces the complexity of feature extraction, enhances the recognition accuracy and robustness, and can effectively process time series data.
Smart Images

Figure CN118606785A
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of deep learning technology, and specifically relates to an efficient deep learning method for constructing prototype features to identify human activities. Background Art
[0002] Human activity recognition refers to the use of sensor technology and machine learning algorithms to identify people's daily activities and behaviors. This technology usually uses sensors such as accelerometers, gyroscopes, magnetometers, etc. to capture human motion data, and then analyzes and classifies this data through machine learning models to identify the activities that people are doing, such as walking, running, sitting, standing, etc. This technology has broad application prospects in health monitoring, smart homes, sports training and other fields. Through human activity recognition technology, smart devices can better understand user behavior and provide personalized services and suggestions.
[0003] Deep learning has many advantages in solving the problem of human activity recognition. First, deep learning models can learn feature representations from large-scale and complex data without manually designing features, thereby improving the model's automation and generalization capabilities. Second, deep learning models can flexibly adapt to activity data of different types and scales, and can process time series information and multimodal data, thereby improving the accuracy and robustness of recognition. In addition, with the improvement of hardware computing power and the continuous optimization of algorithms, deep learning models have also made significant progress in real-time and efficiency, and can meet the needs of rapid response. In summary, deep learning technology provides powerful tools and methods for human activity recognition, promoting the development and application of this field.
[0004] The application of deep learning in human activity recognition also faces some challenges. There may be temporal correlations and sequence information between different activities, which requires deep learning models to have the ability to effectively model time series data. Secondly, deep learning models are complex and computationally demanding, especially when recognizing and processing large amounts of data in real time, which requires powerful computing resources. In addition, deep learning models may be sensitive to noise and data imbalance, which may affect the accuracy and generalization ability of the model. Therefore, how to effectively use deep learning technology to solve the challenges in human activity recognition is still an issue that needs further research.
[0005] Prototype Pool is a technology used to solve the problems of sample efficiency and generalization ability. It is based on the idea of prototype selection and sample reuse, and improves the training efficiency and generalization ability of the model by maintaining a prototype sample pool. During the model training process, these prototype samples can be used to guide model learning, reduce dependence on large-scale labeled data, and thus improve sample efficiency. At the same time, by dynamically updating and maintaining the prototype samples in the pool, the model's adaptability and generalization ability to new data can also be maintained. Transformer is a revolutionary deep learning model that is mainly used to handle sequence-to-sequence tasks such as machine translation and language modeling. Its core idea is the self-attention mechanism, which achieves the modeling of long-distance dependencies by simultaneously considering the information of each position in the input sequence.
[0006] When facing the problem of human activity recognition, the difficulty of existing deep learning-based methods lies in how to efficiently extract features and deal with the problem of inconsistent distribution between the training domain and the test domain. Existing solutions rarely consider the problem of model performance degradation caused by the difference in distribution between the training domain and the test domain. Secondly, for existing technologies, the complexity of Transformer-based models reaches O(L^2) when facing time series data. Effectively reducing complexity is a key challenge, especially when dealing with large-scale data and complex models. The Prototype Pool-based method can maintain the model's adaptability and generalization ability to new data by dynamically updating and maintaining the prototype samples in the pool. The improved Transformer model can achieve effective modeling of time series data while reducing complexity. Summary of the invention
[0007] The present invention aims at the efficient feature extraction in the above-mentioned prior art and faces the problem of inconsistent distribution between the training domain and the test domain. It proposes an efficient deep learning method for constructing prototype features for human activity recognition, and designs a deep learning model for human activity recognition using multivariate sensor data. The model first constructs two sets of one-dimensional matrices by calculating the distance between the QK feature and the mean feature, and uses the similarity of the two sets of mean features as weights, combines the two one-dimensional arrays to calculate the attention weight matrix, and then separates the attention information from the non-attention information through the attention matrix. Next, construct PrototypePool, create m trainable embedding vectors of size T*E for n categories respectively, obtain the n*1 weight control update strength through the gate network, and perform channel time series fusion of the obtained features with the non-attention features to obtain positive samples, and randomly select other category samples to form positive and negative sample pairs. Finally, the positive sample is fused with the attention feature, and the prediction result of each category is obtained through the classifier, while maximizing the value between the positive and negative sample pairs as the loss.
[0008] The inventive idea of the present invention is as follows: the present invention constructs a group of positive samples for each category of input by constructing a Prototype Pool, improves the training efficiency of the model by maintaining a prototype sample pool, dynamically updates and maintains the prototype samples in the pool, and can also maintain the adaptability and generalization ability of the model to new data; secondly, a low-complexity feature extractor based on Transformer is designed, and then two loss functions are designed. Maximizing the loss of positive and negative sample pairs can ensure the validity of positive samples, and the cross entropy loss completes the classification task, so as to enhance the generalization ability of the model, thereby realizing the recognition of human daily activities. Compared with some existing deep learning-based methods, the method of the present invention has higher recognition accuracy and robustness.
[0009] In order to achieve the above-mentioned invention object, the technical solution adopted by the present invention is as follows: an efficient deep learning method for constructing prototype features for human activity recognition comprises the following steps:
[0010] S1. Low-complexity self-attention feature extraction: Calculate the mean features of QK features in the time dimension respectively, measure the distance from the features of each time step to the mean features, and obtain two sets of one-dimensional matrix weights respectively. Calculate the attention weight matrix by the correlation of these two sets of one-dimensional matrices, reduce the complexity, separate the attention features, and divide them into non-attention features and attention features;
[0011] S2. Construct positive samples with prototype features: Initialize the embedding of n*m*L*E to construct the initial Prototype Pool, where n is the number of activity types, m is the number of positive samples of each category, L is the time series length, and E is the embedding dimension. The weight of each category is obtained through a gate network to alleviate the imbalance of training set categories, and non-linear information is added to the forward network layer. Then, the mean is taken on the second dimension, and the prototype samples of each category are the positive samples of each category. The non-attention features and the prototype samples of each category are concatenated into two-channel features. The channel and time series features are obtained through convolution and TCN networks to obtain the positive samples of the input samples. These positive samples will not overlap with the input samples because the key features are shielded;
[0012] S3, positive sample feature extraction and attention feature fusion: After the newly constructed prototype sample is fused with the non-attention feature, it is fused with the attention feature to ensure the integrity of the information. The QK matrix is obtained through encoding, and the operation of S1 is used to realize low-complexity self-attention feature extraction;
[0013] S4. Construction of prototype loss function: The loss function consists of two parts. In the first part, the constructed positive samples must form positive and negative sample pairs with randomly selected samples of other categories to maximize the loss of positive and negative sample pairs. The second part is the cross entropy loss after fusion feature classification. The design of the prototype loss function ensures the effectiveness of the constructed features and the accuracy of recognition.
[0014] Further, as a preferred technical solution of the present invention, the S1 specifically comprises the following steps:
[0015] Use the encoder layer to encode the QKV matrix and obtain the distance metric array between the QK matrix and the mean feature:
[0016] X=DataEmbedding(input) (1)
[0017] Q,K,V=Linear(X,X,X) (2)
[0018]
[0019] Among them, input is the initial input data, X is the embedded feature after DataEmbedding, Q, K, V represent the matrix after linear mapping, Q mean , K mean represents the mean characteristics of Q and K in the time dimension, and Distance represents the Euclidean distance metric function. represents the tth time step and Q mean The similarity of represents the tth time step and K mean Similarity, forming two 1D matrices;
[0020] Using Q 1D , K 1D , Q mean and K mean And recalculate the attention matrix and get the attention features and non-attention features:
[0021]
[0022] V unattn =(1-attn)*V (8)
[0023] V attn =attn*V (9)
[0024] Among them, attn ij represents the attention weight of the ijth position of the two-dimensional matrix, normalize is the normalization operation, Distance represents the Euclidean distance metric function, V represents the feature V value, V unattnrepresents the non-attention feature, V attn Indicates concern for features;
[0025] Further as a preferred technical solution of the present invention, S2 specifically includes the following steps:
[0026] Initialize a set of trainable embeddings to construct the Prototype Pool, which is used to describe the characteristics of the samples of the corresponding category without prior knowledge. Then, a gate network is used to obtain the weight of each category to alleviate the imbalance of the training set categories. Because the number of samples in each category is different, a set of weights is used to control their update strength, and then nonlinear information is added to the forward network layer:
[0027] Prototype=Embedding(n*m*T,embedding_dim=E) (10)
[0028] Prototype=Prototype.reshape(n,m,T,E) (11)
[0029] W=gate(Prototype.permute(3,1,2,0)) (12)
[0030] Prototype=Feedforward((w*Prototype).permute(3,1,2,0))(13)
[0031] Among them, Prototype represents the prototype features in the prototype pool, Embedding represents the operation of creating the initial vector, reshape is used to divide the dimension, gate represents the linear mapping to obtain the weights W of n categories, permute represents the rearrangement of the dimensions of the tensor in the specified order, and Feedforward represents the forward network layer composed of the linear layer and the activation function;
[0032] Take the mean of Prototype in the second dimension to obtain the prototype sample of each category, that is, the positive sample of each category, and concatenate the non-attention features and the prototype samples of each category into two-channel features:
[0033] Prototype=mean(Prototype,dim=1) (14)
[0034] Z=Concat(select(Prototype),V unattn ) (15)
[0035] Among them, mean represents the mean value in the second dimension, select represents the selection of V unattnFor prototype samples with consistent labels, Concat represents the concatenation operation in the channel dimension, and Z represents the features of the two channels;
[0036] Through convolution and TCN network, channel and time series features are obtained to obtain positive samples of input samples, and input samples of other categories are randomly selected as negative samples;
[0037] X pos =dropout(TCN(Conv(Z)),0.1) (16)
[0038] X neg =random_select(input,i,j) (17)
[0039] Among them, Conv represents the convolution operation to obtain channel information, TCN represents the hole convolution operation to obtain timing information, dropout represents the discard operation to prevent overfitting, random_select represents the random selection of the jth sample of the i-th category as a negative sample, and X pos and X neg constitute a positive and negative sample pair.
[0040] Further, as a preferred technical solution of the present invention, S3 specifically includes the following steps:
[0041] After the newly constructed prototype sample is fused with the non-attention feature, it is fused with the attention feature:
[0042] Z = Concat(X pos ,V attn ) (18)
[0043] X out =dropout(TCN(Conv(Z)),0.1) (19)
[0044] Among them, X out Represents the fused features; Concat represents the concatenation operation in the channel dimension;
[0045] Get the QK matrix through encoding, use the S1 operation, and implement the classification task:
[0046] Q out , K out V out =Linear(X out , X out , X out ) (20)
[0047]
[0048] Vout =attn out *V out (26)
[0049] Y i =FC(Reshape(Conv(V out ))) (27)
[0050] Among them, formulas 20 to 26 represent the low-complexity attention feature extraction process. Similar to the process of S1, FC represents the multi-layer fully connected layer as a classifier; Y i Represents the result of predicting the activity category.
[0051] Further, as a preferred technical solution of the present invention, the S4 specifically includes the following steps:
[0052] First, for the constructed positive samples, they are paired with randomly selected samples of other categories to maximize the loss between these positive and negative sample pairs; second, the cross entropy loss after the fusion features are used for classification:
[0053] loss1=max(Loss(X_pos,X_neg)) (28)
[0054]
[0055] Among them, a i is a hyperparameter; CrossEntropyLoss represents the cross entropy loss function; Y true represents the true label; Y i is the predicted label.
[0056] Compared with the prior art, the present invention has the following beneficial effects:
[0057] (1) The present invention constructs Prototype Pool technology, maintains a prototype sample pool, obtains feature information of samples of various categories without prior knowledge, and constructs positive samples in combination with partial information of input features. These prototype samples are used to guide model learning, thereby improving efficiency and maintaining the model's adaptability and generalization capabilities to new data.
[0058] (2) The present invention designs a low-complexity feature extractor based on Transformer. Two sets of one-dimensional matrices are constructed by calculating the distance between the QK feature and the mean feature, and the similarity of the two sets of mean features is used as the weight. The two-dimensional attention matrix value is determined by two one-dimensional arrays, reducing the original O(L^2) complexity to O(L).
[0059] (3) The present invention designs a combination of two sets of loss functions. The max(Loss(X_pos,X_neg)) function ensures the validity of the constructed positive samples and will not allow the features of the positive samples to shift to other categories. It can also ensure that the positive samples are as close to the decision boundary as possible. Such samples can help the model improve its robustness. At the same time, the cross entropy loss function ensures the completion of the classification task. These two loss functions ensure the accuracy and transferability of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 An overall flow chart of the efficient deep learning method for constructing prototype features for human activity recognition provided by the present invention.
[0061] Figure 2 It is a schematic diagram comparing the test results of the model of the present invention and other methods.
[0062] Figure 3 Schematic diagram of multiple rounds of training comparison between the present invention and existing deep learning solutions.
[0063] Figure 4 This is a schematic diagram of the classification confusion matrix after testing on the UCIHAR dataset in the present invention.
[0064] Figure 5 This is a schematic diagram of the classification confusion matrix after testing on the pamap2 dataset in the present invention. DETAILED DESCRIPTION
[0065] The present invention is further explained below in detail with reference to the accompanying drawings so that those skilled in the art can more deeply understand the present invention and be able to implement it. However, the following reference examples are only used to explain the present invention and are not intended to limit the present invention.
[0066] Example 1
[0067] See also Figures 1 to 5 In this embodiment, an efficient deep learning method for constructing prototype features for human activity recognition 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 3050Ti GPU. During the experiment, the model is trained and evaluated on UCIHAR and pamap2 public datasets. This dataset is used for comparison with other methods.
[0068] An efficient deep learning method for constructing prototype features for human activity recognition includes the following steps:
[0069] S1. Low-complexity self-attention feature extraction: Calculate the mean features of QK features in the time dimension respectively, measure the distance from the features of each time step to the mean features, and obtain two sets of one-dimensional matrix weights respectively. Calculate the attention weight matrix by the correlation of these two sets of one-dimensional matrices, reduce the complexity, separate the attention features, and divide them into non-attention features and attention features;
[0070] S2. Construct positive samples with prototype features: Initialize the embedding of n*m*L*E to construct the initial Prototype Pool, where n is the number of activity types, m is the number of positive samples of each category, L is the time series length, and E is the embedding dimension. The weight of each category is obtained through a gate network to alleviate the imbalance of training set categories, and non-linear information is added to the forward network layer. Then, the mean is taken on the second dimension, and the prototype samples of each category are the positive samples of each category. The non-attention features and the prototype samples of each category are concatenated into two-channel features. The channel and time series features are obtained through convolution and TCN networks to obtain the positive samples of the input samples. These positive samples will not overlap with the input samples because the key features are shielded;
[0071] S3, positive sample feature extraction and attention feature fusion: After the newly constructed prototype sample is fused with the non-attention feature, it is fused with the attention feature to ensure the integrity of the information. The QK matrix is obtained through encoding, and the operation of S1 is used to realize low-complexity self-attention feature extraction;
[0072] S4. Construction of prototype loss function: The loss function consists of two parts. In the first part, the constructed positive samples must form positive and negative sample pairs with randomly selected samples of other categories to maximize the loss of positive and negative sample pairs. The second part is the cross entropy loss after fusion feature classification. The design of the prototype loss function ensures the effectiveness of the constructed features and the accuracy of recognition.
[0073] S1 specifically includes the following steps:
[0074] Use the encoder layer to encode the QKV matrix and obtain the distance metric array between the QK matrix and the mean feature:
[0075] X=DataEmbedding(input) (1)
[0076] Q,K,V=Linear(X,X,X) (2)
[0077]
[0078] Among them, input is the initial input data, X is the embedded feature after DataEmbedding, Q, K, V represent the matrix after linear mapping, Q mean , K meanrepresents the mean characteristics of Q and K in the time dimension, and Distance represents the Euclidean distance metric function. represents the tth time step and Q mean The similarity of represents the tth time step and K mean Similarity, forming two 1D matrices;
[0079] Using Q 1D , K 1D , Q mean and K mean And recalculate the attention matrix and get the attention features and non-attention features:
[0080]
[0081] V unattn =(1-attn)*V (8)
[0082] V attn =attn*V (9)
[0083] Among them, attn ij represents the attention weight of the ijth position of the two-dimensional matrix, normalize is the normalization operation, Distance represents the Euclidean distance metric function, V represents the feature V value, V unattn represents the non-attention feature, V attn Indicates concern for features;
[0084] S2 specifically includes the following steps:
[0085] Initialize a set of trainable embeddings to construct the Prototype Pool, which is used to describe the characteristics of the samples of the corresponding category without prior knowledge. Then, a gate network is used to obtain the weight of each category to alleviate the imbalance of the training set categories. Because the number of samples in each category is different, a set of weights is used to control their update strength, and then nonlinear information is added to the forward network layer:
[0086] Prototype=Embedding(n*m*T,embedding_dim=E) (10)
[0087] Prototype=Prototype.reshape(n,m,T,E) (11)
[0088] W=gate(Prototype.permute(3,1,2,0)) (12)
[0089] Prototype=Feedforward((w*Prototype).permute(3,1,2,0))(13)
[0090] Among them, Prototype represents the prototype features in the prototype pool, Embedding represents the operation of creating the initial vector, reshape is used to divide the dimension, gate represents the linear mapping to obtain the weights W of n categories, permute represents the rearrangement of the dimensions of the tensor in the specified order, and Feedforward represents the forward network layer composed of the linear layer and the activation function;
[0091] Take the mean of Prototype in the second dimension to obtain the prototype sample of each category, that is, the positive sample of each category, and concatenate the non-attention features and the prototype samples of each category into two-channel features:
[0092] Prototype=mean(Prototype,dim=1) (14)
[0093] Z=Concat(select(Prototype),V unattn ) (15)
[0094] Among them, mean represents the mean value in the second dimension, select represents the selection of V unattn For prototype samples with consistent labels, Concat represents the concatenation operation in the channel dimension, and Z represents the features of the two channels;
[0095] Through convolution and TCN network, channel and time series features are obtained to obtain positive samples of input samples, and input samples of other categories are randomly selected as negative samples;
[0096] X pos =dropout(TCN(Conv(Z)),0.1) (16)
[0097] X neg =random_select(input,i,j) (17)
[0098] Among them, Conv represents the convolution operation to obtain channel information, TCN represents the hole convolution operation to obtain timing information, dropout represents the discard operation to prevent overfitting, random_select represents the random selection of the jth sample of the i-th category as a negative sample, and X pos and X neg constitute a positive and negative sample pair.
[0099] S3 specifically includes the following steps:
[0100] After the newly constructed prototype sample is fused with the non-attention feature, it is fused with the attention feature:
[0101] Z = Concat(X pos ,V attn ) (18)
[0102] X out =dropout(TCN(Conv(Z)),0.1) (19)
[0103] Among them, X out Represents the fused features; Concat represents the concatenation operation in the channel dimension;
[0104] Get the QK matrix through encoding, use the S1 operation, and implement the classification task:
[0105] Q out ,K out ,V out =Linear(X out ,X out ,X out ) (20)
[0106]
[0107] V out =attn out *V out (26)
[0108] Y i =FC(Reshape(Conv(V out ))) (27)
[0109] Among them, formulas 20 to 26 represent the low-complexity attention feature extraction process. Similar to the process of S1, FC represents the multi-layer fully connected layer as a classifier; Y i Represents the result of predicting the activity category.
[0110] S4 specifically includes the following steps:
[0111] First, for the constructed positive samples, they are paired with randomly selected samples of other categories to maximize the loss between these positive and negative sample pairs; second, the cross entropy loss after the fusion features are used for classification:
[0112] loss1=max(Loss(X_pos,X_neg)) (28)
[0113]
[0114] Among them, a iis a hyperparameter; CrossEntropyLoss represents the cross entropy loss function; Y true represents the true label; Y i is the predicted label.
[0115] Comparative experiment:
[0116] UCIHAR dataset. It was collected and released by researchers at the University of California, Irvine. The dataset was prepared using waist-worn (Samsung Galaxy SII) smartphones worn by 30 volunteers aged between 19 and 48 years old. Each person performed six activities. The three-axis acceleration and three-axis angular velocity were recorded at a constant rate of 50Hz using the smartphone's built-in gyroscope and accelerometer. The data was manually labeled and then randomly divided into training and testing datasets.
[0117] We selected the models that also used this dataset for recognition accuracy comparison, namely, TCN model, Crossformer model, NeuralCDE model, and LSTM model. Figure 2 It can be seen that this embodiment has the best recognition accuracy. Figure 3 It can be seen that the training method of this embodiment is better.
[0118] Example 2
[0119] Based on Example 1, the same operation steps are implemented to test the pamap2 dataset of Example 2, which contains data of 9 participants performing 12 different activities. They each wear an inertial measurement unit (IMU) on their chest, ankle, and hand. In addition, all collected data are recorded at a frequency of 100 Hz. We use 80% of the dataset for training and validation, and the rest for testing.
[0120] This embodiment provides an efficient deep learning method for constructing prototype features for human activity recognition, including the following steps: low-complexity self-attention feature extraction, prototype feature construction of positive samples close to the decision boundary to improve generalization ability, and construction of a prototype loss function to ensure the effectiveness of positive samples and classification accuracy. The beneficial effects of this embodiment are: this embodiment constructs two sets of one-dimensional matrices by calculating the distance between the QK feature and the mean feature, reducing the original O(L^2) to O(L) complexity; secondly, by maintaining a prototype sample pool, the feature information of samples of each category without prior knowledge is obtained, and positive and negative sample pairs are created; then, the positive and negative sample loss and the cross entropy loss ensure the accuracy and robustness of the model; finally, through experiments, it is verified that the method of this embodiment has better recognition accuracy than some existing deep learning methods.
[0121] The specific implementation scheme described above further describes in detail the purpose, technical scheme and beneficial effects of the present invention. It should be understood that the above is only a specific implementation scheme of the present invention and is not intended to limit the scope of the present invention. Any equivalent changes and modifications made by any technician in the field without departing from the concept and principle of the present invention should fall within the scope of protection of the present invention.
Claims
1. An efficient deep learning method for constructing prototype features for human activity recognition, characterized in that: The following steps are involved: S1. Low-complexity self-attention feature extraction: Calculate the mean features of QK features in the time dimension respectively, measure the distance from the features of each time step to the mean features, and obtain two sets of one-dimensional matrix weights respectively. Calculate the attention weight matrix by the correlation of these two sets of one-dimensional matrices, reduce the complexity, separate the attention features, and divide them into non-attention features and attention features; S2. Construct positive samples with prototype features: Initialize the embedding of n*m*L*E to construct the initial Prototype Pool, where n is the number of activity types, m is the number of positive samples of each category, L is the time series length, and E is the embedding dimension. A gate network is used to obtain the weight of each category to alleviate the imbalance of the training set categories. Non-linear information is added to the forward network layer, and then the mean is taken on the second dimension. The prototype samples of each category, that is, the positive samples of each category, concatenate the non-attention features and the prototype samples of each category into two-channel features, obtain the channel and time series features through convolution and TCN networks, and obtain the positive samples of the input samples. These positive samples will not overlap with the input samples because the key features are shielded; S3, positive sample feature extraction and attention feature fusion: After the newly constructed prototype sample is fused with the non-attention feature, it is fused with the attention feature to ensure the integrity of the information. The QK matrix is obtained through encoding, and the operation of S1 is used to realize low-complexity self-attention feature extraction; S4. Construction of prototype loss function: The loss function consists of two parts. In the first part, the constructed positive samples must form positive and negative sample pairs with randomly selected samples of other categories to maximize the loss of positive and negative sample pairs. The second part is the cross entropy loss after fusion feature classification. The design of the prototype loss function ensures the effectiveness of the constructed features and the accuracy of recognition.
2. The efficient deep learning method for human activity recognition based on prototype features according to claim 1 is characterized in that: The S1 specifically includes the following steps: S11. Use the encoder layer to encode the QKV matrix and obtain the distance metric array between the QK matrix and the mean feature: X=DataEmbedding(input) (1) Q, K, V = Linear (X, X, X) (2) Among them, input is the initial input data, X is the embedded feature after DataEmbedding, Q, K, V represent the matrix after linear mapping, Q mean , K mean represents the mean characteristics of Q and K in the time dimension, and Distance represents the Euclidean distance metric function. represents the tth time step and Q mean The similarity of represents the tth time step and K mean Similarity, forming two 1D matrices; S12. Using Q 1D , K 1D , Q mean and K mean And recalculate the attention matrix and get the attention features and non-attention features: V unattn =(1-attn)*V (8) V attn =attn*V (9) Among them, attn ij represents the attention weight of the ijth position of the two-dimensional matrix, normalize is the normalization operation, Distance represents the Euclidean distance metric function, V represents the feature V value, V unattn represents the non-attention feature, V attn Indicates a characteristic of interest.
3. The efficient deep learning method for human activity recognition based on prototype features according to claim 2 is characterized in that: The S2 specifically includes the following steps: S21. Initialize a set of trainable embeddings to construct the Prototype Pool, which is used to describe the characteristics of the samples of the corresponding category without prior knowledge. Then, a gate network is used to obtain the weight of each category to alleviate the imbalance of the training set categories. Because the number of samples in each category is different, a set of weights is used to control their update strength, and then nonlinear information is added to the forward network layer: Prototype=Embedding(n*m*T, embedding_dim=E) (10) Prototype=Prototype.reshape(n, m, T, E) (11) W=gate(Prototype.permute(3,1,2,0)) (12) Prototype=Feedforward((w*Prototype).permute(3, 1, 2, 0)) (13) Among them, Prototype represents the prototype features in the prototype pool, Embedding represents the operation of creating the initial vector, reshape is used to divide the dimension, gate represents the linear mapping to obtain the weights W of n categories, permute represents the rearrangement of the dimensions of the tensor in the specified order, and Feedforward represents the forward network layer composed of the linear layer and the activation function; S22. Take the mean of Prototype in the second dimension to obtain the prototype sample of each category, that is, the positive sample of each category, and concatenate the non-attention features and the prototype samples of each category into two-channel features: Prototype=mean(Prototype, dim=1) (14) Z=Concat(select(Prototype),V unattn ) (15) Among them, mean represents the mean value in the second dimension, select represents the selection of V unattn For prototype samples with consistent labels, Concat represents the concatenation operation in the channel dimension, and Z represents the features of the two channels; S23, obtain channel and time series features through convolution and TCN network, obtain positive samples of input samples, and randomly select input samples of other categories as negative samples; X pos =dropout(TCN(Conv(Z)),0.1) (16) X neg =random_select(input,i,j) (17) Among them, Conv represents the convolution operation to obtain channel information, TCN represents the hole convolution operation to obtain timing information, dropout represents the discard operation to prevent overfitting, random_select represents the random selection of the jth sample of the i-th category as a negative sample, and X pos and X neg constitute a positive and negative sample pair.
4. The efficient deep learning method for human activity recognition based on prototype features according to claim 3 is characterized in that: The S3 specifically includes the following steps: S31. After the newly constructed prototype sample is fused with the non-attention feature, it is fused with the attention feature again: Z=Concat(X pos ,V attn ) (18) X out =dropout(TCN(Conv(Z)),0.1) (19) Among them, X out Represents the fused features; Concat represents the concatenation operation in the channel dimension; S32, get the QK matrix through encode, use the operation of S1, and implement the classification task: Q out ,K out ,V out =Linear(X out ,X out ,X out ) (20) V out =attn out *V out (26) Y i =FC(Reshape(Conv(V out ))) (27) Among them, formulas 20 to 26 represent the low-complexity attention feature extraction process. Similar to the process of S1, FC represents multiple layers of fully connected layers as classifiers; Yi represents the result of predicting the activity category.
5. The efficient deep learning method for human activity recognition based on prototype features according to claim 4 is characterized in that: The S4 specifically comprises the following steps: First, for the constructed positive samples, they are paired with randomly selected samples of other categories to maximize the loss between these positive and negative sample pairs; second, the cross entropy loss after the fusion features are used for classification: loss1=max(Loss(X_pos,X_neg)) (28) Among them, a i is a hyperparameter; CrossEntropyLoss represents the cross entropy loss function; Y true represents the true label; Y i is the predicted label.
Citation Information
Cited By
Model generation method, reasoning method, related device, equipment, medium and product
CN119740609A
