An electrocardiosignal open set identity recognition method based on a hybrid network and a cross attention mechanism
By combining hybrid networks with cross-attention mechanisms, multi-scale local spatial information and long-term time-series dependencies of electrocardiogram (ECG) signals are extracted, solving the problem of accurate classification in open-set environments for ECG identity recognition systems and achieving high-precision identity recognition.
Patent Information
- Application Number
- CN202411219596.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2044-09-02
AI Technical Summary
Existing ECG identification systems are mainly designed for closed-set identification, making it difficult to accurately distinguish known identities from unknown identities in open-set environments. Furthermore, feature extraction methods are limited to local spatial information or long-term time series dependencies, failing to fully extract effective information from the signal.
By employing a hybrid network and cross-attention mechanism, multi-scale convolutional feature extraction channels and Transformer-encoded feature extraction channels are constructed to extract local spatial information and long-term time-series dependencies of electrocardiogram signals. The cross-attention mechanism is then used to fuse feature representations, and combined with an Openmax classification layer, identity recognition in an open-set environment is achieved.
It improves the accuracy and robustness of ECG identity recognition, enabling accurate classification of known identities and rejection of unknown identities in open-set environments, thus meeting practical application needs.
Smart Images

Figure CN119128684B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of identity recognition technology, specifically to a method for open-set identity recognition of electrocardiogram signals based on hybrid networks and cross-attention mechanisms. Background Technology
[0002] Electrocardiogram (ECG), as a biometric identification technology, has attracted widespread attention in the field of identity verification in recent years. Compared with traditional biometrics such as face, fingerprint, iris, and voiceprint, ECG signals not only meet the essential characteristics of biometrics, such as universality, uniqueness, stability, and ease of acquisition, but also offer high security. As an internal physiological signal, ECG signal acquisition requires specific equipment and technology, and its inherent liveness detection characteristics make it difficult to forge or copy. This gives ECG-based identity verification a potential advantage in applications with high security requirements.
[0003] ECG identification, as a typical classification problem, can be divided into closed-set identification and open-set identification. In closed-set identification, it is typically assumed that the test sample must belong to a known identity category in the training set. However, in practical applications, there is a possibility that the test sample comes from an unknown identity category, making the closed-set assumption insufficient. Therefore, open-set identification is introduced. Compared to closed-set identification, open-set identification not only needs to correctly distinguish known identities but also needs to reject unknown identities, thus better meeting the requirements of practical applications. Most existing ECG identification systems are designed for closed-set identification, which to some extent limits their universality and robustness in practical applications.
[0004] Furthermore, the core technology of ECG-based identity recognition lies in feature extraction algorithms. Traditional methods primarily rely on the time, frequency, and statistical domain features of ECG signals to provide effective evidence for identity recognition. However, this method usually requires manual feature design, which is not only time-consuming and labor-intensive but may also overlook potential individual differences in ECG signals. In contrast, deep learning-based feature extraction methods can automatically fit the training data distribution through multi-layer linear and non-linear transformations, thereby extracting more discriminative features. This method avoids the limitations of manual feature extraction and improves the efficiency and accuracy of feature extraction. Nevertheless, existing neural network methods still have some limitations. For example, convolutional neural networks mainly explore the relationship between local spatial information and identity labels, while recurrent neural networks focus on capturing the long-term temporal dependencies of ECG signals. This means that these methods may only utilize some characteristic information in ECG signals, failing to fully and comprehensively mine the effective information of the signal.
[0005] In summary, this invention addresses the shortcomings of existing ECG identity recognition systems, such as closed-set recognition and limitations in feature information extraction. It proposes an open-set identity recognition method for ECG signals based on a hybrid network and cross-attention mechanism. This method aims to comprehensively extract and integrate the local spatial information and long-term time-series dependencies of ECG signals, and to achieve high-precision ECG identity recognition that better meets the needs of practical applications in open-set recognition scenarios. Summary of the Invention
[0006] The purpose of this invention is to address the shortcomings of existing technologies by proposing an open-set recognition method for electrocardiogram (ECG) signals based on a hybrid network and a cross-attention mechanism. The method extracts local spatial information and long-term temporal dependencies from ECG signals using a hybrid network, and fuses two different feature representations using a cross-attention mechanism. This removes redundancy while fully preserving the individual's unique identification information. Furthermore, by constructing an Openmax classification layer, it achieves identity recognition in an open-set environment, enabling accurate classification of signals from known individuals while rejecting unknown or unfamiliar identities.
[0007] To achieve the above objectives, this method provides the following technical solution:
[0008] 1. The technical solution of the present invention includes a method for open-set identity recognition of electrocardiogram signals based on hybrid networks and cross-attention mechanisms, the method comprising the following steps:
[0009] S1: Preprocess the electrocardiogram signal to obtain a standardized two-dimensional heartbeat image input;
[0010] S2: Construct a hybrid network model to extract multi-scale local spatial information and long-term time-series dependencies. The input of the hybrid network model is the standardized two-dimensional heartbeat image, and the output is the multi-scale local spatial information feature representation and the long-term time-series dependency feature representation of the standardized heartbeat image.
[0011] S3: Utilize a cross-attention mechanism to fuse different types of information. The input to the cross-attention mechanism is the output of the hybrid network model, and the output is a fused representation of the multi-scale local spatial information features and the global long-term dependency features;
[0012] S4: Establish an Openmax classification layer to achieve identity label recognition in an open-set environment. The input of the Openmax classification model is the output of the cross-attention mechanism, and the output is the identity recognition result.
[0013] The step in S1 to preprocess the electrocardiogram signal to obtain a standardized heartbeat image input includes:
[0014] S11: The input ECG signal is processed using a high-pass filter with a cutoff frequency of 0.5Hz, a low-pass filter with a cutoff frequency of 100Hz, and a band-stop filter with a notch frequency range of 49.5Hz to 50.5Hz to obtain a clean ECG signal.
[0015] S12: Use the Pan-Tompkins algorithm to locate the R and T wave apexes of the clean ECG signal to obtain the reference point R and T wave apex positions;
[0016] S13: Based on the localization results, take the R wave vertex as the center, the adjacent T wave vertex before the R wave vertex as the starting point, and the adjacent T wave vertex after the R wave vertex as the ending point to segment the clean ECG signal and obtain the heartbeat segmentation segment.
[0017] S14: The obtained heartbeat segmentation is standardized by using the min-max normalization method to obtain a standardized heartbeat segment.
[0018] S15: Use the Python matplotlib toolkit to plot the standardized heartbeat fragments as an RGB two-dimensional image with a size of 224*224*3, store the RGB two-dimensional image data, and use it as network input.
[0019] 2. The ECG signal open-set identity recognition method based on hybrid networks and cross-attention mechanism comprises a hybrid network feature extraction module, a cross-attention mechanism module, and an Openmax classification layer. The hybrid network feature extraction module, the cross-attention mechanism module, and the Openmax classification layer are connected sequentially.
[0020] The hybrid network feature extraction module includes two channels: a multi-scale convolutional feature extraction channel and a Transformer coding feature extraction channel. The multi-scale convolutional feature extraction channel and the Transformer coding feature extraction channel are connected in parallel. The input for both is a 224*224*3 RGB two-dimensional image, and the output for both is a 1*768 feature vector.
[0021] 3. According to the ECG signal open set identity recognition method based on hybrid network and cross-attention mechanism, the multi-scale convolutional feature extraction channel includes a 1*1 convolutional layer, a first multi-scale convolutional feature extraction layer, a second multi-scale convolutional feature extraction layer, a third multi-scale convolutional feature extraction layer, a fourth multi-scale convolutional feature extraction layer, a fifth multi-scale convolutional feature extraction layer, and a fully connected layer.
[0022] The 1*1 convolutional layer, the first multi-scale convolutional feature extraction layer, the second multi-scale convolutional feature extraction layer, the third multi-scale convolutional feature extraction layer, the fourth multi-scale convolutional feature extraction layer, the fifth multi-scale convolutional feature extraction layer, and the fully connected layer are connected in sequence.
[0023] The 1*1 convolutional layer has a kernel size of 1*1 and a stride of 1. It uses the ReLU activation function and employs 4 convolutional kernels for the convolution operation.
[0024] 4. According to the ECG signal open set identity recognition method based on hybrid network and cross-attention mechanism, the first multi-scale convolutional feature extraction layer, the second multi-scale convolutional feature extraction layer, the third multi-scale convolutional feature extraction layer, the fourth multi-scale convolutional feature extraction layer and the fifth multi-scale convolutional feature extraction layer each contain two parts: a multi-scale convolution module and a pooling module.
[0025] The multi-scale convolution module includes four branches, namely the first branch, the second branch, the third branch, and the fourth branch:
[0026] The first branch is a residual connection;
[0027] The second branch is a 3*3 convolution kernel with a stride of 1, using the ReLU activation function, and the padding is set to "same";
[0028] The third branch is a 5*5 convolution kernel with a stride of 1, using the ReLU activation function, and the padding is set to "same";
[0029] The third branch is a 7*7 convolution kernel with a stride of 1, using the ReLU activation function, and the padding is set to "same";
[0030] In the first multi-scale convolution feature extraction layer, each convolution operation of the multi-scale convolution module uses 4 convolution kernels;
[0031] In the second multi-scale convolutional feature extraction layer, each convolutional operation of the multi-scale convolutional module uses 16 convolutional kernels;
[0032] In the third multi-scale convolutional feature extraction layer, each convolutional operation of the multi-scale convolutional module uses 32 convolutional kernels.
[0033] In the fourth multi-scale convolutional feature extraction layer, each convolutional operation of the multi-scale convolutional module uses 64 convolutional kernels.
[0034] In the fifth multi-scale convolutional feature extraction layer, each convolutional operation of the multi-scale convolutional module uses 128 convolutional kernels.
[0035] All pooling modules use max pooling, with a pooling layer size of 2*2 and a step size of 2.
[0036] 5. According to the ECG signal open-set identity recognition method based on hybrid networks and cross-attention mechanism, the fully connected layer is used to expand and map the output of the fifth multi-scale convolutional feature extraction layer into a 1*768 feature vector, using the ReLU activation function. The input of the fully connected layer is the expanded feature vector output of the fifth multi-scale convolutional feature extraction layer, and the output is a 1*768 feature vector. The dimension of the output feature vector is the same as the dimension of the output feature vector of the Transformer encoded feature extraction channel.
[0037] 6. According to the ECG signal open set identity recognition method based on hybrid network and cross-attention mechanism, the Transformer encoded feature extraction channel contains 5 stacked Transformer encoders.
[0038] Step 2 describes constructing a hybrid network model to extract long-term dependencies in time series data. This is accomplished by using Transformer encoding to extract feature channels. The input is a 224*224*3 RGB two-dimensional heart rate image. The feature extraction process includes the following steps:
[0039] S21: Use a convolution operation with a size of 16*16, a stride of 16, and a number of channels of 768 to perform a linear projection on the two-dimensional heart image. After linear projection, the dimension is 196*768, that is, after projection, 196 vector sequences are obtained, and each sequence has a dimension of 768.
[0040] S22: Add a classification label with a dimension of 1*768 to the front of the vector sequence, and after concatenating it with the 196*768 vector sequence, the dimension is 197*768;
[0041] S23: Use the cosine function to generate position codes, superimpose them onto the vector sequence with a dimension of 197*768, and use the result as the input of the Transformer encoder;
[0042] S24: The 5 stacked Transformer encoders are used to extract features from the input 197*768 vector sequence. Each Transformer encoder contains a multi-head attention module and a multilayer perceptron module. The multi-head attention module has 8 attention heads, and the multilayer perceptron contains two fully connected layers with a node count of 768->3072->768.
[0043] S25: Finally, the classification label obtained after mapping is used as the feature extracted by the Transformer encoding feature extraction channel, with a dimension of 1*768, which is the same as the output feature dimension of the multi-scale convolution feature extraction channel.
[0044] 7. According to the ECG signal open set identity recognition method based on hybrid network and cross-attention mechanism, the input of the cross-attention mechanism module is the 1*768 feature vector extracted by the multi-scale convolutional feature extraction channel and the Transformer coding feature extraction channel, denoted as X, respectively. Conv X Trans .
[0045] Step 3, which utilizes the cross-attention mechanism to fuse different types of information, includes the following steps:
[0046] S31: Generate X through linear transformation Conv X Trans The corresponding queries, keys, and values. During the linear transformation process, the linear transformation matrices corresponding to the queries, keys, and values are denoted as W, respectively. Q W K W V The linear transformation matrix is learned by the backpropagation algorithm. Conv The corresponding query, key, and value are Q. Conv K Conv V Conv X Trans The corresponding query, key, and value are Q. Trans K Trans V Trans ;
[0047] S32: Calculate the attention score X based on the query, key, and value. Conv X Trans The corresponding attention score is:
[0048]
[0049] Where Softmax(·) is the Softmax function. After mapping using the Softmax function, the Attention1 value is X. Conv Corresponding attention score, After mapping using the Softmax function, the Attention2 value is X. Trans Corresponding attention score.
[0050] S33: Calculate the fused feature vector based on the attention score:
[0051] X Fuse =Attention1*V Conv +Attention2* VTrans
[0052] Where X Fuse The fused feature vector is denoted as .
[0053] 8. According to the ECG signal open set identity recognition method based on hybrid network and cross-attention mechanism, the Openmax classification layer is a three-layer fully connected network, consisting of an input layer, a hidden layer, and an output layer. The input layer is the output of the cross-attention mechanism module and contains 768 nodes. The hidden layer contains 384 nodes. The number of nodes in the output layer is related to the number of individual categories for identity recognition. If the number of individual categories for identity recognition is N... Total Then the number of output layer nodes is N. Total Step 4, establishing the Openmax classification layer to achieve identity tag recognition in an open set environment, includes the following steps:
[0054] S41: Training of the Openmax classification layer:
[0055] S42: Open set recognition of the Openmax classification layer.
[0056] 9. According to the ECG signal open set identity recognition method based on hybrid network and cross-attention mechanism, the Openmax classification layer training in step 41 includes the following steps:
[0057] S411: Network Weight and Bias Optimization: Following the ten-fold cross-validation method, the dataset is divided into a training set and a test set, with the training set comprising nine parts and the test set comprising one part. The backpropagation algorithm is used to optimize the parameters of the entire network, obtaining the weights and biases of the Openmax classification layer. During the optimization process, the number of output nodes is N. Total At this point, the network is a closed-set recognition system, which only targets samples of individuals with known identities within the training set. The Openmax classification layer is equivalent to the Softmax classifier.
[0058] S412: Weibull distribution parameter fitting: After training, for the training set samples, take the Openmax classification layer hidden layer output set S corresponding to the correctly classified training set data, and divide the obtained hidden layer output set S into N according to the category. Total There are S data subsets, each subset denoted as S. j For each subset S j Take the average value to get N. Total MAV of activation vectors j The activation vector expression is calculated as follows:
[0059]
[0060] Where, N j S is the number of samples in category j. ij Let S be the i-th sample within the subset of data corresponding to category j. Calculate the sample S within each subset. ijTo their respective corresponding activation vectors MAV j The Euclidean distances for each subset are used to fit the Weibull distributions to the corresponding Euclidean distance sets using the built-in Matlab function wblfit, yielding the scale parameters τ of the j Weibull distributions. j Shape parameter λ j With position parameter κ j .
[0061] The network weights, biases, and Weibull distribution parameters included in the Openmax classification layer together constitute the model parameters of the Openmax classification layer.
[0062] 10. According to the ECG signal open set identity recognition method based on hybrid network and cross-attention mechanism, the Openmax classification open set recognition in step S42 includes the following steps:
[0063] S421: Output Score Correction: For each test sample, the output score S of the sample in the hidden layer of the Openmax classification layer is obtained through network mapping. Sample The output score v of the output layer Sample Arrange v in descending order Sample Sort the scores by internal parameters, and denote the sorted sequence as follows: For v Sample The correction formula for the i-th score value in the probability sequence is as follows:
[0064]
[0065] Where, ω i To adjust the weights, the calculation formula is as follows:
[0066]
[0067] Where dis(·) is the Euclidean distance, and MAV is... i τ is the activation vector corresponding to category i. i , λ i With κ i The Weibull distribution parameters corresponding to category i.
[0068] S422: Pseudo-score assignment for the unfamiliar / unknown category: Assign label 0 to the unfamiliar / unknown identity. The pseudo-score for label 0 is as follows:
[0069]
[0070] S423: Calculation of classification probability under open set conditions: using the Softmax function to analyze sequences After normalization, under the condition of open set recognition, the test sample can be classified into categories 0 to N. Total probability sequence
[0071] S424: Open set identification: Take the maximum value p in the probability sequence max If the maximum value p max p0 or p max If the value is less than the preset threshold ε, it is judged as an unfamiliar or unknown identity and identification is rejected; if the maximum value p max Not p0 and p max If the value is greater than the preset threshold ε, it is determined to be a known identity, and the category label corresponding to the maximum value is assigned to the test sample.
[0072] The beneficial effects of this invention are as follows: It constructs a dual-channel feature extraction hybrid network containing multi-scale convolutional feature extraction channels and Transformer coding feature extraction channels, which can simultaneously extract multi-scale local spatial representations and obtain long-term dependency feature representations of ECG sequences, fully and comprehensively mining information related to identity recognition in ECG signals; it establishes a cross-attention mechanism module, which enhances the model's perception of key features, improves the discriminative power of feature representations, and increases recognition accuracy by effectively fusing features from the two channels; and it utilizes an Openmax classification layer to assign pseudo-scores to unfamiliar and unknown identity labels based on the output of the Softmax classifier through output score correction, obtaining the classification probability of samples in an open-set environment, thus achieving open-set recognition and making the recognition results more in line with the needs of practical application environments. Attached Figure Description
[0073] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0074] Figure 1 The diagram shows a flowchart of an open set ECG identity recognition method based on a hybrid network and cross-attention mechanism according to an embodiment of the present invention.
[0075] Figure 2 The diagram shown is a preprocessing flowchart according to an embodiment of the present invention;
[0076] Figure 3 The diagram shown is a structural diagram of an open set ECG identity recognition method based on a hybrid network and cross-attention mechanism according to an embodiment of the present invention.
[0077] Figure 4 The diagram shown is a structural diagram of a hybrid network feature extraction module according to an embodiment of the present invention.
[0078] Figure 5 The diagram shown is a multi-scale convolutional feature extraction layer structure according to an embodiment of the present invention.
[0079] Figure 6 The diagram shown is a flowchart of channel feature extraction for Transformer encoding according to an embodiment of the present invention.
[0080] Figure 7 The diagram shown is a structural diagram of the cross-attention mechanism module according to an embodiment of the present invention.
[0081] Figure 8 The diagram shown is a flowchart of obtaining the Weibull distribution parameters of the Openmax classification layer according to an embodiment of the present invention.
[0082] Figure 9 The diagram shown is a flowchart of the Openmax classification layer open set recognition according to an embodiment of the present invention.
[0083] Figure 10 The diagram shown is a flowchart for determining the open set identity recognition result of electrocardiogram according to an embodiment of the present invention. Detailed Implementation
[0084] This section will describe specific embodiments of the present invention in detail with reference to the accompanying drawings. It should be noted that the description of these embodiments is intended to aid in understanding the present invention, but does not constitute a limitation thereof. The accompanying drawings are intended to supplement the textual description with graphics, enabling a visual and intuitive understanding of each technical feature and the overall technical solution of the present invention, but they should not be construed as limiting the scope of protection of the present invention.
[0085] In the description of this invention, "several" means one or more, "multiple" means two or more, "greater than", "less than", "exceeding" are understood to exclude the number itself, and "above", "below", "within" are understood to include the number itself.
[0086] In the description of this invention, the consecutive numbers of the method steps are for ease of review and understanding. Considering the overall technical solution of this invention and the logical relationship between each step, adjusting the implementation order of the steps will not affect the technical effect achieved by the technical solution of this invention.
[0087] In the description of this invention, unless otherwise explicitly defined, terms such as "setup" should be interpreted broadly, and those skilled in the art can reasonably determine the specific meaning of the above terms in this invention in conjunction with the specific content of the technical solution.
[0088] In this embodiment, the ECG data used are the PTB public dataset and the ECG-ID public dataset. During implementation, the PTB dataset is used as the set of known individuals to conduct closed-set recognition performance tests, while the ECG-ID dataset is used as the set of unknown individuals to conduct open-set recognition performance tests.
[0089] like Figure 1As shown, this embodiment provides a method for open-set identity recognition of electrocardiogram signals based on hybrid networks and cross-attention mechanisms, including the following steps:
[0090] S1: Preprocess the electrocardiogram signal to obtain a standardized two-dimensional heartbeat image input;
[0091] S2: Construct a hybrid network model to extract multi-scale local spatial information and long-term time-series dependencies. The input of the hybrid network model is a standardized two-dimensional heartbeat image, and the output is a multi-scale local spatial information feature representation and a long-term time-series dependency feature representation of the standardized heartbeat image.
[0092] S3: Utilize a cross-attention mechanism to fuse different types of information. The input to the cross-attention mechanism is the output of the hybrid network model, and the output is a fused representation of multi-scale local spatial information features and global long-term dependency features;
[0093] S4: Establish an Openmax classification layer to achieve identity label recognition in an open-set environment. The Openmax classification model takes the output of the cross-attention mechanism as input and outputs the identity recognition result.
[0094] like Figure 2 As shown, the steps for preprocessing all ECG signals to obtain standardized heartbeat image input include:
[0095] S11: The input ECG signal is processed using a high-pass filter with a cutoff frequency of 0.5Hz, a low-pass filter with a cutoff frequency of 100Hz, and a band-stop filter with a notch frequency range of 49.5Hz to 50.5Hz to obtain a clean ECG signal.
[0096] S12: Use the Pan-Tompkins algorithm to locate the R and T wave apexes of clean ECG signals and obtain the reference point R and T wave apex positions;
[0097] S13: Based on the localization results, take the R wave vertex as the center, the adjacent T wave vertex before the R wave vertex as the starting point, and the adjacent T wave vertex after the R wave vertex as the ending point to segment the clean ECG signal and obtain the heartbeat segmentation segment.
[0098] S14: The obtained heartbeat segmentation is standardized by using the min-max normalization method to obtain standardized heartbeat segments;
[0099] S15: Use the Python matplotlib toolkit to plot standardized heartbeat fragments as RGB two-dimensional images with a size of 224*224*3, store the RGB two-dimensional image data, and use it as network input.
[0100] like Figure 3As shown, the ECG signal open-set identity recognition method based on hybrid networks and cross-attention mechanism includes a hybrid network feature extraction module, a cross-attention mechanism module, and an Openmax classification layer. The hybrid network feature extraction module, the cross-attention mechanism module, and the Openmax classification layer are connected sequentially.
[0101] like Figure 4 As shown, the hybrid network feature extraction module includes two channels: a multi-scale convolutional feature extraction channel and a Transformer coding feature extraction channel. The multi-scale convolutional feature extraction channel and the Transformer coding feature extraction channel are connected in parallel. The input for both is a 224*224*3 RGB two-dimensional image, and the output for both is a 1*768 feature vector.
[0102] like Figure 4 As shown, the multi-scale convolutional feature extraction channel includes a 1*1 convolutional layer, a first multi-scale convolutional feature extraction layer, a second multi-scale convolutional feature extraction layer, a third multi-scale convolutional feature extraction layer, a fourth multi-scale convolutional feature extraction layer, a fifth multi-scale convolutional feature extraction layer, and a fully connected layer.
[0103] The 1*1 convolutional layer, the first multi-scale convolutional feature extraction layer, the second multi-scale convolutional feature extraction layer, the third multi-scale convolutional feature extraction layer, the fourth multi-scale convolutional feature extraction layer, the fifth multi-scale convolutional feature extraction layer, and the fully connected layer are connected in sequence.
[0104] The 1*1 convolutional layer has a kernel size of 1*1 and a stride of 1. It uses the ReLU activation function and employs 4 convolutional kernels for the convolution operation.
[0105] like Figure 5 As shown, the first, second, third, fourth, and fifth multi-scale convolutional feature extraction layers each contain two parts: a multi-scale convolution module and a pooling module.
[0106] The multi-scale convolution module consists of four branches: the first branch, the second branch, the third branch, and the fourth branch.
[0107] The first branch is a residual connection;
[0108] The second branch uses a 3x3 convolution kernel with a stride of 1, employs the ReLU activation function, and sets the padding to "same".
[0109] The third branch is a 5x5 convolution kernel with a stride of 1, using the ReLU activation function, and the padding is set to "same";
[0110] The third branch is a 7*7 convolution kernel with a stride of 1, using the ReLU activation function, and the padding is set to "same";
[0111] In the first multi-scale convolutional feature extraction layer, each convolutional operation of the multi-scale convolutional module uses 4 convolutional kernels;
[0112] In the second multi-scale convolutional feature extraction layer, each convolutional operation of the multi-scale convolutional module uses 16 convolutional kernels.
[0113] In the third multi-scale convolutional feature extraction layer, each convolutional operation of the multi-scale convolutional module uses 32 convolutional kernels.
[0114] In the fourth multi-scale convolution feature extraction layer, each convolution operation of the multi-scale convolution module uses 64 convolution kernels;
[0115] In the fifth multi-scale convolution feature extraction layer, each convolution operation of the multi-scale convolution module uses 128 convolution kernels.
[0116] All pooling modules use max pooling, with a pooling layer size of 2*2 and a step size of 2.
[0117] The fully connected layer is used to expand and map the output of the fifth multi-scale convolutional feature extraction layer into a 1*768 feature vector, employing the ReLU activation function. The input to the fully connected layer is the expanded feature vector from the fifth multi-scale convolutional feature extraction layer, and the output is a 1*768 feature vector. The dimension of the output feature vector is the same as the dimension of the output feature vector from the Transformer encoded feature extraction channel.
[0118] like Figure 6 As shown, the Transformer encoded feature extraction channel contains 5 stacked Transformer encoders.
[0119] In step 2, the construction of a hybrid network model to extract long-term dependencies in the time series is accomplished by using Transformer encoding to extract feature channels. The input is a 224*224*3 RGB two-dimensional heart rate image. The feature extraction process includes the following steps:
[0120] S21: Use a convolution operation with a size of 16*16, a stride of 16, and 768 channels to perform a linear projection on the two-dimensional heart image. After linear projection, the dimension is 196*768, that is, after projection, 196 vector sequences are obtained, and each sequence has a dimension of 768.
[0121] S22: Add a classification label with a dimension of 1*768 to the front of the vector sequence. After concatenating it with the 196*768 vector sequence, the dimension is 197*768.
[0122] S23: Use the cosine function to generate position codes, superimpose them onto a projection vector sequence with a dimension of 197*768, and use the result as input to the Transformer encoder;
[0123] S24: Five stacked Transformer encoders are used to extract features from the input 197*768 vector sequence. Each Transformer encoder contains a multi-head attention module and a multilayer perceptron module. The multi-head attention module has 8 attention heads, and the multilayer perceptron contains two fully connected layers with a node count of 768->3072->768.
[0124] In this embodiment, linear projection is performed only on the first Transformer encoder, adding classification labels and overlay position encoding. The subsequent four Transformer encoders do not need to repeat the above operations; they directly take the 197*768-dimensional vector sequence output from the previous layer as input.
[0125] S25: Finally, the classification label obtained after mapping is extracted as the feature extracted by the Transformer encoding feature extraction channel, with a dimension of 1*768, which is the same as the output feature dimension of the multi-scale convolution feature extraction channel.
[0126] like Figure 7 As shown, the input to the cross-attention mechanism module is the 1*768 feature vector extracted by the multi-scale convolution feature extraction channel and the Transformer coding feature extraction channel, denoted as X. Conv X Trans .
[0127] Step 3, which utilizes the cross-attention mechanism to fuse different types of information, includes the following steps:
[0128] S31: Generate X through linear transformation Conv X Trans The corresponding queries, keys, and values. During the linear transformation process, the linear transformation matrices corresponding to the queries, keys, and values are denoted as W, respectively. Q W K W V The linear transformation matrix is learned by the backpropagation algorithm. Connv The corresponding query, key, and value are Q. Conv K Conv V Conv X Trans The corresponding query, key, and value are Q. Trans K Trans V Trans ;
[0129] S32: Calculate the attention score based on the query, key, and value, X Conv X Trans The corresponding attention score is:
[0130]
[0131] Where Softmax(·) is the Softmax function. After mapping using the Softmax function, the Attention1 value is X. Conv Corresponding attention score, After mapping using the Softmax function, the Attention2 value is X. Trans Corresponding attention score.
[0132] S33: Calculate the fused feature vector based on the attention score:
[0133] X Fuse =Attention1*V conv +Atttention2*V Trans
[0134] Where X Fuse This is the fused feature vector.
[0135] 9. The OpenMax classification layer is a three-layer fully connected network consisting of an input layer, hidden layers, and an output layer. The input layer is the output of the cross-attention mechanism module and contains 768 nodes. The hidden layer contains 384 nodes, and the number of nodes in the output layer is related to the number of individual categories being identified. If the number of individual categories is N... Total Then the number of output layer nodes is N. Total In this embodiment, since the number of individuals included in the PTB is selected to be 290, therefore N Total It is 290.
[0136] Step 4, establishing the Openmax classification layer to achieve identity tag recognition in an open set environment, includes the following steps:
[0137] S41: Training of the Openmax classification layer;
[0138] S42: Open set recognition of the Openmax classification layer.
[0139] 10. Step 41, the Openmax classification layer training, includes the following steps:
[0140] S411: Network Weight and Bias Optimization: Following the ten-fold cross-validation method, the PTB dataset is divided into a training set and a test set, with nine parts for training and one part for testing. Backpropagation is used to optimize the parameters of the entire network, obtaining the weights and biases of the Openmax classification layer. During the optimization process, the number of output nodes is N. Total At this point, the network is a closed-set recognition system, which only targets samples of individuals with known identities within the training set. The Openmax classification layer is equivalent to the Softmax classifier.
[0141] In this embodiment, the data used during training is all from the PTB dataset, and needs to cover the signal data of 290 individuals in the PTB dataset. The training process is mainly aimed at closed-set recognition.
[0142] S412: As Figure 8 As shown, the Weibull distribution parameter fitting is as follows: After training, for the training set samples in PTB, the Openmax classification layer hidden layer output set S corresponding to the correctly classified training set data is taken, and the obtained hidden layer output set S is divided into N according to the category. Total There are S data subsets, each subset denoted as S. j For each subset S j Take the average value to get N. Total MAV of activation vectors j The activation vector expression is calculated as follows:
[0143]
[0144] Where, N j S is the number of samples in category j. ij Let S be the i-th sample within the subset of data corresponding to category j. Calculate the sample S within each subset. ij To their respective corresponding activation vectors MAV j The Euclidean distances for each subset are used to fit the Weibull distributions to the corresponding Euclidean distance sets using the built-in Matlab function wblfit, yielding the scale parameters τ of the j Weibull distributions. j Shape parameter λ j With position parameter κ j .
[0145] The network weights, biases, and Weibull distribution parameters of the Openmax classification layer together constitute the model parameters of the Openmax classification layer.
[0146] like Figure 9 As shown, step S42, Openmax classification and open set recognition, includes the following steps:
[0147] S421: Output Score Correction: For each test sample in the ECG-ID dataset, the output score S of the sample in the hidden layer of the Openmax classification layer is obtained through network mapping. Sample The output score v of the output layer Sample Arrange v in descending order Sampple Sort the scores by internal parameters, and denote the sorted sequence as follows: For v Sample The correction formula for the i-th score value in the probability sequence is as follows:
[0148]
[0149] Where, ω i To adjust the weights, the calculation formula is as follows:
[0150]
[0151] Where dis(·) is the Euclidean distance, and MAV is... i τ is the activation vector corresponding to category i. i , λ i With κ i The Weibull distribution parameters corresponding to category i.
[0152] S422: Pseudo-score assignment for the unfamiliar / unknown category: Assign label 0 to the unfamiliar / unknown identity. The pseudo-score for label 0 is as follows:
[0153]
[0154] S423: Calculation of classification probability under open set conditions: using the Softmax function to analyze sequences After normalization, under the condition of open set recognition, the test sample can be classified into categories 0 to N. Total probability sequence
[0155] S424: As Figure 10 As shown, open set recognition: take the maximum value p in the probability sequence. max If the maximum value p max p0 or p max If the value is less than the preset threshold ε, it is judged as an unfamiliar or unknown identity and identification is rejected; if the maximum value p max Not p0 and p max If the value exceeds a preset threshold ε, the sample is considered a known identity, and the category label corresponding to the maximum value is assigned to the test sample. Here, the threshold ε is set to 0.9.
Claims
1. A method for open-set identity recognition based on hybrid networks and cross-attention mechanism of electrocardiogram signals, characterized in that, The method includes the following steps: S1: Preprocess the electrocardiogram signal to obtain a standardized two-dimensional heartbeat image as input; S2: Construct a hybrid network model to extract multi-scale local spatial information and long-term time-series dependencies. The input of the hybrid network model is the standardized two-dimensional heartbeat image, and the output is the multi-scale local spatial information feature representation and the long-term time-series dependency feature representation of the standardized heartbeat image. This method includes a hybrid network feature extraction module, a cross-attention mechanism module, and an Openmax classification layer connected in sequence; The hybrid network feature extraction module includes two channels: a multi-scale convolutional feature extraction channel and a Transformer coding feature extraction channel. The multi-scale convolutional feature extraction channel and the Transformer coding feature extraction channel are connected in parallel. The input for both is a 224*224*3 RGB two-dimensional image, and the output for both is a 1*768 feature vector. The multi-scale convolutional feature extraction channel includes a 1*1 convolutional layer, a first multi-scale convolutional feature extraction layer, a second multi-scale convolutional feature extraction layer, a third multi-scale convolutional feature extraction layer, a fourth multi-scale convolutional feature extraction layer, a fifth multi-scale convolutional feature extraction layer, and a fully connected layer. The 1*1 convolutional layer, the first multi-scale convolutional feature extraction layer, the second multi-scale convolutional feature extraction layer, the third multi-scale convolutional feature extraction layer, the fourth multi-scale convolutional feature extraction layer, the fifth multi-scale convolutional feature extraction layer, and the fully connected layer are connected in sequence. The 1*1 convolutional layer has a kernel size of 1*1, a stride of 1, uses the ReLU activation function, and employs 4 convolutional kernels for the convolution operation. The first, second, third, fourth, and fifth multi-scale convolutional feature extraction layers each contain two parts: a multi-scale convolution module and a pooling module. The multi-scale convolution module includes four branches, namely the first branch, the second branch, the third branch, and the fourth branch: The first branch is a residual connection; The second branch uses a 3x3 convolution kernel with a stride of 1, employs the ReLU activation function, and sets the padding to "same". The third branch is a 5*5 convolution kernel with a stride of 1, using the ReLU activation function, and the padding is set to "same"; The fourth branch is a 7*7 convolution kernel with a stride of 1, using the ReLU activation function, and the padding is set to "same"; In the first multi-scale convolution feature extraction layer, each convolution operation of the multi-scale convolution module uses 4 convolution kernels; In the second multi-scale convolutional feature extraction layer, each convolutional operation of the multi-scale convolutional module uses 16 convolutional kernels; In the third multi-scale convolutional feature extraction layer, each convolutional operation of the multi-scale convolutional module uses 32 convolutional kernels. In the fourth multi-scale convolutional feature extraction layer, each convolutional operation of the multi-scale convolutional module uses 64 convolutional kernels. In the fifth multi-scale convolutional feature extraction layer, each convolutional operation of the multi-scale convolutional module uses 128 convolutional kernels. All pooling modules use max pooling, with a pooling layer size of 2*2 and a step size of 2. S3: Different types of information are fused using a cross-attention mechanism, where the input of the cross-attention mechanism is the output of the hybrid network model, and the output is a fused representation of the multi-scale local spatial information features and the long-term time-series dependency features; S4: Establish an Openmax classification layer to realize identity label recognition in an open set environment. The input of the Openmax classification model is the output of the cross-attention mechanism, and the output is the identity recognition result. The step in S1 to preprocess the electrocardiogram signal to obtain a standardized heartbeat image input includes: S11: The input ECG signal is processed using a high-pass filter with a cutoff frequency of 0.5Hz, a low-pass filter with a cutoff frequency of 100Hz, and a band-stop filter with a notch frequency range of 49.5Hz~50.5Hz to obtain a clean ECG signal. S12: Use the Pan-Tompkins algorithm to locate the R and T wave apexes of the clean ECG signal to obtain the reference point R and T wave apex positions; S13: Based on the localization results, take the R wave peak as the center, the adjacent T wave peak before the R wave peak as the starting point, and the adjacent T wave peak after the R wave peak as the ending point to segment the clean ECG signal and obtain the heartbeat segment. S14: The obtained heartbeat segmentation fragments are standardized using the min-max normalization method to obtain standardized heartbeat fragments; S15: Using the Python matplotlib toolkit, the standardized heartbeat fragments are plotted as RGB two-dimensional images with a size of 224*224*3. The RGB two-dimensional image data is stored and used as network input.
2. The ECG signal open-set identity recognition method based on hybrid networks and cross-attention mechanism according to claim 1, characterized in that, The fully connected layer is used to expand and map the output of the fifth multi-scale convolutional feature extraction layer into a 1*768 feature vector, using the ReLU activation function. The input to the fully connected layer is the expanded feature vector output from the fifth multi-scale convolutional feature extraction layer, and the output is a 1*768 feature vector. The dimension of the output feature vector is the same as the dimension of the output feature vector from the Transformer encoded feature extraction channel.
3. The ECG signal open set identity recognition method based on hybrid network and cross-attention mechanism according to claim 1, characterized in that, The Transformer encoded feature extraction channel contains 5 stacked Transformer encoders; The construction of the hybrid network model in step S2 to extract long-term dependencies in the time series is accomplished by the Transformer encoding feature extraction channel. The input is a 224*224*3 RGB two-dimensional heart rate image. The feature extraction process includes the following steps: S21: Use a convolution operation with a size of 16*16, a stride of 16, and 768 channels to perform a linear projection on the two-dimensional heart image. After linear projection, the dimension is 196*768, that is, after projection, 196 vector sequences are obtained, and each sequence has a dimension of 768. S22: Add a classification label with a dimension of 1*768 to the front of the vector sequence, and after concatenating it with the 196*768 vector sequence, the dimension is 197*768; S23: Use the cosine function to generate position codes, superimpose them onto the 197*768 dimension projection vector sequence, and use the result as the input of the Transformer encoder; S24: The 5 stacked Transformer encoders are used to extract features from the input 197*768 vector sequence. Each Transformer encoder contains a multi-head attention module and a multilayer perceptron module. The number of attention heads in the multi-head attention module is set to 8, and the multilayer perceptron contains two fully connected layers with the number of nodes being 768->3072->768. Linear projection is performed only on the first Transformer encoder, and classification labels and superimposed position encoding are added. The following four Transformer encoders do not need to repeat the above operations and can directly take the 197*768-dimensional vector sequence output by the previous layer as input. S25: Finally, the classification label obtained after mapping is used as the feature extracted by the Transformer encoding feature extraction channel, with a dimension of 1*768, which is the same as the output feature dimension of the multi-scale convolution feature extraction channel.
4. The ECG signal open-set identity recognition method based on hybrid networks and cross-attention mechanism according to claim 1, characterized in that, The input to the cross-attention mechanism module is the 1*768 feature vector extracted by the multi-scale convolutional feature extraction channel and the Transformer coding feature extraction channel, denoted as follows: , ; Step S3, which uses a cross-attention mechanism to fuse different types of information, includes the following steps: S31: Generate the above through linear transformation , For the corresponding query, key, and value, the linear transformation matrices for the query, key, and value during the linear transformation process are denoted as follows: , , The linear transformation matrix is learned by the backpropagation algorithm. The corresponding queries, keys, and values are respectively , , The corresponding queries, keys, and values are respectively , , ; S32: Calculate the attention score based on the query, key, and value. , The corresponding attention score is: ; Where Softmax(·) is the Softmax function. After mapping by the Softmax function, the result is obtained Value Corresponding attention score, After mapping by the Softmax function, the result is obtained Value Corresponding attention score; S33: Calculate the fused feature vector based on the attention score: ; in The fused feature vector is denoted as .
5. The ECG signal open-set identity recognition method based on hybrid networks and cross-attention mechanism according to claim 1, characterized in that, The Openmax classification layer is a three-layer fully connected network consisting of an input layer, a hidden layer, and an output layer. The input layer, which is the output of the cross-attention mechanism module, contains 768 nodes. The hidden layer contains 384 nodes. The number of nodes in the output layer is related to the number of individual categories being identified. If the number of individual categories being identified is... Then the number of output layer nodes is Step S4, establishing the Openmax classification layer to achieve identity tag recognition in an open set environment, includes the following steps: S41: Training of the Openmax classification layer; S42: Open set recognition of the Openmax classification layer.
6. The ECG signal open set identity recognition method based on hybrid network and cross-attention mechanism according to claim 5, characterized in that, The Openmax classification layer training described in step S41 includes the following steps: S411: Network Weight and Bias Optimization: Following the ten-fold cross-validation method, the dataset is divided into a training set and a test set, with the training set comprising nine parts and the test set comprising one part. The backpropagation algorithm is used to optimize the parameters of the entire network, obtaining the weights and biases of the Openmax classification layer. During the optimization process, the number of output nodes is... At this point, the network is a closed-set recognition system, only targeting samples of individuals with known identities within the training set. The Openmax classification layer is equivalent to the Softmax classifier. S412: Weibull distribution parameter fitting: After training, for the training set samples, take the output set of the hidden layer of the Openmax classification layer corresponding to the correctly classified training set data. The hidden layer output set obtained according to the category Divided into There are data subsets, each subset denoted as . For each of the subsets Take the average value to get activation vectors The activation vector expression is calculated as follows: ; in, For category The number of samples, For category The corresponding data subset For each sample, calculate the samples within each subset. to their respective activation vectors The Euclidean distances for each subset are obtained by fitting the Weibull distribution to the set of Euclidean distances corresponding to each subset using the built-in function wblfit in Matlab. The scale parameter of a Weibull distribution Shape parameters With position parameters The network weights, biases, and Weibull distribution parameters contained in the Openmax classification layer together constitute the model parameters of the Openmax classification layer.
7. The ECG signal open-set identity recognition method based on hybrid networks and cross-attention mechanism according to claim 6, characterized in that, The Openmax classification open set recognition described in step S42 includes the following steps: S421: Output score correction: for each test sample By mapping the network, the output score of the sample in the hidden layer of the Openmax classification layer is obtained. Output score of the output layer Arranged in descending order Sort the scores by internal parameters, and denote the sorted sequence as follows: ,right The probability sequence of the middle The correction formula for each score value is as follows: ; in, To adjust the weights, the calculation formula is as follows: ; in, Euclidean distance. For category The corresponding activation vector, , and For category The corresponding Weibull distribution parameters; S422: Pseudo-score assignment for the unfamiliar / unknown category: Assign label 0 to the unfamiliar / unknown identity. The pseudo-score for label 0 is as follows: ; S423: Calculation of classification probability under open set conditions: using the Softmax function to analyze the sequence [ , , , , After normalization, under the condition of open set recognition, the test samples are recognized. Category 0~ probability sequence ; S424: Open set recognition: Take the maximum value in the probability sequence If the maximum value for or Less than the preset threshold If the value is unknown, it is judged as an unfamiliar identity and recognition is rejected; if the maximum value is... Not for and Greater than the preset threshold If the value is positive, it is considered a known identity, and the category label corresponding to the maximum value is assigned to the test sample.
Citation Information
Patent Citations
Brain electrical emotion recognition method based on attention mechanism space-time position coding
CN115736923A
ECG identity recognition method based on attention-enhanced multi-branch convolutional neural network
CN116992421A
