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.
New to topics? Read the docs here!