torch_ecg.models#
This module contains the model architectures for ECG various tasks.
Convolutional neural backbones#
|
ResNet model. |
|
RegNet model. |
|
CNN feature extractor of VGG architecture. |
|
Xception model. |
|
The core part of the SOTA model (framework) of CPSC2020. |
|
MobileNet V1. |
|
MobileNet V2. |
|
MobileNet V3. |
|
CNN part of the SOTA model from CPSC2019 challenge (entry 0416). |
Downstream task models#
|
U-Net for (multi-lead) ECG wave delineation. |
|
U-Net for ECG wave delineation. |
|
Convolutional (Recurrent) Neural Network for ECG tasks. |
|
SOTA model from CPSC2019 challenge. |
|
LSTM model for RR time series classification or sequence labeling. |
Saliency analysis#
|
Gradient-weighted Class Activation Mapping for ECG models. |
Transformer backbones#
|
Transformer feature extractor. |
Registries#
torch_ecg.model_configs#
Ready-made configurations for the model architectures and their building
blocks. A config is a plain CFG; pick one, adapt
it, and pass it to the model constructor together with n_leads /
n_classes (see the tutorial):
>>> from torch_ecg.model_configs import ECG_CRNN_CONFIG
>>> from torch_ecg.models import ECG_CRNN
>>> config = ECG_CRNN_CONFIG.copy()
>>> config.cnn.name = "resnet_block_leadwise"
>>> model = ECG_CRNN(config, n_leads=12, n_classes=26)
Full model configs#
Each top-level *_CONFIG collects the complete specification of one
architecture family (fs, cnn, rnn, attn, clf, …);
its cnn / rnn / attn entries accept any of the building
blocks catalogued below.
CNN building blocks (cnn submodule)#
Grouped by family; *_leadwise variants use lead-wise (per-lead)
convolutions adapted to 12-lead ECG, *_gc / *_nl / *_se
suffixes add global-context / non-local / squeeze-and-excitation
attention to the block.
VGG family:
vgg16,vgg16_leadwise,vgg_block_basic,vgg_block_mish,vgg_block_swishvanilla ResNet:
resnet_vanilla_18/34/50/101/152, wide variantsresnet_vanilla_wide_50_2,resnet_vanilla_wide_101_2, blocksresnet_block_basic,resnet_bottle_neckCPSC2018-style ResNet (small, contest-proven):
resnet_cpsc2018,resnet_cpsc2018_leadwise, blockscpsc_block_basic/mish/swish,cpsc_2018,cpsc_2018_leadwisescaled ResNet (He et al.):
resnetN,resnetNB,resnetNS,resnetNBS, bottle-neck variantsresnet_bottle_neck_B/Dstanford ResNet:
resnet_stanford,resnet_block_stanfordResNet Nature Communications (Moskalenko et al.):
resnet_nature_comm+_bottle_neckand_gc/_nl/_sevariantsTResNet (together with the block configs above):
tresnetN/S/M/L/P/F/XL,tresnetM_V2DenseNet:
densenet_vanilla,densenet_leadwiseXception:
xception_vanilla,xception_leadwiseMobileNet:
mobilenet_1_vanilla,mobilenet_2_vanilla,mobilenet_3_smallMultiScopicCNN (CPSC2019 winner):
multi_scopic,multi_scopic_block,multi_scopic_leadwiseResNeXt:
resnext_vanilla_50_32x4d,resnext_vanilla_101_32x8d
Attention modules (attn submodule)#
Usable as the attn entry of the CRNN-family configs:
squeeze_excitation(SE),global_context(GC),non_local(NL)transformer– multi-head self-attention (transformer_encoderstyle heads)
RNN configs (rnn submodule)#
lstm– bidirectional LSTM used after the CNN feature extractorlinear– non-recurrent (linear) alternative
MLP / heads (mlp submodule)#
linear– plain linear headmlp– multi-layer perceptron classification head (with optionaldropout)
Notes
cnn.name selects a backbone (family name or full config name), e.g.
to switch the CRNN backbone to the SE-enhanced Nature-Communications
ResNet (the default of the cinc2021 benchmark):
config.cnn.name = "resnet_nature_comm_bottle_neck_se"
Concrete end-to-end usages are linked from the examples (the benchmarks select and adapt these configs).