TL;DR
A transposed convolution takes a small grid of numbers and produces a larger one. Each input value is multiplied by every weight in a small kernel, and those scaled copies are added together at the positions they land on. The operation has a learnable kernel, so the network decides how to fill in the bigger grid.
It is the usual tool for upsampling inside a network, such as turning a coarse feature map back into a full-resolution image. Despite the common name "deconvolution", it does not undo a convolution.
Where you'll see it: in the decoder half of image segmentation networks such as U-Net, in generators that turn a noise vector into an image, and in autoencoders that rebuild their input.
Intuition
A normal convolution looks at a window of inputs and produces one output. It gathers. A transposed convolution goes the other way. Each input value is a sender. It pushes a scaled copy of the kernel onto the output grid, starting at its own position. Where several senders reach the same output cell, their contributions add up.
Why would a network want this? Most of a convolutional network makes the picture smaller and more abstract. A classifier ends with a single label. A segmentation model, though, must label every pixel, and an image generator must produce a full picture. Something has to make the grid bigger again. Fixed rules such as nearest-neighbour or bilinear resizing do this with no learning. A transposed convolution does it with a kernel the network trains, so the enlarged picture can contain patterns the training data calls for, such as sharp edges or textures.
The name is worth a moment. Convolution is a matrix product with a banded matrix, and transposing that matrix gives the transposed convolution. The original maps a long signal to a short one, so the transpose maps a short one to a long one. It runs backwards in shape, not in meaning.
The plot below shows the simplest case: a stride-2 transposed convolution with a kernel of width 2 turns the input into four values. The two inputs are spaced two output cells apart, so the output doubles in length.
- input [1, 10] (two values)
- transposed output [1, 2, 10, 20] (four values)
The flow below shows where the operation sits in a segmentation network. The encoder shrinks the image with ordinary convolutions and pooling. The decoder grows it again with transposed convolutions.
flowchart LR A[Input image 32x32] --> B[Convolutions and pooling] B --> C[Coarse features 8x8] C --> D[Transposed convolution x2] D --> E[Features 16x16] E --> F[Transposed convolution x2] F --> G[Full-resolution output 32x32]
The math
Convolution as a matrix
Take a one-dimensional input of length and a kernel of length . The valid convolution used in deep learning (strictly speaking a cross-correlation, since the kernel is not flipped) produces an output of length :
Each output is a dot product of the kernel with a window of the input. That means the whole operation is a matrix product , where is an matrix with entries
Each row of is the kernel, shifted one place to the right. A matrix like this, with constant diagonals, is called banded. See Matrix Multiplication for the matrix product itself.
The transposed convolution
The transposed convolution uses the transpose , which is an matrix. Given a vector of length , it returns a vector of length :
The second form is the one to remember. Each is a sender. It adds to output position for every , which is the "spread out and add" picture from the intuition section. Position collects a contribution from every output whose window covers it.
It is the transpose of a linear map, so it is linear in the input and in the kernel, and it trains with ordinary backpropagation.
Stride and output size
Let the stride be , meaning the senders are placed cells apart. For an input of length and a kernel of length , with no padding, the output length is
With stride this is , the full convolution. With stride and it is , so the length doubles. With padding removed from each end, the length becomes .
Stride is what makes this an upsampler. The output grid is roughly times longer than the input grid.
Equivalent view: a convolution on a zero-filled input
The same operation can be written as an ordinary convolution. Insert zeros between neighbouring input values, add zeros at each end, and convolve with the kernel flipped left to right. This is the form most libraries use internally, and it is why the operation is sometimes called a fractionally strided convolution: the stride is effectively .
Worked examples
Take the input and the kernel . Here , , so .
- Forward convolution: and . So .
- As a matrix, . Check: .
- Transposed convolution of : .
- In the scatter view: adds , and adds . The sum is , the same result.
- Interpretation: the output has length 3 again, the original input length. The transposed convolution has restored the shape, not the values. Applying it to gives , which is not .
Take the input , a kernel , and stride .
- Output length: .
- Place each sender at position and spread the kernel from there. The first value, , adds at positions 0 and 1. The second value, , adds at positions 2 and 3.
- Stack the results: .
- Check with the zero-filled view: insert one zero between the inputs to get , pad one zero on each side to get , and convolve with the flipped kernel . The outputs are . Same answer.
- Interpretation: each input value now controls its own pair of output cells. The two pairs do not touch, so nothing is added twice.
Keep the input but change the kernel to , width 3, with stride 2.
- Output length: .
- The first sender, , adds at positions 0, 1 and 2. The second, , adds at positions 2, 3 and 4.
- Position 2 is covered by both senders, so it receives . Every other position receives a single contribution.
- Output: .
- Interpretation: the middle value is larger than its neighbours for no reason in the input. When the kernel width is not a multiple of the stride, some cells are covered more often than others. Repeated over a 2D image, this becomes the grid pattern known as a checkerboard artifact.
A decoder receives a feature map of size with 64 channels and must produce with 32 channels. A common setting is kernel , stride 2, padding 1.
- Output side length: . The spatial size doubles, as intended.
- Each pair of input and output channels needs its own kernel, which is 16 weights. That gives weights, plus 32 biases.
- The same layer with kernel and stride 2 gives with no padding. It has weights, and every output cell is covered exactly once, so no checkerboard forms.
- Interpretation: kernel 4 with stride 2 is more flexible and still divisible by the stride, so its overlap is even. Kernel 2 is cheaper but has less room to learn smooth interpolation.
Tradeoffs and failure modes
Transposed convolution is a learned upsampler, which makes it powerful and easy to misuse. The table below lists the common situations.
| Situation | Problem | Better choice |
|---|---|---|
| Kernel width not divisible by stride (for example , ) | Uneven overlap gives a checkerboard pattern in the output | Use divisible by , such as or with |
| Need to recover the original signal exactly | Transposed convolution is not the inverse of convolution, so values are not restored | A trained autoencoder, or an invertible layer if exact reconstruction is the goal |
| Very large upsampling factor | Many overlapping steps, slow, and prone to artifacts | Upsample in several smaller steps |
| Upsampling should be smooth and predictable | Learned kernels can produce blocky or noisy results with little data | Resize (nearest or bilinear) followed by an ordinary convolution |
| Speed on tight hardware budgets | Transposed convolution is more expensive than a plain resize | Resize plus a convolution, or sub-pixel convolution |
Two practical warnings. "Deconvolution" suggests undoing a convolution, which this is not, so say "transposed convolution". And libraries differ in how they define padding and output padding here, so check the output shape on a small test input before building on it.
History
The operation appeared in several research threads before it had a standard name. In 2010, Zeiler, Krishnan, Taylor and Fergus used the transposed form in deconvolutional networks, which tried to reconstruct image layers from learned features. That work called it deconvolution, and the name stuck in the literature even though the operation is not an inverse.
Long, Shelhamer and Darrell's fully convolutional networks in 2015 made the idea central to dense prediction. They replaced the fully connected layers of a classifier with convolutions and used learned upsampling to produce a full-resolution segmentation map. Ronneberger, Fischer and Brox's U-Net, also in 2015, combined this decoder with skip connections from the encoder, and it became one of the most widely used segmentation architectures in medicine and beyond.
In 2016 Dumoulin and Visin wrote a systematic guide to convolution arithmetic. It set out the shape rules for strides, padding and transposed convolutions, and it pushed the term "transposed convolution" as the accurate name. The same year, Odena, Dumoulin and Olah published an analysis showing that uneven overlap causes checkerboard artifacts, which explained a visible problem many people had seen in generated images. The standard fixes are a kernel size divisible by the stride, or resizing before convolving.
Check yourself
QuestionA transposed convolution has input length , kernel length , stride 1 and no padding. What is its output length?Show answer
The formula is . With stride 1, each input value adds a full copy of the kernel and the copies overlap, so the output is the full convolution length.
QuestionInput , kernel , stride 2. Compute the transposed convolution.Show answer
The output length is . The value 2 adds at positions 0 and 1. The value 3 adds at positions 2 and 3. The result is . Each input value is spread over its own pair of cells, and nothing overlaps.
QuestionIf you apply convolution to an image and then a transposed convolution with the same kernel, do you get the original image back? Why or why not?Show answer
No. Convolution with a kernel of width and stride 1 maps a length signal to length , so information is lost at the edges and inside each window. The transposed convolution maps the shorter result back to length , but the matrix is not the identity. Its values are sums of kernel products, not the original pixels. Transposed convolution restores the shape, not the content.
QuestionA segmentation decoder upsamples a feature map to using a transposed convolution with kernel and stride 2 (with padding set to give the right size). A colleague sees a grid-like pattern in the predictions. What is the likely cause and how would you fix it?Show answer
The kernel width 3 is not divisible by the stride 2, so some output cells are covered by two senders and others by one. Those uneven sums produce the checkerboard. Fix it by changing the kernel to or so the overlap is even, or by replacing the layer with a nearest or bilinear resize followed by a convolution. Either approach removes the uneven coverage that causes the grid.
Sources
- A guide to convolution arithmetic for deep learning (Dumoulin, Visin, 2016)
- Deconvolution and Checkerboard Artifacts (Odena, Dumoulin, Olah, 2016)
- Fully Convolutional Networks for Semantic Segmentation (Long, Shelhamer, Darrell, 2015)
- U-Net: Convolutional Networks for Biomedical Image Segmentation (Ronneberger, Fischer, Brox, 2015)