Code

Initializing Transposed Convolution with Bilinear Interpolation

To implement bilinear interpolation upsampling using a transposed convolutional layer, the layer's kernel weights are explicitly initialized using a bilinear kernel function. This ensures the layer performs the equivalent distance-weighted upsampling. For instance, to double the height and width of an image with 33 channels, a transposed convolutional layer is created with a stride of 22, padding of 11, and a kernel size of 44. Its weights are then populated by copying the output of the bilinear_kernel function.

# PyTorch conv_trans = nn.ConvTranspose2d(3, 3, kernel_size=4, padding=1, stride=2, bias=False) conv_trans.weight.data.copy_(bilinear_kernel(3, 3, 4))
# MXNet conv_trans = nn.Conv2DTranspose(3, kernel_size=4, padding=1, strides=2) conv_trans.initialize(init.Constant(bilinear_kernel(3, 3, 4)))

0

1

Updated 2026-05-21

Contributors are:

Who are from:

Tags

D2L

Dive into Deep Learning @ D2L