We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
← CNNs from Scratch step 3 of 15
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$
Loading visualization…
Nothing accepted yet. When a submission passes, the code that passed shows up
here, one entry per mode.
Stuck?
PyTorch reference solution
Sign in to attempt this problem and reveal the reference solution.