Skip to content
class

LPPool3d

extendsModule
LPPool3d(norm_type: float, kernel_size: int | tuple[int, int, int], stride: int | tuple[int, int, int] | None = None, ceil_mode: bool = False)

Applies 3-D power-average (Lp-norm) pooling over a volumetric input.

Extends LPPool2d to three spatial dimensions. For each kD×kH×kWk_D \times k_H \times k_W window:

y[n,c,d,h,w]=(∑kd∑kh∑kwx ⁣[n,c, d⋅sD+kd, h⋅sH+kh, w⋅sW+kw]p)1/py[n,c,d,h,w] = \left( \sum_{k_d}\sum_{k_h}\sum_{k_w} x\!\left[n,c,\, d \cdot s_D + k_d,\, h \cdot s_H + k_h,\, w \cdot s_W + k_w \right]^p \right)^{1/p}

The power keeps the sign of xx, as in LPPool1d.

Parameters

norm_typefloat
The exponent pp. Must be positive; inf is allowed.
kernel_sizeint or tuple[int, int, int]
Window size (k_D, k_H, k_W). A scalar is broadcast.
strideint or tuple[int, int, int] or None= None
Step between windows. Defaults to kernel_size.
ceil_modebool= False
Use ceiling for output sizes. Default: False.

Attributes

norm_typefloat
kernel_sizeint or tuple[int, int, int]
strideint or tuple[int, int, int]
ceil_modebool

Notes

  • Input: (N, C, D_in, H_in, W_in)
  • Output: (N, C, D_out, H_out, W_out)
  • Thin wrapper around lucid.nn.functional.pooling.lp_pool3d, providing the standard Module interface.
  • Special cases follow those of LPPool1d and LPPool2d — the exponent pp smoothly interpolates between sum (p=1p=1), energy (p=2p=2), and max pooling.

Examples

L2 energy pooling over a volumetric map:
>>> import lucid
>>> import lucid.nn as nn
>>> pool = nn.LPPool3d(norm_type=2, kernel_size=2, stride=2)
>>> x = lucid.ones((1, 16, 8, 8, 8))
>>> y = pool(x)
>>> y.shape
(1, 16, 4, 4, 4)
Non-overlapping sum pooling (p=1):
>>> pool = nn.LPPool3d(norm_type=1, kernel_size=(1, 2, 2))
>>> x = lucid.ones((2, 32, 4, 16, 16))
>>> y = pool(x)
>>> y.shape
(2, 32, 4, 8, 8)

Used by 1

Constructors

1
dunder

__init__

→None
__init__(norm_type: float, kernel_size: int | tuple[int, int, int], stride: int | tuple[int, int, int] | None = None, ceil_mode: bool = False)

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

Instance methods

2
fn

extra_repr

→str
extra_repr()

Return a string representation of the layer's configuration.

fn

forward

→Tensor
forward(input: Tensor)

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.