Chapter 4 — Sub-chapter 4.3

Pooling & Stride

Down-sampling feature maps to keep what matters and discard what doesn't — the key to making CNNs computationally tractable while preserving the structural features a civil engineer cares about most.

30 min read 2 interactive demos 4 quiz questions

Why Shrink a Feature Map?

In the previous sub-chapter you saw how convolution transforms a raw pixel grid into a feature map that highlights edges, textures, and patterns. But a single convolutional layer on a 4000×3000 drone photograph can produce feature maps with millions of values — and a practical CNN may have dozens of such layers stacked in sequence. Without a mechanism to reduce the spatial dimensions progressively, the computation quickly becomes unmanageable.

Enter pooling and stride: two complementary strategies that shrink feature maps while retaining the most important information. Think of it as reducing a detailed structural survey into a concise executive summary — the critical findings are preserved, but the volume of raw data is drastically cut.

Pooling layers have been a staple of CNN architectures since LeNet-5 (1998). They sit between convolutional layers and systematically reduce the height and width of feature maps. Meanwhile, stride — which you briefly encountered in the convolution formula — offers an alternative approach by simply making the convolutional kernel skip positions as it slides across the input.

In this sub-chapter we will dissect both techniques. We will explore three flavours of pooling (max, average, and global average), understand why pooling promotes translation invariance, derive the output size formula, and examine stride as a modern replacement for pooling in many architectures. Along the way, two interactive demos will let you see pooling and stride in action on simulated crack-detection imagery.

Prerequisites

This sub-chapter builds directly on Sub-chapter 4.2: The Convolution Operation. You should be comfortable with the concept of a sliding kernel, element-wise multiply-and-sum, and the output size formula for convolution. No additional mathematics is required.

The Need for Downsampling

Consider a typical drone-based bridge inspection workflow. The camera captures images at 4000×3000 pixels. A first convolutional layer with 64 filters produces 64 feature maps, each 3998×2998 (assuming a 3×3 kernel, stride 1, no padding). That is roughly 767 million floating-point values — just from the first layer. Stack ten more layers at the same resolution and the memory and compute requirements become prohibitive.

Downsampling solves three problems simultaneously:

Three Reasons to Downsample

  1. Reducing computation — Fewer spatial positions means fewer multiply-add operations in subsequent convolutional layers. Halving each dimension reduces the computation by roughly 4×.
  2. Reducing memory — Smaller feature maps consume less GPU/CPU RAM, allowing deeper networks or larger batch sizes.
  3. Translation invariance — Small shifts in the input (e.g. a crack displaced by a few pixels between two photos) produce the same pooled output, making the network more robust to slight positional variations.
Civil Engineering Analogy

Downsampling is like creating a project summary from a full inspection report. After a detailed site survey, the inspector writes a 200-page report with readings at every measurement point. The project manager does not read all 200 pages. Instead, a summary extracts the maximum severity defect per zone (max pooling) or the average condition score per zone (average pooling). The summary is far shorter, yet preserves the critical findings needed for decision-making.

Max Pooling

Max pooling is the most widely used pooling operation. It works by sliding a small window (typically 2×2) across the feature map and, at each position, outputting only the maximum value within that window. The window then moves by its own size (stride = 2) so that the regions do not overlap.

Max Pooling: Step by Step

Consider a 4×4 feature map with the following values:

  1   3   2   4
  5   6   1   2
  7   2   8   0
  3   4   5   1

A 2×2 max pooling window with stride 2 divides the grid into four non-overlapping 2×2 blocks:

  • Top-left block [1,3,5,6] → max = 6
  • Top-right block [2,4,1,2] → max = 4
  • Bottom-left block [7,2,3,4] → max = 7
  • Bottom-right block [8,0,5,1] → max = 8

The output is a 2×2 feature map:

  6   4
  7   8

The spatial dimensions have been halved in each direction (4→2), reducing the total number of values from 16 to 4 — a 4× reduction — while the strongest activations in each region are preserved.

Why "Max" Works for Feature Detection

After convolution, each value in a feature map represents how strongly a particular pattern (e.g. a horizontal edge) was detected at that position. A high value means "strong match"; a low or zero value means "no match". Max pooling selects the strongest detection in each local neighbourhood, effectively saying: "I do not care exactly where within this 2×2 block the edge was — only that it was detected."

This is the essence of translation invariance. If a crack in a concrete surface shifts one pixel to the right between two photos, the max value within the pooling window remains the same, so the network produces the same downstream response.

Civil Engineering Analogy

Max pooling is like a building inspector grading zones. Imagine dividing a concrete slab into a grid of zones. For each zone, the inspector records only the worst (maximum severity) defect found. It does not matter whether the crack is in the top-left or bottom-right of the zone — the zone score is the same. This is exactly what max pooling does: it collapses each local region into its single most prominent feature.

Average Pooling

Average pooling works identically to max pooling in its sliding-window mechanics, but instead of taking the maximum value in each window, it computes the arithmetic mean of all values.

Average Pooling: Same Grid, Different Result

Using the same 4×4 feature map from above:

  1   3   2   4
  5   6   1   2
  7   2   8   0
  3   4   5   1

A 2×2 average pooling window with stride 2:

  • Top-left block [1,3,5,6] → avg = (1+3+5+6)/4 = 3.75
  • Top-right block [2,4,1,2] → avg = (2+4+1+2)/4 = 2.25
  • Bottom-left block [7,2,3,4] → avg = (7+2+3+4)/4 = 4.00
  • Bottom-right block [8,0,5,1] → avg = (8+0+5+1)/4 = 3.50

The output is:

  3.75   2.25
  4.00   3.50

Max vs. Average: When to Use Which?

In practice, max pooling is preferred in most CNN architectures because feature detection cares about whether a pattern exists in a region, not the average strength of all patterns. Max pooling retains the strongest signal and discards weaker ones.

Average pooling is sometimes used in later layers where the feature maps are already quite small and the goal is to smooth representations rather than detect sharp features. It is also used in certain specialised architectures for texture classification, where the overall distribution of features matters more than individual peaks.

Key Takeaway

For crack detection and structural defect identification, max pooling is almost always the better choice. A crack produces a strong local activation; average pooling would dilute that signal with the surrounding uniform concrete. Max pooling preserves it.

Global Average Pooling

Global Average Pooling (GAP) is a special case where the pooling window covers the entire spatial extent of the feature map. If the feature map is 7×7, a GAP layer computes the average of all 49 values and outputs a single number.

Global Average Pooling in Action

Suppose the last convolutional layer produces 256 feature maps, each of size 7×7. Global average pooling reduces each 7×7 map to a single value, producing a vector of length 256. This vector is then fed directly to the final classification layer.

Before GAP became popular, networks used fully connected (dense) layers to collapse the spatial dimensions. A 256 × 7 × 7 = 12,544-dimensional vector was connected to (say) 4096 neurons, adding over 51 million parameters. GAP replaces all of that with zero learnable parameters.

Benefits of Global Average Pooling

  • Drastically reduces parameters — no dense layers needed between the last conv layer and the output.
  • Reduces overfitting — fewer parameters means less capacity to memorise training data.
  • Spatially agnostic — the network learns to identify "whether a feature exists" rather than "where it exists," making it more robust to spatial translations.

Modern architectures like GoogLeNet (Inception), ResNet, and EfficientNet all use GAP before their final classification head. In a civil engineering context, a drone crack-detection model using ResNet-50 relies on GAP to condense its final 2048×7×7 feature block into a compact 2048-element vector for classification.

Civil Engineering Analogy

Global average pooling is like a project-level condition index. After the inspector rates individual zones of a structure, the project manager computes an overall condition score for the entire structure by averaging all zone scores. This single number summarises the whole structure and feeds directly into the rehabilitation decision — just as GAP produces a single number per feature channel that feeds into the classifier.

Output Size Formula

The output size after pooling follows the same formula you learned for convolution. For a pooling layer with window size k, stride s, and padding p applied to an input of size n:

Pooling Output Size

output = floor( (n + 2p − k) / s ) + 1

For the most common configuration — 2×2 window, stride 2, no padding:

output = floor( (n − 2) / 2 ) + 1 = n / 2

A 224×224 feature map becomes 112×112. A 112×112 becomes 56×56. Each pooling layer halves the spatial dimensions, reducing the total number of values by 4×.

Worked Examples

Input Pool Size Stride Padding Output
224 × 224 2 × 2 2 0 112 × 112
56 × 56 2 × 2 2 0 28 × 28
13 × 13 3 × 3 2 0 6 × 6
7 × 7 7 × 7 1 0 1 × 1 (GAP)

Notice the last row: a 7×7 pool on a 7×7 input is global average pooling — it collapses the entire feature map to a single number.

Stride as an Alternative to Pooling

In Sub-chapter 4.2 you learned that the convolution kernel normally slides one pixel at a time (stride = 1). But what happens if the kernel skips positions — say, moving two pixels at a time (stride = 2)?

The answer: the output feature map becomes smaller, just as it would with a pooling layer. A stride-2 convolution on a 224×224 input with a 3×3 kernel and padding 1 produces a 112×112 output — exactly the same spatial reduction as a stride-1 convolution followed by 2×2 max pooling. But it does so in a single operation, combining feature extraction and downsampling in one step.

Pooling vs. Strided Convolution

Aspect Max Pooling Strided Conv
Learnable? No (fixed operation) Yes (kernel weights are learned)
Parameters 0 k × k × channels
Information loss Discards all non-max values Learns what to keep/discard
Computation Very cheap (comparison only) More expensive (multiply-add)
Modern usage Still common (ResNet, VGG) Increasingly preferred (all-conv nets)

The "Striding is All You Need" Argument

The influential 2015 paper "Striving for Simplicity: The All Convolutional Net" showed that replacing all pooling layers with strided convolutions produced equal or better accuracy on standard benchmarks. The key insight: because strided convolutions have learnable parameters, the network can learn the best way to downsample, rather than being forced into a fixed max or average operation.

Modern architectures often use a mix: strided convolutions for downsampling within convolutional blocks, and global average pooling just before the classifier head. Pure pooling-only pipelines (like VGG-16) are now considered somewhat dated.

Civil Engineering Analogy

Stride vs. pooling is like choosing between a fixed sampling protocol and an adaptive one. A fixed protocol (pooling) says: "take the worst reading in every 2-metre zone." An adaptive protocol (strided convolution) says: "let the inspector decide what combination of readings best represents each zone." The adaptive protocol requires more training (the inspector needs expertise) but may capture important nuances that a rigid max-or-average rule misses.

Stride Caveat: Aliasing

When stride is used aggressively (e.g. stride 4 or more), fine details can be lost — a phenomenon borrowed from signal processing called aliasing. A hairline crack that occupies only a single pixel might be skipped entirely if the stride is too large. In crack-detection networks, conservative strides (2 at most) combined with anti-aliasing convolutions are recommended.

Pooling in a Full CNN Pipeline

To cement the big picture, let us trace how spatial dimensions evolve through a simple CNN designed for drone-based crack detection on 224×224 images:

Example CNN Dimension Flow

Input image            224 x 224 x 3
Conv1  (3x3, s=1, p=1) 224 x 224 x 32
MaxPool (2x2, s=2)     112 x 112 x 32      <- halved
Conv2  (3x3, s=1, p=1) 112 x 112 x 64
MaxPool (2x2, s=2)      56 x  56 x 64      <- halved
Conv3  (3x3, s=2, p=1)  28 x  28 x 128     <- strided conv
Conv4  (3x3, s=1, p=1)  28 x  28 x 128
Conv5  (3x3, s=2, p=1)  14 x  14 x 256     <- strided conv
Conv6  (3x3, s=1, p=1)  14 x  14 x 256
GAP                       1 x   1 x 256     <- global avg pool
FC  (256 -> 2)            2                  <- crack / no-crack

The input shrank from 224×224 = 50,176 spatial positions to a single value per channel. The combination of max pooling and strided convolutions achieved a 50,176× spatial reduction while the number of channels (feature types) increased from 3 to 256.

This progressive shrink-and-deepen pattern is the hallmark of virtually every CNN architecture, from AlexNet (2012) to the latest EfficientNet variants. Early layers have large spatial maps with few channels (capturing low-level features like edges). Late layers have tiny spatial maps with many channels (capturing high-level features like "crack" or "spalling").

Civil Engineering Application: Drone Crack Detection

A UAV-mounted camera captures a 4000×3000 image of a bridge deck. The image is divided into overlapping 224×224 patches. Each patch passes through the CNN above. Pooling and stride reduce each patch from 150,528 input values (224×224×3) to a 2-element output (crack probability, no-crack probability). Without pooling, the intermediate feature maps alone would consume gigabytes of memory per patch — making real-time inspection impossible even on high-end GPUs.

Translation Invariance: A Closer Look

Translation invariance means that if the input shifts slightly, the output remains (approximately) the same. This property is critical for robustness in real-world applications where the camera position, angle, and distance vary between shots.

How Pooling Creates Translation Invariance

Consider a 1D feature map: [0, 0, 8, 2, 0, 0]. The "8" represents a detected crack at position 3.

After 2×1 max pooling with stride 2: [0, 8, 0].

Now shift the input by 1 pixel: [0, 0, 0, 8, 2, 0].

After pooling: [0, 8, 0]. Same result! The 1-pixel shift was absorbed by the pooling window.

Without pooling, the two feature maps differ at every position. With pooling, the network sees them as identical — crack detected, same location at the coarser resolution.

In practice, pooling provides only approximate translation invariance (up to the size of the pooling window). Larger pooling windows give more invariance but also lose more spatial precision. This trade-off is one reason why modern networks favour smaller, more frequent downsampling steps (stride-2 convolutions) over large pooling windows.

Interactive Demo 1: Pooling Visualiser

Watch a 2×2 pooling window slide across a feature map, selecting the max or average value at each position. The output grid builds up in real time. Toggle between max and average pooling to see how the results differ.

Pooling Step-by-Step Visualiser

Press Play to watch the pooling window slide across the grid, or Step to advance one position at a time.

Interactive Demo 2: Stride vs. Pooling Comparison

This demo compares the effect of max pooling (centre) against strided sampling (right) on a simulated concrete surface with a crack. Notice how max pooling tends to preserve the strongest crack pixels, while naive strided sampling may skip over fine details.

Stride vs. Pooling — Side-by-Side

Left: Original surface  |  Centre: Max pooled  |  Right: Stride (subsample). Click New Surface to generate a fresh crack pattern.

Pooling Has No Learnable Parameters

An important detail that often surprises beginners: standard pooling layers (max, average, GAP) have zero learnable parameters. There are no weights to train, no biases to update. The operation is entirely fixed — it is a hard-coded rule ("take the max" or "take the average") applied identically at every position.

Consequences of Zero Parameters

  • Pooling layers add no training cost — no gradients to compute for the pooling operation itself (though gradients still flow through to earlier layers).
  • Pooling layers add no model size — a network with or without pooling has the same number of stored weights (though the feature map sizes differ).
  • Pooling is not adaptive — it cannot learn to downsample differently for cracks vs. spalling. This is the main argument for strided convolutions instead.

Backpropagation Through Pooling

Even though pooling has no parameters, gradients must still flow backward through it during training. The rules are simple:

  • Max pooling: the gradient passes only to the position that had the maximum value. All other positions receive zero gradient. This is sometimes called a "routing" operation — the gradient is routed to the winner.
  • Average pooling: the gradient is distributed equally among all positions in the window. Each position receives (gradient / window_size).

Common Pooling Configurations

While 2×2 max pooling with stride 2 is by far the most common, you will encounter a few other configurations in the wild:

Configurations You Will See

Architecture Pool Type Window Stride Notes
VGG-16 Max 2×2 2 5 pooling layers
AlexNet Max 3×3 2 Overlapping pooling
GoogLeNet Max + GAP 3×3 / global 2 / — GAP before classifier
ResNet-50 Max + GAP 3×3 / global 2 / — Also uses strided convs
All-Conv Net None — — Strided convs only

Civil Engineering Application: Multi-Scale Structural Analysis

Pooling enables CNNs to analyze infrastructure damage at multiple scales — from hairline cracks to building-level deformation.

Why Max Pooling Works for Cracks

Max pooling preserves the strongest edge responses — exactly where crack boundaries are. A 2×2 max pool on a crack detector's feature map keeps the high-activation crack pixels while halving computation. Average pooling would dilute these critical signals.

Post-Earthquake Assessment

After earthquakes, CNNs with progressive pooling analyze building facades: early layers detect cracks (pixel-level), middle layers identify spalling patterns (cm-level), deep layers assess story-level damage (m-level). The stride/pooling hierarchy mirrors engineering damage scales.

Dam Face Monitoring

Concrete dam faces span hundreds of meters. Pooling lets a CNN trained on 256×256 patches generalize: the same network can detect seepage stains (local, pre-pooling features) and large displacement patterns (global, post-pooling features) in a single pass.

Knowledge Check

Test your understanding of pooling and stride with these four questions.

Question 1 of 4

A 6×6 feature map undergoes 2×2 max pooling with stride 2 and no padding. What is the output size?

Question 2 of 4

Which pooling method is generally preferred for crack detection and why?

Question 3 of 4

How many learnable parameters does a 2×2 max pooling layer have?

Question 4 of 4

What is the main advantage of using strided convolution instead of pooling for downsampling?

Chapter Summary

Key Takeaways

  • Max pooling selects the maximum value in each window, preserving the strongest feature activation. Ideal for detecting sharp, localised features like cracks.
  • Average pooling computes the mean, providing a smoother but potentially diluted representation.
  • Global Average Pooling (GAP) collapses the entire spatial map to a single value per channel, eliminating the need for large fully connected layers.
  • Pooling reduces computation, memory, and provides translation invariance — small shifts in the input produce the same pooled output.
  • Strided convolution offers a learnable alternative to pooling. Modern architectures often combine both.
  • Pooling has zero learnable parameters. Strided convolutions add parameters but let the network learn how to downsample optimally.
  • The output size formula is: floor((n + 2p − k) / s) + 1.
Mini case study

Pooling on the edge: DroneDeploy “Progress AI” at Skanska & Webcor

A 360° reality-capture image from a hard-hat camera is 12 MP per frame, 4 Hz, 8–10 hours per shift. Pushing all of that raw video to a GPU server is hopeless on a site Wi‑Fi link — so DroneDeploy’s “Progress AI” CNN runs on the helmet, where aggressive pooling and stride decide whether the inference pipeline meets its 250 ms latency budget on a Snapdragon 865.

0Latency budget / frame
0Trade-bin classifier F1
0FPS gain (stride 2→4)
0Active project sites

Tracking what got installed today — framing %, drywall %, MEP rough-in — used to mean weekly walk-throughs with a clipboard. Cameras give every superintendent that data continuously, if the CNN can label thousands of square metres of imagery per shift, on a battery-powered phone, before the worker walks out of the area.

“Every extra pooling layer is a few extra hours of battery and another floor we can cover.” — DroneDeploy ML engineering blog, 2022

  • Backbone — MobileNetV3-Small with depthwise-separable convolutions, then a custom 8-class trade-bin head (framing, drywall, electrical, HVAC, plumbing, …).
  • Pooling / stride tuning — the team systematically swept conv stride and max-pool placement to find the smallest receptive field that still resolved trade boundaries.
  • Distill, then quantise — a ResNet-50 teacher labels weak data, MobileNetV3 student distils, then 8‑bit INT quantisation through TensorFlow Lite for the Snapdragon Hexagon DSP.
Per-frame inference time vs effective stride on Snapdragon 865

Effective stride 8 gets the pipeline under the 250 ms helmet-cam budget; going further yields diminishing returns but starts to lose framing-detail accuracy.

  • 3.2× throughput when effective stride was raised from 2 to 4, with only a 0.7 pp drop in trade-bin F1.
  • 92% F1 on the 8-class trade classifier in production, evaluated on 1.2 M held-out frames across 14 projects.
  • ~20 minutes per floor — what used to be a 4‑hour superintendent walk is now passive helmet capture.
  • Stride is the cheapest knob. Doubling stride quarters the activation map — bigger savings than any other architectural change at the same accuracy point.
  • Pool, don’t crop. Max-pool preserves the strongest local feature; aggressive cropping loses the framing edges the model needs.
  • Profile on the real device. The latency curve on a desktop GPU has zero predictive value for the Hexagon DSP.