class
MaxUnpool3d
extends
_MaxUnpoolNdMaxUnpool3d(kernel_size: int | tuple[int, ...], stride: int | tuple[int, ...] | None = None, padding: int | tuple[int, ...] = 0)Computes a partial inverse of MaxPool3d.
Extends MaxUnpool2d to three spatial dimensions. Each
pooled value is scattered back to its 3-D source position (recorded
in indices) and all other voxels are set to zero.
Parameters
kernel_sizeint or tuple[int, int, int]Must match the
kernel_size of the paired MaxPool3d.strideint or tuple[int, int, int] or None= NoneMust match the
stride of the paired pool. Defaults to
kernel_size.paddingint or tuple[int, int, int]= 0Must match the
padding of the paired pool. Default: 0.Attributes
kernel_sizeint or tuple[int, int, int]strideint or tuple[int, int, int]paddingint or tuple[int, int, int]Notes
- Input
x:(N, C, D_pooled, H_pooled, W_pooled) - Input
indices:(N, C, D_pooled, H_pooled, W_pooled) - Output:
(N, C, D_original, H_original, W_original)
- 3-D unpooling is used in volumetric segmentation networks that mirror a pooling encoder with an unpooling decoder.
- As with
MaxUnpool2d, the output is sparse — only voxels that were pool maxima receive non-zero values. - Pass
output_sizewhen the original volumetric shape cannot be uniquely determined from the pooling hyperparameters.
Examples
Reconstruct a volumetric map:
>>> import lucid
>>> import lucid.nn as nn
>>> unpool = nn.MaxUnpool3d(kernel_size=2, stride=2)
>>> x = lucid.ones((1, 32, 4, 4, 4))
>>> indices = lucid.zeros((1, 32, 4, 4, 4), dtype="int32")
>>> y = unpool(x, indices)
>>> y.shape
(1, 32, 8, 8, 8)
With explicit output_size:
>>> unpool = nn.MaxUnpool3d(kernel_size=2, stride=2)
>>> x = lucid.ones((1, 8, 3, 3, 3))
>>> indices = lucid.zeros((1, 8, 3, 3, 3), dtype="int32")
>>> y = unpool(x, indices, output_size=(1, 8, 7, 7, 7))
>>> y.shape
(1, 8, 7, 7, 7)Methods (1)
fn
forward
→Tensorforward(x: Tensor, indices: Tensor, output_size: tuple[int, ...] | None = None)Apply the pooling operation to the input tensor.
Parameters
inputTensorInput tensor of shape where are the
spatial dimensions appropriate for this pooling layer.
Returns
TensorPooled output tensor.