Principle:Tensorflow Tfjs Pooling Operations
| Knowledge Sources | |
|---|---|
| Domains | Deep_Learning, Computer_Vision, Neural_Network_Architecture |
| Last Updated | 2026-02-10 06:00 GMT |
Overview
Downsampling operations that reduce spatial dimensions of feature maps while retaining the most important information, providing translation invariance and computational efficiency.
Description
Pooling layers reduce the spatial resolution of feature maps by aggregating values within local windows. TensorFlow.js implements pooling for 1D, 2D, and 3D data:
- MaxPooling: Takes the maximum value in each window. Preserves the strongest activations.
- AveragePooling: Takes the mean value in each window. Provides smoother downsampling.
- GlobalMaxPooling / GlobalAveragePooling: Reduce each feature map to a single value. Commonly used before the final classification layer.
Pooling layers have no trainable parameters and serve to progressively reduce spatial dimensions, control overfitting, and make the representation more invariant to small translations.
Usage
Insert pooling layers between convolutional blocks to reduce spatial dimensions. MaxPooling2D is the standard choice in CNN architectures. GlobalAveragePooling2D is commonly used to replace the flatten-then-dense pattern at the end of a CNN, reducing parameter count.
Theoretical Basis
Pseudo-code Logic:
# For each pooling window of size (ph, pw) with stride (sh, sw):
for i in range(0, H - ph + 1, sh):
for j in range(0, W - pw + 1, sw):
window = input[i:i+ph, j:j+pw]
output[i//sh, j//sw] = max(window) # MaxPool
# or mean(window) for AvgPool