ConvTranspose2d Output Size Calculator
Calculate the output size of a PyTorch ConvTranspose2d (transposed convolution) layer. Enter input shape, kernel, stride, padding, and output_padding for exact results.
Built by Michael Lip
Frequently Asked Questions
What is the ConvTranspose2d output size formula?
The formula is: H_out = (H_in - 1) * stride - 2*padding + dilation*(kernel_size-1) + output_padding + 1. This is the inverse of Conv2d and is used in decoder networks and GANs to upsample feature maps.
What is output_padding in ConvTranspose2d?
output_padding adds extra pixels to one side of the output. It resolves the ambiguity where multiple input sizes can map to the same Conv2d output. It must be less than stride. Common value is 0 or 1.
When should I use ConvTranspose2d vs Upsample + Conv2d?
ConvTranspose2d can produce checkerboard artifacts. An alternative is nn.Upsample followed by nn.Conv2d, which often gives smoother results. However, ConvTranspose2d is more parameter-efficient and widely used in U-Net and GAN architectures.
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].