NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Attention Based Pruning for Shift Networks

Ghouthi Boukli Hacene, Carlos Lassance, Vincent Gripon, Matthieu Courbariaux, Yoshua Bengio

TL;DR

This paper introduces Shift Attention Layers (SALs), a novel method that prunes convolutional layers into efficient "shift layers" by learning which shifts are most important during training. SALs achieve better accuracy than existing shift-layer methods and standard CNNs while significantly reducing computational cost and parameter count, making them ideal for resource-constrained devices.

What Problem Does This Paper Address?

Deep learning models, particularly Convolutional Neural Networks (CNNs), achieve state-of-the-art performance in computer vision tasks. However, their accuracy often comes at the cost of a massive number of parameters and high computational complexity, making them unsuitable for deployment on devices with limited resources (e.g., mobile phones, embedded systems). While various compression techniques exist, this paper focuses on improving the efficiency of convolutional layers by replacing them with simpler, faster operations. Previous work introduced "Shift Layers" (SLs) that combine a shift operation with a 1x1 convolution, offering a good trade-off between accuracy and efficiency. However, these shifts were often hand-crafted or arbitrarily predetermined. The challenge addressed here is how to learn the optimal shifts for these layers during training to maximize accuracy while minimizing computational overhead.

Methods

The core innovation is the Shift Attention Layer (SAL). SALs build upon the concept of Shift Layers (SLs) but introduce an attention mechanism. Here's how it works:

  • Vanilla Convolution: The process starts with a standard convolutional layer.
  • Attention Tensor (A): A new tensor, A, is introduced, which has the same dimensions as the convolutional layer's weights. Each element in A represents the importance of the corresponding weight. Initially, these values are normalized between 0 and 1.
  • Softmax with Temperature: During training, A is processed using a softmax function with a decreasing temperature. This encourages A to become more selective over time.
  • Pruning via Attention: As training progresses, the attention mechanism learns which weights are most crucial for the task. The goal is for A to become binary, with only one non-zero element per slice of the weight tensor. This effectively "prunes" the convolutional kernel, leaving only a single connection per input channel.
  • Shift Operation: The learned attention tensor A dictates which shifts are performed. Instead of arbitrary shifts, SALs learn to transform a standard convolution into a shift operation where only the selected weights (corresponding to the highest attention values) are used. This effectively replaces a large convolutional kernel with a 1x1 convolution applied to a shifted version of the input.
  • Training: The weights of the convolutional layer (W) and the attention tensor (A) are trained jointly via back-propagation.

This approach allows the network to dynamically learn the most effective shifts for each layer, rather than relying on pre-defined strategies.

Datasets

The paper evaluates SALs on standard computer vision benchmarks:

  • CIFAR10
  • CIFAR100
  • ImageNet ILSVRC 2012

Key Insights and Ideas

  • Learning Optimal Shifts: The most significant insight is that learning the shift operations dynamically through an attention mechanism leads to better performance than pre-determined or arbitrarily chosen shifts. This allows the network to adapt its structure to the specific task and dataset.
  • Attention as a Pruning Mechanism: The attention tensor A acts as a sophisticated pruning mechanism, identifying and retaining only the most critical connections within a convolutional kernel. This leads to a significant reduction in parameters and FLOPs.
  • Layer-Specific Shift Distributions: Experiments reveal that deeper layers tend to favor corner shifts, while earlier layers exhibit more uniform shift distributions. This suggests that the importance of spatial locality varies across network depth, a finding that challenges uniform shift assumptions.
  • Efficiency without Sacrificing Accuracy: SALs demonstrate that it's possible to achieve high accuracy comparable to or even exceeding baseline models, while drastically reducing computational cost and memory footprint.

Key Results

  • Improved Accuracy: On CIFAR10 and CIFAR100, SALs (referred to as SANet) achieved better accuracy than the baseline CNNs and vanilla ShiftNet. For instance, on CIFAR10, SANet reached 95.52% accuracy compared to the baseline's 94.66% and ShiftNet's 93.17%.
  • Reduced Parameters and FLOPs: SALs significantly reduce the number of parameters and floating-point operations (FLOPs). For example, on CIFAR10, SANet used 0.98M parameters and achieved 77.39% accuracy on CIFAR100 with 1.01M parameters, compared to the baseline's 1.22M and 1.24M respectively. On ImageNet, SAL achieved better accuracy with a comparable or smaller FLOPs budget than standard CNNs and vanilla ShiftNet.
  • Competitive with Pruning Methods: When compared to other pruning techniques on CIFAR10, SANet achieved comparable or better accuracy with fewer parameters and FLOPs. For instance, on CIFAR10 with Resnet-56, SANet achieved 94% accuracy with 0.36M parameters and 42M FLOPs, outperforming other pruning methods in terms of efficiency.
  • Layer-Specific Shift Behavior: Heatmaps visualizing the learned attention weights showed that earlier layers tend to have more uniform shift distributions, while later layers exhibit a preference for corner shifts, indicating a learned adaptation to spatial feature importance.

Limitations and Future Work

  • Temperature Sensitivity: The authors note that the choice of initial and final softmax temperatures is sensitive and impacts the final accuracy. Too slow a decrease can lead to local minima, while too fast a decrease prevents finding optimal shifts.
  • Uneven Shift Distribution: While beneficial for accuracy, the learned uneven distribution of shifts requires storing information about which shift is performed for each feature map, adding a slight memory overhead. To mitigate this, the authors reduced the number of feature maps in their experiments to keep total memory comparable.
  • Future Work: The paper suggests that the observed layer-specific shift distributions (favoring corners in deeper layers) raise interesting questions about hyperparameter choices in existing architectures. Further exploration of how to leverage these learned, non-uniform shift patterns could lead to even more efficient and accurate models. The authors also mention that SAL is an interesting alternative to channel-pruning methods.

Summary updated

BibTeX
@inproceedings{hacene2020attention,
  author = {Ghouthi Boukli Hacene and Carlos Lassance and Vincent Gripon and Matthieu Courbariaux and Yoshua Bengio},
  title = {{Attention Based Pruning for Shift Networks}},
  booktitle = {ICPR},
  year = {2020},
  doi = {10.1109/icpr48806.2021.9412859},
}
Figure