torch_ecg.utils.compute_output_shape

torch_ecg.utils.compute_output_shape(layer_type: str, input_shape: Sequence[int | None], num_filters: int | None = None, kernel_size: Sequence[int] | int = 1, stride: Sequence[int] | int = 1, padding: Sequence[int] | int = 0, output_padding: Sequence[int] | int = 0, dilation: Sequence[int] | int = 1, channel_last: bool = False, asymmetric_padding: Sequence[int] | Sequence[Sequence[int]] | None = None) Tuple[int | None][source]

Compute the output shape of a (transpose) convolution/maxpool/avgpool layer.

This function is based on the discussion [1].

Parameters:
  • layer_type (str) – Type (conv, maxpool, avgpool, etc.) of the layer.

  • input_shape (Sequence[Union[int, None]]) – Shape of an input Tensor. The first dimension is the batch dimension, which is allowed to be None.

  • num_filters (int, optional) – Number of filters, also the channel dimension.

  • kernel_size (int or Sequence[int], default 1) – Kernel size (filter size) of the layer, should be compatible with input_shape.

  • stride (int or Sequence[int], default 1) – Stride (down-sampling length) of the layer, should be compatible with input_shape.

  • padding (int or Sequence[int], default 0) – Padding length(s) of the layer, should be compatible with input_shape.

  • output_padding (int or Sequence[int], default 0) – Additional size added to one side of the output shape, used only for transpose convolution.

  • dilation (int or Sequence[int], default 1) – Dilation of the layer, should be compatible with input_shape.

  • channel_last (bool, default False) – Whether the channel dimension is the last dimension, or the second dimension (the first is the batch dimension by convention).

  • asymmetric_padding (Sequence[int] or Sequence[Sequence[int]], optional) – (2-)sequence of int or sequence of (2-)sequence of int asymmetric paddings for all dimensions or for each dimension.

Returns:

output_shape – Shape of the output Tensor.

Return type:

tuple

References