Convolution
Convolution applies a local filter across positions with shared weights. It is the core operation behind many CNNs, image models, audio models, contact-map models, and voxel-grid models.
For a 1D signal:
is the filter weight at offset , and the same weights are reused at every position .
For a 2D input with channels:
The filter mixes local spatial neighborhoods and input channels.
Cross-Correlation vs Convolution
Deep learning libraries usually implement cross-correlation rather than mathematically flipped convolution:
instead of
The distinction rarely matters for learning because is learned, but it matters when comparing formulas with signal-processing texts.
Locality and Equivariance
Before boundary effects, convolution is translation equivariant:
shifts the input by offset . This means shifting the input shifts the output in the same way.
Shape Formula
For one spatial dimension, output length is:
where is kernel size, padding, dilation, and stride.
| Parameter | Effect | Tradeoff |
|---|---|---|
| kernel size | local receptive field | larger kernels cost more and smooth locality |
| stride | downsampling | loses resolution but reduces compute |
| padding | boundary treatment | can create artificial edge context |
| dilation | sparse larger field | can miss fine local patterns |
| groups | channel factorization | cheaper but less cross-channel mixing |
Receptive Field
Stacked convolutions increase receptive field. For stride-1 layers with kernel size , a rough receptive field after layers is:
Pooling, stride, and dilation change this faster. The key question is whether the receptive field covers the dependency scale required by the task.
| Data | Useful convolution view |
|---|---|
| image | local texture and spatial hierarchy |
| audio | local temporal waveform pattern |
| sequence | local motif or n-gram-like feature |
| contact map | local 2D pattern over residue pairs |
| voxel grid | local 3D occupancy or density pattern |
Convolution vs Attention
| Property | Convolution | Attention |
|---|---|---|
| connectivity | local by default | global or masked |
| weight sharing | fixed offsets share weights | content-dependent weights |
| inductive bias | locality and translation equivariance | flexible pairwise interaction |
| compute pattern | dense local stencil | pairwise token interaction |
| good baseline for | images, grids, local signals | long-range dependencies and variable relations |
This is why convolution remains useful even when Transformers dominate many sequence tasks: it encodes a strong local prior cheaply.
Long Convolution
For sequence models, convolution does not have to be local. A long convolution can use a kernel over the full context:
If the kernel is implicitly parameterized,
the model can represent long filters without storing an independent parameter for every offset. Hyena is the canonical paper note here for gated implicit long convolution as a dense-attention-free sequence mixer.
Exponential moving average is a related sequence-memory pattern:
It behaves like a decayed causal filter. Mega uses this moving-average bias inside a gated attention block rather than as a standalone convolutional sequence model.
Design Parameters
- Kernel size: local window size.
- Stride: step size between filter positions.
- Padding: boundary handling.
- Dilation: spacing between kernel positions.
- Groups: whether channels are split into independent convolution groups.
- Dimension: 1D sequence, 2D image/contact map, or 3D voxel/grid.
- Receptive field: whether stacked layers can cover the dependency scale.
- Boundary policy: whether padding is physically meaningful for the data.
Checks
- What axis is spatial, sequence, channel, batch, or feature?
- Does padding introduce artifacts at boundaries?
- Does stride or pooling discard resolution needed by the task?
- Is a dense grid representation appropriate, or is the object naturally a graph or point cloud?
- Does the convolution encode the right symmetry for the data?
- Is the receptive field large enough without destroying resolution?
- Are local interactions enough, or is attention/graph message passing needed?
Canonical Papers
| Paper | Why It Matters |
|---|---|
| WaveNet | dilated causal convolution for autoregressive sequence generation |
| Mega | exponential moving average as local sequence memory inside gated attention |
| Hyena | implicit long convolution plus gating for long-context sequence modeling |
| ConvNeXt | depthwise convolution as modern vision token mixing |