conv1d(input: Tensor, weight: Tensor, bias: Tensor | None = None, stride: int | tuple[int, ...] = 1, padding: str | int | tuple[int, ...] = 0, dilation: int | tuple[int, ...] = 1, groups: int = 1)Implementing kernel
C++ engine symbols that back this Python API.1-D cross-correlation over a 3-D (or unbatched 2-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
inputTensorInput of shape
(N, C_in, L), or (C_in, L) unbatched.weightTensorFilters of shape
(C_out, C_in/groups, kL).Per-output-channel bias of shape
(C_out,).strideint or tuple of int= 1Step between adjacent kernel positions (default
1).paddingint, tuple of int, or {'valid', 'same'}= 0Zero padding applied to both sides of the spatial axis.
"valid" is no padding; "same" pads so the output is as long
as the input, which needs stride=1 — an odd total puts the
extra element at the end.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 input,
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)