#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
🧱 FREE · SHAPES + PARAMS

CNN Output Size Calculator: No More Shape Errors

List your layers and get the output shape and parameters at every step, with the total model size.

  • 📐 Stride, padding, dilation
  • 🔢 Parameter count
  • 💾 Model size

How to use the CNN Output Size Calculator

  1. 1. Set the inputEnter the image height, width and channels.
  2. 2. List the layersOne per line, like conv 32 3 p=same, pool 2, flatten, dense 10.
  3. 3. CalculateSee each layer's output shape and parameters, and the total.

The formulas

For a convolution or pooling layer, each spatial size becomes ⌊(input + 2·padding − dilation·(kernel − 1) − 1) ÷ stride⌋ + 1, the formula PyTorch uses. p=same follows Keras: output = ⌈input ÷ stride⌉. A convolution has (kernel × kernel × input channels + 1) × filters parameters (weights plus one bias per filter). A dense layer has (inputs + 1) × units. Batch norm has 4 values per channel, 2 of them trainable. Pooling, flatten and dropout have none.

Worked example

A small CIFAR-10-style network on 32 × 32 × 3 images: conv 32 3 p=same keeps 32 × 32 and adds 896 parameters (3·3·3 + 1 = 28, × 32). Pool 2 halves it to 16 × 16. Conv 64 3 p=same adds 18,496 parameters, and pool 2 gives 8 × 8 × 64. Flatten makes 4,096 values, dense 128 adds 5,24,416 parameters and dense 10 adds 1,290. The total is 5,45,098 parameters, about 2.08 MB as 32-bit floats. Most of them sit in the first dense layer, which is why many modern CNNs use global average pooling (gap) instead of flatten.

Checks

  • Shapes and counts were checked against an independent implementation of the same formulas on 80 random networks, including stride, dilation and padding.
  • The tool flags layers whose output would shrink below 1 × 1.
  • Grouped and depthwise convolutions, transposed convolutions and non-square kernels aren't supported.

Frequently asked questions

Why is my output size a fraction in my notes?

Frameworks round down (floor) for valid or explicit padding. If the numbers don't divide evenly, the last rows or columns are simply not covered.

Does 'same' padding work with stride 2?

Yes. As in Keras, the output is the input divided by the stride, rounded up.

Is the CNN output size calculator free?

Yes. You can open the CNN output size calculator and enter everything without signing up. When you calculate shapes for the first time, we ask once for your name and WhatsApp number; after that it, and every other Uncodemy tool, opens straight away.

More free tools

See all free tools