MaxPool2d Output Size Calculator

Calculate the output size of a PyTorch MaxPool2d layer. Enter input shape, kernel size, stride, and padding to compute the output tensor dimensions.

Built by Michael Lip

Frequently Asked Questions

What is the MaxPool2d output size formula?

The formula is identical to Conv2d: H_out = floor((H_in + 2*padding - dilation*(kernel_size-1) - 1) / stride) + 1. By default, MaxPool2d uses stride equal to kernel_size if not specified.

What is the difference between MaxPool2d and AvgPool2d?

Both have the same output shape formula. MaxPool2d takes the maximum value in each window, while AvgPool2d computes the average. MaxPool2d is more common in classification networks, while AvgPool2d is often used as the final global pooling layer.

Does MaxPool2d change the number of channels?

No. MaxPool2d only reduces the spatial dimensions (height and width). The batch size and channel count remain unchanged. If input is [8, 64, 32, 32] and you apply MaxPool2d(2), output is [8, 64, 16, 16].

About This Tool

This tool is part of HeyTensor, a free suite of PyTorch and deep learning utilities. All calculations run entirely in your browser — no data is sent to any server. The source code is open on GitHub.

Contact

HeyTensor is built and maintained by Michael Lip. For questions or feedback, email [email protected].

📊 Based on real data from our Most Common PyTorch Errors research — 20 errors ranked by frequency