class
ConstantPad3d
extends
_ConstantPadNdConstantPad3d(padding: int | tuple[int, int, int, int, int, int], value: float)Pad a 5-D tensor (N, C, D, H, W) on all six faces with a constant.
Adds padding around the depth, height, and width dimensions. The
padding tuple follows the convention
(left, right, top, bottom, front, back):
Parameters
paddingint or tuple[int, int, int, int, int, int](left, right, top, bottom, front, back) padding sizes. A single
int applies the same amount on all six faces.valuefloatConstant fill value.
Attributes
paddingtuple[int, int, int, int, int, int]Normalised 6-element padding tuple.
valuefloatFill value.
Notes
- Input: .
- Output: .
Examples
**Uniform 1-voxel border around a volumetric tensor:**
>>> import lucid
>>> import lucid.nn as nn
>>>
>>> pad = nn.ConstantPad3d(padding=1, value=0.0)
>>> x = lucid.zeros(1, 4, 16, 16, 16)
>>> pad(x).shape
(1, 4, 18, 18, 18)
**Pad only the depth axis (front/back) for temporal video data:**
>>> pad = nn.ConstantPad3d(padding=(0, 0, 0, 0, 2, 2), value=0.0)
>>> x = lucid.zeros(2, 3, 8, 32, 32) # (N, C, T, H, W)
>>> pad(x).shape
(2, 3, 12, 32, 32)Methods (1)
dunder
__init__
→None__init__(padding: int | tuple[int, int, int, int, int, int], value: float)Initialise the ConstantPad3d module. See the class docstring for parameter semantics.