Convolutional layer

ID: convolutional-layer

A convolutional layer applies shared local filters across an input grid to produce output neural network channels. Each filter combines the input channels and nearby positions, with the same learned weights reused at different output positions. This weight sharing distinguishes it from assigning unrelated weights to every grid location.[ref]
For real-valued input , dense channel connectivity, no padding and convolution stride one, write the affine output as
Here selects the output channel, an input channel, the filter weights and a neural network bias. The spatial indices stay in range. This unflipped-filter formula is the cross-correlation convention used by the Conv2d implementation, despite its convolution name. Mathematical discrete convolution reverses the kernel's displacement indices; state the convention when comparing formulas.[ref]
For one input channel, take
The first patch gives . Applying the same weights everywhere gives
A following rectified linear unit produces . The affine filter operation and the subsequent activation function are separate steps, although an architectural description sometimes groups them together.
For an input grid in this unpadded, unit-stride case, the output dimensions are . There are weights for each output channel and one bias, so the total parameter count is
It does not grow with or ; the number of filter applications does.[ref]
The neural network receptive field identifies which input positions can influence an output. Local filters restrict that dependency, while successive layers can combine information from a larger region. Convolution stride and zero padding alter the spatial sampling and boundary behavior; the explicit formulas above assume neither subsampling nor padding.

New to topics? Read the docs here!