Partial Convolution based Padding

Guilin Liu, Kevin J. Shih, Ting-Chun Wang, Fitsum A. Reda, Karan Sapra, Zhiding Yu, Andrew Tao, Bryan CatanzaroarXiv 2018

Abstract: In this paper, we present a simple yet effective padding scheme that can be used as a drop-in module for existing convolutional neural networks. We call it partial convolution based padding, with the intuition that the padded region can be treated as holes and the original input as non-holes. Specifically, during the convolution operation, the convolution results are re-weighted near image borders based on the ratios between the padded area and the convolution sliding window area. Extensive experiments with various deep network models on ImageNet classification and semantic segmentation demonstrate that the proposed padding scheme consistently outperforms standard zero padding with better accuracy.

Introduction

Standard convolutional neural networks (CNNs) usually "pad" image borders with zeros to maintain spatial dimensions. However, this common practice is fundamentally flawed as the network treats these zeros as real data. This introduces "unrelated data" that can confuse the network, forcing it to waste capacity learning to ignore artificial boundaries. Other methods like reflection or replication padding create unrealistic patterns that also lead to border artifacts and reduced accuracy.

This paper introduces Partial Convolution based Padding, a drop-in replacement that treats padded regions as missing data ("holes") and re-weights the convolution output based on the ratio of valid pixels. This approach leads to higher accuracy, faster convergence, and fewer border artifacts.

Methodology

The core innovation adapts the concept of Partial Convolutions—originally designed for image inpainting—to the task of padding. The process involves three main steps:

  1. Masking: A binary mask is created where original pixels are assigned a value of 1 and padded pixels are assigned 0.
  2. Re-weighting: During the convolution operation, the output at each position is scaled by a ratio: $$\text{Scaling Factor} = \frac{\text{Total area of the convolution window}}{\text{Area of the valid (non-padded) pixels in the window}}$$
  3. Bias Adjustment: The convolution only considers the weighted sum of the valid pixels.
Illustration of the partial convolution padding components: (a) input feature map, (b) binary mask, (c) zero-padded input, (d) zero-padded mask, and (e) one-padded mask used for normalization.

Essentially, if a $3\times3$ filter is partially off the image, the partial convolution calculates the result based only on the pixels it can see and then "boosts" that value to account for the missing area. Standard zero padding is a special case of this formula where the scaling factor is always 1, regardless of how much of the window is empty.

Experimental Results

The researchers evaluated the proposed method on two primary tasks: ImageNet classification and Cityscapes semantic segmentation.

ImageNet Classification

Using architectures such as VGG and ResNet, the method consistently outperformed standard zero padding. For instance, VGG19 saw a 0.68% top-1 accuracy increase, and ResNet50 saw a 0.48% increase. Beyond raw accuracy, the method also demonstrated faster convergence; ResNet50 reached 74.9% accuracy in 63 epochs with partial convolution padding, compared to 68 epochs with zero padding.

Comparison of ImageNet Top-1 Accuracy between standard zero padding and the proposed partial convolution-based padding across various model architectures.

Semantic Segmentation

On the Cityscapes dataset using the DeepLabV3+ framework, the method improved Mean Intersection over Union (mIOU). The gains were most pronounced at the image borders, where partial convolution padding outperformed zero padding by up to 1.25% mIOU. Standard padding often causes "strong activation regions" at the edges of feature maps, whereas partial convolution eliminates these artifacts, leading to cleaner predictions at boundaries.

Discussion and Conclusion

Partial convolution based padding offers a robust alternative to standard padding techniques. Models trained with this method are less sensitive to the specific padding type used at inference time. While the current PyTorch implementation is approximately 4% slower than standard padding, this overhead could be mitigated with custom CUDA kernels that pre-calculate and cache re-weighting factors.

Future work includes exploring the impact of this padding scheme on more modern architectures like Vision Transformers and investigating its utility in specialized domains like medical imaging or satellite photography, where large padding offsets are often required.

Summary updated

BibTeX
@misc{liu2018partial,
  author = {Guilin Liu and Kevin J. Shih and Ting-Chun Wang and Fitsum A. Reda and Karan Sapra and Zhiding Yu and Andrew Tao and Bryan Catanzaro},
  title = {{Partial Convolution based Padding}},
  year = {2018},
  eprint = {1811.11718},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1811.11718},
}
Figure