class

AdaptiveMaxPool3d

extendsModule
AdaptiveMaxPool3d(output_size: _Size3d, return_indices: bool = False)
source

Applies adaptive 3-D max pooling to produce a fixed output volume.

Extends AdaptiveMaxPool2d by one depth dimension. For each output voxel (d,h,w)(d, h, w) the maximum is taken over the adaptively-sized 3-D window:

y[n,c,d,h,w]=maxi[ds,de)j[hs,he)k[ws,we)x[n,c,i,j,k]y[n,c,d,h,w] = \max_{\substack{i \in [d_s, d_e) \\ j \in [h_s, h_e) \\ k \in [w_s, w_e)}} x[n,c,i,j,k]

where the window bounds follow the same ratio formula as AdaptiveAvgPool3d.

Parameters

output_sizeint or tuple[int, int, int]
Target (D_out, H_out, W_out). A scalar is broadcast.
return_indicesbool= False
Not yet supported. Default: False.

Attributes

output_sizeint or tuple[int, int, int]

Notes

  • Input: (N, C, D_in, H_in, W_in)
  • Output: (N, C, D_out, H_out, W_out)
  • 3-D adaptive max pooling is useful for video classification models that must handle clips of arbitrary duration.
  • Like all adaptive pooling layers, the variable-sized windows can produce slightly different effective receptive fields per output cell when the input is not evenly divisible.

Examples

Compress volumetric feature map to ``2 × 2 × 2``:
>>> import lucid
>>> import lucid.nn as nn
>>> pool = nn.AdaptiveMaxPool3d(output_size=2)
>>> x = lucid.ones((1, 32, 8, 8, 8))
>>> y = pool(x)
>>> y.shape
(1, 32, 2, 2, 2)
Mixed output sizes (keep depth, compress spatial):
>>> pool = nn.AdaptiveMaxPool3d(output_size=(8, 1, 1))
>>> x = lucid.ones((2, 64, 8, 14, 14))
>>> y = pool(x)
>>> y.shape
(2, 64, 8, 1, 1)

Methods (3)

dunder

__init__

None
__init__(output_size: _Size3d, return_indices: bool = False)
source

Initialise the AdaptiveMaxPool3d module. See the class docstring for parameter semantics.

fn

forward

Tensor
forward(x: Tensor)
source

Apply the pooling operation to the input tensor.

Parameters

inputTensor
Input tensor of shape (N,C,)(N, C, *) where * are the spatial dimensions appropriate for this pooling layer.

Returns

Tensor

Pooled output tensor.

fn

extra_repr

str
extra_repr()
source

Return a string representation of the layer's configuration.