Skip to content
ENExplore Calculators

CNN Output Shape Calculator

Calculate the output feature map shape of a convolutional layer given kernel and stride.

About CNN Output Shape Calculator

Every convolutional or pooling layer transforms spatial dimensions according to: output_size = floor((input_size − kernel_size + 2 × padding) / stride) + 1. This formula applies independently to height and width, so square inputs/kernels give square outputs, while rectangular inputs require running the calculation separately for each dimension. Padding compensates for the kernel 'eating into' the input at the borders (with 'same' padding chosen so output size matches input size at stride 1), while stride greater than 1 downsamples the spatial resolution, commonly used to reduce feature map size progressively through a network.

Formula

output_size = floor((input_size - kernel_size + 2 * padding) / stride) + 1

W
Input spatial size (height or width)
K
Kernel size
P
Padding (pixels added to each side)
S
Stride

Worked example

With the default values below, CNN Output Shape Calculator returns Output Size (H or W) of 112. Change any input above and every figure here is recalculated in your browser.

Inputs used

Input Size (H or W)accepts 1–1,000,000 px
224 px
Kernel Sizeaccepts 1–10,000 px
3 px
Paddingaccepts 0–10,000 px
1 px
Strideaccepts 1–10,000 px
2 px

Results

Output Size (H or W)
112 px
Raw (Pre-Floor) Size
111.500

Step by step

  1. 1Raw size: (input − kernel + 2 × padding) ÷ stride= 111.500
  2. 2Output size: ⌊raw size⌋ + 1= 112

Assumptions and limits

  • The result is derived only from the 4 inputs listed above. Anything not among them is not part of the calculation.
  • In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
  • Figures are rounded for display to 3 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.

How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.

Frequently Asked Questions

What padding gives 'same' output size (at stride 1)?

For stride 1, choosing padding = (kernel_size − 1) / 2 (when kernel_size is odd) keeps the output size equal to the input size, which is the common 'same' padding convention in CNN architectures.

What happens if the output size formula gives a non-integer raw size?

The result is floored — any 'leftover' pixels at the edge that don't form a complete kernel window are simply dropped, which is standard behavior for convolution operations in frameworks like PyTorch and TensorFlow.

How do I compute the output shape for rectangular (non-square) inputs?

Apply the same formula separately using the height and its corresponding kernel/padding/stride values, then again for the width, since the two spatial dimensions are computed independently.

Does this formula also apply to pooling layers (MaxPool, AvgPool)?

Yes, pooling layers use the identical output-size formula as convolutions, just without learnable weights — a MaxPool with kernel=2, stride=2, padding=0 uses this same calculation to halve spatial dimensions.

CNN Output Shape Calculator – Calculate Output Size (H or W)