The interview problem

Practice prompt

Explain transposed convolution shape arithmetic and why it is not generally the inverse of a convolution.

Original practice, not a reported company interview. Scenarios and numbers are illustrative. Interview date: not applicable. Sources retrieved October 1, 2026.

1. Scope and worked approach

Assume a one-dimensional layer. Use output length (input−1)×stride−2×padding+dilation×(kernel−1)+output_padding+1. Transposed convolution applies the transpose of a linear convolution operator under the relevant layout; it does not recover information discarded by stride or nonlinearities. Treat output padding as shape disambiguation rather than invented evidence.

2. Trace the design or derivation

Set shape parameters
  → compute output length
  → check alignment
  → inspect reconstruction

To see the distinction from an inverse, imagine a strided convolution that keeps only alternating values. Many inputs share the same output, so no transpose can uniquely recover the discarded values without additional assumptions. Learned upsampling produces a reconstruction according to training, not a mathematical recovery guarantee.

3. Calculate the example

Input length 5, stride 2, padding 1, kernel 3, dilation 1 and output padding 0 produce (5−1)×2−2+2+1=9. Setting output padding to 1 gives length 10 under valid parameter constraints.

4. Failure cases and trade-offs

Overlapping kernel contributions can create uneven spatial patterns. Matching output shape does not guarantee alignment with skip connections or faithful reconstruction. Resize-then-convolve offers a different artifact/cost trade-off; compare actual image quality rather than choosing by shape alone.

5. Validation, follow-ups and self-review

Check the formula against a small explicit linear operator and its transpose. Follow-up: why can several original input shapes map to one strided output shape? Self-review: separate transpose, inverse and interpolation.

Sources and related practice

Technical reference: docs.pytorch.org — Transposed convolution shape and output-padding semantics.

Source publication/update: Not established. Retrieved October 1, 2026. The workflow, calculations and review exercises are original; this reference is not evidence that a company asked this question.

Continue with Calculate a convolutional network's receptive field; Restore scanned images without inventing evidence.

Continue your preparation

Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.