Shortcuts

MaxPool1d

class continual.MaxPool1d(kernel_size, stride=None, padding=0, dilation=1, ceil_mode=False, temporal_fill='neg_inf')[source]

Applies a Continual 1D max pooling over an input signal.

In the simplest case, the output value of the layer with input size (N,C,T)(N, C, T) and output (N,C,Tout)(N, C, T_{out}) can be precisely described as:

out(Ni,Cj,k)=maxm=0,,kernel_size1input(Ni,Cj,stride×k+m)out(N_i, C_j, k) = \max_{m=0, \ldots, \text{kernel\_size} - 1} input(N_i, C_j, stride \times k + m)

If padding is non-zero, then the input is implicitly padded with negative infinity on both sides for padding number of points. dilation is the stride between the elements within the sliding window. This link has a nice visualization of the pooling parameters.

Note

When stride > 1, the forward_step will only produce non-None values every stride steps.

Note

When ceil_mode=True, sliding windows are allowed to go off-bounds if they start within the left padding or the input. Sliding windows that would start in the right padded region are ignored.

Parameters:
  • kernel_size (Union[int, Tuple[int]]) – The size of the sliding window, must be > 0.

  • stride (Union[int, Tuple[int]]) – The stride of the sliding window, must be > 0. Default value is kernel_size.

  • padding (Union[int, Tuple[int]]) – Implicit negative infinity padding to be added on both sides, must be >= 0 and <= kernel_size / 2.

  • dilation (Union[int, Tuple[int]]) – The stride between elements within a sliding window, must be > 0.

  • ceil_mode (bool) – If True, will use ceil instead of floor to compute the output shape. This ensures that every element in the input tensor is covered by a sliding window.

  • temporal_fill (PaddingMode) – How temporal states are initialized.

Shape:
  • Input: (N,C,Tin)(N, C, T_{in}).

  • Output: (N,C,Tout)(N, C, T_{out}), where

    Tout=Lin+2×paddingdilation×(kernel_size1)1stride+1T_{out} = \left\lfloor \frac{L_{in} + 2 \times \text{padding} - \text{dilation} \times (\text{kernel\_size} - 1) - 1}{\text{stride}} + 1\right\rfloor

Examples:

m = co.MaxPool1d(kernel_size=3, dilation=2)
x = torch.randn(20, 16, 50)
assert torch.allclose(m.forward(x), m.forward_steps(x))
Read the Docs v: latest
Versions
latest
stable
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.