Concept

Transposed Convolution Shape Reversal

A primary application of transposed convolutional layers is to perfectly reverse the spatial dimensionality transformations introduced by standard convolutional layers. If an input tensor X\mathsf{X} is passed through a convolutional layer ff to produce an output Y=f(X)\mathsf{Y} = f(\mathsf{X}), a transposed convolutional layer gg can be constructed to invert this shape change. By configuring gg with the exact same spatial hyperparameters (kernel size, padding, and stride) as ff, and setting its output channel count to match the channels of X\mathsf{X}, the resulting tensor g(Y)g(\mathsf{Y}) will possess the identical shape as the original input X\mathsf{X}. This property can be verified programmatically in frameworks like PyTorch and MXNet by ensuring tconv(conv(X)).shape == X.shape when both layers share identical parameters.

# PyTorch X = torch.rand(size=(1, 10, 16, 16)) conv = nn.Conv2d(10, 20, kernel_size=5, padding=2, stride=3) tconv = nn.ConvTranspose2d(20, 10, kernel_size=5, padding=2, stride=3) tconv(conv(X)).shape == X.shape
# MXNet X = np.random.uniform(size=(1, 10, 16, 16)) conv = nn.Conv2D(20, kernel_size=5, padding=2, strides=3) tconv = nn.Conv2DTranspose(10, kernel_size=5, padding=2, strides=3) conv.initialize() tconv.initialize() tconv(conv(X)).shape == X.shape

0

1

Updated 2026-05-21

Contributors are:

Who are from:

Tags

D2L

Dive into Deep Learning @ D2L