Depth-Wise Convolutions in Vision Transformers for efficient training on small datasets

Tianxiao Zhang, Wenju Xu, Bo Luo, Guanghui Wang

TL;DR

Vision Transformers (ViTs) often struggle on small datasets because they lack the "inductive bias" that neighboring pixels are related. This paper introduces a lightweight Depth-Wise Convolution (DWConv) shortcut that bypasses Transformer blocks, allowing models to capture local details efficiently and achieve massive performance gains—up to 11% on Tiny-ImageNet—with negligible computational overhead.

What Problem Does This Paper Address?

While Vision Transformers have revolutionized computer vision, they are notoriously data-hungry. Their core mechanism, self-attention, treats every patch of an image equally from the very first layer, focusing on global relationships. However, images are inherently local; a pixel is usually much more related to its neighbor than to a pixel on the opposite side of the frame.

Convolutional Neural Networks (CNNs) have this "local inductive bias" built-in via their sliding filters. ViTs, lacking this, must spend a lot of time and data "learning" that locality matters. This makes training ViTs from scratch on small datasets difficult and slow. The authors aim to bridge this gap by injecting local information back into the ViT architecture without sacrificing its global reasoning power or making it computationally heavy.

Methods

The authors propose a "plug-and-play" module called the DWConv module. Instead of modifying the complex internal structure of the Transformer (like Multi-Head Self-Attention or Feed-Forward Networks), they add a parallel shortcut path.

As shown in Figure 1, the module works as follows:

  1. Reshaping: It takes the 1D sequence of tokens used by the Transformer and reshapes them back into a 2D feature map.
  2. Processing: It applies a sequence of GELU activation, Batch Normalization, and a 3×3 Depth-Wise Convolution.
  3. Integration: The result is reshaped back to 1D and added to the output of the corresponding Transformer block.
Figure 1: The architecture of the proposed DWConv module acting as a shortcut for Transformer blocks.

The paper also explores two architectural variants:

  • Multi-block Bypass: A single DWConv module can bypass 2, 3, or 4 Transformer blocks at once to save parameters in deeper models.
  • Parallel Kernels: Using multiple DWConv modules in parallel with different kernel sizes (e.g., 3x3, 5x5, 7x7) to capture multi-scale local information.

Datasets

The approach was evaluated across a variety of scales:

  • Small Classification Datasets: CIFAR-10, CIFAR-100, and Tiny-ImageNet.
  • Large Classification Dataset: ImageNet-1K.
  • Downstream Tasks: COCO dataset for object detection and instance segmentation (using Swin-Tiny as a backbone).

Key Insights and Ideas

  • Inductive Bias as a Shortcut: The most significant insight is that you don't need to bake convolutions into the attention mechanism. Simply providing a parallel "local" path allows the model to capture fine-grained details that the global attention might overlook.
  • Positional Embedding Redundancy: The authors found that because convolutions with zero-padding can implicitly encode positional information, standard learnable positional embeddings become less critical—and sometimes even redundant—when the DWConv module is present.
  • Efficiency vs. Performance: The overhead is remarkably low. For a ViT-Tiny model, the module adds only about 0.023M parameters and 0.004G FLOPs, which is negligible compared to the backbone's 5.5M parameters and 1.26G FLOPs.
  • Faster Convergence: The hybrid models reach the peak accuracy of vanilla ViTs in roughly 1/3 of the training time (100 epochs vs. 300 epochs).

Key Results

The quantitative improvements are particularly striking on smaller datasets:

  • Tiny-ImageNet: Adding the module to CaiT-xxs12 boosted Top-1 accuracy from 59.17% to 70.47% (an 11.3% jump).
  • Surpassing Larger Models: A ViT-Tiny equipped with DWConv (5.6M params) outperformed a vanilla ViT-Small (21.7M params) on CIFAR-100 by over 4%.
  • Object Detection: On the COCO dataset using Mask R-CNN, the DWConv-enhanced Swin-Tiny improved mAP from 28.2 to 30.6.
  • ImageNet-1K: Even on large-scale data, the method provided a consistent boost, improving CaiT-xxs24 accuracy by 2.0%.

Limitations and Future Work

  • Large Dataset Diminishing Returns: While still beneficial, the performance gains are less dramatic on massive datasets like ImageNet-1K compared to CIFAR or Tiny-ImageNet. This is because abundant data eventually allows vanilla ViTs to learn the necessary inductive biases on their own.
  • Transfer Learning: The authors note that the module provides less benefit during fine-tuning of pre-trained models, as those models have already acquired substantial representation ability during pre-training.
  • Future Directions: The authors suggest further research into how these lightweight local modules can be optimized for even deeper architectures or different types of vision tasks beyond standard classification and detection.

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