Md. Asif Uddin

    Chapter 11 I.11

    Convolutional Neural Networks

    A convolution reuses one local rule across a grid. Its efficiency comes from restricting connectivity and sharing parameters, not from ignoring spatial structure.

    Local filters, shared gradients, spatial shapes, receptive fields and the information lost in downsampling.

    How this chapter is built

    M3Load-bearing

    The content is mathematics. Understanding is demonstrated by computation, not recall.

    basics11/11what the words mean
    concept2/2what to picture
    theory4/4why it works, and when it does not
    mathematics15/15derive it, then compute it
    practice9/9build it, break it, read the papers

    Five strands, not one. Mathematics is the spine; the other four are the body. A chapter cannot pay its way out of teaching with problems, nor out of problems with teaching.

    Before you start

    The problem

    A 224 by 224 RGB image has 150,528 scalar inputs. One dense output unit would require that many weights, and separate units would not share a detector between locations. A local shared kernel imposes a different hypothesis class. We compute its output, differentiate its shared weights, and track precisely what it sees and what downsampling discards.

    One kernel applied at every positionA three by three kernel scans the first two rows of a six by six input. The corresponding output cell moves in step. Valid cross-correlation produces a four by four output, using nine shared weights and one bias.6 × 6 input4 × 4 outputsame9 weights10 parameters, including the shared bias.A dense 36 → 16 map needs 592, including biases.
    Fig. 11 — One kernel applied at every position. Nine shared weights and one bias produce a 4×4 map from a 6×6 input.

    What this chapter covers

    • Cross-correlation, kernels and feature maps
    • Input channels, output channels and groups
    • Parameter counts and multiply-accumulates
    • Padding, stride, dilation and exact output shapes
    • Backpropagation as accumulation over overlapping windows
    • Transposed convolution is an adjoint, not an inverse
    • Translation equivariance and its boundary conditions
    • Receptive-field size, spacing and effective influence
    • Max pooling, average pooling and their derivatives
    • LeNet, AlexNet, VGG, ResNet and EfficientNet

    Apparatus

    The mathematics this chapter leans on, held in Book 0 so it can be assumed here without being taught here. Not a gate — follow a link when a step stops making sense.

    The chain rule 0.MC.03 · The chain rule for matrix products 0.MC.07 · Inner products, norms and cosine similarity 0.LA.03

    Notation

    • HSpatial height in pixels
    • W (spatial)Spatial width in pixels
    • CChannels in vision; compute in FLOPs in the scaling chapters
    • WA weight matrix
    • ∇Gradient operator
    • JA Jacobian matrix

    Definitions

    Definition 1Kernel

    A small array of shared weights. In an ordinary two-dimensional layer, each output channel has one spatial kernel for each input channel; their responses are added.

    Definition 2Cross-correlation

    Multiplying a window by the kernel in its stored orientation and summing. Common CNN layers call this convolution. Mathematical convolution reverses the kernel along each spatial axis.

    Definition 3Feature map

    The spatial array of activations in one channel. A convolutional layer normally returns several feature maps; an activation function is a separate operation.

    Definition 4Stride

    The spacing between successive kernel origins in the input grid. A stride above one samples fewer output locations and changes which translations preserve the output sampling grid.

    Definition 5Padding

    The boundary extension applied before evaluating windows. Zero, reflection and circular padding are different functions. The number of added positions can differ on the two sides.

    Definition 6Dilation

    The spacing between adjacent kernel taps. A kernel of width k and dilation d spans d(k - 1) + 1 input positions while retaining k weights along that axis.

    Definition 7Receptive field

    The input positions that can influence a chosen output through the computation graph. Its bounding span may contain holes, and possible influence need not mean a large learned derivative.

    Definition 8Translation equivariance

    Shifting an input shifts its output by the corresponding amount. This differs from invariance, where the output stays unchanged. Boundaries and subsampling restrict an equivariance claim.

    Definition 9Pooling

    A fixed reduction over a spatial window, often its maximum or mean. Pooling usually operates independently per channel. Window size, stride and padding remain part of its definition.

    Definition 10Grouped and depthwise convolution

    A grouped layer splits input and output channels into disjoint groups. Depthwise convolution uses one group per input channel, optionally with several output filters per channel. A following pointwise layer can mix channels.

    Definition 11Transposed convolution

    The linear adjoint of a chosen convolutional map, implemented with its transposed connectivity. It distributes input values into overlapping output windows. It does not generally reconstruct the input of the original map.

    Formal results

    I.11.T1

    Stride-one convolution commutes with translation on an unrestricted grid

    For F_K(X)[i,j] = sum_(c,u,v) K[c,u,v] X[c,i+u,j+v] and translation T_a X[i,j] = X[i-a_1,j-a_2], substitution gives F_K(T_a X) = T_a F_K(X). A spatially constant bias and pointwise activation preserve this property.

    What this does not promise

    A finite crop with boundary padding may break the identity near its edges. Stride s preserves the correspondence only for translations aligned with that sampling lattice. Equivariance does not imply an unchanged classification output.

    I.11.T2

    Shared-kernel gradients sum over every window

    For one stride-one valid channel, Y[i,j] = sum_(u,v) K[u,v] X[i+u,j+v] + b and upstream G, dL/dK[u,v] = sum_(i,j) G[i,j] X[i+u,j+v]. The input derivative accumulates G[i,j] K[u,v] at each participating input entry. I.11.B02 derives both and checks them by finite differences.

    What this does not promise

    No additional kernel flip belongs in this scatter-add rule. A different convolution convention, stride, dilation or padding changes the index map. Padding constants are not trainable input values.

    I.11.T3

    Receptive-field span follows the preceding sampling jump

    For a sequential stack, start with R_0 = J_0 = 1. At layer l, effective kernel width is e_l = d_l(k_l - 1) + 1; then R_l = R_(l-1) + (e_l - 1)J_(l-1) and J_l = s_l J_(l-1). Apply separately to height and width.

    What this does not promise

    This gives a bounding span and sampling jump for local layers, not the learned strength of influence. Dilation may leave holes. Global operations, branching and boundary alignment need their own dependency accounting.

    Assumptions

    Each is paired with the problem that shows what its removal costs. An assumption nobody tests is a disclaimer.

    • The declared boundary extension and stride are compatible with the translation being tested. I.11.X03
    • A max-pooling window has a unique maximum when using the one-hot derivative. I.11.X05
    • Both channel counts are divisible by the group count, and tensor layouts match the implementation. I.11.X08
    • A residual addition joins tensors with identical shapes; an identity path is not a universal lower bound on the total derivative. I.11.X09

    Propositions

    1. Prop. 1A convolution reuses one local rule across a grid.Local connectivity and parameter sharing are separate constraints. Together they define a filter bank whose parameter count is independent of image size.
    2. Prop. 2Output 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.
    3. Prop. 3Depth grows a receptive field, but does not guarantee that the model uses it.Track each layer's kernel span and sampling jump. Then distinguish architectural access from the learned influence of each input.
    4. Prop. 4Pooling removes information within a window, but does not guarantee shift invariance.Max and average pooling discard different details. Their behaviour under a translation depends on which values remain inside each sampled window.

    Numbered equations

    1. Y[o,i,j] = b[o] + sum_(c,u,v) K[o,c,u,v] X[c,is_h - p_t + ud_h,js_w - p_l + vd_w]

      One shared kernel bank is applied to explicitly indexed windows.

      (I.11.1)
    2. P = C_out (C_in/g) k_h k_w + C_out; MACs = N H_out W_out C_out (C_in/g) k_h k_w

      Parameters do not grow with image size; computation does.

      (I.11.2)
    3. dK[u,v] = sum_(i,j) G[i,j] X[i+u,j+v]; dX[i+u,j+v] += G[i,j] K[u,v]

      Every use of a shared weight or overlapping input contributes.

      (I.11.3)
    4. e = d(k - 1) + 1; out = floor((in + p_left + p_right - e)/s) + 1

      Count valid kernel origins, including dilation and both boundaries.

      (I.11.4)
    5. out_transpose = (in - 1)s - 2p + d(k - 1) + output_padding + 1

      Output padding selects a compatible shape, not missing information.

      (I.11.5)
    6. R_l = R_(l-1) + d_l(k_l - 1) J_(l-1); J_l = s_l J_(l-1)

      The preceding jump converts a local window into original input coordinates.

      (I.11.6)
    7. maxpool(x) = max_i x_i; avgpool(x) = (1/m) sum_i x_i

      The reductions lose different information and have different backward rules.

      (I.11.7)
    8. y = x + F(x); dy/dx = I + J_F(x)

      An identity path adds to the branch derivative, but does not prevent cancellation.

      (I.11.8)

    Worked problems

    5/5 problems5/4 variants10/10 exercisesquota met, and enforced

    1. I.11.B01 — Slide one kernel, keep its orientationnumeric▲△△
    2. I.11.B02 — Overlapping windows add their gradientssymbolic▲▲▲
    3. I.11.B03 — Include dilation before counting windowsshape▲▲△
    4. I.11.B04 — A one-pixel shift can cross a pooling boundarycounterexample▲▲△
    5. I.11.B05 — What a depthwise factorisation savescomplexity▲▲△

    The whole problem set, with the exercises →

    Practice

    • For input width 7, kernel 3, padding 1 and stride 2, the output is floor((7 + 2 - 3)/2) + 1 = 4, not 5. The explicit floor-mode layer does not silently add a fifth window.
    • A zero-filled boundary can break translation equivariance. I.11.X03 shifts a finite three-value input and gets a different edge response from shifting the original output.
    • A response moved within one pooling window may leave its maximum unchanged. Moving it across a window boundary changes the pooled map. Pooling does not guarantee invariance to every small translation.
    • Assigning an input gradient instead of adding contributions loses derivatives where convolution windows overlap. The centre entry in I.11.B02 receives four contributions.
    • Reducing spatial resolution can alias high-frequency patterns. Low-pass filtering before subsampling can reduce this sensitivity, but cannot guarantee recovery of information already discarded.