Md. Asif Uddin

    Proposition 2I.11.P0237 of 100 in the corpus

    Output size is a count of valid kernel origins.

    Kernel span, both padding widths, stride and the boundary convention determine the output grid. Dilation belongs in the calculation.

    Padding and stride change the output gridFor a seven by seven input, a three by three kernel and dilation one: padding zero and stride one give five by five outputs; padding one and stride one give seven by seven; padding one and stride two give four by four.7 × 7 input · 3 × 3 kernel · dilation 1No paddingpadding 0, stride 15 × 5 outputKeep the sizepadding 1, stride 17 × 7 outputSample every second positionpadding 1, stride 24 × 4 outputOutput per axis: floor((7 + 2p − 3) / s) + 1.
    Fig. 2 — Type D · Comparison — A 7×7 input under three settings, holding the kernel and dilation fixed. Padding and stride change the output grid.

    Count the last window that fits

    Work along one axis. The unpadded input has length nn, the left and right padding widths are pL,pRp_L,p_R, kernel width is kk, dilation is dd, and stride is ss. The effective kernel span is e=d(k−1)+1e=d(k-1)+1.

    A window with origin qsqs in padded coordinates occupies positions qsqs through qs+e−1qs+e-1. It fits exactly when qs+e−1≤n+pL+pR−1qs+e-1\leq n+p_L+p_R-1. Therefore q≤(n+pL+pR−e)/sq\leq(n+p_L+p_R-e)/s. Counting integer origins starting at zero yields

    e=d(k−1)+1,nout=⌊n+pL+pR−es⌋+1.\begin{aligned} e&=d(k-1)+1,\\ n_{\mathrm{out}} &=\left\lfloor\frac{n+p_L+p_R-e}{s}\right\rfloor+1. \end{aligned}
    (I.11.4)

    The floor comes from counting complete windows, not from a rounding preference.

    Equation (I.11.4) assumes positive integer kernel, stride and dilation, non-negative padding, and at least one fitting window. A padded input smaller than the effective kernel is not a valid positive-sized output for this convention. Apply the same derivation independently to height and width.

    For n=7n=7, k=3k=3, d=1d=1, pL=pR=1p_L=p_R=1 and s=2s=2, the result is ⌊(7+2−3)/2⌋+1=4\lfloor(7+2-3)/2\rfloor+1=4. The padded origins are 0,2,4,60,2,4,6. Origin eight would overrun the padded length nine and is not evaluated.

    The diagram compares this with the stride-one outputs of widths five and seven. I.11.B03 adds channels, batches and dilation.

    “Same” must name an alignment convention

    At stride one, keeping the input size requires total padding e−1e-1. If ee is odd this can be split equally. If ee is even, equal integer padding cannot give exactly that total.

    A common stride-ss convention chooses output length ⌈n/s⌉\lceil n/s\rceil and total padding

    P=max⁡(0,(⌈n/s⌉−1)s+e−n).P=\max\left(0,(\lceil n/s\rceil-1)s+e-n\right).

    When PP is odd, assigning the extra element to the left rather than the right changes alignment even though the shape is identical. Frameworks do not all support the same named modes for every stride; the documented PyTorch Conv2d string mode ‘same’, for example, requires stride one. Record actual padding widths when reproducing a model.

    Two arrays can have equal shapes and refer to different input centres. For a feature whose preceding input-centre jump is JJ, a layer shifts the first centre by ((e−1)/2−pL)J((e-1)/2-p_L)J. With even kernels this may be a half-grid offset. Shape equality alone is not sufficient evidence that decoder and skip-connection features align spatially.

    A transposed convolution follows the backward connectivity

    Flatten a bias-free convolution into a matrix AA so that y=Axy=Ax. Then a linear objective with upstream vector gg has input gradient ATgA^{\mathsf T}g. A transposed convolution computes this adjoint connectivity, summing contributions wherever output windows overlap.

    For symmetric padding, its common one-axis shape formula is

    ntransposed=(nin−1)s−2p+d(k−1)+o+1.\begin{aligned} n_{\mathrm{transposed}} ={}&(n_{\mathrm{in}}-1)s-2p\\ &+d(k-1)+o+1. \end{aligned}
    (I.11.5)

    A shape choice resolves stride ambiguity; it cannot reverse information loss.

    Here oo is the output-padding shape parameter. In the usual stride-ambiguity case choose 0≤o<s0\leq o<s; consult the operator’s documented constraints for other dilation combinations. Different input sizes can have the same forward output size because of the floor in (I.11.4). The parameter oo selects a compatible output shape.

    It does not mean that the operator pads missing observations back into existence. A map from four coordinates to two cannot have a two-sided inverse. I.11.X07 writes its matrix, verifies the adjoint identity and chooses the output shape explicitly.

    For segmentation, upsampling restores the size of a prediction grid. Whether it restores useful detail depends on the representations available to the decoder. Equal image dimensions do not prove reconstruction.

    Sources