DropKey

Bonan Li, Yinhan Hu, Xuecheng Nie, Congying Han, Xiangjian Jiang, Tiande Guo, Luoqi Liu · DOI

Vision Transformers (ViTs) have significantly advanced computer vision, yet many of their regularization techniques are directly inherited from Natural Language Processing (NLP). In "DropKey," researchers Bonan Li and colleagues argue that standard dropout applied to attention layers is fundamentally flawed for visual tasks. By shifting the target and timing of the dropout operation, DropKey provides a simple yet effective method to enhance ViT performance across various benchmarks.

The Limitations of Standard Dropout in ViTs

In a standard Transformer architecture, dropout is typically applied to attention weights after the softmax normalization. The authors identify three primary issues with this "vanilla" approach in vision:

  1. Probability Distortion: Applying dropout after softmax and then re-averaging the remaining units disrupts the original probability distribution. This fails to penalize "score peaks," allowing the model to overfit to specific local patterns (local-bias) instead of capturing broader global context.
  2. Sensitivity to Constant Ratios: Most models apply a fixed dropout rate across all layers. However, shallow layers (low-level features) and deep layers (high-level semantics) have distinct regularization requirements.
  3. Lack of Spatial Awareness: Standard dropout treats every patch or token as an independent entity, ignoring the inherent structured, grid-like nature of images.

The DropKey Methodology

To address these issues, the authors propose DropKey, which introduces three key innovations:

Drop-Before-Softmax

Instead of dropping attention weights, DropKey masks the Key ($K$) matrix before the softmax operation. Mathematically, this acts as an adaptive smoothing coefficient. It effectively "lifts the floor" of low-attention areas and "lowers the ceiling" of high-attention peaks, forcing the model to distribute its focus more broadly across the image.

Comparison of standard attention, attention with dropout, and the proposed DropKey mechanism. Note how DropKey results in a more distributed attention map.

Linearly Decreasing Schedule

Rather than a constant rate, DropKey employs a linearly decreasing drop ratio. Shallow layers receive a higher drop rate to prevent overfitting to low-level textures, while deeper layers use a lower rate to preserve the complex semantic information required for final tasks.

Structured Drop Patterns

The researchers also explored "Structured DropKey" variants, including dropping blocks or crosses of patches to account for spatial correlations.

Different spatial drop patterns explored in the study: (a) Random Drop, (b) Block Drop, and (c) Cross Drop.

Interestingly, the authors found that unlike in Convolutional Neural Networks (CNNs), these structured patterns were not strictly necessary for ViTs. This suggests that the self-attention mechanism is inherently capable of grasping contextual information if prevented from overfitting to local peaks.

Experimental Results

DropKey was validated across a wide range of benchmarks, consistently outperforming standard dropout:

  • ImageNet-1K: On T2T-ViT-14, DropKey improved Top-1 accuracy from 81.76% to 82.04%. On the larger VOLOd2, it reached 85.38%.
  • CIFAR-100: T2T-ViT-19 achieved a significant 1.7% accuracy boost.
  • Object Detection: Integrating DropKey into the DETR framework yielded a +1.0 AP improvement on the MS COCO dataset.
  • 3D Human Mesh Recovery: On the HUMBI dataset, DropKey reduced the Mean Per Vertex Error (mPVE) from 57.8 to 57.1, whereas standard dropout actually increased error in some metrics.

Conclusion

DropKey demonstrates that rethinking basic regularization components can lead to substantial gains in Vision Transformers. By encouraging a "smoother" attention distribution—evidenced by higher entropy in attention maps—DropKey makes models more robust to occlusions and less prone to local-bias. While it requires a brief finetuning phase to align expectations between training and inference, its consistent performance gains across classification, detection, and 3D recovery tasks make it a compelling alternative to vanilla dropout for vision-centric Transformers.

Summary updated

BibTeX
@inproceedings{li2023dropkey,
  author = {Bonan Li and Yinhan Hu and Xuecheng Nie and Congying Han and Xiangjian Jiang and Tiande Guo and Luoqi Liu},
  title = {{DropKey}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2023},
  doi = {10.1109/cvpr52729.2023.02174},
}
Figure