Pad a 3-D tensor (N, C, L) by replicating the edge values.
Replication padding fills out-of-bounds positions with the value of the nearest valid element (edge replication):
The leftmost valid element is repeated to the left; the rightmost valid element is repeated to the right.
Parameters
paddingint or tuple[int, int](left, right) replication padding sizes. A single int pads
equally on both sides.Attributes
paddingtuple[int, int]Normalised
(left, right) padding.Notes
- Input: .
- Output: .
- Replication padding is particularly useful when the input represents a signal whose boundary should be extended with the last known value (e.g. padding a time series at the end with its final sample).
- Unlike reflection padding, replication padding is valid even for padding sizes equal to or larger than the input length.
Examples
**Edge-extend a short time series before a convolution:**
>>> import lucid
>>> import lucid.nn as nn
>>>
>>> pad = nn.ReplicationPad1d(padding=5)
>>> x = lucid.zeros(2, 4, 20)
>>> pad(x).shape
(2, 4, 30)
**One-sided extension (right-only):**
>>> pad = nn.ReplicationPad1d(padding=(0, 10))
>>> x = lucid.zeros(1, 8, 50)
>>> pad(x).shape
(1, 8, 60)Used by 1
Constructors
1Instance methods
2Return a string representation of the layer's configuration.