An electrocardiogram classification method based on task difficulty adaptive meta-learning
Through the task difficulty adaptive meta-learning method, using wavelet transform and dynamic learning rate adjustment, the problems of scarce label data and uneven task difficulty in electrocardiogram classification are solved, the classification accuracy and efficiency are improved, and it can adapt to electrocardiogram tasks of different difficulty levels.
Patent Information
- Application Number
- CN202311301817.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-10
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2043-10-10
AI Technical Summary
Existing technologies have problems in ECG classification such as scarcity of labeled data and uneven task construction, which leads to poor transfer learning results. Meta-learning methods also face the problem of uneven task difficulty in ECG classification, which affects classification accuracy and efficiency.
A task difficulty adaptive meta-learning method is adopted to measure the irregularity of the electrocardiogram through wavelet transform, dynamically adjust the learning rate, combine meta-learning strategy and adaptive learning strategy, optimize the model training process, and adapt to electrocardiogram classification tasks of different difficulty levels.
The accuracy and efficiency of electrocardiogram classification are improved, especially maintaining good performance in data-scarce conditions, and flexible model adaptation and efficient classification are achieved.
Smart Images

Figure CN117557825B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of meta-learning of time series, and in particular to an electrocardiogram classification method based on task difficulty adaptive meta-learning. Background Art
[0002] Electrocardiogram (ECG) classification has attracted considerable attention in recent years, but the scarcity of labeled data has made it challenging. Transfer learning is currently being used to address this issue. It typically utilizes large amounts of time series data from different domains to pre-train deep network models, which are then fine-tuned using a small amount of labeled data from the target domain. However, this strategy does not always guarantee superior results on small amounts of labeled data. In particular, when there is a significant difference in data distribution between the source and target tasks, the performance of transfer learning can be significantly affected. In contrast, meta-learning focuses more on learning general learning strategies from a task perspective to more quickly adapt to new tasks. However, when applied to ECG classification, it still faces challenges with task construction and uneven difficulty of classification tasks. Given these issues, a new approach is urgently needed to improve the accuracy and efficiency of ECG classification. Summary of the Invention
[0003] The purpose of the present invention is to address the above-mentioned defects in the prior art and to provide an electrocardiogram classification method based on task difficulty adaptive meta-learning.
[0004] The purpose of the present invention can be achieved by taking the following technical solutions:
[0005] An electrocardiogram classification method based on task difficulty adaptive meta-learning is proposed. The meta-learning strategy is used to train multiple electrocardiogram classification tasks, so that the model can quickly adapt to new few-shot electrocardiogram classification tasks. The electrocardiogram classification method includes the following steps:
[0006] S1. For the i-th ECG classification task, use the ECG classification model f() to classify all samples in the i-th ECG classification task. The classification process can be expressed as:
[0007] Y i,j =f(X i,j ,θ)
[0008] Among them, X i,j represents the jth ECG time series sample of the i-th ECG classification task, γ represents the model parameters of the ECG classification model f(), and the model parameters θ are learned from the ECG data and determine the classification output of the ECG classification model f() for the input sample. The sample set of each ECG classification task contains N samples, N≤50, j=1,…,N;
[0009] The loss value of all ECG samples in the i-th ECG classification task is calculated by the cross entropy loss function The calculation process is as follows:
[0010]
[0011] in, Y represents the cross entropy loss value of the ECG classification model f() on the i-th ECG classification task; i,j is the output of the ECG classification model f(), which represents the jth ECG sample X of the i-th ECG classification task predicted by the ECG classification model f() i,j Corresponding ECG sample category;
[0012] Calculate the cross entropy loss value Gradient with respect to model parameters θ And update the model parameters:
[0013]
[0014] Among them, θ′ i It represents the updated parameters of the model after training on the i-th ECG classification task, and α represents the learning rate, which is used to control the step size of each update of the model parameters;
[0015] S2: After the model has been trained for n tasks, step S1 is repeated n times to update the global model parameters. The updated calculation formula is as follows:
[0016]
[0017] Where n is the number of ECG classification tasks, β i It is a learning rate that is adaptive based on the difficulty of the task and is used to control the step size of each update of the model parameters. Represents the model parameters θ′ after training for the i-th ECG classification task i Cross entropy loss value on the i-th ECG classification task;
[0018] S3. Model fine-tuning: In this step, the ECG classification model f() trained by the meta-learning strategy is first fine-tuned using a small amount of annotated ECG data. This process is achieved by adjusting the model parameters θ to minimize the cross-entropy loss function of the small amount of annotated ECG data. The fine-tuning process is expressed as:
[0019]
[0020] Among them, θ new are the model parameters after fine-tuning, η is the learning rate during fine-tuning, is the gradient of the cross entropy loss function with respect to the model parameters θ.
[0021] S4, ECG classification: After fine-tuning, the next step is to perform ECG classification. test The input is fed into the fine-tuned ECG classification model f(). The ECG classification model f() will use the fine-tuned parameters to accurately classify the input ECG data.
[0022] The classification process is expressed as:
[0023] Y test =f(X test ,θ new )
[0024] Among them, Y test Is the output ECG classification result, which represents the ECG sample X classified by the ECG classification model f() test Corresponding ECG sample category.
[0025] Furthermore, the learning rate β based on task difficulty adaptation is i The update calculation formula is as follows:
[0026] β i =β i +a×D i
[0027] Among them, D i represents the task difficulty of the i-th ECG classification task, A represents the task difficulty weighted update parameter of the learning rate, and represents the task difficulty D i For the learning rate β i The larger A is, the greater the impact of task difficulty on the learning rate. Using the above formula, the learning rate is dynamically adjusted based on the actual difficulty of each ECG classification task, enabling more efficient model training and optimization. This design addresses the problem of how to dynamically adjust the learning rate for more efficient model training and optimization under varying task difficulties.
[0028] Furthermore, the task difficulty D of the i-th electrocardiogram classification task i The calculation process is as follows:
[0029] Calculate x t The high-frequency coefficient c of the wavelet transform t , high-frequency coefficients c of wavelet transform t It is used to measure the irregularity of the electrocardiogram and is calculated as follows:
[0030]
[0031] Among them, x tis the jth ECG sample X for the i-th ECG classification task i,j The sample at the t-th time step in X i,j ={x1,...,x t ,...,x T Where T is the total time length of the ECG sample data, ψ(t) is the wavelet mother function, a is the scale parameter used to control the expansion and contraction of the wavelet function, k is the translation parameter used to control the movement of the wavelet function, and the symbol ()* represents the complex conjugate. This step aims to accurately measure the volatility of the ECG and provide a basis for further difficulty calculations.
[0032] Calculate the jth ECG sample X for the i-th ECG classification task i,j The task difficulty is D i,j , the calculation formula is as follows:
[0033]
[0034] is x t The high-frequency coefficient c at T time steps t The average value of , T is the total time length of the ECG sample data;
[0035] The task difficulty D of the i-th ECG classification task i It is expressed as the average difficulty of all samples in the i-th ECG classification task, and the calculation formula is as follows:
[0036]
[0037] This part provides a practical basis for adjusting the learning rate by calculating the difficulty of each sample and the entire task, ensuring that the adjustment of the learning rate is more in line with the actual task situation, thereby optimizing the training of the model.
[0038] Furthermore, the wavelet mother function adopts Haar wavelet, and the expression is as follows:
[0039]
[0040] The present invention selects the Haar wavelet function because it is computationally simple and effective, and can accurately capture the characteristics of electrocardiogram data. In addition, the present invention uses the Haar wavelet function to perform wavelet transform, which can effectively extract the characteristics of the electrocardiogram signal for further classification and difficulty calculation.
[0041] The present invention has the following advantages and effects compared to the prior art:
[0042] (1) The task difficulty adaptive meta-learning model disclosed in the present invention significantly improves the efficiency and accuracy of electrocardiogram classification by introducing a unique task difficulty adaptive mechanism. In traditional electrocardiogram classification methods, the difficulty of different tasks is often different, and fixed learning strategies cannot adapt well to tasks of various difficulties. The present invention achieves effective learning of tasks of different difficulty levels by evaluating the difficulty of each electrocardiogram classification task in real time and adjusting the learning rate accordingly. This not only optimizes the learning process, but also improves the classification performance of the model.
[0043] (2) The present invention uses wavelet transform to accurately measure the irregularity of the ECG and thus estimate the difficulty of the task. Traditional methods often cannot accurately reflect the complexity of the ECG, while wavelet transform can effectively capture the high-frequency characteristics of the ECG, thereby providing a more accurate assessment of the task difficulty. This precise task difficulty assessment further guides the dynamic adjustment of the learning rate, allowing the model to achieve flexible switching and learning between different tasks, thereby ensuring efficient and accurate ECG classification in a variety of different situations.
[0044] (3) Even in the case of data scarcity, the present invention can still maintain good performance by combining meta-learning and adaptive learning strategies. The meta-learning strategy learns effective model parameters from a large amount of data, while the adaptive learning strategy dynamically adjusts the learning rate according to the difficulty of the task. The combination of the two enables the present invention to still show excellent performance in the face of data scarcity. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0046] Figure 1 This is a flowchart of an electrocardiogram classification method based on task difficulty adaptive meta-learning disclosed by the present invention.
[0047] Figure 2 This is a comparison chart of the classification performance curves of the electrocardiogram data classification method based on task difficulty adaptive meta-learning disclosed in the present invention and other methods (Transformer) on the TwoLeadECG and ECG5000 datasets; wherein, Figure 2 (a) is a comparison of the classification accuracy curves of the ECG data classification method based on task difficulty adaptive meta-learning disclosed in the present invention and other methods (Transformer) on the TwoLeadECG dataset; Figure 2(b) is a comparison of the classification F1 score curves of the electrocardiogram data classification method based on task difficulty adaptive meta-learning disclosed in the present invention and other methods (Transformer) on the ECG5000 dataset. DETAILED DESCRIPTION
[0048] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0049] Example 1
[0050] This embodiment specifically discloses an electrocardiogram classification method based on task difficulty adaptive meta-learning. Based on task difficulty modeling and adaptive meta-learning implementation, a meta-learning strategy is used to train multiple electrocardiogram classification tasks, so that the model can quickly adapt to new few-sample electrocardiogram classification tasks, including the following steps:
[0051] S1. Predict and calculate the loss value of the i-th ECG classification task. First, set the model parameter learning rate α to 0.001. For the selected i-th ECG classification task, use the ECG classification model f() to classify all samples X i,j Perform classification prediction and obtain the prediction result Y i,j , the calculation process is described as Y i,j =f(X i,j ,θ).
[0052] Among them, X i,j represents the jth ECG time series sample of the i-th ECG classification task, θ represents the model parameters of the ECG classification model f(), which are learned from the ECG data and determine the classification output of the ECG classification model f() for the input sample. The sample set of each ECG classification task contains N samples, N≤50, j=1,…,N;
[0053] The loss value of all ECG samples in the i-th ECG classification task is calculated by the cross entropy loss function The calculation process is as follows:
[0054]
[0055] in, Y represents the cross entropy loss value of the ECG classification model f() on the i-th ECG classification task; i,jis the output of the ECG classification model f(), which represents the jth ECG sample X of the i-th ECG classification task predicted by the ECG classification model f() i,j Corresponding ECG sample category;
[0056] Next, calculate the cross entropy loss value The gradient of the model parameters θ is calculated and the learning rate α is used to update the model parameters to obtain θ′ i , the update process is:
[0057]
[0058] Among them, θ′ i It represents the updated parameters of the model after training on the i-th ECG classification task, and α represents the learning rate, which is used to control the step size of each update of the model parameters;
[0059] S2. Update the global model parameters after each n-task training. In this step, set the number of tasks n to 10. After completing the training of n tasks, update the global model parameters. Calculate the gradient of the cross entropy loss value for each task and use a learning rate βi that is adaptive based on the task difficulty (βi initial value is 0.1, A is 0.01, β i =β i +A×D i ) to update.
[0060] The updated calculation formula is:
[0061] S3. Model fine-tuning. In the model fine-tuning step, we first use a small amount of labeled ECG data for fine-tuning. We set the fine-tuning learning rate η to 0.0001 and adjust the model parameters θ by minimizing the cross entropy loss function of these data to obtain the fine-tuned model parameters θ. new The fine-tuning process is expressed as the formula:
[0062] S4, ECG classification. In the ECG classification step, we take the ECG sample X to be classified test Input to the fine-tuned ECG classification model f(θ new ). The model will accurately classify the input ECG data and the fine-tuned parameters. The classification process can be expressed as Y test =f(X test ,θ new Table 1 shows the comparison results of the electrocardiogram data classification method based on task difficulty adaptive meta-learning disclosed in the present invention and other methods on the ECG5000 dataset.
[0063] Table 1. Experimental results of the present invention and other methods on the ECG5000 dataset
[0064] Accuracy F1 score LSTM 0.485 0.482 FCN 0.823 0.847 TCN 0.819 0.801 ResCNN 0.548 0.513 ResNet 0.765 0.772 InceptionTime 0.837 0.809 Transformer 0.926 0.934 The method proposed by the present invention 0.986 0.983
[0065] In Table 1, the higher the evaluation index (accuracy, F1 score), the better the classification performance of the method. From the comparison of the experimental results in Table 1, it can be seen that compared with the methods that do not use any task difficulty-related methods (LSTM, FCN, TCN, ResCNN, ResNet, InceptionTime, Transformer), the method based on task difficulty adaptive meta-learning in the present invention achieves the best classification effect on the ECG5000 dataset, verifying the effectiveness and practicality of the present invention.
[0066] Example 2
[0067] To further demonstrate the effect of the electrocardiogram data classification method based on task difficulty adaptive meta-learning disclosed in the present invention. This embodiment considers the TwoLeadECG electrocardiogram dataset. The specific implementation steps are the same as those in Example 1, and only the final classification effect is described here. Table 2 shows the comparison results of the electrocardiogram data classification method based on task difficulty adaptive meta-learning disclosed in the present invention and other methods on the TwoLeadECG dataset. The compared methods and the evaluation indicators adopted are the same as those in Example 1. Table 2 shows that the method proposed in the present invention achieved the best classification effect on this dataset, verifying the effectiveness and practicality of the present invention.
[0068] Table 2. Experimental results of the present invention and other methods on the TwoLeadECG dataset
[0069]
[0070]
[0071] like Figure 2 As shown, Figure 2 middle Figure 2 (a) and Figure 2 (b) shows a comparison of the classification test accuracy curves of using the method disclosed in the present invention and the Transformer without using any method for few-shot learning. It can be observed that the ECG neural network classification model based on task difficulty adaptive meta-learning can well ensure the generalization ability of the model due to the use of the task difficulty adaptive meta-learning method, while the Transformer affects the generalization ability of the ECG neural network classification model because it does not adjust the learning process according to the task difficulty, resulting in a slightly lower classification accuracy of the test.
[0072] The above embodiments are preferred implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be considered as equivalent replacement methods and are included in the scope of protection of the present invention.
Claims
1. An electrocardiogram classification method based on task difficulty adaptive meta-learning, characterized in that: The electrocardiogram classification method comprises the following steps: S1. For the i-th ECG classification task, use the ECG classification model f() to classify all samples in the i-th ECG classification task. The classification process is expressed as: Y i,j =f(X i,j ,i) Among them, X i,j represents the jth ECG time series sample of the i-th ECG classification task, θ represents the model parameters of the ECG classification model f(), which are learned from the ECG data and determine the classification output of the ECG classification model f() for the input sample. The sample set of each ECG classification task contains N samples, N≤50, j=1,…,N; The loss value of all ECG samples in the i-th ECG classification task is calculated by the cross entropy loss function The calculation process is as follows: in, Y represents the cross entropy loss value of the ECG classification model f() on the i-th ECG classification task; i,j is the output of the ECG classification model f(), which represents the j-th ECG sample X of the i-th ECG classification task predicted by the ECG classification model f() i,j Corresponding ECG sample category; Calculate the cross entropy loss value Gradient with respect to model parameters θ And update the model parameters: Among them, θ′ i It represents the updated parameters of the model after training on the i-th ECG classification task, and α represents the learning rate, which is used to control the step size of each update of the model parameters; S2: After the model has been trained for n tasks, step S1 is repeated n times to update the global model parameters. The updated calculation formula is as follows: Where n is the number of ECG classification tasks, β i It is a learning rate that is adaptive based on the difficulty of the task and is used to control the step size of each update of the model parameters. Represents the model parameters θ after training for the i-th ECG classification task ′ Cross entropy loss value on the i-th ECG classification task; S3. Model fine-tuning: Use the annotated ECG data to fine-tune the ECG classification model f() trained by the meta-learning strategy. The fine-tuning process is achieved by adjusting the model parameters θ to minimize the cross-entropy loss function of a small amount of annotated ECG data. The fine-tuning process is as follows: Among them, θ new are the model parameters after fine-tuning, η is the learning rate during fine-tuning, is the gradient of the cross entropy loss function with respect to the model parameters θ; S4. ECG classification: The ECG sample to be classified X test The data is input into the fine-tuned ECG classification model f(). The ECG classification model f() uses the fine-tuned parameters to perform accurate classification based on the input ECG data. The classification process is as follows: Y test =f(X test ,i new ) Among them, Y test Is the output ECG classification result, which represents the ECG sample X classified by the ECG classification model f() tes The ECG sample category corresponding to t.
2. The electrocardiogram classification method based on task difficulty adaptive meta-learning according to claim 1, characterized in that: According to the difficulty D of the i-th ECG classification task i Dynamically adjust the learning rate. The update formula for dynamic adjustment is as follows: b i =b i +A×D i Among them, A represents the task difficulty weighted update parameter of the learning rate, which represents the task difficulty D i For the learning rate β i The greater the value of A, the greater the impact of task difficulty on the learning rate.
3. The electrocardiogram classification method based on task difficulty adaptive meta-learning according to claim 2, characterized in that: The task difficulty D of the i-th ECG classification task i The calculation process is as follows: Calculate x t The high-frequency coefficient c of the wavelet transform t , high-frequency coefficient c of wavelet transform t It is used to measure the irregularity of the electrocardiogram and is calculated as follows: Among them, x t is the jth ECG sample X for the i-th ECG classification task i,j The sample at the t-th time step in X i,j ={x1,...,x t ,...,x T }, T is the total time length of the ECG sample data, ψ(t) is the wavelet mother function, a is the scale parameter used to control the expansion and contraction of the wavelet function, k is the translation parameter used to control the movement of the wavelet function, and the symbol ()* represents the complex conjugate; Calculate the jth ECG sample X for the i-th ECG classification task i,j The task difficulty is D i,j , the calculation formula is as follows: is x t The high-frequency coefficient c at T time steps t The average value of , T is the total time length of the ECG sample data; The task difficulty D of the i-th ECG classification task i It represents the average difficulty of all samples in the i-th electrocardiogram classification task, and the calculation formula is as follows:
4. The electrocardiogram classification method based on task difficulty adaptive meta-learning according to claim 3 is characterized in that The wavelet mother function adopts Haar wavelet, and its expression is as follows:
Citation Information
Patent Citations
Electrocardiogram classification method with self-adaptive data length characteristic
CN108090509A
Electrocardiogram classification method based on dynamic multi-scale convolutional neural network
CN112560784A