Code

Transposed Convolution Configuration for FCN Upsampling

To restore the spatial dimensions of feature maps to the original input image size in a Fully Convolutional Network (FCN), a transposed convolutional layer is employed. If the spatial dimensions need to be increased by a factor of ss, the transposed convolution is configured with a stride of ss. To achieve the exact original dimensions, the padding is set to s/2s/2 (assuming s/2s/2 is an integer), and the height and width of the convolution kernel are set to 2s2s. For instance, to upscale a feature map by 32 times, the stride is 32, the padding is 16, and the kernel size is 64.

# PyTorch net.add_module('transpose_conv', nn.ConvTranspose2d(num_classes, num_classes, kernel_size=64, padding=16, stride=32))
# MXNet net.add(nn.Conv2DTranspose(num_classes, kernel_size=64, padding=16, strides=32))

0

1

Updated 2026-06-07

Tags

D2L

Dive into Deep Learning @ D2L