From Discrete to Continuous Convolution Layers

Assaf Shocher, Ben Feinstein, Niv Haim, Michal IraniarXiv 2020

Abstract

A basic operation in Convolutional Neural Networks (CNNs) is spatial resizing of feature maps. This is done either by strided convolution (downscaling) or transposed convolution (upscaling). Such operations are limited to a fixed filter moving at predetermined integer steps (strides). Spatial sizes of consecutive layers are related by integer scale factors, predetermined at architectural design, and remain fixed throughout training and inference time. We propose a generalization of the common Conv-layer, from a discrete layer to a Continuous Convolution (CC) Layer. CC Layers naturally extend Conv-layers by representing the filter as a learned continuous function over sub-pixel coordinates. This allows learnable and principled resizing of feature maps, to any size, dynamically and consistently across scales. Once trained, the CC layer can be used to output any scale/size chosen at inference time. The scale can be non-integer and differ between the axes. CC gives rise to new freedoms for architectural design, such as dynamic layer shapes at inference time, or gradual architectures where the size changes by a small factor at each layer. This gives rise to many desired CNN properties, new architectural design capabilities, and useful applications. We further show that current Conv-layers suffer from inherent misalignments, which are ameliorated by CC layers.

Introduction

Standard Convolutional Neural Networks (CNNs) are constrained by discrete grids and integer-based resizing. In traditional architectures, spatial resizing is handled by strided convolutions (downscaling) or transposed convolutions (upscaling). These operations are "rigid": they move in fixed integer steps (strides), meaning the relationship between layer sizes is locked in at design time.

This rigidity leads to several issues:

  1. Aliasing: Large integer strides often discard too much information, breaking "shift-equivariance"—where a small shift in the input image causes a massive, unpredictable change in the output.
  2. Fixed Architectures: The output resolution of a specific layer cannot be changed once the model is trained.
  3. Misalignments: Standard convolutions often introduce subtle sub-pixel shifts between layers, especially when using even-sized kernels, which accumulate and degrade performance in tasks like super-resolution.

Continuous Convolution (CC) Layers

To address these limitations, this paper introduces Continuous Convolution (CC) Layers. Instead of a fixed grid of weights, the CC-layer represents the filter as a learned continuous function over sub-pixel coordinates. This allows neural networks to resize feature maps to any arbitrary scale—even non-integers—dynamically at inference time.

The underlying process of CC, moving from a discrete input to a continuous representation that can be resampled at any scale.

The CC-layer generalizes the discrete convolution layer through a process involving four main steps:

  1. Projected Grid: The desired output size is projected onto the input's coordinate space, allowing for non-integer "sub-pixel" coordinates.
  2. Extract Neighbors: For every point on the output grid, the layer identifies the nearest discrete pixels in the input feature map.
  3. Calculate Weights via "Internal-Net": A small, secondary neural network (the Internal-Net) takes the distances between the output point and its neighbors as input and outputs the convolution weights.
  4. Apply Weights: These weights are multiplied by the input features to produce the final output.
A detailed look at the CC-layer architecture, highlighting the Internal-Net that generates weights on the fly.

Key Insights and Architectural Benefits

  • Standard Conv as a Special Case: When the scale factor is an integer and alignment is perfect, a CC-layer mathematically reduces to a standard discrete convolution.
  • Gradual Architectures: CC-layers enable "gradual" networks where downscaling happens by small factors (e.g., $1/\sqrt{2}$) over multiple layers, reducing aliasing and preserving shift-equivariance.
  • Scale Ensembles: Since a trained CC-Net is scale-agnostic, "self-ensembling" can be performed at inference time by passing an image through different internal scaling sequences and averaging results for better accuracy.
  • Fixing Misalignment: CC-layers naturally handle sub-pixel offsets, preventing the "drifting" effect often seen in standard even-sized convolutions.

Experimental Results

The researchers evaluated CC-layers on CIFAR-10 and synthetic datasets.

  • Shift-Equivariance: CC-Nets showed significantly higher resilience to input shifts. For a 6-pixel shift, the CC-Net maintained a cosine similarity of 0.77, compared to 0.65 for the baseline discrete network.
  • Classification Accuracy: On CIFAR-10, CC-Net achieved 87.81% accuracy, slightly outperforming the 87.14% baseline. Scale ensembling at inference time provided an additional boost of +1.7% to +2.4% without additional training.
  • Kernel Learning: Visualizations showed that CC-layers successfully learn to approximate complex continuous functions, such as rotated Gaussian kernels, over several hundred iterations.

Limitations and Future Work

The primary drawback of CC-layers is computational cost; calculating weights on the fly via an Internal-Net is more expensive than using fixed weights. In experiments, CC-Nets took about 15x longer per epoch than baselines. Future work includes optimizing computation through "chunking" and applying CC-layers to Super-Resolution tasks to create universal models for arbitrary upscaling factors.

Summary updated

BibTeX
@misc{shocher2020from,
  author = {Assaf Shocher and Ben Feinstein and Niv Haim and Michal Irani},
  title = {{From Discrete to Continuous Convolution Layers}},
  year = {2020},
  eprint = {2006.11120},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2006.11120},
}
Figure