class

ZeroPad1d

extendsConstantPad1d
ZeroPad1d(padding: _Size2d)
source

Pad a 3-D tensor (N, C, L) with zeros along the sequence dimension.

Equivalent to ConstantPad1d(padding, value=0.0). Zero-padding is the most common padding mode for 1-D convolutional networks because it introduces no spurious signal at the boundaries and is implicit in most convolution implementations.

Parameters

paddingint or tuple[int, int]
(left, right) padding sizes. A single int pads equally on both sides.

Attributes

paddingtuple[int, int]
Normalised (left, right) padding.
valuefloat
Always 0.0.

Notes

  • Input: (N,C,L)(N, C, L).
  • Output: (N,C,L+pleft+pright)(N, C, L + p_{\text{left}} + p_{\text{right}}).

Examples

**Same-padding for a 1-D convolution with kernel size 5:**
>>> import lucid
>>> import lucid.nn as nn
>>>
>>> # kernel=5 → same-padding = (kernel-1)//2 = 2 on each side
>>> pad = nn.ZeroPad1d(padding=2)
>>> x = lucid.zeros(8, 32, 100)
>>> pad(x).shape
(8, 32, 104)
**Asymmetric padding for causal convolution:**
>>> causal = nn.ZeroPad1d(padding=(4, 0))
>>> x = lucid.zeros(4, 16, 50)
>>> causal(x).shape
(4, 16, 54)

Methods (2)

dunder

__init__

None
__init__(padding: _Size2d)
source

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

fn

extra_repr

str
extra_repr()
source

Return a string representation of the layer's configuration.