fn
pad
→Tensorpad(input: Tensor, padding: Sequence[int], mode: str = ..., value: float = ...)Pad a tensor with the specified border widths.
padding lists (left, right) pairs starting from the last
dimension and proceeding outward — the same convention used by the
reference framework. The mode selects how new elements are
filled.
Parameters
inputTensorSource tensor.
paddingsequence of intBorder widths, in last-axis-first order.
modestr= ``'constant'``One of
'constant', 'reflect', 'replicate',
'circular'.valuefloat= 0.0Fill value used by
mode='constant'.Returns
TensorPadded tensor.
Notes
Padding mode semantics:
constant— fill withvalue;reflect— mirror without repeating the edge element;replicate— repeat the edge element;circular— wrap around.
Examples
>>> import lucid
>>> x = lucid.tensor([[1, 2], [3, 4]])
>>> lucid.pad(x, [1, 1, 0, 0], mode='constant', value=0)
Tensor([[0, 1, 2, 0],
[0, 3, 4, 0]])