Large Separable Kernel Attention: Rethinking the Large Kernel Attention design in CNN

Kin Wai Lau, Lai-Man Po, Yasar Abbas Ur Rehman

TL;DR

This paper introduces Large Separable Kernel Attention (LSKA), a novel attention module for Convolutional Neural Networks (CNNs) that significantly reduces computational cost and memory footprint while maintaining or improving performance. LSKA achieves this by decomposing large 2D convolutional kernels into cascaded 1D kernels, making it more efficient and scalable for large kernel sizes compared to existing Large Kernel Attention (LKA) designs.

What Problem Does This Paper Address?

Convolutional Neural Networks (CNNs) have been a cornerstone of computer vision for years, but they have recently been challenged by Vision Transformers (ViTs) in tasks like image classification, object detection, and semantic segmentation. A key factor in ViTs' success is their ability to model long-range dependencies, a capability that has also been explored in CNNs through the use of large kernels. However, a naive implementation of large kernels in CNNs, particularly within attention modules like the Large Kernel Attention (LKA) in Visual Attention Networks (VANs), leads to a quadratic increase in computational and memory requirements as kernel size grows. This makes it impractical to use very large kernels, limiting their potential benefits. This paper aims to address this computational bottleneck while retaining the advantages of large kernel attention.

Methods

The core innovation of this paper is the Large Separable Kernel Attention (LSKA) module. LSKA builds upon the existing LKA module in VANs but fundamentally rethinks its implementation.

  • Decomposition of Large Kernels: The standard LKA uses a depth-wise convolution with a large 2D kernel. LSKA decomposes this large 2D kernel into two cascaded 1D kernels: one horizontal and one vertical. This "separable" approach is inspired by separable convolutions, which are known for their efficiency.
  • LSKA-trivial vs. LSKA: The authors first analyze a "trivial" LKA design (LKA-trivial) that directly uses a large 2D depth-wise convolution. They then introduce LSKA-trivial, which applies the separable kernel decomposition to this trivial design. Finally, they extend this separable decomposition to the full LKA module (which includes dilated depth-wise convolution), resulting in the proposed LSKA module.
  • Efficiency Gains: By decomposing the 2D kernel into two 1D kernels, LSKA significantly reduces the number of parameters and floating-point operations (FLOPs) compared to the standard LKA, especially as the kernel size increases. This allows for the effective use of much larger kernels without prohibitive computational costs.
  • Attention Mechanism: Like LKA, LSKA incorporates an attention mechanism that uses a 1x1 convolution to infer an attention map, which is then multiplied with the input features for adaptive refinement.

Datasets

The paper uses the following datasets for training and evaluation:

  • ImageNet-1K: For image classification and robustness evaluation.
  • COCO 2017: For object detection and instance segmentation.
  • ADE20K: For semantic segmentation.
  • ImageNet-C, ImageNet-A, ImageNet-R, ImageNet-SK: For robustness evaluation against various corruptions, adversarial examples, semantic shifts, and out-of-domain distributions.
  • Describable Textures Dataset (DTD): For texture classification experiments.

No new benchmarks were introduced; instead, the paper focuses on evaluating existing models and their proposed LSKA module on established datasets.

Key Insights and Ideas

  • Separable Kernels are Key to Scalability: The core insight is that decomposing large 2D kernels into separable 1D kernels is a highly effective strategy for reducing computational complexity in attention modules without sacrificing performance. This is a significant step towards making very large receptive fields practical in CNNs.
  • LSKA Balances Performance and Efficiency: LSKA demonstrates a superior speed-accuracy trade-off compared to LKA, especially at larger kernel sizes. It achieves comparable or better accuracy with significantly fewer parameters and FLOPs.
  • Larger Kernels Bias Towards Shape: The study reveals that increasing the kernel size in VAN models (both LKA and LSKA) leads to a stronger bias towards encoding object shape and a weaker bias towards texture. This shape bias is hypothesized to be a key factor in improved robustness.
  • Robustness Advantage: LSKA-based VAN models show improved robustness against various corruptions and out-of-distribution data compared to other models, including ViTs and large kernel CNNs. This robustness is linked to the increased shape bias.

Key Results

  • Computational Efficiency: LSKA significantly reduces parameters and GFLOPs compared to LKA. For instance, VAN-LSKA-Tiny saves 2.4% parameters and 11.1% GFLOPs compared to VAN-LKA-Tiny. These savings increase with larger kernel sizes.
  • Performance Parity/Improvement: LSKA achieves comparable or slightly better accuracy than LKA across various tasks, including image classification (e.g., 75.0% vs. 74.7% Top-1 on ImageNet for Tiny models), object detection (similar AP scores on COCO), and semantic segmentation (similar mIoU on ADE20K).
  • Scalability: LSKA shows better scalability with increasing kernel size. While LKA performance saturates beyond a kernel size of 23, LSKA continues to show improvements or maintain performance up to kernel sizes of 53 and beyond.
  • Robustness: LSKA-based VAN models consistently outperform LKA-based VANs and other state-of-the-art models (ConvNeXt, RepLKNet, SLaK, ViTs) on various robustness benchmarks, demonstrating greater resilience to corruptions and distribution shifts.

Limitations and Future Work

  • Saturation of LKA: The paper notes that the performance of the original LKA design starts to saturate beyond a kernel size of 23. While LSKA mitigates this saturation to some extent, it also shows signs of saturation at very large kernel sizes (e.g., beyond 53), which the authors attribute to potential limitations in network width and depth.
  • Future Work: The authors suggest exploring the benefits of LSKA in other domains, such as video tasks and acoustic tasks. They also propose investigating the impact of network width and depth on the performance saturation observed with very large kernels.

Summary updated

BibTeX
@article{lau2024large,
  author = {Kin Wai Lau and Lai-Man Po and Yasar Abbas Ur Rehman},
  title = {{Large Separable Kernel Attention: Rethinking the Large Kernel Attention design in CNN}},
  journal = {Expert Systems with Applications},
  year = {2024},
  doi = {10.1016/j.eswa.2023.121352},
}
Figure