ConvTranspose3d
_ConvTransposeNdConvTranspose3d(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, padding_mode: str = 'zeros', device: DeviceLike = None, dtype: DTypeLike = None)Implementing kernel
C++ engine symbols that back this Python API.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.padding_modestr= 'zeros'"zeros", the only mode; another raises ValueError.deviceDeviceLike= NoneNone.dtypeDTypeLike= NoneNone.Attributes
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)Used by 1
Constructors
1__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, padding_mode: str = 'zeros', device: DeviceLike = None, dtype: DTypeLike = None)Initialise the ConvTranspose3d module. See the class docstring for parameter semantics.
Instance methods
1Upsample x of shape (N, C_in, D, H, W), or unbatched.
output_size picks one of the stride sizes the layer can
produce, in place of output_padding: the output's depth, height and width,
optionally after its batch and channel sizes.