AdaptiveAvgPool2d Calculator
Calculate PyTorch AdaptiveAvgPool2d output shape. Specify target output size and input dimensions to see the pooling result. Commonly used before Linear layers.
Built by Michael Lip
Frequently Asked Questions
What does AdaptiveAvgPool2d do?
AdaptiveAvgPool2d automatically computes the kernel size, stride, and padding needed to produce an output of the specified spatial dimensions. You only specify the desired output size (e.g., (1,1) for global average pooling).
Why use AdaptiveAvgPool2d(1,1)?
AdaptiveAvgPool2d((1,1)) performs global average pooling, reducing each channel to a single value. This is used in ResNet and many modern architectures before the final Linear layer. It makes the network accept any input spatial size.
What is the output shape?
Output shape is (batch, channels, output_height, output_width). Batch and channel dimensions are unchanged. Only spatial dimensions are set to your specified output_size.
Difference from AvgPool2d?
AvgPool2d requires explicit kernel_size, stride, and padding. AdaptiveAvgPool2d only requires desired output size and computes pooling parameters automatically. Use Adaptive when you want resolution independence.
Is this tool free?
Yes. All HeyTensor tools are free, run in your browser, and require no signup.
About This Tool
Part of HeyTensor. All calculations run in your browser. Source code on GitHub.
Contact
Built by Michael Lip. Email [email protected].
TENSOR PREFLIGHT · DOWNLOADABLE PYTORCH TOOLKIT
Take the next step in your own PyTorch model.
Trace a local forward pass, inspect tensor shapes in an HTML report, and turn a repair into a regression check. Includes eight broken-and-fixed workflows, source code and setup instructions.
Is this toolkit right for my problem?
Use the free calculator for a layer formula or a quick shape check.
Consider Tensor Preflight when you have a local PyTorch model and want a forward-pass report plus repeatable checks. Python 3.9+ and PyTorch 2.8+ are required. It does not run your model in this website or automatically repair it.
Open the sample report before buying to check the output format.
Python 3.9+ · PyTorch 2.8+ · Runs locally