ResNet

class torch_ecg.models.ResNet(in_channels: int, **config)[source]

Bases: Sequential, SizeMixin, CitationMixin

ResNet model.

The ResNet model is used for ECG classification by a team from the Stanford University [1], from which the application of deep learning to ECG analysis becomes more widely known and accepted.

This implementation bases much on the torchvision implementation [2], although which is for image tasks.

Parameters:
  • in_channels (int) – Number of channels in the input signal tensor.

  • config (dict) –

    Hyper-parameters of the Module, ref. corr. config file. keyword arguments that must be set:

    • bias: bool, if True, each convolution will have a bias term.

    • num_blocks: sequence of int, number of building blocks in each macro block.

    • filter_lengths: int or sequence of int or sequence of sequences of int, filter length(s) (kernel size(s)) of the convolutions, with granularity to the whole network, to each macro block, or to each building block.

    • subsample_lengths: int or sequence of int or sequence of sequences of int, subsampling length(s) (ratio(s)) of all blocks, with granularity to the whole network, to each macro block, or to each building block, the former 2 subsample at the first building block.

    • groups: int, connection pattern (of channels) of the inputs and outputs.

    • stem: dict, other parameters that can be set for the input stem.

    • block: dict, other parameters that can be set for the building blocks.

    For a full list of configurable parameters, ref. corr. config file.

References

TODO

  1. Check performances of activations other than ReLU, especially Mish, etc.

  2. Add functionality of replace_stride_with_dilation.

building_block

alias of ResNetBasicBlock

compute_output_shape(seq_len: int | None = None, batch_size: int | None = None) Sequence[int | None][source]

Compute the output shape of the model.

Parameters:
  • seq_len (int, optional) – Length of the input tensors.

  • batch_size (int, optional) – Batch size of the input tensors.

Returns:

output_shape – The output shape of the module.

Return type:

sequence