Semi-supervised Vision Transformers

Zejia Weng, Xitong Yang, Ang Li, Zuxuan Wu, Yu-Gang Jiang

Abstract

We study the training of Vision Transformers for semi-supervised image classification. Transformers have recently demonstrated impressive performance on a multitude of supervised learning tasks. Surprisingly, we show Vision Transformers perform significantly worse than Convolutional Neural Networks when only a small set of labeled data is available. Inspired by this observation, we introduce a joint semi-supervised learning framework, Semiformer, which contains a transformer stream, a convolutional stream and a carefully designed fusion module for knowledge sharing between these streams. The convolutional stream is trained on limited labeled data and further used to generate pseudo labels to supervise the training of the transformer stream on unlabeled data. Extensive experiments on ImageNet demonstrate that Semiformer achieves 75.5% top-1 accuracy, outperforming the state-of-the-art by a clear margin. In addition, we show, among other things, Semiformer is a general framework that is compatible with most modern transformer and convolutional neural architectures. Code is available at https://github.com/wengzejia1/Semiformer .

Introduction

Vision Transformers (ViTs) have revolutionized computer vision, often surpassing traditional Convolutional Neural Networks (CNNs) when trained on massive datasets. However, ViTs possess a notable "data-hunger" due to their lack of inductive bias—the built-in assumptions about local image structure that CNNs inherently utilize. This makes ViTs difficult to train when labeled data is scarce. In semi-supervised learning (SSL) settings, where models must leverage a small set of labeled images alongside a large pool of unlabeled ones, ViTs typically underperform compared to CNNs. This paper introduces Semiformer, a novel dual-stream framework designed to bridge this gap by combining the strengths of both architectures.

Methodology

The Semiformer framework addresses the limitations of ViTs in low-data regimes by pairing a transformer stream with a convolutional stream. This dual-stream approach allows the model to benefit from the CNN's superior inductive bias for generating reliable pseudo-labels.

Evolution of the Semiformer architecture from Vanilla and Conv-labeled baselines.

Dual-Stream Architecture and Fusion

  1. CNN as the Teacher: Recognizing that CNNs are more reliable when data is limited, Semiformer uses the convolutional stream to generate pseudo-labels for unlabeled images. These labels supervise the training of both the CNN and the Transformer streams.
  2. Cross-Stream Feature Fusion: Beyond label sharing, the two streams interact at the feature level. CNN features are downsampled and aligned with Transformer patch tokens, while Transformer tokens are upsampled to match CNN feature maps. This synergy allows the Transformer to leverage local textures while the CNN benefits from global context.
  3. SSL Strategy: The framework builds on the FixMatch paradigm, utilizing weak augmentations for pseudo-label generation and strong augmentations for the primary training step.

Datasets

The researchers evaluated Semiformer on ImageNet-1K (using 1%, 5%, 10%, and 20% labeling ratios) and Places205 to demonstrate generalizability across both object-centric and scene-centric data.

Results and Analysis

A key finding of this research is that a ViT's performance in SSL is primarily bottlenecked by its own inaccurate predictions. By supervising a Transformer with a CNN's pseudo-labels (the "Conv-labeled" setup), accuracy improves significantly.

Comparison of Top-1 accuracy on ImageNet-1K with 10% labeled data across different configurations.

Performance Benchmarks

On ImageNet with 10% labeled data, Semiformer achieved a state-of-the-art 75.5% top-1 accuracy, outperforming previous methods like MPL (73.9%) and CowMix (73.9%). At the 5% labeling ratio, Semiformer (66.3%) significantly outperformed both the Vanilla ViT (45.7%) and the Vanilla CNN (61.3%).

Efficiency and Robustness

Despite its dual-stream nature, Semiformer is highly parameter-efficient. It outperforms massive CNN-only SSL models, such as S4L (ResNet-50 4x), by 2.3% while utilizing only 11% of the parameters. Qualitative analysis via attention maps further shows that Semiformer focuses more precisely on critical objects compared to standard ViTs, which often produce scattered attention in low-data settings.

Discussion and Conclusion

While Semiformer introduces additional computational overhead during training due to its parallel streams, it provides a robust solution for deploying Vision Transformers in data-constrained environments. The framework is highly generalizable and compatible with various modern architectures. Future work may involve exploring more advanced teacher strategies or applying this dual-stream SSL approach to dense prediction tasks like object detection and segmentation.

Summary updated

BibTeX
@inproceedings{weng2022semi,
  author = {Zejia Weng and Xitong Yang and Ang Li and Zuxuan Wu and Yu-Gang Jiang},
  title = {{Semi-supervised Vision Transformers}},
  booktitle = {European Conference on Computer Vision},
  year = {2022},
  url = {https://openreview.net/forum?id=qw6-hcA1PI},
}
Figure