Depth-Wise Convolutions in Vision Transformers for Efficient Training on Small Datasets

Tianxiao Zhang, Wenju Xu, Bo Luo, Guanghui Wang · DOI

Abstract

Vision Transformers (ViTs) have demonstrated state-of-the-art performance on large-scale datasets but often struggle when trained on smaller datasets due to a lack of spatial inductive bias. Unlike Convolutional Neural Networks (CNNs), ViTs must learn spatial locality from scratch. This paper introduces a "plug-and-play" Depth-Wise Convolution (DWConv) shortcut module that runs in parallel with standard Transformer blocks. By injecting local spatial information, this approach enables ViTs to converge up to three times faster and achieve significantly higher accuracy on datasets like CIFAR-10 and Tiny-ImageNet, all while adding less than 1% to the total parameter count.

Introduction

Vision Transformers (ViTs) have emerged as powerful alternatives to Convolutional Neural Networks (CNNs). However, a primary drawback is their "data hunger." The self-attention mechanism treats all image patches equally, lacking the inherent spatial inductive bias (locality) that CNNs possess through local filters. Consequently, ViTs require massive datasets to learn that neighboring pixels are typically more related. When trained on smaller datasets like CIFAR-10 or Tiny-ImageNet, ViTs often underperform or require excessively long training times. This research addresses this gap by efficiently reintroducing locality into the Transformer architecture.

Methodology

The authors propose the DWConv module, a lightweight parallel path for each Transformer block. This module acts as a "supervisor," capturing fine-grained local details that global attention might miss in early training stages.

The process involves four key steps:

  1. Shortcut Path: Input tokens are simultaneously processed by the standard Transformer block and the parallel DWConv module.
  2. Reshaping: 1D token sequences are reshaped into 2D feature maps to facilitate convolutional operations.
  3. Processing: The module applies Batch Normalization, GELU activation, and a 3×3 Depth-Wise Convolution. Depth-wise convolutions are chosen for their extreme efficiency.
  4. Fusion: The processed 2D maps are reshaped back to 1D and summed with the output of the Transformer block.
Architecture of the Transformer block with the parallel DWConv module and its internal components.

The authors also explored architectural variants such as multi-block bypasses (where one DWConv module skips multiple Transformer blocks) and parallel kernels of varying sizes (3x3, 5x5, 7x7) to capture multi-scale features.

Experimental Setup

The architecture was evaluated across various scales to test its robustness:

  • Small Datasets: CIFAR-10, CIFAR-100, and Tiny-ImageNet (trained from scratch).
  • Large Dataset: ImageNet-1K for scalability verification.
  • Downstream Tasks: Object detection and instance segmentation on the COCO dataset using Swin-Tiny as a backbone.

Results and Discussion

The inclusion of the DWConv shortcut yielded dramatic improvements in both convergence speed and final accuracy.

Convergence and Accuracy

One of the most striking findings is that ViTs with the DWConv shortcut reached the baseline accuracy of standard ViTs in approximately one-third of the training time (e.g., 100 epochs vs. 300 epochs). Performance gains were substantial across benchmarks:

  • Tiny-ImageNet: ViT-Tiny accuracy jumped from 59.00% to 64.10%.
  • CIFAR-100: CaiT-xxs12 improved from 73.43% to 81.72%.
  • ImageNet-1K: Even on larger data, CaiT-xxs24 saw a 2.0% boost.
  • Object Detection: Swin-Tiny achieved a 2.4 point increase in mAP on COCO, indicating superior local feature extraction for localization tasks.

Efficiency and Redundancy

The overhead is minimal. For a ViT-Tiny (5.5M parameters), the DWConv module adds only 0.023M parameters—a negligible 0.4% increase. Furthermore, the presence of the convolution makes certain complex Transformer features, like specific positional embeddings or LayerScale, less critical, as the convolution naturally encodes spatial relationships.

Conclusion

The DWConv shortcut effectively bridges the gap between the global modeling of Transformers and the local efficiency of CNNs. While the benefits are most pronounced on small-to-medium datasets where inductive bias is crucial, the method remains beneficial even at scale. Future work may explore adaptive fusion mechanisms, such as gating, to dynamically balance local and global information paths throughout the network's depth.

Summary updated

BibTeX
@article{zhang2025depth,
  author = {Tianxiao Zhang and Wenju Xu and Bo Luo and Guanghui Wang},
  title = {{Depth-Wise Convolutions in Vision Transformers for Efficient Training on Small Datasets}},
  journal = {Neurocomputing},
  year = {2025},
  doi = {10.1016/j.neucom.2024.128998},
}
Figure