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]
Deep Learning by Ian Goodfellow and others. Chapter 9, §9.2, sparse interactions and parameter sharing
For real-valued input , dense channel connectivity, no padding and convolution stride one, write the affine output asHere 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]
Conv2d in the PyTorch documentation. Opening equation, valid two-dimensional cross-correlation and channel summation
For one input channel, takeThe first patch gives . Applying the same weights everywhere givesA 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 isIt 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.
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.[ref]
Conv2d in the PyTorch documentation. Opening parameter descriptions; Parameters, dilation and stride
For an own real one-dimensional example, takeand coefficients , with stride one, no padding and no bias. Use the unflipped cross-correlation convention. Dilation one sums three adjacent values and gives . Dilation two instead uses offsets :The second filter evaluates a wider input span while still using three coefficients.
For sampled coefficients separated by positions, the first-to-last displacement is . Including the first position gives the effective convolution kernel sizeThus 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 . 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.[ref]
Conv2d in the PyTorch documentation. Variables, weight shape depends on kernel dimensions and channel connectivity
For input length , symmetric zero padding and stride , the usual per-axis size formula becomeswhen the padded input accommodates the footprint. The example gives outputs. The floor function counts origins whose final sample remains in range.[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.
The effective convolution kernel size is the bounding extent of a dilated convolution kernel along a spatial axis. For sampled coefficients with convolution dilation , their offsets are . The first-to-last displacement is , so including the first position givesThis extent determines the kernel footprint used in spatial shape calculations; it is not generally the number of coefficients.[ref]
For a two-dimensional example, choose a sampled kernel shape with dilation . Its row offsets are and column offsets are . The bounding shape is thereforeThere are six sampled spatial positions inside a twenty-position bounding box. Fourteen intermediate positions are absent from the sampling pattern.
With three input neural network channels and four output channels, ordinary dense channel connectivity usesweights and optionally four biases, giving parameters. A general dense five-by-four kernel with the same channel counts would have weights. Representing the dilated operation that way would require of them to be fixed zeros, rather than independently learned parameters.[ref]
For an unpadded -by- input and convolution stride one, the output grid isMore generally, for one axis with symmetric zero padding and stride ,when the padded input accommodates the footprint. The floor function counts admissible filter origins.[ref]
The effective size is a geometric quantity for one layer. The complete neural network receptive field through several layers additionally depends on their kernels, strides and connections. Likewise, changing stride moves the spacing of origins; changing dilation changes the footprint at each origin. Keeping bounding extent, sampled-position count and learned-parameter count separate avoids confusing three different sizes.
The convolution stride specifies how far the filter's origin advances between neighboring output positions of a convolutional layer. It controls which spatial positions are evaluated. A larger stride usually produces a smaller output grid without changing the number of coefficients in each filter.[ref]
For a real one-dimensional example, take the inputand a size-three all-ones filter, no bias and no padding. Using the unflipped cross-correlation convention, stride one evaluates windows beginning at indices and givesStride two evaluates windows beginning at indices , givingThe second result keeps every second origin from this first grid; it still combines three input values for each retained origin.
For an undilated length- input and length- filter, no padding and stride , a zero-indexed output uses input indices through . Requiring its last index not to exceed gives . Counting the admissible nonnegative integers therefore giveswhen and is a positive integer. The floor function is essential when the last candidate origin would extend beyond the input.
With symmetric zero padding of positions per side and convolution dilation , the corresponding standard shape expression isHere dilation changes the spacing of samples within a filter footprint; stride changes the spacing between filter origins. The two parameters have different roles.[ref]
Conv2d in the PyTorch documentation. Parameters, stride/padding/dilation; Shape, each spatial-axis formula
For two-dimensional data, specify a stride for each spatial axis; unequal strides need not reduce height and width by the same amount. The weights of the filter remain shared across the visited positions. Stride also changes how neighboring outputs' neural network receptive fields are spaced in the original input, so it affects more than just a displayed array size.
A pointwise convolution uses a spatial kernel of size one to combine neural network channels independently at each spatial position. For a two-dimensional input this is a one-by-one convolutional layer. In the ordinary dense-channel, unit-stride case, the same affine map acts on the channel vector at every grid point.[ref]
Conv2d in the PyTorch documentation. Opening equation and kernel_size/stride parameters, specialized to kernel size one and groups=1
Let be the channel vector at position . With weight matrix and neural network bias vector , the output isThis is matrix multiplication across channels, not an average of neighboring spatial positions. The same and are reused throughout the grid.
For an example without biases, takeAt a point with input the output is . At another point with input it is . A three-channel neural network feature map has become a two-channel map without mixing the two positions.
There are weights, plus optional biases. Thus three input and two output channels require six weights, or eight parameters including biases. A dense three-by-three filter with the same channel counts requires weights, or fifty-six parameters with biases. This comparison counts parameters for the stated connectivity; it does not claim that the two layers compute equivalent functions.
Channel reduction can make a later spatial convolutional layer cheaper. The original Inception uses one-by-one reductions before some larger filters. A pointwise operation can also increase the channel count; size one refers to its spatial footprint, not to the number of channels.[ref]
Going Deeper with Convolutions by Christian Szegedy and others. §4 and Fig. 2, one-by-one dimension-reduction branches
With no intervening spatial operation, pointwise layers and pointwise activation functions alone do not enlarge the spatial neural network receptive field. Articles by others on the same topic
There are currently no matching articles.