Foundations to Frontier
Tests
E. Deep Learning › E7 CNN Building Blocks

Transposed Convolution, Upsampling and Pixel Shuffle

Segmentation, generation and super-resolution networks must make feature maps larger. Transposed convolution (sometimes miscalled deconvolution) learns the upsampling: each input pixel paints a weighted copy of the kernel onto a larger output. It is the adjoint, and the input gradient, of a strided convolution. Alternatives are fixed resizing followed by a convolution, and pixel shuffle (sub-pixel convolution), which rearranges channels into space. This page covers all three, their output sizes, and the checkerboard artefacts that uneven kernel overlap causes. In the exercises you verify the adjoint identity and pixel shuffle, then measure checkerboard strength on a constant image: 50% for a 3×3 stride-2 transposed convolution, 12% for 4×4, 8% for pixel shuffle and none for resize-then-convolve.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Making images bigger

A classifier shrinks an image down to a label; a segmentation or image-generation network must grow small feature maps back to full size. A transposed convolution does this by letting every input value “stamp” a small learned pattern onto a bigger canvas, with the stamps spaced apart and overlapping. Simpler options are to enlarge the map with a fixed rule (nearest or bilinear) and then convolve, or to compute several channels and rearrange them into extra pixels (pixel shuffle).

CNN building blocks
kernel copies overlapping each output pixel (9 × 9 input → 19 × 19)
overlap in the interior ranges from 1 to 4: uneven — checkerboard artefacts likely (uneven whenever the kernel size is not divisible by the stride)
Deep-learning "convolution" slides a small learned kernel over the input (no flip). Stride shrinks the output, padding preserves borders, dilation spreads the kernel to see further without more weights. Pooling summarises windows. Stacking layers grows the receptive field. Depthwise-separable and grouped convolutions cut cost by not connecting every input channel to every output channel. Transposed convolution upsamples, but uneven kernel overlap leaves checkerboard patterns. Squeeze-and-excitation rescales whole channels by gates computed from their global averages; CBAM adds a per-pixel spatial gate. (Here the gates are fixed functions of the averages so you can see their effect; in a network the excitation is learned.)
Why engineers care

Upsampling layers produce the pixels you see in segmentation masks, depth maps, super-resolved satellite images and generated images. Poor choices leave checkerboard patterns that can fool downstream processing, so choosing and initialising them well matters.

📝 Quick check (Level 0)
0/3 answered
  1. 1. A transposed convolution…
  2. 2. Pixel shuffle turns…
  3. 3. A common artefact of transposed convolutions is…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Transposed convolution output size: (n − 1)s − 2p + k + output_padding. Examples:
    • n = 4, k = 3, s = 2 → 9;
    • n = 7, k = 4, s = 2, p = 1 → 14;
    • n = 14, k = 3, s = 2, p = 1, output_padding = 1 → 28.
  • Overlap (1-D): three inputs, k = 3, s = 2 give coverage counts 1, 1, 2, 1, 2, 1, 1 (uneven); with k = 4: 1, 1, 2, 2, 2, 2, 1, 1 (even inside). Overlap is even in the interior exactly when k is divisible by s.
  • Nearest upsampling by 2: [1, 2] → [1, 1, 2, 2] in each row and column.
  • Pixel shuffle: a convolution produces C·r² channels at low resolution, then they are rearranged into C channels at r times the resolution: 12 channels for an RGB image at r = 2.
📝 Quick check (Level 1)
0/3 answered
  1. 1. Output size for n = 7, k = 4, s = 2, p = 1:
  2. 2. Is overlap even for k = 3, s = 2?
  3. 3. Channels needed for pixel shuffle to RGB at r = 2:

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 20 minUndergraduate students and practising engineers.

Upsampling in code

Exercise 1.

  • The inner products ⟨conv(x), y⟩ and ⟨x, conv_transpose(y)⟩ agreed, confirming that the transposed convolution is the adjoint of the strided convolution; it mapped 4 × 4 back to 9 × 9.
  • Pixel shuffle placed channel 0, 1, 2 and 3 values in the four phases of each 2 × 2 output block.

Practice.

  • nn.ConvTranspose2d(C_in, C_out, k, stride, padding, output_padding); choose k divisible by s (for example k = 4, s = 2, p = 1 doubles the size exactly).
  • Alternatively nn.Upsample(scale_factor=2, mode="nearest") followed by nn.Conv2d avoids checkerboards (Odena et al., 2016).
  • For super-resolution, nn.PixelShuffle(r) after a convolution with C·r² outputs; initialise with ICNR (copying one phase’s kernel to all phases) to avoid initial artefacts.
up = torch.nn.Sequential(torch.nn.Upsample(scale_factor=2, mode="nearest"), torch.nn.Conv2d(64, 32, 3, padding=1))
🐍 Exercise 1: the transpose is the adjoint
Implement strided and transposed convolutions and pixel shuffle; check the adjoint identity and the pixel shuffle arrangement.
📝 Quick check (Level 2)
0/3 answered
  1. 1. A checkerboard-free alternative is…
  2. 2. ICNR initialisation is for…
  3. 3. The transposed convolution is also…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Adjoint. A strided convolution is a linear map y = Cx. Its transpose Cᵀ maps the output space back to the input space; backpropagation through the convolution computes exactly Cᵀ applied to the output gradient. A transposed-convolution layer is Cᵀ with learnable weights, which is why the operation is not an inverse (“deconvolution” in the signal-processing sense).

Checkerboards. In a transposed convolution with stride s, each output pixel receives contributions from a number of kernel taps that depends on its position modulo s. When k is not divisible by s, these counts differ between phases, so even a constant input produces a periodic pattern. When counts are equal, different phases still use different subsets of weights, so random or poorly trained kernels still create patterns, more weakly (exercise 2).

Resize-convolution. Nearest or bilinear resizing produces a smooth or piecewise-constant image with no phase dependence, and the following convolution is shift-equivariant, so no checkerboard can arise from a constant input.

Pixel shuffle is equivalent to a transposed convolution with stride r and a particular kernel arrangement; it is efficient because all computation happens at low resolution (Shi et al., 2016).

📝 Quick check (Level 3)
0/3 answered
  1. 1. "Deconvolution" layers are really…
  2. 2. Even overlap removes checkerboards from…
  3. 3. Pixel shuffle is efficient because its computation is at…

Level 4: Expert

★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.

Checkerboard artefacts

History.

  • M. Zeiler et al. (2010) used “deconvolutional” networks; J. Long, E. Shelhamer and T. Darrell (2015) used learned upsampling in FCNs.
  • W. Shi et al. (2016) introduced the efficient sub-pixel convolution (pixel shuffle).
  • A. Odena, V. Dumoulin and C. Olah (2016) explained checkerboard artefacts and recommended resize-convolution.
  • A. Aitken et al. (2017) proposed ICNR initialisation.

Exercise 2. A constant 12 × 12 image upsampled by 2 with random positive kernels (as at the start of training); checkerboard strength is the standard deviation of the four phase means divided by the overall mean, averaged over 200 draws:

method checkerboard strength
transposed convolution, k = 3, s = 2 0.498
transposed convolution, k = 4, s = 2 0.124
pixel shuffle (sub-pixel convolution) 0.076
nearest upsampling + 3 × 3 convolution 0.000
  • Uneven overlap (k = 3, s = 2) gave a strong checkerboard.
  • Even overlap (k = 4) and pixel shuffle reduced it but did not remove it, because different output phases still use different weights.
  • Resize-then-convolve produced none. Training can learn to suppress artefacts, but avoiding them by design is more reliable.
🐍 Exercise 2 (research): checkerboard artefacts
Upsample a constant image with transposed convolutions of two kernel sizes, pixel shuffle and resize-then-convolve, and measure checkerboard strength.

Upsampling in AI, robotics and aerospace

  • Segmentation and depth decoders for robot and vehicle perception (U-Net, E10-2).
  • Super-resolution of satellite and aerial imagery with pixel-shuffle networks.
  • Generative models for simulation and data augmentation, where artefacts can bias downstream detectors.

References

  1. V. Dumoulin, F. Visin (2016). “A guide to convolution arithmetic for deep learning.” arXiv:1603.07285.
  2. A. Odena, V. Dumoulin, C. Olah (2016). “Deconvolution and checkerboard artifacts.” Distill.
  3. W. Shi et al. (2016). “Real-time single image and video super-resolution using an efficient sub-pixel convolutional neural network.” Proc. CVPR.
  4. A. Aitken et al. (2017). “Checkerboard artifact free sub-pixel convolution.” arXiv:1707.02937.