mlx.nn.MaxPool3d#
- class MaxPool3d(kernel_size: int | Tuple[int, int, int], stride: int | Tuple[int, int, int] | None = None, padding: int | Tuple[int, int, int] | None = 0)#
Applies 3-dimensional max pooling.
Spatially downsamples the input by taking the maximum of a sliding window of size
kernel_size
and sliding stridestride
.The parameters
kernel_size
,stride
, andpadding
can either be:a single
int
– in which case the same value is used for the depth, height, and width axis.a
tuple
of threeint
s – in which case, the firstint
is used for the depth axis, the secondint
for the height axis, and the thirdint
for the width axis.
- Parameters:
kernel_size (int or tuple(int, int, int)) – The size of the pooling window.
stride (int or tuple(int, int, int), optional) – The stride of the pooling window. Default:
kernel_size
.padding (int or tuple(int, int, int), optional) – How much negative infinity padding to apply to the input. The padding is applied on both sides of the depth, height and width axis. Default:
0
.
Examples
>>> import mlx.core as mx >>> import mlx.nn.layers as nn >>> x = mx.random.normal(shape=(8, 16, 32, 32, 4)) >>> pool = nn.MaxPool3d(kernel_size=2, stride=2) >>> pool(x)
Methods