A Small Sample Multi-Label Electrocardiogram Classification Method

By employing cross-scale feature extraction and dynamic weight fusion techniques in the CSHM-Net model, the problem of insufficient feature extraction in small-sample ECG classification is solved, achieving accurate classification of fine-grained details and global temporal patterns of ECG signals, and improving classification accuracy and stability in multi-label scenarios.

CN121901859BActive Publication Date: 2026-05-26CHONGQING UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHONGQING UNIV
Filing Date
2026-03-24
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Existing small-sample ECG classification methods struggle to fully extract fine-grained details and large-scale temporal patterns from ECG signals, resulting in weak ability to distinguish complex and multi-pathological signals in multi-label scenarios and difficulty in achieving accurate classification.

Method used

The CSHM-Net model is used for feature extraction and classification. Through a cross-scale feature extraction module, a class prototype generation module, and a hybrid metric fusion learning module, a high-dimensional fusion feature map with both fine-grained details and global temporal patterns is generated. The final classification result is output by dynamic weight fusion of local detail similarity and global distribution similarity.

Benefits of technology

It improves the accuracy and stability of small-sample multi-label electrocardiogram classification, enables accurate classification in complex multi-pathological signal scenarios, and enhances the model's generalization ability and the reliability of classification results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121901859B_ABST
    Figure CN121901859B_ABST
Patent Text Reader

Abstract

This invention provides a small-sample, multi-label electrocardiogram (ECG) classification method, comprising: acquiring a support set and a query set of ECGs, each including multiple ECG signals; for each ECG signal in the support set and query set, performing feature extraction at multiple different scales to obtain multiple extracted features corresponding to each ECG signal; performing attention enhancement on each extracted feature to obtain corresponding enhanced features, and then fusing all enhanced features across scales to obtain a fused feature map corresponding to each ECG signal; aggregating the fused feature maps corresponding to the support set into class prototypes, then calculating the similarity matrix between the class prototypes and the fused feature maps corresponding to the query set, and determining the category of each ECG signal in the query set based on the similarity matrix. This invention solves the problem in existing technologies that cannot fully extract ECG features and perform accurate classification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of electrocardiogram (ECG) signal processing technology, and in particular to a small-sample, multi-label ECG classification method. Background Technology

[0002] Electrocardiogram (ECG) signals capture the electrical activity of the heart, reflecting the state of cardiac function by recording changes in electrical signals over time. Accurate and rapid identification of abnormal ECGs is crucial for physicians' diagnostic and treatment decisions. With the development of machine learning and artificial intelligence technologies, automated ECG classification systems have received widespread attention.

[0003] Traditional classification methods combine manual feature extraction with traditional models such as support vector machines (SVM) and decision trees, requiring manual feature extraction from time dimensions (such as RR intervals) and frequency ranges (such as wavelet transform and principal component analysis). Deep learning technology (deep neural networks, DNNs) can automatically extract raw electrocardiogram features to achieve end-to-end classification without manual feature engineering, but it requires large-scale datasets to optimize parameters, resulting in low efficiency and a tendency to overfit in scenarios where clinical samples are scarce.

[0004] Therefore, few-shot learning (FSL) technology has emerged, mainly divided into metric learning and meta-learning. It has been applied to the field of electrocardiogram (ECG) classification, aiming to achieve rapid model adaptation with a small number of labeled samples. However, patients in clinical practice often have multiple complications, and ECG signals contain overlapping abnormal features. Existing few-shot ECG classification methods mostly rely on single-scale feature representation and single-label classification, which cannot fully extract fine-grained morphological details (such as ST segment shift) and large-scale temporal patterns (such as arrhythmia cycles) in ECG signals. It is difficult to accurately identify complex multi-pathological signals, especially in multi-label and few-shot scenarios. The ability to distinguish overlapping abnormal features is weak, making it difficult to accurately classify ECG types and causing doctors to make accurate judgments about patients' conditions. Summary of the Invention

[0005] To address the shortcomings of existing technologies, this invention provides a small-sample, multi-label electrocardiogram (ECG) classification method, which solves the problem that existing technologies cannot fully extract ECG features and perform accurate classification.

[0006] According to an embodiment of the present invention, a small-sample multi-label electrocardiogram classification method includes:

[0007] Obtain the support set and query set of electrocardiograms, each of which includes multiple electrocardiogram signals;

[0008] For each ECG signal in the support set and query set, feature extraction is performed at multiple different scales to obtain multiple extracted features corresponding to each ECG signal;

[0009] Global average pooling and global max pooling are performed on each extracted feature to obtain the first descriptor and the second descriptor, respectively. Then, the first descriptor and the second descriptor are input into a shared multilayer perceptron to generate a channel attention weight map.

[0010] The extracted features are modulated using a channel attention weight map to obtain modulated features. Then, the modulated features are subjected to average pooling and max pooling along the channel dimension to obtain the first pooling features and the second pooling features.

[0011] The first pooling feature and the second pooling feature are concatenated to obtain the spatial feature descriptor. Then, the spatial feature descriptor is convolved with a convolution kernel to obtain the spatial attention weight map.

[0012] The modulation features are enhanced using spatial attention weight maps to obtain corresponding enhanced features. Then, all enhanced features are fused across scales to obtain a fused feature map for each ECG signal.

[0013] The fusion feature maps corresponding to the support set are aggregated into class prototypes. Then, the local detail similarity and global distribution similarity between the class prototypes and the fusion feature maps corresponding to the query set are calculated. The local detail similarity and global distribution similarity are weighted and fused to obtain a similarity matrix. The category of each electrocardiogram signal in the query set is determined based on the similarity matrix.

[0014] Preferably, three scales—small scale, medium scale, and large scale—are used to extract features from electrocardiogram signals. In the attention enhancement of the extracted features extracted at small and medium scales, a convolution kernel of the same scale as the extracted features is used to convolve the spatial feature descriptors corresponding to the extracted features.

[0015] In the attention enhancement of the extracted features extracted at a large scale, a convolution kernel of the same scale as the extracted features is used to perform convolution processing on the spatial feature descriptors corresponding to the extracted features with a preset stride.

[0016] Preferably, in the attention enhancement of the extracted features extracted at a large scale, after obtaining the spatial attention weight map, the spatial attention weight map is restored to the same length as the extracted features by bilinear interpolation, and then the restored spatial attention weight map is used to enhance the modulated features to obtain the corresponding enhanced features.

[0017] Preferably, the method for fusing all enhancement features across scales to obtain the fused features corresponding to each electrocardiogram signal includes:

[0018] The augmented features corresponding to the three different scales are dimensionally aligned, and the mean cosine similarity between each augmented feature and augmented features of other different scales is calculated.

[0019] The Softmax function is used to normalize the inverse of the mean cosine similarity to obtain the fusion weight. Then, based on the fusion weight, all enhanced features are concatenated to obtain the concatenated features.

[0020] Attention enhancement is applied to the spliced ​​features to obtain the fused feature map.

[0021] Preferably, each electrocardiogram signal in the support set has a corresponding classification label;

[0022] Methods for aggregating the fused feature maps corresponding to support sets into class prototypes include:

[0023] All fused feature maps are converted into one-dimensional high-dimensional vectors to obtain multiple sample flattened feature vectors.

[0024] Based on the classification labels, the flattened feature vectors of the samples are classified to obtain multiple feature classes;

[0025] For each feature class, a weighted average aggregation of all flattened feature vectors is performed to obtain the class prototype corresponding to that feature class.

[0026] Preferably, the method for calculating the local detail similarity and global distribution similarity between the fused feature maps corresponding to the class prototype and the query set, and then weighting and fusing the local detail similarity and global distribution similarity to obtain the similarity matrix includes:

[0027] Project the fused feature maps corresponding to all class prototypes and query sets onto the same low-dimensional space to obtain the corresponding projected class prototype set and projected query set feature vector;

[0028] Calculate the local detail similarity and global distribution similarity between the feature vectors of the projection class prototype set and the projection query set;

[0029] The local detail similarity and global distribution similarity are concatenated to obtain a similarity feature vector. Then, the similarity feature vector is input into a two-layer fully connected network to generate the corresponding importance.

[0030] The importance is normalized using the Softmax function to obtain the weight coefficients corresponding to local detail similarity and global distribution similarity;

[0031] The similarity matrix is ​​obtained by weighting and fusing local detail similarity, global distribution similarity, and corresponding weight coefficients.

[0032] Preferably, the projection query set feature vector includes multiple projection query set features, and the projection class prototype set includes multiple projection class prototypes;

[0033] The method for calculating local detail similarity is as follows:

[0034] Perform one-to-one matching between all projection query set features and all projection class prototypes to obtain multiple metric pairs;

[0035] For each metric pair, calculate the variance between the projected query set features and the projected class prototype for each dimension, and assign corresponding local weights to each dimension based on the variance;

[0036] The local weights corresponding to all dimensions are combined into a local weight diagonal matrix, and then the local detail similarity of the metric pair is calculated based on the local weight diagonal matrix.

[0037] Preferably, the method for calculating global distribution similarity is as follows:

[0038] For each projection query set feature in the projection query set feature vector, construct the corresponding local neighborhood feature set; for each projection class prototype in the projection class prototype set, construct the corresponding inter-class neighborhood set.

[0039] Calculate the global statistical features of all local neighborhood feature sets to obtain local statistical features. Calculate the global statistical features of all inter-class neighborhood sets to obtain inter-class statistical features. Then map all local neighborhood feature sets, all inter-class neighborhood sets, local statistical features, and inter-class statistical features to a high-dimensional kernel space to obtain the corresponding local feature kernel mapping, local statistical kernel mapping, inter-class kernel mapping, and inter-class statistical kernel mapping.

[0040] Calculate the neighborhood kernel distance between the local feature kernel mapping and the inter-class kernel mapping, as well as the statistical kernel distance between the local statistical kernel mapping and the inter-class statistical kernel mapping. Then, weight the neighborhood kernel distance and the statistical kernel distance to obtain the fused kernel distance.

[0041] The global distribution similarity is obtained by normalizing the fusion kernel distance using the sigmoid function.

[0042] Preferably, the method for determining the category of each electrocardiogram signal in the query set based on the similarity matrix includes:

[0043] The similarity matrix is ​​split into multiple row matrices. Then, the Sigmoid function is applied to each row matrix to obtain multiple category probability distributions. Each category probability distribution corresponds to an electrocardiogram signal in the query set.

[0044] Then, the electrocardiogram signals are classified according to the classification labels of the class prototypes corresponding to the elements in the probability distribution that are greater than the preset value.

[0045] Compared with the prior art, the present invention has the following beneficial effects:

[0046] This invention takes ECG signals from both the support set and the query set as input. Through attention enhancement at different scales and adaptive fusion, it generates a high-dimensional fusion feature map that combines fine-grained details and global temporal patterns, fully extracting ECG features. Then, through a prototype generation mechanism, the fusion feature map of the support set is aggregated into a class prototype, which serves as a benchmark for similarity matching. Finally, the similarity between the fusion feature map of the query set and the class prototype is calculated at both the local feature level and the global set level. Through dynamic weight fusion, a more accurate classification result is output. Attached Figure Description

[0047] Figure 1 This is a diagram illustrating a small-sample, multi-label electrocardiogram classification method according to an embodiment of the present invention. Detailed Implementation

[0048] The technical solutions of the present invention will be further described below with reference to the accompanying drawings and embodiments.

[0049] like Figure 1 As shown in the figure, this invention proposes a small-sample multi-label electrocardiogram classification method, including:

[0050] Obtain the support set and query set of electrocardiograms, each of which includes multiple electrocardiogram signals;

[0051] This invention constructs a CSHM-Net model for feature extraction and classification. The overall architecture of the CSHM-Net model follows a few-shot learning paradigm of "feature extraction - prototype construction - metric classification," including a cross-scale feature extraction module (CSFEM), a class prototype generation module (ProtoGen), and a hybrid metric fusion learning module (HMFLM). The core logic is as follows: ECG signals from the support set and the query set are simultaneously input into the cross-scale feature extraction module (CSFEM). Through scale-based attention enhancement and adaptive fusion, a high-dimensional fused feature map with both fine-grained details and global temporal patterns is generated. Then, the class prototype generation module (ProtoGen) aggregates the fused feature map of the support set into a class-level prototype, which serves as the benchmark for similarity matching. Finally, the hybrid metric fusion learning module (HMFLM) calculates the similarity at the local feature level and the global set level, respectively, and outputs the final classification result through dynamic weight fusion.

[0052] First, obtain the support set and query set of the electrocardiogram (ECG). Let the support set be... ,in For the first kind( The support set consists of subsets of samples, each containing multiple ECG signals with the same classification label. Different subsets of the support set have different classification labels. The dimension is ( That is, a single-channel electrocardiogram signal. (for signal length); query set is Each electrocardiogram signal The dimensions are consistent with the support set samples. The ECG signals in the query set are ECG signals that need to be classified, so they do not have classification labels.

[0053] For each ECG signal in the support set and query set, feature extraction is performed at multiple different scales to obtain multiple extracted features corresponding to each ECG signal;

[0054] The cross-scale feature extraction module (CSFEM) in the CSHM-Net model aims to address the problem that single-scale features cannot simultaneously capture both fine-grained ECG morphology (such as ST segment deviation and T wave morphology) and global temporal patterns (such as arrhythmia cycles and RR interval sequences). Through a four-level structure of "segmented feature extraction - single-scale attention enhancement - cross-scale adaptive fusion - global attention optimization", it achieves a comprehensive improvement in feature comprehensiveness and discriminativeness.

[0055] First, n parallel convolutional branches are designed. In this invention, m=3 is used as an example (the number of branches can be adjusted according to the actual scenario in actual use). They are defined as small scale, medium scale and large scale respectively. Each branch uses a 1D convolutional kernel of different size. By expanding the receptive field range, it adapts to physiological features of different scales.

[0056] ① Branch 1 (small-scale branch, fine-grained branch): uses small-sized convolution kernels. Step length ,filling It focuses on capturing local waveform details of the electrocardiogram (ST segment deviation, internal morphology of QRS complex).

[0057] ②Branch 2 (Medium-scale branch): Uses a medium-sized convolution kernel Step length ,filling Capture the temporal characteristics of a medium span (the association between a single QRS complex and adjacent T waves).

[0058] ③ Branch 3 (Large-scale branch, global-scale branch): Uses large-size convolutional kernels Step length ,filling Capture long-term time patterns (arrhythmia cycles, RR interval sequence changes).

[0059] The convolution operation formula for each branch is as follows:

[0060] ( )

[0061] Where X represents the raw features (dimension 1) of all electrocardiogram signals in the support set and query set. ,in For batch size, Input the number of channels. (signal length) This is a 1D convolution operation. For the first Convolution kernel parameters for each branch (dimensions) ), For the first The bias parameters of each branch To pad the size, ensure that the length of the feature map after convolution is the same as the length of the input signal. The GELU activation function is given by the formula: ( (where is the cumulative distribution function of the standard normal distribution), used to introduce nonlinearity and alleviate the gradient vanishing problem. For the first Extraction features of each scale branch ( ).

[0062] 25. Attention enhancement is performed on each extracted feature to obtain the corresponding enhanced feature. Then, all enhanced features are fused across scales to obtain the fused feature map corresponding to each ECG signal.

[0063] Each scale branch is configured with an independent attention enhancement unit (based on an improved CBAM design), containing channel attention subunits and spatial attention subunits, and performing element-wise optimization of the extracted features in the order of "channel modulation-spatial modulation". The parameter settings differ according to the characteristics of features at different scales, as follows:

[0064] 1. Small-scale branching ( (Focusing on local waveform details)

[0065] Small-scale feature extraction requires precise capture of local details such as ST segment shifts and QRS group internal morphology. Therefore, the attention module parameter settings focus more on "local sensitivity" to enhance the ability to filter subtle features.

[0066] (1) Channel attention calculation:

[0067] Feature maps extracted from small-scale branches Global average pooling (GAP) and global max pooling (GMP) are performed respectively to obtain two channel-level first descriptors. Second descriptor The importance weights of learning channels are achieved by sharing a multilayer perceptron (MLP):

[0068]

[0069]

[0070]

[0071] in The first layer output dimension is (Higher than other scales, improving channel discrimination), the activation function is Leaky ReLU (negative slope 0.01, preserving more local detail information); The sigmoid function outputs a channel attention weight map. .

[0072] (2) Spatial attention calculation:

[0073] Modulated features are obtained by modulating the extracted features using a channel attention weight map. Then, the modulation features are subjected to average pooling and max pooling along the channel dimension of the modulation features to obtain the first pooled features. Second pooling features The spatial feature descriptor is obtained by concatenating the first pooling feature and the second pooling feature. Then, local spatial dependency capture is enhanced by using small-sized convolutional kernels:

[0074]

[0075]

[0076]

[0077]

[0078]

[0079] in For spatial attention convolution kernels, For bias; This is a spatial attention weight map.

[0080] (3) Single-scale feature enhancement output:

[0081]

[0082] 2. Mesoscale branch ( (Focusing on medium-span time correlations)

[0083] Similarly, feature extraction at the mesoscale needs to balance local details and temporal relevance. Parameter settings should focus on "balanced perception," taking into account both the local discriminability and temporal continuity of features.

[0084] (1) Channel attention calculation:

[0085]

[0086]

[0087]

[0088] in The first layer output dimension is (Default settings) The activation function is ReLU; This is a channel attention weight map at a mesoscale.

[0089] (2) Spatial attention calculation:

[0090] Using medium-sized convolutional kernels to balance local and mid-range spatial dependencies:

[0091]

[0092]

[0093]

[0094]

[0095]

[0096] in For spatial attention convolution kernels, For bias; This is a spatial attention weight map.

[0097] (3) Single-scale feature enhancement output:

[0098]

[0099] 3. Large-scale, global-scale branches ( (Focusing on long-term time patterns)

[0100] Similarly, feature extraction at a large scale needs to capture long-term patterns such as RR interval sequences and arrhythmia cycles. Parameter settings should focus on "global smoothness," weakening local noise interference and strengthening long-term dependence.

[0101] (1) Channel attention calculation:

[0102]

[0103]

[0104]

[0105] in The first layer output dimension is (Lower than other scales, reducing channel dimension redundancy), the activation function is ReLU (smooth activation property); This is a large-scale channel attention weight map.

[0106] (2) Spatial attention calculation:

[0107] By using large-size convolutional kernels and strides, the receptive field is expanded to capture long-term spatial dependencies:

[0108]

[0109]

[0110]

[0111]

[0112]

[0113] in For spatial attention convolution kernels, stride , For bias; This is a spatial attention weight map.

[0114] (3) Single-scale feature enhancement output:

[0115] The spatial attention weight map is restored to the same length as the extracted features using bilinear interpolation. Then perform element-by-element modulation:

[0116]

[0117]

[0118] In summary, each ECG signal in the support set and query set can yield corresponding enhanced features at three scales through the feature extraction described above. , and .

[0119] Since the semantic granularity of enhanced features at different scales differs, direct splicing can lead to feature redundancy or the burying of effective information. This invention automatically learns the fusion weights through the correlation of the features themselves, and achieves adaptive fusion through three steps: "dimensional alignment - similarity modeling - dynamic weight fusion".

[0120] 1. Dimension alignment (solving the issue of feature dimension consistency):

[0121] Despite the length of the enhancement features at each scale and number of channels They are consistent, but their semantic spaces are different, so they need to be mapped to a unified feature space through linear transformation:

[0122]

[0123] in For linear transformation weights, For bias (dimension) ), This is the aligned feature map.

[0124] 2. Cross-scale similarity modeling (measuring the complementarity of features at different scales):

[0125] Calculate the cosine similarity between the augmented features at each scale and the augmented features at all other scales, then calculate the mean of all cosine similarities to obtain the average cosine similarity, which serves as the "complementarity index" of the augmented features at that scale.

[0126]

[0127]

[0128] in: The smaller the value, the stronger the complementarity between the scale feature and other scale features, and the higher the weight should be given in the fusion.

[0129] 3. Dynamic weight allocation (adaptive fusion based on complementary indicators):

[0130] The fusion weights of the enhanced features at each scale are obtained by normalizing the inverse of the mean cosine phase velocity (complementarity index) using the Softmax function:

[0131]

[0132] Then, all enhanced features will be weighted:

[0133]

[0134] in For the weighted number of Scale characteristics For channel-level splicing operations, output splicing features. .

[0135] The present invention then focuses on splicing features. Attention enhancement is performed to further suppress redundant information remaining after cross-scale fusion and strengthen the global discriminative features that are key to multi-label classification (such as feature association patterns when multiple types of arrhythmias coexist). The attention enhancement at this time adopts a two-level optimization structure of "channel attention-spatial attention". The difference from the previous single-scale attention enhancement is that global attention is learned based on the global features after cross-scale fusion, focusing on the overall discriminativeness after multi-scale information fusion, rather than local features within a single scale.

[0136] 1. Global channel attention calculation:

[0137]

[0138]

[0139]

[0140] in The first layer output dimension is The second layer output dimension is , This is a global channel attention weight map.

[0141] 2. Global Spatial Attention Calculation:

[0142]

[0143]

[0144]

[0145]

[0146]

[0147] in For global spatial attention convolution kernels, For bias, This is the global spatial attention weight map.

[0148] 3. Global attention enhances output:

[0149]

[0150] Finally, the fused feature map is obtained. .

[0151] The fusion feature maps corresponding to the support set are aggregated into class prototypes. Then, the similarity matrix between the class prototypes and the fusion feature maps corresponding to the query set is calculated, and the category of each ECG signal in the query set is determined based on the similarity matrix.

[0152] Since each ECG signal in the support set has a corresponding classification label, the fusion feature map corresponding to each ECG signal in the support set also has the same classification label. This invention aggregates the fusion feature maps corresponding to the ECG signals in the support set into class-level prototypes to construct a "reference benchmark" for small sample classification, thereby solving the problems of randomness and outlier interference of individual sample features in small sample scenarios and improving the stability and reliability of metric matching.

[0153] In few-shot learning, the support set contains only a small number of samples per class, and the features of a single sample may not represent the true feature distribution of that class due to noise, individual differences, and other factors. By generating prototypes and aggregating the features of samples of the same class, the influence of individual outliers can be weakened, forming a more representative class-level feature benchmark (prototype). This allows subsequent similarity calculations to be based on matching "classes and samples" rather than matching "samples," significantly improving the model's generalization ability and classification stability.

[0154] 1. Feature flattening

[0155] This invention will support a set of fused feature maps corresponding to all ECG signals in a centralized manner. An ordered flattening operation is used to fuse the feature maps. (i.e., set) The channel and time dimensions of the b-th fused feature map are expanded into a one-dimensional vector in a "channel-first" order, generating the corresponding sample flattened feature vector. To ensure that the spatial structure and temporal order of features are not disrupted:

[0156]

[0157] in: This is a flattening operation function. For dimension reshaping operations, the output vector is... Each element corresponds to a feature value at a location in the fused feature map.

[0158] 2. Class Prototype Aggregation

[0159] Since each ECG signal in the dataset has a corresponding classification label, the flattened feature vectors of the samples are classified into multiple feature classes based on the classification labels. For the feature class composed of the k-th class of flattened feature vectors... The "weighted average aggregation" strategy is adopted, and the specific steps are as follows:

[0160] (1) Calculation of sample confidence:

[0161] Calculate the mean cosine similarity between each flattened feature vector and other flattened feature vectors of the same class, and use this as the confidence score for the sample. A higher similarity score indicates a higher confidence score, meaning the sample better reflects the class features.

[0162]

[0163] in , for the first The confidence level of each sample.

[0164] (2) Confidence normalization:

[0165] Softmax normalization is applied to the confidence scores of samples within the same category to obtain the aggregate weight for each sample:

[0166]

[0167] in Ensure that the sum of the weights is 1.

[0168] (3) Class prototype weighted aggregation:

[0169]

[0170] in For the first The class prototype of the flattened feature vector (the kth feature class) aggregates the common features of samples of the same class through weighted averaging, thus weakening the interference of low-confidence samples.

[0171] To address the rigidity of existing single-measure models, this invention employs a dual-granularity design that fuses local feature measurements with global set measurements. This captures both the "local detail matching of the query set's sample features with the class prototype" and the "global distribution matching of the query set's sample feature set with the class prototype set," respectively. Finally, the similarity is obtained through dynamic weight fusion, achieving accurate classification in multi-label scenarios.

[0172] 1. Dimensional Adjustment

[0173] By projecting the fused feature map corresponding to the ECG signal of the query set and the class prototype onto the same low-dimensional quantity space, the problem of inaccurate measurement caused by the curse of high-dimensional feature dimensions is solved, and the feature dimensions are unified for subsequent calculations.

[0174] This invention employs a task-specific learnable affine transformation to map high-dimensional feature vectors to a low-dimensional target space. During the mapping process, the inter-class separability is maximized by optimizing the target.

[0175] (1) Flattening and projection of the fused feature map of the query set:

[0176] First, the fused feature map of the query set is flattened:

[0177]

[0178] in For the query set A fused feature map, This is the m-th flattened fused feature map.

[0179] Then, it is projected onto the target dimension through an affine transformation:

[0180]

[0181] in The projection weight matrix is... Let be the projection bias vector. This is the m-th projected query set feature after projection. Then, all projected query set features are combined into a projected query set feature vector.

[0182] (2) Class prototype projection:

[0183] Perform the same affine transformation on the class prototypes corresponding to all feature classes:

[0184]

[0185] in This is the prototype of the projection class after projection, and then all projection class prototypes are combined into a projection class prototype set.

[0186] (3) Projection optimization objective:

[0187] In the fused feature map of the query set and the class prototype projection, the projection parameters and The optimization objective is to maximize the separation of prototypes between classes, and the loss function is defined as follows:

[0188]

[0189] By minimizing this loss function, we can ensure that the projected class prototypes have good separability in the metric space.

[0190] 2. Local Feature Measurement

[0191] Calculate the local detail similarity between the feature vector of the projection query set and the prototype vector of the projection class, focusing on the local element correspondence of the feature vectors, and reflecting the "relationship between features".

[0192] This invention employs an improved cosine similarity method, introducing a local feature weighting factor to highlight the contribution of local discriminative features. Specific steps include:

[0193] (1) Calculation of local feature weights:

[0194] One of the projection query set features in the projection query set feature vector and a class prototype in the projection class prototype set. These are combined into a single metric pair, from which multiple metric pairs can be obtained. For each metric pair, the projected query set features are... and class prototype Calculate the projected query set features for each dimension. With class prototype The larger the variance, the stronger the feature discrimination in that dimension, and thus the higher its weight.

[0195]

[0196]

[0197] in For the projection query set feature number The variance of the dimension, For the first Local weights of dimension ( ).

[0198] (2) Calculation of local detail similarity:

[0199]

[0200] in The local weight diagonal matrix is ​​a combination of local weights across all dimensions. This is for inner product operations.

[0201] Local detail similarity can be understood as the similarity between each projection query set feature and each projection class prototype. This similarity focuses on the corresponding matching of each local dimension of the feature vector, reflecting the relationship between "parts".

[0202] 3. Global Feature Measurement

[0203] Global feature metrics are used to calculate the global distribution similarity between the feature vectors of the projected query set and the prototype set of the projected classes. They focus on the overall distribution pattern of features, reflecting the "relationship between feature sets", and complement local feature metrics.

[0204] This invention employs a complex process of "feature distribution modeling - global statistical fusion - kernelized metric learning," which differs from local point-to-point matching. The global metric focuses more on the consistency of the overall distribution. The specific steps are as follows:

[0205] (1) Modeling the local feature distribution of the query set

[0206] For the For each projection query set feature, construct its local neighborhood feature set, which includes itself, the query set, and the feature set most similar to itself. Features of a projection query set This is a hyperparameter that captures the local distribution of the projected query set features within the query set.

[0207]

[0208] in For the first Local neighborhood feature set of each projection query set feature.

[0209] (2) Local distribution modeling of class prototypes

[0210] For the For each projection class prototype, construct its inter-class neighborhood set, which includes itself and the class most similar to itself. Other class prototypes, capturing the local distribution of that class prototype across all classes:

[0211]

[0212] in For the first The inter-class neighborhood set of each class prototype.

[0213] (3) Global statistical feature extraction

[0214] Each local neighborhood feature set Inter-class neighborhood set The global statistical characteristics, including the mean, variance, trace of the covariance matrix, maximum eigenvalue, and minimum eigenvalue, form a statistical feature vector:

[0215] Neighborhood mean: , ;

[0216] Neighborhood variance: , ;

[0217] Covariance: , ,in It is the covariance matrix;

[0218] Maximum / Minimum Eigenvalues: , , , ;

[0219] Statistical feature vector concatenation: local statistical features Inter-class statistical characteristics .

[0220] (3) Distribution kernel function mapping

[0221] All local neighborhood feature sets All inter-class neighborhood sets Local and inter-class statistical features are mapped to a high-dimensional kernel space to enhance the distinguishability of distribution differences. A combination kernel function of Gaussian and polynomial kernels is used.

[0222] Local feature kernel mapping: ,in , , These are the hyperparameters of the kernel function;

[0223] Local statistical kernel mapping: ,in To find the mean of the statistical feature vectors of all samples in the query set, , , For hyperparameters;

[0224] Performing the same kernel mapping on the class prototype side yields inter-class kernel mappings. Inter-class statistical kernel mapping .

[0225] (4) Calculation of nuclear spatial distance

[0226] The neighborhood kernel distance between local feature kernel maps and inter-class kernel maps, as well as the statistical kernel distance between local statistical kernel maps and inter-class statistical kernel maps, are calculated using weighted Euclidean distance.

[0227] Neighborhood kernel distance: ,in The weights are based on distance; samples from the nearest neighbor have a higher weight.

[0228] Statistical kernel distance: .

[0229] We obtain the fused kernel distance by weighting and fusing the neighborhood kernel distance and the statistical kernel distance: ,in This is the balance coefficient.

[0230] (4) Global similarity normalization

[0231] The fusion kernel distance is normalized to a value using the sigmoid function. Interval:

[0232]

[0233] in This is the distance sensitivity coefficient. This is the offset. This is the sigmoid function. This similarity score focuses on the overall distribution matching of the feature set, reflecting the relationship between "wholes".

[0234] 4. Dynamic weight fusion

[0235] Based on the complementarity of local detail similarity and global distribution similarity, the fusion weights are adaptively learned to ensure that the fused similarity score can take into account the matching information of both local details and global distribution.

[0236] The learning of fusion weights is based on "feature property adaptability": local detail similarity reflects the degree of matching of fine-grained features and is sensitive to local pathological features of ECG (such as ST segment deviation); global distribution similarity reflects the degree of matching of the overall distribution and is sensitive to global patterns with multiple labels coexisting. The weight coefficients of both are automatically learned through an attention mechanism. Specific steps include:

[0237] (1) Similarity feature extraction:

[0238] For projection query set features and class prototype The corresponding local detail similarity Similarity to global distribution The similarity feature vectors are concatenated and then input into a two-layer fully connected network to learn their importance.

[0239]

[0240]

[0241]

[0242] in , , , These are parameters for a fully connected network.

[0243] (2) Dynamic weight generation:

[0244] The three importance metrics mentioned above are normalized using the Softmax function to obtain the fusion weights for local detail similarity and global distribution similarity:

[0245]

[0246]

[0247] in The weighting coefficients are adaptively generated based on the properties of the similarity features; for example, when local similarity has higher discriminative power, It increases automatically.

[0248] Final similarity fusion:

[0249]

[0250] Among them, due to the characteristics of the projection query set Points to the m-th electrocardiogram signal in the query set, class prototype It points to the classification label of the k-th type of ECG signal in the support set, therefore This can be interpreted as the similarity between the m-th ECG signal in the query set and the k-th type of ECG signal in the support set. Then, for each ECG signal in the query set, the similarity between it and each type of ECG signal in the support set can be calculated. All similarities are then converted into a similarity matrix. In this matrix, the row labels are the ECG signals in the query set, the column labels are the k-th category labels in the support set, and the element values ​​in the matrix are the similarity scores.

[0251] The similarity matrix is ​​then split into multiple row matrices, each containing only one row label corresponding to an ECG signal in the query set. Therefore, each row matrix represents the similarity between the ECG signal and each class of ECG signals in the support sets. The Sigmoid function is then applied to each row matrix to obtain multiple class probability distribution matrices. Set probability threshold ,when At that time, predict the first The sample belongs to the first The system classifies and outputs the classification label for each ECG sample in the query set, thus completing the classification.

[0252] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

Claims

1. A small-sample, multi-label electrocardiogram classification method, characterized in that: include: Obtain the support set and query set of electrocardiograms, each of which includes multiple electrocardiogram signals; For each ECG signal in the support set and query set, feature extraction is performed at multiple different scales to obtain multiple extracted features corresponding to each ECG signal; Global average pooling and global max pooling are performed on each extracted feature to obtain the first descriptor and the second descriptor, respectively. Then, the first descriptor and the second descriptor are input into a shared multilayer perceptron to generate a channel attention weight map. The extracted features are modulated using a channel attention weight map to obtain modulated features. Then, the modulated features are subjected to average pooling and max pooling along the channel dimension to obtain the first pooling features and the second pooling features. The first pooling feature and the second pooling feature are concatenated to obtain the spatial feature descriptor. Then, the spatial feature descriptor is convolved with a convolution kernel to obtain the spatial attention weight map. The modulation features are enhanced using spatial attention weight maps to obtain corresponding enhanced features. Then, all enhanced features are fused across scales to obtain a fused feature map for each ECG signal. The fusion feature maps corresponding to the support set are aggregated into class prototypes. Then, the local detail similarity and global distribution similarity between the class prototypes and the fusion feature maps corresponding to the query set are calculated. The local detail similarity and global distribution similarity are weighted and fused to obtain a similarity matrix. The category of each electrocardiogram signal in the query set is determined based on the similarity matrix.

2. The small-sample multi-label electrocardiogram classification method as described in claim 1, characterized in that: We used three scales—small-scale, medium-scale, and large-scale—to extract features from electrocardiogram signals. In the attention enhancement of the extracted features at the small and medium scales, we used convolution kernels of the same scale as the extracted features to convolve the spatial feature descriptors corresponding to the extracted features. In the attention enhancement of the extracted features extracted at a large scale, a convolution kernel of the same scale as the extracted features is used to perform convolution processing on the spatial feature descriptors corresponding to the extracted features with a preset stride.

3. The small-sample multi-label electrocardiogram classification method as described in claim 2, characterized in that: In the attention enhancement of the extracted features extracted at a large scale, after obtaining the spatial attention weight map, the spatial attention weight map is restored to the same length as the extracted features through bilinear interpolation. Then, the restored spatial attention weight map is used to enhance the modulated features to obtain the corresponding enhanced features.

4. The small-sample multi-label electrocardiogram classification method as described in claim 2, characterized in that: Methods for fusing all enhancement features across scales to obtain the fused features corresponding to each electrocardiogram signal include: The augmented features corresponding to the three different scales are dimensionally aligned, and the mean cosine similarity between each augmented feature and augmented features of other different scales is calculated. The Softmax function is used to normalize the inverse of the mean cosine similarity to obtain the fusion weight. Then, based on the fusion weight, all enhanced features are concatenated to obtain the concatenated features. Attention enhancement is applied to the spliced ​​features to obtain the fused feature map.

5. The small-sample multi-label electrocardiogram classification method as described in claim 1, characterized in that: Each ECG signal in the support set has a corresponding classification label; Methods for aggregating the fused feature maps corresponding to support sets into class prototypes include: All fused feature maps are converted into one-dimensional high-dimensional vectors to obtain multiple sample flattened feature vectors. Based on the classification labels, the flattened feature vectors of the samples are classified to obtain multiple feature classes; For each feature class, a weighted average aggregation of all flattened feature vectors is performed to obtain the class prototype corresponding to that feature class.

6. The small-sample multi-label electrocardiogram classification method as described in claim 1, characterized in that: Methods for calculating the local detail similarity and global distribution similarity between the fused feature maps corresponding to the class prototype and the query set, and then weighting and fusing the local detail similarity and global distribution similarity to obtain a similarity matrix include: Project the fused feature maps corresponding to all class prototypes and query sets onto the same low-dimensional space to obtain the corresponding projected class prototype set and projected query set feature vector; Calculate the local detail similarity and global distribution similarity between the feature vectors of the projection class prototype set and the projection query set; The local detail similarity and global distribution similarity are concatenated to obtain a similarity feature vector. Then, the similarity feature vector is input into a two-layer fully connected network to generate the corresponding importance. The importance is normalized using the Softmax function to obtain the weight coefficients corresponding to local detail similarity and global distribution similarity; The similarity matrix is ​​obtained by weighting and fusing local detail similarity, global distribution similarity, and corresponding weight coefficients.

7. The small-sample multi-label electrocardiogram classification method as described in claim 6, characterized in that: The projection query set feature vector includes multiple projection query set features, and the projection class prototype set includes multiple projection class prototypes. The method for calculating local detail similarity is as follows: Perform one-to-one matching between all projection query set features and all projection class prototypes to obtain multiple metric pairs; For each metric pair, calculate the variance between the projected query set features and the projected class prototype for each dimension, and assign corresponding local weights to each dimension based on the variance; The local weights corresponding to all dimensions are combined into a local weight diagonal matrix, and then the local detail similarity of the metric pair is calculated based on the local weight diagonal matrix.

8. The small-sample multi-label electrocardiogram classification method as described in claim 6, characterized in that: The method for calculating global distribution similarity is as follows: For each projection query set feature in the projection query set feature vector, construct the corresponding local neighborhood feature set; for each projection class prototype in the projection class prototype set, construct the corresponding inter-class neighborhood set. Calculate the global statistical features of all local neighborhood feature sets to obtain local statistical features. Calculate the global statistical features of all inter-class neighborhood sets to obtain inter-class statistical features. Then map all local neighborhood feature sets, all inter-class neighborhood sets, local statistical features, and inter-class statistical features to a high-dimensional kernel space to obtain the corresponding local feature kernel mapping, local statistical kernel mapping, inter-class kernel mapping, and inter-class statistical kernel mapping. Calculate the neighborhood kernel distance between the local feature kernel mapping and the inter-class kernel mapping, as well as the statistical kernel distance between the local statistical kernel mapping and the inter-class statistical kernel mapping. Then, weight the neighborhood kernel distance and the statistical kernel distance to obtain the fused kernel distance. The global distribution similarity is obtained by normalizing the fusion kernel distance using the sigmoid function.

9. The small-sample multi-label electrocardiogram classification method as described in claim 1, characterized in that: Methods for determining the category of each electrocardiogram signal in the query set based on a similarity matrix include: The similarity matrix is ​​split into multiple row matrices. Then, the Sigmoid function is applied to each row matrix to obtain multiple category probability distributions. Each category probability distribution corresponds to an electrocardiogram signal in the query set. Then, the electrocardiogram signals are classified according to the classification labels of the class prototypes corresponding to the elements in the probability distribution that are greater than the preset value.