Abstract
In contrast to fully connected networks, Convolutional Neural Networks (CNNs) achieve efficiency by learning weights associated with local filters with a finite spatial extent. An implication of this is that a filter may know what it is looking at, but not where it is positioned in the image. In this paper, we first test this hypothesis and reveal that a surprising degree of absolute position information is encoded in commonly used CNNs. We show that zero padding drives CNNs to encode position information in their internal representations, while a lack of padding precludes position encoding. This gives rise to deeper questions about the role of position information in CNNs: (i) What boundary heuristics enable optimal position encoding for downstream tasks?; (ii) Does position encoding affect the learning of semantic representations?; (iii) Does position encoding always improve performance? To provide answers, we perform the largest case study to date on the role that padding and border heuristics play in CNNs. We design novel tasks which allow us to quantify boundary effects as a function of the distance to the border. Numerous semantic objectives reveal the effect of the border on semantic representations. Finally, we demonstrate the implications of these findings on multiple real-world tasks to show that position information can both help or hurt performance.
Introduction
The success of Convolutional Neural Networks (CNNs) is traditionally attributed to translation equivariance—the property where a filter's response is independent of an object's absolute position. Theoretically, this suggests that CNNs are "spatially agnostic." However, in practice, many visual tasks rely on spatial priors (e.g., the sky is usually at the top). This paper investigates whether CNNs implicitly learn absolute position, the source of this information, and its impact on semantic representation learning.
Methodology
To interrogate the spatial awareness of CNNs, the researchers developed several experimental frameworks:
- PosENet (Position Encoding Network): A diagnostic tool designed to predict gradient-like maps (e.g., horizontal or vertical ramps) from the frozen feature maps of pre-trained backbones like VGG or ResNet. Success in this task indicates that the backbone already encodes positional data.
- Location-Dependent Testing: A grid-based framework where small CIFAR-10 patches are placed on larger canvases (Black, White, or Mean-colored). Performance is measured as a function of the patch's distance from the image border.
- Padding Analysis: A comparative study of various boundary heuristics, including standard zero padding, circular, reflection, and replicate padding, as well as architectures without padding.
The study utilized diverse datasets, including PASCAL-S and DUT-S for saliency, Cityscapes for semantic segmentation, and GTOS-Mobile/DTD for texture recognition.
The Role of Zero Padding
A key finding is that standard zero padding acts as a "spatial anchor." Because zero values are statistically distinct from natural image data, they create a boundary signal that the network can propagate inward to determine absolute coordinates.
The researchers observed a "Black Canvas" effect, where placing images on a black background (effectively a large field of zeros) injects significantly more positional information than other canvas types. Furthermore, there is a positive correlation between a network's ability to encode position and its ability to learn robust semantic features, suggesting that "knowing where" assists in "knowing what."
Experimental Results
The diagnostic PosENet revealed that pre-trained ResNet-152 models encode horizontal and vertical position with near-perfect Spearman Correlation (0.93 to 0.99), even on synthetic black-and-white images.
In location-dependent classification, models without padding suffered severe performance degradation as objects moved away from the borders. On a white canvas, accuracy dropped from ~82% near the edge to ~25% at the center, as the network lost its spatial bearings. Conversely, in real-world semantic segmentation (Cityscapes), zero padding significantly improved the detection of thin, vertical objects like light poles near boundaries.
However, position information is not always beneficial. In texture recognition (GTOS-M), where translation invariance is preferred, reflection padding achieved 85.0% accuracy, outperforming zero padding (81.7%) by effectively hiding the boundary signal.
Conclusion
This study demonstrates that absolute position information in CNNs is often a byproduct of zero padding rather than an inherent architectural property. While this information aids tasks like segmentation, it can act as a "bug" in others like texture recognition. These findings suggest that the choice of padding should be a deliberate design decision based on the task's requirement for spatial awareness versus translation invariance. Future work may involve developing "boundary-aware" convolutions to provide finer control over these effects.
Summary updated