fn
conv1d
→Tensorconv1d(x: Tensor, weight: Tensor, bias: Tensor | None = None, stride: int | tuple[int, ...] = 1, padding: int | tuple[int, ...] = 0, dilation: int | tuple[int, ...] = 1, groups: int = 1)1-D cross-correlation over batched 3-D input.
Slides a learned filter along a single spatial axis. As with every
major deep-learning framework, the operation is technically
cross-correlation rather than strict mathematical convolution (no
kernel flip), but the "conv" name is kept for familiarity. Channel
mixing happens through the in_channels dimension of weight.
Parameters
xTensorInput of shape
(N, C_in, L).weightTensorFilters of shape
(C_out, C_in/groups, kL).biasTensor= NonePer-output-channel bias of shape
(C_out,).strideint or tuple of int= 1Step between adjacent kernel positions (default
1).paddingint or tuple of int= 0Zero padding applied to both sides of the spatial axis.
dilationint or tuple of int= 1Spacing between kernel taps (atrous convolution). Default
1.groupsint= 1Split the channel dimension into
groups independent groups.Returns
TensorOutput of shape (N, C_out, L_out) where
Notes
Math:
Backward is registered automatically; gradients flow to x,
weight, and bias. Set groups == C_in and C_out == C_in
for a depthwise convolution. Using dilation > 1 enlarges the
receptive field without increasing parameter count — common in
speech / audio models (WaveNet) and 1-D temporal CNNs.
Examples
>>> import lucid
>>> from lucid.nn.functional import conv1d
>>> x = lucid.randn(2, 4, 50)
>>> w = lucid.randn(8, 4, 3)
>>> y = conv1d(x, w, padding=1)
>>> y.shape
(2, 8, 50)