Knowledge distillation-based heartbeat signal identity recognition method and system, storage medium and electronic equipment
By using knowledge distillation technology in heartbeat signal identity recognition and using ResNet to guide ViT model training, the problem of low accuracy of center jump signal identity recognition in the existing technology is solved, and more efficient and accurate heartbeat signal identity recognition is achieved.
Patent Information
- Application Number
- CN202510049408.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-13
- Publication Date
- 2025-05-09
- Estimated Expiration
- 2045-01-13
AI Technical Summary
In actual application, the existing identity recognition method based on heartbeat signals is low in accuracy and has not yet achieved ideal results due to factors such as millimeter wave radar sampling rate and sampling duration.
Using a knowledge distillation method, ViT students are guided to train models through ResNet as a teacher model, combining data preprocessing and model training steps to improve the accuracy and generalization ability of the model.
Through the knowledge distillation framework, the student model's dependence on large-scale data is reduced, the overfitting problem is effectively overcome, and the accuracy of heartbeat signal identity recognition is improved.
Smart Images

Figure CN119961909A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of physiological signal processing, and specifically relates to a heartbeat signal identity recognition method and system based on knowledge distillation, a storage medium and an electronic device. The present invention is a technical solution for identity recognition through heartbeat signals collected by millimeter wave radar. Background Art
[0002] Heartbeat signal is an important physiological signal of the human body, and the identity recognition technology based on heartbeat signal has broad application prospects. Traditional identity recognition methods, such as face recognition and fingerprint recognition, have significant disadvantages: face recognition faces privacy issues and high risk of false recognition rate, mainly involving the collection of face data without consent, potential data abuse and leakage, poor image quality, poor lighting conditions, and easy to be affected by insufficient light and obstructions; fingerprint recognition requires physical contact, and fingerprints are easily unrecognizable due to wear, injury or contamination, and there is also a risk of being copied. Therefore, the identity recognition method based on heartbeat signal has gradually attracted attention in recent years. This method realizes identity recognition by analyzing the characteristics of heartbeat signals of different people, and has the advantages of high security, anti-counterfeiting ability and anti-interference ability. However, the current identity recognition method based on heartbeat signal has low accuracy in practical applications due to the influence of factors such as millimeter wave radar sampling rate and sampling time, and still needs to be further improved. Therefore, seeking more accurate and efficient heartbeat signal identity recognition methods is a current research hotspot. Summary of the invention
[0003] In view of the above problems existing in the prior art, the present invention provides a heartbeat signal identity recognition method and system based on knowledge distillation, a storage medium and an electronic device.
[0004] The present invention adopts the following technical scheme:
[0005] The heartbeat signal identification method based on knowledge distillation includes data preprocessing stage, training stage and testing stage. The specific steps are as follows:
[0006] 1) Data preprocessing stage: The heartbeat signal collected by the millimeter-wave radar is processed in segments, and each segment of the heartbeat signal is analyzed in the frequency domain to obtain a log-mel (log mel) spectrum diagram, and a set of log-mel spectrum diagrams is obtained, which is divided into a training set and a test set.
[0007] 2) Training phase: First, a knowledge distillation model is built based on ResNet (residual network) and (Vision Transformer, ViT), ResNet is used as the teacher model to guide the training of the ViT student model, and then the model training is completed based on the training set.
[0008] 3) Testing phase: Use the model trained in step 2) to test the model performance based on the test set to obtain the accuracy on the test set.
[0009] The present invention adopts a knowledge distillation framework to solve the overfitting problem of the model. Specifically, ResNet is used as a teacher model to guide the training of the student model ViT, thereby greatly reducing ViT's dependence on large-scale data.
[0010] Preferably, in the data preprocessing stage, the heartbeat signal collected by the millimeter wave radar is processed in sections according to the length of each time window being 2s and the overlap ratio of adjacent time windows being 50%. Each section of the heartbeat signal is analyzed in the frequency domain to obtain a log-mel (logarithmic Mel) spectrum diagram, and a set of log-mel spectrum diagrams is obtained, and the set is divided into a training set and a test set.
[0011] Preferably, the data preprocessing stage is specifically as follows:
[0012] Step 1.1), the heartbeat signal is processed in segments, as follows: In order to enhance the contextual relevance between adjacent signals, adjacent time windows are overlapped to allow them to share a portion of data. The time window length and overlap ratio are set to 2s and 50% respectively.
[0013] Step 1.2), the heartbeat signal is denoised as follows: each segment of the heartbeat signal is passed through the bandwidth range
[0014] A bandpass filter of [0.75, 2.5] Hz is used to filter out noise and retain frequency components directly related to cardiac activity. Subsequently, a Hamming window is used to eliminate spectral leakage caused by truncation. The Hamming window has a narrow main lobe and strong side lobe suppression function, which reduces the influence of side lobes in the frequency domain. As shown in formula (1):
[0015]
[0016] In formula (1), w(q) is the Hamming window function, N is the length of the window, and q is the sample index in the window.
[0017] Step 1.3) The frequency domain analysis of the heartbeat signal is as follows: Map the original frequency of the heartbeat signal to the mel scale. The mapping process is shown in equations (2) and (3):
[0018]
[0019] f=700(10 m / 2595 -1) (3)
[0020] In formulas (2) and (3), f represents a specific frequency value, and m represents the mel scale.
[0021] Then a set of triangular filters is used to create the mel filter, as shown in equation (4):
[0022]
[0023] Among them, f m-1 ,f m , and f m+1 They are three adjacent mel frequency points, which are used to define the boundary of each triangular filter. The STFT (short-time Fourier transform) spectrum is multiplied by the mel filter to obtain the mel spectrum, as shown in formula (5):
[0024] MS(x,f)=Spectrogram(x)⊙B m (f) (5)
[0025] Where x represents the heartbeat signal, Spectrogram(x) represents the STFT spectrum, and B m (f) represents a mel filter, and ⊙ represents a product operation.
[0026] Furthermore, the spectrum graph needs to be converted into dB units by using logarithmic operations to enhance the low-frequency components, as shown in equation (6):
[0027] logMelSpec=10*log 10 (MS(x,f))-10*log 10 (ref) (6)
[0028] Where LogMelSpec is the log-mel spectrum, ref is the reference value, set to 1, and the amplitude MS(x, f) is scaled relative to ref.
[0029] Preferably, during the training phase:
[0030] Step 2.1), first establish the teacher model network.
[0031] ResNet is selected as the basic architecture, and the input is log-mel spectrogram. The specific steps are as follows: First, the log-mel spectrogram obtained in step 1.3) is used as the input of the network, and its initial dimension is (3, 64, 64), where 3 represents the number of color channels and 64x64 is the spatial size of the image. Next, the input image passes through a 7x7 convolutional layer with 64 output channels and a stride of 2 to extract primary features. This step converts the input size from (3, 64, 64) to (64, 32, 32). Subsequently, these feature maps pass through a 3x3 max pooling layer with a stride of 2 to further reduce the spatial size to (64, 16, 16), thereby reducing the amount of computation and preventing overfitting. Then, the data passes through four residual block groups in sequence, each of which contains two 3x3 convolutional layers with batch normalization and ReLU activation functions. The first residual block group keeps the input and output dimensions unchanged, that is, both the input and output are (64, 16, 16). The first convolutional layer in the second residual block group uses stride 2, making the output dimension (128, 8, 8). The first convolutional layer in the third residual block group uses stride 2, further reducing the output dimension to (256, 4, 4). The first convolutional layer in the fourth residual block group also uses stride 2, and the final output dimension is (512, 2, 2). After all residual blocks, the feature map passes through the global average pooling layer, which averages the data of each channel to generate a 512-dimensional one-dimensional vector with a size of (512). This process not only reduces the number of parameters, but also retains the average information of each channel, which helps to improve the generalization ability of the model. Finally, this one-dimensional feature vector is passed to the fully connected layer, which maps the features to the specified number of categories to complete the classification task. The number of output nodes of the fully connected layer is equal to the number of categories, and each node represents the prediction score of a category.
[0032] Step 2.2), further establish the student model network.
[0033] First, the ViT model obtained by pre-training on the ImageNet dataset is used as the student model. ViT's powerful feature extraction ability is attributed to the multi-head self-attention mechanism (MHSA). The Vanilla ViTTransformer (basic ViT transformer) is used, which contains multiple cascaded encoder layers, so that the student model can fully capture the relationship between time and frequency in the log-mel spectrogram. seq ∈R n×d Represents the embedding matrix of the entire input sequence, where n is the number of tokens and d is the embedding dimension of each token. seq Linear transformation into query key Sum d k d v Denote the query (key) and value dimensions respectively. Then Q, K, and V are divided into h heads. For the i-th head, SA i The (self-attention) formula is shown in formula (7):
[0034]
[0035] Among them, Q, K and V are respectively obtained by linear transformation from the input sequence x seq The resulting query, key, and value matrix, Q i , K i and V i The sub-matrices after these matrices are split in the multi-head mechanism correspond to the query, key, and value of the i-th head respectively. The self-attention in each head runs in parallel, and the outputs of multiple heads are connected, that is, the self-attention outputs of multiple heads are SA 1 , S.A. 2 ,…,SA i , …, SA h The concatenation is done along the feature dimension to form an n×d matrix. The next step is to apply a linear transformation (i.e., multiply it with a learnable weight matrix) to the concatenated matrix to map the output back to the original feature dimension. In order to better utilize the position information in the sequence, in the multi-head self-attention mechanism (MHSA), the original input is mapped to a vector representation of a fixed dimension, called a token. Each token not only contains the local feature information of the input data, but also reflects its position in the sequence by introducing relative position encoding or absolute position encoding. Although both encoding methods can help the model understand the position of the token, the absolute position encoding is static, while the relative position encoding is more flexible because it depends on the relative distance between tokens and can be adjusted through a learnable parameter matrix (such as the bias B). i ) to more accurately capture the relative position relationship between tokens. Deviation B i ∈R n×n Introduced in each self-attention head, the modified self-attention definition is shown in formula (8):
[0036]
[0037] In addition, the absolute position pos is encoded using sine and cosine functions. i ,…,pos n ), add these position codes to the input token embedding vector, as shown in formula (9):
[0038]
[0039] in, indicates assignment, i is the position index, indicating the i-th token in the sequence, x i Represents x seq The embedding vector of the i-th token in , pos i represents the encoding of the i-th position, and the encoding method is shown in formula (10):
[0040]
[0041] Among them, j is the dimension index of the embedding vector, pos i,2j The value of the even index position in the position embedding vector is calculated, pos i,2j+1 The values calculated are for odd-indexed positions in the position embedding vector.
[0042] Step 2.3), further, the knowledge distillation method is used to improve the accuracy of the student model. The distillation method uses Logits (unnormalized predicted values) distillation to train the student model by minimizing the difference between the teacher model and the student model on Logits. Since the identity recognition based on heartbeat signals is a multi-classification task, the soft target calculated by the temperature-scaled softmax function is used to guide the student model training. Specifically, the soft target is the probability distribution of a specific category, and this process is implemented by softmax, as shown in formula (11):
[0043]
[0044] Among them, p i represents the probability that the test result is the i-th category, z i is the Logits of the teacher model for the i-th category, T is the temperature parameter used to control the influence of each category, and C is the number of categories. Then, the distillation loss function shown in formula (12) is used to characterize the difference between the output of the student model and the teacher model:
[0045] L ResD (p(z t ,T),p(z s ,T))=KL(p(z t ,T),p(z s ,T)) (12)
[0046] Among them, L ResD represents the residual loss, which is used to measure the difference between the teacher model and the student model, KL represents the Kullback-Leibler divergence loss function, and p(z t ,T) represents the probability distribution of the output of the teacher model after temperature scaling, p(z s,T) represents the probability distribution of the output of the student model after temperature scaling, z t is the Logits of the teacher model, z s are the Logits of the student model.
[0047] The student loss function adopts the cross entropy loss function as shown in formula (13):
[0048]
[0049] Among them, y refers to the true label, y i and p(z s ,T=1) i are the i-th element in the true label and predicted probability distribution, respectively. p represents the soft target of the student model, which enables the student model to learn the correct classification of the data. In the present invention, the soft target is obtained by pre-training ResNet and ViT, and then the student model learns deep knowledge from the teacher model through distillation loss. At the same time, the cross entropy loss function learns the intrinsic features from the true label. Finally, the hybrid loss function obtained by combining the distillation loss function and the cross entropy loss function is shown in formula (14):
[0050] L Global =(1-λ)·L ResD (p(z t ,T),p(z s ,T))+λ·L CE (y,p(z s ,T=1)) (14)
[0051] Here, λ is the weight used to balance the two losses.
[0052] Step 2.4) The training model is as follows: First, a knowledge distillation model is built based on ResNet and ViT, and a pre-trained ResNet is used as the teacher model to guide the training of the VIT student model. The ViT student model is trained using the data in the training set through the adaptive moment estimation optimizer Adam (initial learning rate is 1e-3, the amount size is 8, and the weight decay is 0.2). During the entire training process, the ResNet teacher model does not participate in parameter updates, and the intrinsic features are only used for inference to generate soft targets; while the ViT student model gradually optimizes its performance through back-propagation and parameter updates, and finally inherits the ResNet knowledge while maintaining a high accuracy rate.
[0053] Preferably, in the testing phase, the trained knowledge distillation model is used to perform a model performance test based on a test set, and the steps are as follows:
[0054] Step 3.1) Use an independent test dataset, making sure it is different from the training and validation datasets.
[0055] Step 3.2) Load the teacher model and its weights, and then load the student model and its weights obtained after knowledge distillation training.
[0056] Step 3.3) Call the evaluation method of the student model and input the test set data into the student model that has been trained through knowledge distillation for evaluation.
[0057] Step 3.4) Calculate the accuracy and initialize two counters: correct is used to record the number of samples predicted correctly, and total is used to record the total number of samples. Then, traverse each sample in the test set, use the knowledge distillation model to predict and obtain the predicted label; if the predicted label is the same as the true label, add 1 to the correct counter; regardless of whether the prediction is correct or not, add 1 to the total counter. Finally, calculate the accuracy by dividing correct by total, that is, Accuracy = correct / total. The result is the accuracy of the model on the test set.
[0058] The present invention also discloses a heartbeat signal identification system based on knowledge distillation, which is used to execute the above method and includes the following units:
[0059] Data preprocessing unit: The millimeter-wave radar collects heartbeat signals and processes them in segments. Each segment of the heartbeat signal is analyzed in the frequency domain to obtain a log-mel spectrum graph, and a set of log-mel spectrum graphs is obtained. The set is divided into a training set and a test set.
[0060] Training unit: First build a knowledge distillation model based on ResNet and ViT, and then complete model training based on the training set;
[0061] Testing unit: Use the trained knowledge distillation model to test the test set, and calculate the accuracy based on the real labels corresponding to the heartbeat signals.
[0062] A storage medium stores computer instructions, wherein the computer instructions are used to make a computer execute the method or system described above.
[0063] An electronic device, comprising:
[0064] processor;
[0065] The memory is used to store a program. When the program is called and executed by the processor, the processor executes the above method or system.
[0066] The beneficial effects of the present invention are as follows:
[0067] The present invention proposes a heartbeat signal identity recognition method and system based on knowledge distillation. In the knowledge distillation framework, the pre-trained ResNet model is used as a teacher model to effectively guide the student model ViT training process, thereby overcoming the overfitting problem caused by the small data scale. This is the first time that knowledge distillation has been applied to solve the overfitting problem in the field of heartbeat-based identity recognition. The present invention improves the accuracy of identity recognition using heartbeat signals. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art description are introduced below:
[0069] Figure 1 The figure is a schematic diagram of the heartbeat signal preprocessing process in a preferred embodiment of the present invention.
[0070] Figure 2 Schematic diagram of the knowledge distillation framework structure of the preferred embodiment of the present invention.
[0071] Figure 3 The figure is a flow chart of a heartbeat signal identification method based on knowledge distillation according to a preferred embodiment of the present invention.
[0072] Figure 4 This is a block diagram of a heartbeat signal identification system based on knowledge distillation according to a preferred embodiment of the present invention. DETAILED DESCRIPTION
[0073] The present invention is described in detail below in conjunction with embodiments and drawings so that those skilled in the art can better understand the present invention.
[0074] like Figure 1-3 As shown, this embodiment is a heartbeat signal identity recognition method based on knowledge distillation, including a data preprocessing stage, a training stage, and a testing stage. The specific steps are described as follows.
[0075] 1) Data preprocessing stage: The heartbeat signal collected by the millimeter wave radar is processed in segments, and each segment of the heartbeat signal is analyzed in the frequency domain to obtain a log-mel spectrum graph, and the log-mel spectrum graph set is divided into a training set and a test set; the details are as follows:
[0076] Step 1.1), the heartbeat signal is processed in segments, specifically as follows: In order to enhance the context relevance between adjacent signals, adjacent time windows are overlapped to allow them to share a portion of data. In this embodiment, the time window length and overlap ratio are set to 2s and 50% respectively.
[0077] Step 1.2), heartbeat signal denoising, as follows: each segment of the heartbeat signal is passed through a bandpass filter with a bandwidth range of [0.75, 2.5] Hz to filter out the noise and retain the frequency components directly related to cardiac activity. Subsequently, a Hamming window is used to eliminate the spectrum leakage caused by truncation. The Hamming window has a narrow main lobe and strong side lobe suppression function, which reduces the influence of the side lobe in the frequency domain. As shown in formula (1):
[0078]
[0079] In formula (1), N is the length of the window and q is the sample index in the window.
[0080] Step 1.3) The frequency domain analysis of the heartbeat signal is as follows: Map the original frequency of the heartbeat signal to the mel scale. The mapping process is shown in equations (2) and (3):
[0081]
[0082] f=700(10 m / 2595 -1)(3)
[0083] In formulas (2) and (3), f represents a specific frequency value, and m represents the mel scale.
[0084] Due to the logarithmic transformation, the change of the mel scale m tends to be gentle when f is large. Then a set of triangular filters is used to create the mel filter, as shown in equation (4):
[0085]
[0086] Among them, f m-1 , f m , and f m+1 They are three adjacent mel frequency points, which are used to define the boundary of each triangular filter. The STFT (short-time Fourier transform) spectrum is multiplied by the mel filter to obtain the mel spectrum, as shown in formula (5):
[0087] MS(x,f)=Spectrogram(x)⊙B m (f) (5)
[0088] Where x represents the heartbeat signal, Spectrogram(x) represents the STFT spectrum, and B m (f) represents a mel filter, and ⊙ represents a product operation.
[0089] The spectrum needs to be converted to dB units by using logarithmic operations to enhance the low-frequency components, as shown in equation (6):
[0090] LogMelSpec=10*log10 (MS(x,f))-10*log 10 (ref) (6)
[0091] Where LogMelSpec is the log-mel spectrum, ref is the reference value, set to 1, and the amplitude MS(x, f) is scaled relative to ref.
[0092] 2) In the training phase, a knowledge distillation model is constructed based on the residual network ResNet and ViT. ResNet is used as the teacher model to guide the training of the ViT student model, and then the knowledge distillation model training is completed based on the training set; the details are as follows:
[0093] Step 2.1), first establish the teacher model network.
[0094] This embodiment selects ResNet as the basic architecture, and the input is a log-mel spectrogram. The specific steps are as follows: First, the log-mel spectrogram obtained in step 1.3) is used as the input of the network, and its initial dimension is (3, 64, 64), where 3 represents the number of color channels and 64x64 is the spatial size of the image. Next, the input image passes through a 7x7 convolutional layer with 64 output channels and a stride of 2 for extracting primary features. This step converts the input size from (3, 64, 64) to (64, 32, 32). Subsequently, these feature maps pass through a 3x3 maximum pooling layer with a stride of 2, further reducing the spatial size to (64, 16, 16), thereby reducing the amount of calculation and preventing overfitting. Then, the data passes through four residual block groups in sequence, each of which contains two 3x3 convolutional layers with batch normalization and ReLU activation functions. The first residual block group keeps the input and output dimensions unchanged, that is, both the input and output are (64, 16, 16). The first convolutional layer in the second residual block group uses stride 2, making the output dimension (128, 8, 8). The first convolutional layer of the third residual block group uses stride 2, further reducing the output dimension to (256, 4, 4). The first convolutional layer of the fourth residual block group also uses stride 2, and the final output dimension is (512, 2, 2). After all residual blocks, the feature map passes through the global average pooling layer, which averages the data of each channel to generate a 512-dimensional one-dimensional vector with a size of (512). This process not only reduces the number of parameters, but also retains the average information of each channel, which helps to improve the generalization ability of the model. Finally, this one-dimensional feature vector is passed to the fully connected layer, which maps the features to the specified number of categories to complete the classification task. The number of output nodes of the fully connected layer is equal to the number of categories, and each node represents the prediction score of a category.
[0095] Step 2.2), further establish the student model network.
[0096] First, the ViT model obtained by pre-training on the ImageNet dataset is used as the student model. ViT's powerful feature extraction ability is attributed to the multi-head self-attention mechanism (MHSA). Using the Vanilla ViTTransformer, which contains multiple cascaded encoder layers, the student model can fully capture the relationship between time and frequency in the log-mel spectrogram. seq ∈R n×d Represents the embedding matrix of the entire input sequence, where n is the number of tokens and d is the embedding dimension of each token. seq Linear transformation into query key Sum d k d v Denote the query (key) and value dimensions respectively. Then Q, K, and V are divided into h heads. For the i-th head, SA i The (self-attention) formula is shown in formula (7):
[0097]
[0098] Among them, Q, K and V are obtained by linear transformation from the input sequence x seq The resulting query, key, and value matrix, Q i , K i and V i The sub-matrices after these matrices are split in the multi-head mechanism correspond to the query, key, and value of the i-th head respectively. The self-attention in each head runs in parallel, and the outputs of multiple heads are connected, that is, the self-attention outputs of multiple heads are SA 1 , S.A. 2 ,…,SA i , …, SA h The concatenation is done along the feature dimension to form an n×d matrix. The next step is to apply a linear transformation (i.e., multiply it with a learnable weight matrix) to the concatenated matrix to map the output back to the original feature dimension. In order to better utilize the position information in the sequence, in the multi-head self-attention mechanism (MHSA), the original input is mapped to a vector representation of a fixed dimension, called a token. Each token not only contains the local feature information of the input data, but also reflects its position in the sequence by introducing relative position encoding or absolute position encoding. Although both encoding methods can help the model understand the position of the token, the absolute position encoding is static, while the relative position encoding is more flexible because it depends on the relative distance between tokens and can be adjusted through a learnable parameter matrix (such as the bias B).i ) to more accurately capture the relative position relationship between tokens. Deviation B i ∈R n×n Introduced in each self-attention head, the modified self-attention definition is shown in formula (8):
[0099]
[0100] In addition, the absolute position pos is encoded using sine and cosine functions. i ,…,pos n ), these positional encodings are added to the input token embedding vector, as shown in formula (9):
[0101]
[0102] in, is an assignment operation, i is the position index, indicating the i-th token in the sequence, x i Represents x seq The embedding vector of the i-th token in , pos i represents the encoding of the i-th position, and the encoding method is shown in formula (10):
[0103]
[0104] Among them, j is the dimension index of the embedding vector, pos i,2j The value of the even index position in the position embedding vector is calculated, pos i,2j+1 The values calculated are for odd-indexed positions in the position embedding vector.
[0105] Step 2.3), further, the knowledge distillation method is used to improve the accuracy of the student model. The distillation method uses Logits (unnormalized predicted values) distillation to train the student model by minimizing the difference between the teacher model and the student model in Logits. Since the identity recognition based on the heartbeat signal is a multi-classification task, the soft target calculated by the temperature-scaled softmax function is used to guide the student model training. Specifically, the soft target is the probability distribution of a specific category, and this process is implemented by softmax, as shown in formula (11):
[0106]
[0107] Among them, p i represents the probability that the test result is the i-th category, z iis the Logits of the teacher model for the i-th category, T is the temperature parameter used to control the influence of each category, and C is the number of categories. Then, the distillation loss function shown in formula (12) is used to characterize the difference between the output of the student model and the teacher model:
[0108] L ResD (p(z t ,T),p(z s ,T))=KL(p(z t ,T),p(z s ,T)) (12)
[0109] Among them, L ResD represents the residual loss, which is used to measure the difference between the teacher model and the student model, KL represents the Kullback-Leibler divergence loss function, and p(z t ,T) represents the probability distribution of the output of the teacher model after temperature scaling, p(z s ,T) represents the probability distribution of the output of the student model after temperature scaling, z t is the Logits of the teacher model, z s are the Logits of the student model.
[0110] The student loss function adopts the cross entropy loss function as shown in formula (13):
[0111]
[0112] Among them, y refers to the true label, y i and p(z s ,T=1) i are the i-th element in the true label and predicted probability distribution, respectively. p represents the soft target of the student model, which enables the student model to learn the correct classification of the data. In the present invention, the soft target is obtained by pre-training ResNet and ViT, and then the student model learns deep knowledge from the teacher model through distillation loss. At the same time, the cross entropy loss function learns the intrinsic features from the true label. Finally, the hybrid loss function obtained by combining the distillation loss function and the cross entropy loss function is shown in formula (14):
[0113] L Global =(1-λ)·L ResD (p(z t ,T),p(z s ,T))+λ·L cE (y,p(z s ,T=1)) (14)
[0114] Here, λ is the weight used to balance the two losses.
[0115] Step 2.4) The training model is as follows:
[0116] First, a knowledge distillation model was built based on ResNet and ViT, and a pre-trained ResNet was used as the teacher model to guide the training of the VIT student model. The ViT student model was trained using the data in the training set through the adaptive moment estimation optimizer Adam (initial learning rate is 1e-3, volume size is 8, and weight decay is 0.2). During the entire training process, the ResNet teacher model does not participate in parameter updates, and the intrinsic features are only used for inference to generate soft targets; while the ViT student model gradually optimizes its performance through backpropagation and parameter updates, and finally inherits the ResNet knowledge while maintaining a high accuracy rate.
[0117] 3) Testing phase: Use the trained knowledge distillation model to test the model performance based on the test set. The steps are as follows:
[0118] Step 3.1) Use an independent test dataset and ensure that it is different from the training dataset and the validation dataset.
[0119] Step 3.2) Load the teacher model and its weights, and then load the student model and its weights obtained after knowledge distillation training.
[0120] Step 3.3) Call the evaluation method of the student model and input the test set data into the student model that has been trained through knowledge distillation for evaluation.
[0121] Step 3.4) Calculate the accuracy and initialize two counters: correct is used to record the number of samples predicted correctly, and total is used to record the total number of samples. Then, traverse each sample in the test set, use the knowledge distillation model to predict and obtain the predicted label; if the predicted label is the same as the true label, add 1 to the correct counter; regardless of whether the prediction is correct or not, add 1 to the total counter. Finally, calculate the accuracy by dividing correct by total, that is, Accuracy = correct / total, and the result is the accuracy of the model on the test set.
[0122] like Figure 4 As shown, this embodiment discloses a heartbeat signal identification system based on knowledge distillation, which is used to execute the method of the above embodiment, and includes the following units:
[0123] Data preprocessing unit: The millimeter-wave radar collects heartbeat signals, and the complete heartbeat signals are segmented according to the length of each time window of 2s and the overlap ratio of adjacent time windows of 50%. Each segment of the heartbeat signal is analyzed in the frequency domain to obtain a log-mel spectrum graph, and a set of log-mel spectrum graphs is obtained, which is divided into a training set and a test set.
[0124] Training unit: First build a knowledge distillation model based on ResNet and ViT, and then complete model training based on the training set;
[0125] Testing unit: Use the trained knowledge distillation model to test the test set, and calculate the accuracy based on the real labels corresponding to the heartbeat signals.
[0126] For other contents of this embodiment, reference may be made to the above method embodiment.
[0127] A storage medium stores computer instructions, wherein the computer instructions are used to enable a computer to execute the method or system according to the above embodiment.
[0128] An electronic device, comprising:
[0129] processor;
[0130] The memory is used to store a program. When the program is called and executed by the processor, the processor executes the method or system of the above embodiment.
[0131] The specific embodiments described herein are merely examples of the spirit of the present invention. Those skilled in the art may make various modifications or additions to the specific embodiments described or replace them in similar ways, but they will not deviate from the spirit of the present invention or exceed the scope defined by the attached claims.
Claims
1. A heartbeat signal identification method based on knowledge distillation, characterized in that: The steps include: 1) Data preprocessing stage: The heartbeat signal collected by the millimeter-wave radar is processed in segments, and each segment of the heartbeat signal is analyzed in the frequency domain to obtain a log-mel spectrum graph, and the log-mel spectrum graph set is divided into a training set and a test set; 2) Training phase: A knowledge distillation model is constructed based on the residual network ResNet and ViT. ResNet is used as the teacher model to guide the training of the ViT student model, and then the knowledge distillation model training is completed based on the training set; 3) Testing phase: Use the knowledge distillation model trained in step 2) to perform model performance testing based on the test set to obtain the heartbeat signal identity recognition result.
2. The heartbeat signal identification method based on knowledge distillation as claimed in claim 1, characterized in that: Step 1), in the data preprocessing stage: Step 1.1), the heartbeat signal is processed in segments, specifically as follows: the time window length and overlap ratio are set to 2s and 50% respectively; Step 1.2) Heartbeat signal denoising is as follows: each segment of the heartbeat signal is passed through a bandpass filter with a bandwidth range of [0.75, 2.5] Hz to filter out the noise; a Hamming window is used to eliminate the spectrum leakage caused by truncation, as shown in formula (1): In formula (1), w(q) is the Hamming window function, N is the length of the window, and q is the sample index in the window; Step 1.3), frequency domain analysis of the heartbeat signal, specifically as follows: Map the original frequency of the heartbeat signal to the Mel scale, the mapping process is shown in equations (2) and (3): f=700(10 m / 2595 -1)(3) In formulas (2) and (3), f represents a specific frequency value, and m represents the mel scale.
3. The heartbeat signal identification method based on knowledge distillation as claimed in claim 2, characterized in that: In step 1.3), a set of triangular filters is used to create a mel filter, as shown in formula (4): Among them, f m-1 、f m and f m+1 are three adjacent mel frequency points, which are used to define the boundary of each triangular filter. The short-time Fourier transform STFT spectrum map is multiplied by the mel filter to obtain the mel spectrum map, as shown in formula (5): MS(x,f)=Spectrogram(x)⊙B m (f) (5) Where x represents the heartbeat signal, Spectrogram(x) represents the STFT spectrum, and B m (f) represents a mel filter, and ⊙ represents a product operation.
4. The heartbeat signal identification method based on knowledge distillation as claimed in claim 3 is characterized in that the steps 1.3), the spectrum is converted to dB units using logarithmic operation, as shown in formula (6): LogMelSpec=10*log 10 (MS(x,f))-10*log 10 (ref) (6) Among them, LogMelSpec is the log-mel spectrum, ref is the reference value, and MS(x, f) is the amplitude.
5. The heartbeat signal identification method based on knowledge distillation according to any one of claims 1 to 4, characterized in that: Step 2), during the training phase: Step 2.1), establish the teacher model; First, the log-mel spectrogram obtained in step 1.3) is used as input, with an initial dimension of (3, 64, 64), where 3 represents the number of color channels and 64x64 is the spatial size of the image; then, the input spectrogram passes through a 7x7 convolutional layer with 64 output channels and a stride of 2, thereby converting the input size from (3, 64, 64) to (64, 32, 32); then, the feature map passes through a 3x3 maximum pooling layer with a stride of 2 to reduce the spatial size to (64, 16, 16); then, it passes through four residual block groups in sequence, each of which contains two 3x3 convolutional layers with batch normalization and ReLU activation functions; the first residual block group keeps the input and output dimensions unchanged, that is, both the input and output are (6 4,16,16); the first convolutional layer in the second residual block group uses stride 2, making the output dimension (128,8,8); the first convolutional layer in the third residual block group uses stride 2, reducing the output dimension to (256,4,4); the first convolutional layer in the fourth residual block group uses stride 2, and the final output dimension is (512,2,2); after all residual blocks, the feature map passes through the global average pooling layer to average the data of each channel to generate a 512-dimensional one-dimensional vector with a size of (512); finally, the one-dimensional vector is passed to the fully connected layer, which maps the features to the specified number of categories to complete the classification task; the number of output nodes of the fully connected layer is equal to the number of categories, and each node represents the prediction score of a category; Step 2.2), establish the student model; The ViT model obtained by pre-training the public dataset ImageNet dataset is used as the student model; seq ∈R n×d Represents the embedding matrix of the entire input sequence, where R is a set of real numbers, n is the number of tokens, and d is the embedding dimension of each token; the input x of the multi-head attention mechanism seq Linear transformation into query key Sum d k ,d v denote the dimensions of query and value respectively; Q, K and V are then divided into h heads, and for the i-th head, the self-attention SA i The formula is shown in formula (7): Among them, Q, K and V are respectively obtained by linear transformation from the input sequence x seq The resulting query, key, and value matrix, Q i , K i and V i They are the sub-matrices after the corresponding matrix is split in the multi-head mechanism, corresponding to the query, key and value of the i-th head respectively; the self-attention in each head runs in parallel, and the self-attention outputs of multiple heads are SA1, SA2, ..., SA i , …, SA h The n×d matrix is concatenated along the feature dimension, and a linear transformation is applied to the concatenated matrix to map the output back to the original feature dimension. In the multi-head self-attention mechanism, the original input is mapped to a vector representation of a fixed dimension, called a token, and the bias B i ∈R n×n Introduced in each self-attention head, the modified self-attention definition is shown in formula (8): Encoding the absolute position pos using sine and cosine functions = (pos i ,…,pos n ), add the positional encoding to the input token embedding vector, as shown in formula (9): in, indicates assignment, i is the position index, indicating the i-th token in the sequence, x i Represents x seq The embedding vector of the i-th token in , pos i represents the encoding of the i-th position, and the encoding method is shown in formula (10): Among them, j is the dimension index of the embedding vector, pos i,2j is the value of the even-indexed position in the position embedding vector, pos i,2j+1 is the value of the odd-indexed position in the position embedding vector; Step 2.3), use knowledge distillation method to improve the accuracy of student model; The knowledge distillation method uses unnormalized predicted value Logits distillation to train the student model by minimizing the difference between the teacher model and the student model on Logits; the soft target is the probability distribution of a specific category. This process is shown in formula (11): Among them, p i represents the probability that the test result is the i-th category, z i is the Logits of the teacher model for the i-th category, T is the temperature parameter used to control the influence of each category, and C is the number of categories. The distillation loss function shown in formula (12) is used to characterize the difference between the output of the student model and the teacher model: L ResD (p(z t ,T),p(z s ,T))=KL(p(z t ,T),p(z s ,T)) (12) Among them, L ResD represents the residual loss, which is used to measure the difference between the teacher model and the student model, KL represents the Kullback-Leibler divergence loss function, and p(z t ,T) represents the probability distribution of the output of the teacher model after temperature scaling, p(z s ,T) represents the probability distribution of the output of the student model after temperature scaling, z t is the Logits of the teacher model, z s are the Logits of the student model; The student loss function adopts the cross entropy loss function as shown in formula (13): Among them, y refers to the true label, y i and p(z s ,T=1) i are the i-th element in the true label and predicted probability distribution respectively; p represents the soft target of the student model, which enables the student model to learn the correct classification of the data; the soft target is obtained by pre-training ResNet and ViT, and then the student model learns deep knowledge from the teacher model through distillation loss. At the same time, the cross entropy loss function learns the intrinsic features from the true label; finally, the hybrid loss function obtained by combining the distillation loss function and the cross entropy loss function is shown in formula (14): L Global =(1-λ)·L ResD (p(z t ,T),p(z s ,T))+λ·L CE (y,p(z s ,T=1)) (14) Among them, λ is the weight used to balance the two losses; Step 2.4) The training model is as follows: Firstly, based on the knowledge distillation model constructed by ResNet and ViT, the pre-trained ResNet is used as the teacher model to guide the training of the ViT student model; the ViT student model is trained by the adaptive moment estimation optimizer using the data in the training set.
6. The heartbeat signal identification method based on knowledge distillation as claimed in claim 5, characterized in that: Step 3), testing phase, is as follows: Step 3.1) Select the test set; Step 3.2), load the teacher model and its weights, and then load the student model and its weights obtained after knowledge distillation training; Step 3.3), input the test set data into the student model that has been trained by knowledge distillation for evaluation; Step 3.4) Calculate the accuracy of the model.
7. The heartbeat signal identification method based on knowledge distillation as claimed in claim 6, characterized in that the steps 3.4) The details are as follows: Initialize two counters correct and total, correct is used to record the number of samples predicted correctly, and total is used to record the total number of samples; then, traverse each sample in the test set, use the knowledge distillation model to predict and obtain the predicted label; if the predicted label is the same as the true label, the correct counter is increased by 1; each time a prediction is made, the total counter is increased by 1; finally, the accuracy is calculated by dividing correct by total.
8. A heartbeat signal identification system based on knowledge distillation, used to execute the method according to any one of claims 1 to 7, characterized in that: The following units are included: Data preprocessing unit: collects the heartbeat signal by millimeter-wave radar, processes it in segments, obtains a log-mel spectrum graph for each segment of the heartbeat signal through frequency domain analysis, and divides the log-mel spectrum graph set into a training set and a test set; Training unit: First, build a knowledge distillation model based on the residual network ResNet and ViT, use ResNet as the teacher model to guide the training of the ViT student model, and then complete the knowledge distillation model training based on the training set; Testing unit: Use the trained knowledge distillation model to test the test set and calculate the model accuracy.
9. A storage medium, characterized in that: Computer instructions are stored, wherein the computer instructions are used to cause a computer to execute the method according to any one of claims 1 to 7 or the system according to claim 8.
10. An electronic device, characterized in that: include: processor; A memory for storing a program, wherein when the program is called and executed by a processor, the processor executes the method according to any one of claims 1 to 7 or the system according to claim 8.
Citation Information
Patent Citations
Methods and systems for non-invasive gene detection using artificial intelligence (ai) models
CN114846507A
Method and apparatus for coding a noise-suppressed audio signal
US20040083095A1
Contactless sleep detection and disturbance attribution for multiple users
US20220047209A1
Contactless device for respiratory health monitoring
WO2022046072A1
Methods, devices and media for improving knowledge distillation using intermediate representations
WO2022217853A1
Cited By
Millimeter wave radar identity verification method and system based on heartbeat harmonic focus separation
CN121256373A