Convolution dilation (source code)

= Convolution dilation
{title2=$d$}

<Convolution dilation> specifies the spacing between neighboring kernel sample points in a <convolutional layer>. Dilation one samples adjacent positions; larger dilation separates those positions while keeping the filter's learned coefficient count fixed. <Convolution stride> instead controls the spacing between successive filter origins.<Conv2d in the PyTorch documentation>[Opening parameter descriptions; Parameters, dilation and stride]{ref}

For an own real one-dimensional example, take
$$
x=(1,2,4,8,16,32,64)
$$
and coefficients $(1,1,1)$, with stride one, no padding and no bias. Use the unflipped <cross-correlation> convention. Dilation one sums three adjacent values and gives $(7,14,28,56,112)$. Dilation two instead uses offsets $0,2,4$:
$$
y_0=1+4+16=21,\qquad
y_1=2+8+32=42,\qquad
y_2=4+16+64=84.
$$
The second filter evaluates a wider input span while still using three coefficients.

For $k$ sampled coefficients separated by $d$ positions, the first-to-last displacement is $d(k-1)$. Including the first position gives the <effective convolution kernel size>
$$
k_{\mathrm{eff}}=1+d(k-1).
$$
Thus $k=3,d=2$ spans five positions. At each origin only three of those five positions are sampled directly.

The same linear operation can be represented by a dense width-five kernel $(1,0,1,0,1)$. The inserted zeros are fixed structure, not additional trainable coefficients. Dilation changes the footprint without making the original three-parameter filter a general five-parameter one.<Conv2d in the PyTorch documentation>[Variables, weight shape depends on kernel dimensions and channel connectivity]{ref}

For input length $L$, symmetric <zero padding> $p$ and stride $s$, the usual per-axis size formula becomes
$$
L_{\mathrm{out}}=
\left\lfloor\frac{L+2p-d(k-1)-1}{s}\right\rfloor+1,
$$
when the padded input accommodates the footprint. The example gives $\lfloor(7-4-1)/1\rfloor+1=3$ outputs. The <floor function> counts origins whose final sample remains in range.<Conv2d in the PyTorch documentation>[Shape, spatial-axis formulas]{ref}

Dilation can enlarge a unit's spatial <neural network receptive field> without evaluating every intervening input position. Whether later layers fill those gaps depends on the architecture. A wider span alone does not establish greater numerical influence at every position or better performance on a learning task.