class

LazyConvTranspose3d

extendsConvTranspose3d
LazyConvTranspose3d(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)
source

A ConvTranspose3d that infers in_channels from the first input.

Lazy version of the 3D transposed convolution. Combines volumetric upsampling with deferred weight allocation, simplifying the construction of 3D generative decoders and medical image synthesis networks where channel dimensions are computed dynamically.

Parameters

out_channelsint
Number of output channels.
kernel_sizeint or tuple[int, int, int]
Size of the 3D convolving kernel.
strideint or tuple[int, int, int]= 1
Stride (upsampling factor). Default: 1.
paddingint or tuple[int, int, int]= 0
dilation * (kernel_size - 1) - padding zero-padding applied on each side of each spatial axis. String padding is not supported. Default: 0.
output_paddingint or tuple[int, int, int]= 0
Additional size added to one side of each spatial output dimension. Default: 0.
groupsint= 1
Number of blocked connections. Default: 1.
biasbool= True
If True, a learnable bias is added after materialization. Default: True.
dilationint or tuple[int, int, int]= 1
Spacing between kernel elements. Default: 1.
deviceDeviceLike= None
Device used when allocating weights. Default: None.
dtypeDTypeLike= None
Data type used when allocating weights. Default: None.

Attributes

weightParameter or None
None before materialization; shape (in_channels, out_channels // groups, K_D, K_H, K_W) afterwards.
biasParameter or None
None before materialization; (out_channels,) if bias=True.
in_channelsint or None
None before the first forward pass.

Notes

Input: (N,Cin,D,H,W)(N, C_{\text{in}}, D, H, W)CinC_{\text{in}} is inferred automatically. Output: (N,Cout,Dout,Hout,Wout)(N, C_{\text{out}}, D_{\text{out}}, H_{\text{out}}, W_{\text{out}}) — same formula as ConvTranspose3d.

State-dict loading. A 5-D weight tensor triggers materialization before parameter copying.

Symmetric 3D encoder–decoder. Pair each LazyConv3d with a LazyConvTranspose3d using matching kernel_size, stride, and padding for lossless spatial reconstruction.

Examples

Lazy 3D decoder block:
>>> import lucid
>>> import lucid.nn as nn
>>> up3d = nn.LazyConvTranspose3d(
...     out_channels=32, kernel_size=4, stride=2, padding=1
... )
>>> x = lucid.zeros(2, 64, 4, 8, 8)   # in_channels=64 inferred
>>> y = up3d(x)
>>> y.shape
(2, 32, 8, 16, 16)
Verify materialization:
>>> import lucid
>>> import lucid.nn as nn
>>> lazy = nn.LazyConvTranspose3d(out_channels=16, kernel_size=3, padding=1)
>>> print(lazy.in_channels)
None
>>> _ = lazy(lucid.zeros(1, 8, 4, 4, 4))
>>> print(lazy.in_channels)
8

Methods (3)

dunder

__init__

None
__init__(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)
source

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

fn

forward

Tensor
forward(x: Tensor)
source

Apply the convolution to the input tensor.

Parameters

inputTensor
Input tensor of shape (N,Cin,)(N, C_{\text{in}}, *).

Returns

Tensor

Output tensor of shape (N,Cout,)(N, C_{\text{out}}, *) with spatial dimensions determined by stride, padding, dilation, and kernel size.

fn

extra_repr

str
extra_repr()
source

Return a string representation of the layer's configuration.