Pad a 3-D tensor (N, C, L) by wrapping the sequence around itself.
Circular (or periodic) padding treats the input as if it were a circular buffer: values from the right end of the sequence appear on the left, and values from the left end appear on the right.
Parameters
paddingint or tuple[int, int](left, right) circular padding sizes. A single int pads
equally on both sides. Values may be larger than the input length
(the wrap-around simply repeats).Attributes
paddingtuple[int, int]Normalised
(left, right) padding.Notes
- Input: .
- Output: .
- Circular padding is the natural choice for signals that are inherently periodic: audio spectral features, astronomical data, or any domain with wrap-around semantics.
- For 1-D convolutions on periodic signals it ensures that the convolution filter sees a seamless boundary, unlike zero or reflection padding.
Examples
**Periodic extension of an audio spectrogram feature:**
>>> import lucid
>>> import lucid.nn as nn
>>>
>>> pad = nn.CircularPad1d(padding=8)
>>> x = lucid.zeros(4, 64, 256)
>>> pad(x).shape
(4, 64, 272)
**Asymmetric wrap-around:**
>>> pad = nn.CircularPad1d(padding=(3, 0))
>>> x = lucid.zeros(2, 16, 100)
>>> pad(x).shape
(2, 16, 103)Used by 1
Constructors
1Instance methods
2Return a string representation of the layer's configuration.