Adaptive pooling produces a requested output size instead of shrinking by a fixed factor. It changes the pooling region to match the input, making variable-sized inputs produce consistent tensors. section 8.4.1
For a 3 × 3 target, a 6 × 6 input pools over 2 × 2 regions, while a 12 × 12 input pools over 4 × 4 regions. In PyTorch, nn.AdaptiveMaxPool2d((7,7)) standardizes each RoI before flattening and classification. section 8.4.1
Common shape transformations include:
- Average embeddings with nn.AdaptiveAvgPool2d((1,D)): (B,T,D) becomes (B,1,D), then flattening gives (B,D). The target leaves the feature dimension unchanged and collapses time. section 12.2
- After 1D convolutions, nn.AdaptiveMaxPool1d(1) changes (B,D′,T′) to (B,D′,1), allowing a linear classifier to receive a consistent shape. section 12.3
- Prefer adaptive max pooling for padded variable-length sequences when padding produces zero activations that should not become the selected representation. section 12.3
Collapsing sequence time
Given embeddings shaped (B,T,D), apply nn.AdaptiveAvgPool2d((1,D)), then nn.Flatten(), producing (B,D) for subsequent fully connected layers. This works even when T changes between batches, but averaging discards temporal order. section 12.2
