ECG_UNET

class torch_ecg.models.ECG_UNET(classes: Sequence[str], n_leads: int, config: Optional[torch_ecg.cfg.CFG] = None)[source]

Bases: torch.nn.modules.module.Module, torch_ecg.utils.utils_nn.CkptMixin, torch_ecg.utils.utils_nn.SizeMixin, torch_ecg.utils.misc.CitationMixin

U-Net for (multi-lead) ECG wave delineation.

The U-Net is a fully convolutional network originally proposed for biomedical image segmentation 1. This architecture is applied to ECG wave delineation in 2. This implementation is based on an open-source implementation on GitHub 3.

Parameters
  • classes (Sequence[str]) – List of names of the classes.

  • n_leads (int) – Number of input leads (number of input channels).

  • config (CFG, optional,) – Other hyper-parameters, including kernel sizes, etc. Refer to the corresponding config file.

References

1

Ronneberger, Olaf, Philipp Fischer, and Thomas Brox. “U-net: Convolutional networks for biomedical image segmentation.” International Conference on Medical image computing and computer-assisted intervention. Springer, 2015.

2

Moskalenko, Viktor, Nikolai Zolotykh, and Grigory Osipov. “Deep Learning for ECG Segmentation.” International Conference on Neuroinformatics. Springer, Cham, 2019.

3

https://github.com/milesial/Pytorch-UNet/

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

Compute the output shape of the model.

Parameters
  • seq_len (int, optional) – The length of the input signal tensor.

  • batch_size (int, optional) – The batch size of the input signal tensor.

Returns

output_shape – The output shape of the model.

Return type

sequence

forward(input: torch.Tensor) torch.Tensor[source]

Forward pass of the model.

Parameters

input (torch.Tensor) – Input signal tensor, of shape (batch_size, n_channels, seq_len).

Returns

output – Output tensor, of shape (batch_size, n_channels, seq_len).

Return type

torch.Tensor

inference(input: torch.Tensor, bin_pred_thr: float = 0.5) torch.Tensor[source]

Method for making inference on a single input.