medium primitives

Implement Max Pooling 1D

Implement 1D Max Pooling.

Slide a window of size kernel_size along the input with a given stride and take the maximum value in each window.

Input:

  • x: 1D tensor of shape (L,)
  • kernel_size: size of the pooling window (integer)
  • stride: stride of the pooling window (integer)

Output: 1D tensor of shape (L_out,) where $L_{out} = \lfloor \frac{L - \text{kernel\_size}}{\text{stride}} \rfloor + 1$

Hints

pooling cnn basics
Detecting runtime...