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.

ParameterEffectTradeoff
kernel size local receptive fieldlarger kernels cost more and smooth locality
stride downsamplingloses resolution but reduces compute
padding boundary treatmentcan create artificial edge context
dilation sparse larger fieldcan miss fine local patterns
groupschannel factorizationcheaper 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.

DataUseful convolution view
imagelocal texture and spatial hierarchy
audiolocal temporal waveform pattern
sequencelocal motif or n-gram-like feature
contact maplocal 2D pattern over residue pairs
voxel gridlocal 3D occupancy or density pattern

Convolution vs Attention

PropertyConvolutionAttention
connectivitylocal by defaultglobal or masked
weight sharingfixed offsets share weightscontent-dependent weights
inductive biaslocality and translation equivarianceflexible pairwise interaction
compute patterndense local stencilpairwise token interaction
good baseline forimages, grids, local signalslong-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

PaperWhy It Matters
WaveNetdilated causal convolution for autoregressive sequence generation
Megaexponential moving average as local sequence memory inside gated attention
Hyenaimplicit long convolution plus gating for long-context sequence modeling
ConvNeXtdepthwise convolution as modern vision token mixing