C.W.K.
Stream
Lesson 02 of 06 · published

Pooling Layers and Modern Alternatives

~10 min · pooling, max-pool, global-avg-pool

Level 0Level 0
0 XP0/78 lessons0/17 achievements
0/100 XP to next level100 XP to go0% complete

Reduce spatial size, build invariance

After convolution, pooling reduces the spatial dimensions of feature maps. Two purposes: cheaper computation in subsequent layers, and a degree of spatial invariance — the exact position of a feature matters less.

MaxPooling2D takes the max value in each pool window. Most common; preserves the strongest activations. AveragePooling2D takes the mean — used in some architectures, generally weaker for classification.

GlobalAveragePooling2D is the modern replacement for Flatten + Dense. It averages each entire feature map down to a single value: (batch, h, w, channels) → (batch, channels). ResNet, EfficientNet, MobileNet all use this — dramatically fewer parameters than Flatten, and it acts as a structural regularizer.

Modern alternative: instead of Conv → MaxPool, use Conv with stride=2 for learned downsampling. The network decides how to combine spatial info, rather than applying a fixed max operation.

Code

Pooling 종류들·python
from keras import layers

# MaxPooling — most common
max_pool = layers.MaxPooling2D(pool_size=2, strides=2)
# Input (batch, 32, 32, 64) → Output (batch, 16, 16, 64)

avg_pool = layers.AveragePooling2D(pool_size=2)

# GlobalAveragePooling2D — modern replacement for Flatten
# Input (batch, 8, 8, 256) → Output (batch, 256)
global_avg = layers.GlobalAveragePooling2D()
global_max = layers.GlobalMaxPooling2D()

# Flatten — only when GlobalAvgPool isn't appropriate
flat = layers.Flatten()
# Input (batch, h, w, c) → Output (batch, h*w*c)
Strided conv — pool 대안·python
from keras import layers

# Traditional: Conv + MaxPool
traditional = [
    layers.Conv2D(64, 3, padding='same', activation='relu'),
    layers.MaxPooling2D(2),    # halve spatial
]

# Modern: stride=2 conv (learned downsampling)
strided = [
    layers.Conv2D(64, 3, strides=2, padding='same', activation='relu'),
]

# Dilated conv — expand receptive field without downsampling
dilated = layers.Conv2D(64, 3, dilation_rate=2, padding='same',
                         activation='relu')

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.