Learn Before
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 is passed through a convolutional layer to produce an output , a transposed convolutional layer can be constructed to invert this shape change. By configuring with the exact same spatial hyperparameters (kernel size, padding, and stride) as , and setting its output channel count to match the channels of , the resulting tensor will possess the identical shape as the original input . 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
Tags
D2L
Dive into Deep Learning @ D2L