Md. Asif Uddin
    Problem I.11.B03

    Include dilation before counting windows

    shape▲▲△

    Exact integers and fractions where possible; six decimals otherwise.

    STATEMENT

    Audit an entire batched convolution without relying on a framework’s inferred shape.

    GIVEN

    Input layout is (N,C,H,W)=(2,3,7,8)(N,C,H,W)=(2,3,7,8). There are four output channels, a 33 by 33 kernel, dilation two, stride two and padding one on every side. Use one group and a trainable output-channel bias.

    FIND

    Effective kernel span, output shape, weight shape, parameter count and main-product multiply-accumulates.

    STRATEGY

    Use (I.11.4) on each spatial axis, then (I.11.2) on the resulting grid. Dilation spreads taps; it does not create additional weights.

    SOLUTION

    The effective kernel width is 2(3−1)+1=52(3-1)+1=5 on both axes. Therefore

    Hout=⌊7+2−52⌋+1=3,Wout=⌊8+2−52⌋+1=3.\begin{aligned} H_{\mathrm{out}}&=\left\lfloor\frac{7+2-5}{2}\right\rfloor+1=3,\\ W_{\mathrm{out}}&=\left\lfloor\frac{8+2-5}{2}\right\rfloor+1=3. \end{aligned}

    The output shape is (2,4,3,3)(2,4,3,3). The weight shape is (4,3,3,3)(4,3,3,3) and bias shape is (4)(4). There are 4⋅3⋅3⋅3+4=1124\cdot3\cdot3\cdot3+4=112 parameters.

    Each output scalar uses 3⋅3⋅3=273\cdot3\cdot3=27 weights. There are 2⋅4⋅3⋅3=722\cdot4\cdot3\cdot3=72 output scalars, giving 72⋅27=194472\cdot27=1944 multiply-accumulates. This dense accounting includes multiplications by padded zero entries; a specialised implementation may skip some.

    Answer

    Span 55 by 55, output (2,4,3,3)(2,4,3,3), 112 parameters and 1944 main-product multiply-accumulates.

    Check — sanity

    Ignoring dilation would give spatial outputs 44 by 44, a different model. The number of weights would not change, which is why a parameter-count check alone cannot catch that shape error.

    Where this breaks

    The weight layout here is output-channel, input-channel, height, width. A channels-last input convention changes array organisation, not the mathematical count. Named ‘same’ padding need not mean one pixel on each side.

    Variation

    Keep the input and kernel but set dilation to one. The output becomes (2,4,4,4)(2,4,4,4), with 34563456 multiply-accumulates and still 112 parameters.

    Draws on