Introduction
In standard Convolutional Neural Networks (CNNs), the size of the convolutional kernel (e.g., 3x3 or 7x7) is a fixed hyperparameter chosen prior to training. While research indicates that different layers benefit from varying kernel sizes, exhaustively searching for the optimal combination is computationally prohibitive.
Existing attempts to learn kernel sizes typically rely on dilation—spacing out discrete weights. However, dilation limits the kernel's "bandwidth." It struggles to describe fine details in large kernels because the underlying weights remain sparse. Furthermore, standard CNNs are "resolution-locked." A model trained on 32x32 images often fails when tested on 64x64 images because discrete kernels do not scale naturally.
To address these limitations, researchers introduce FlexConv, a novel convolutional layer that learns its own kernel size during training by combining continuous parameterization with a learnable Gaussian mask. This allows "FlexNets" to achieve state-of-the-art results on long-sequence data without pooling layers and enables models to generalize across different image resolutions with minimal accuracy loss.
The FlexConv Approach
FlexConv reimagines the convolutional kernel not as a fixed grid of discrete weights, but as a continuous function.
- Continuous Kernel Parameterization: Instead of a traditional weight tensor, FlexConv uses a small Multi-Layer Perceptron (MLP) that takes spatial coordinates $(x, y)$ as input and outputs the weight for that specific position. This continuous representation allows the kernel to be sampled at any arbitrary resolution.
- The Differentiable Gaussian Mask: To make the kernel size learnable, the MLP's output is multiplied by an anisotropic Gaussian mask. By making the mask's variance ($\sigma$) a learnable parameter, the network effectively "crops" its own kernels. A small $\sigma$ yields a small kernel, while a large $\sigma$ expands the kernel to capture long-range dependencies.
- MAGNets (Multiplicative Anisotropic Gabor Networks): To boost the expressive power of the MLP, the authors introduce MAGNets. These networks utilize Gabor functions (sine waves multiplied by Gaussians) as their basis functions, allowing them to model complex, high-frequency patterns efficiently.
- Analytic Anti-Aliasing: Because MAGNets are mathematically well-defined, the maximum frequency a kernel can represent can be analytically calculated. The authors use this property to regularize the model, preventing it from learning high-frequency patterns that would cause visual artifacts ("aliasing") when deployed at higher resolutions than seen during training.
Key Insights and Performance
The authors evaluated FlexConv across a wide variety of benchmarks, including sequential datasets (sMNIST, pMNIST), time-series/audio (SpeechCommands), and image classification (CIFAR-10, ImageNet-32).
- Automatic Architectural Priors: Interestingly, FlexNets naturally learn to use small kernels in shallow layers and larger kernels in deeper layers. This mirrors common human-designed architectures (like the Inception network), but the network discovers this optimal distribution automatically.
- High Bandwidth at Any Size: Unlike dilation-based methods that become sparse or "blurry" as they grow, FlexConv maintains high-frequency detail regardless of the kernel's spatial extent. This makes it exceptionally well-suited for tasks requiring long-term dependencies, avoiding the information loss typically associated with pooling layers.
- Resolution Independence: Thanks to continuous functions and anti-aliasing regularization, a FlexNet can be trained on low-resolution images—saving roughly 24% in compute time—and then "upscaled" to higher resolutions during inference with very little loss in accuracy.
- State-of-the-Art Results: FlexTCN-6 achieved state-of-the-art performance on almost all tested sequential tasks. Notably, on the challenging
SC_rawdataset (which features 16,000-length sequences), it outperformed previous methods by over 20%. On CIFAR-10, FlexNets achieved 92.2% accuracy, making them competitive with much deeper ResNets while utilizing a simpler, pooling-free architecture.
Limitations and Future Directions
While "cropping" kernels via the Gaussian mask saves some computation, performing convolutions with very large kernels remains computationally expensive ($O(N^2)$). The authors suggest using FFT-based convolutions for massive kernels, though they note that current deep learning frameworks are heavily optimized for small discrete kernels, sometimes masking the theoretical wall-clock gains of cropping.
Additionally, even with anti-aliasing, there is still a minor drop in accuracy when moving to higher resolutions. The authors suspect this is due to the non-linearities (like ReLU) between layers, which are harder to analyze mathematically than the continuous kernels themselves.
Looking forward, FlexConv presents a powerful tool for Neural Architecture Search (NAS). By making kernel size a continuously learnable parameter, it removes a major discrete hyperparameter from the search space, paving the way for more efficient and flexible network design.
Summary updated