ConvTranspose3d
ModuleConvTranspose3d(in_channels: int, out_channels: int, kernel_size: _Size3d, stride: _Size3d = 1, padding: _Size3d = 0, output_padding: _Size3d = 0, groups: int = 1, bias: bool = True, dilation: _Size3d = 1, device: DeviceLike = None, dtype: DTypeLike = None)Applies a 3D transposed convolution (fractionally-strided convolution).
The 3D extension of ConvTranspose2d. It upsamples all
three spatial dimensions simultaneously and is used in volumetric
decoders such as 3D autoencoders, video generators, and medical
image synthesis.
Output size along each spatial axis :
Parameters
in_channelsintout_channelsintkernel_sizeint or tuple[int, int, int]strideint or tuple[int, int, int]= 1> 1 upsample the spatial dimensions.
Default: 1.paddingint or tuple[int, int, int]= 0dilation * (kernel_size - 1) - padding zero-padding applied
on both sides of each axis. Default: 0.output_paddingint or tuple[int, int, int]= 00.groupsint= 11.biasbool= TrueTrue, adds a learnable bias. Default: True.dilationint or tuple[int, int, int]= 11.deviceDeviceLike= NoneNone.dtypeDTypeLike= NoneNone.Attributes
weightParameter(in_channels, out_channels // groups, K_D, K_H, K_W).
Leading axis is in_channels (same convention as
ConvTranspose2d).
Initialized with Kaiming uniform ().biasParameter or None(out_channels,), or None.Notes
Input: Output: as given by the formula above.
Memory. 3D transposed convolutions produce large feature maps
at decoder stages. Gradient checkpointing or smaller
out_channels values are often necessary when operating on
high-resolution volumes.
Symmetric decoder design. Pair each Conv3d in the
encoder with a ConvTranspose3d having identical
kernel_size, stride, and padding in the decoder to
guarantee exact shape reconstruction.
Examples
Volumetric upsampling (2× along all spatial axes):
>>> import lucid
>>> import lucid.nn as nn
>>> up3d = nn.ConvTranspose3d(
... in_channels=64, out_channels=32,
... kernel_size=4, stride=2, padding=1
... )
>>> x = lucid.zeros(2, 64, 4, 8, 8)
>>> y = up3d(x)
>>> y.shape
(2, 32, 8, 16, 16)
3D autoencoder decoder block:
>>> import lucid
>>> import lucid.nn as nn
>>> decoder3d = nn.ConvTranspose3d(128, 64, kernel_size=3, stride=1, padding=1)
>>> x = lucid.zeros(1, 128, 8, 8, 8)
>>> y = decoder3d(x)
>>> y.shape
(1, 64, 8, 8, 8)Methods (3)
__init__
→None__init__(in_channels: int, out_channels: int, kernel_size: _Size3d, stride: _Size3d = 1, padding: _Size3d = 0, output_padding: _Size3d = 0, groups: int = 1, bias: bool = True, dilation: _Size3d = 1, device: DeviceLike = None, dtype: DTypeLike = None)Initialise the ConvTranspose3d module. See the class docstring for parameter semantics.
forward
→Tensorforward(x: Tensor)Apply the convolution to the input tensor.
Parameters
inputTensorReturns
TensorOutput tensor of shape with spatial dimensions determined by stride, padding, dilation, and kernel size.
extra_repr
→strextra_repr()Return a string representation of the layer's configuration.