ECG_SUBTRACT_UNET

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

Bases: Module, CkptMixin, SizeMixin

U-Net for ECG wave delineation.

Entry 0433 of CPSC2019, which is a modification of the U-Net using subtraction instead of addition in branched bottom block.

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.

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 signal tensor.

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

Returns:

output_shape – Output shape of the model.

Return type:

sequence

forward(input: Tensor) 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: ndarray | Tensor, bin_pred_thr: float = 0.5) Tensor[source]

Method for making inference on a single input.