Improve Supervised Representation Learning with Masked Image Modeling

Kaifeng Chen, Daniel Salz, Huiwen Chang, Kihyuk Sohn, Dilip Krishnan, Mojtaba SeyedhosseiniarXiv 2023

Abstract

Training visual embeddings with labeled data supervision has been the de facto setup for representation learning in computer vision. Inspired by recent success of adopting masked image modeling (MIM) in self-supervised representation learning, we propose a simple yet effective setup that can easily integrate MIM into existing supervised training paradigms. In our design, in addition to the original classification task applied to a vision transformer image encoder, we add a shallow transformer-based decoder on top of the encoder and introduce an MIM task which tries to reconstruct image tokens based on masked image inputs. We show with minimal change in architecture and no overhead in inference that this setup is able to improve the quality of the learned representations for downstream tasks such as classification, image retrieval, and semantic segmentation. We conduct a comprehensive study and evaluation of our setup on public benchmarks. On ImageNet-1k, our ViT-B/14 model achieves 81.72% validation accuracy, 2.01% higher than the baseline model. On K-Nearest-Neighbor image retrieval evaluation with ImageNet-1k, the same model outperforms the baseline by 1.32%. We also show that this setup can be easily scaled to larger models and datasets.

Introduction

Computer vision models typically rely on either supervised learning or self-supervised learning. Supervised learning excels at capturing high-level semantics through human-provided labels but may overlook fine-grained structural details. Conversely, self-supervised methods like Masked Image Modeling (MIM) force models to understand local structures by reconstructing missing image parts, yet they lack top-down semantic guidance.

While MIM is frequently used as a pre-training step followed by supervised fine-tuning, this research explores a joint training framework. By combining these objectives into a single stage, the model receives complementary signals: "what" an object is (classification) and "how" it is structured (MIM). This approach yields more robust visual representations with zero additional cost during inference.

Proposed Method: Joint Supervised and MIM Training

The core of the proposed framework is a "two-stream" training setup utilizing a shared Vision Transformer (ViT) encoder.

The two-stream architecture: Supervised Learning Task (top) and MIM Task (bottom) sharing a common encoder.

Architecture Components

  1. Supervised Stream: The model processes a full, unmasked image. Global Average Pooling (GAP) is applied to the encoder's output tokens, followed by a linear classifier to predict labels via cross-entropy loss.
  2. MIM Stream: The same image is masked (optimally at a 20% ratio). Unmasked patches are processed by the shared encoder. A shallow, single-layer transformer decoder then attempts to reconstruct the missing patches.
  3. Reconstruction Target: Instead of raw pixels, the model predicts visual tokens from a pre-trained VQGAN tokenizer, focusing the learning on semantic structures rather than low-level noise.
  4. Joint Loss: The total training loss is a weighted sum of the classification and MIM reconstruction losses.

During inference, the decoder and masking components are discarded, leaving a standard ViT encoder that has benefited from multi-task training.

Experimental Results and Insights

The joint training approach provides a consistent performance boost across various benchmarks, including ImageNet-1k, ImageNet-21k, and downstream tasks like semantic segmentation (ADE20k) and image retrieval.

Comparison of validation accuracy across different masking ratios for classification, masked classification, and the proposed joint MIM methods.

Key Findings

  • Optimal Masking Ratio: Unlike pure self-supervised learning (e.g., MAE) which uses high masking ratios (75%+), this joint setup performs best at a lower ratio of 20%. This ensures the MIM task remains aligned with the full-image classification task.
  • Shallow Decoders: A single-layer decoder outperformed deeper alternatives. A "weaker" decoder forces the encoder to learn more descriptive features to successfully solve the reconstruction task.
  • GAP vs. [CLS] Token: Using Global Average Pooling (GAP) for representations proved significantly more robust than the traditional [CLS] token, which exhibited instability at certain masking ratios.
  • Performance Gains: The ViT-B/14 model achieved 81.72% accuracy on ImageNet-1k, a 2.01% absolute improvement over the supervised baseline. Robustness also improved, with a +2.66% gain on ImageNet-v2.

Conclusion and Future Work

This framework demonstrates that MIM can serve as a powerful regularizer for supervised learning, preventing overfitting and enhancing spatial understanding. While training compute increases due to the dual forward passes, the inference remains efficient. Future research may explore tokenizer-free reconstruction targets or the application of this joint training paradigm to modern convolutional architectures.

Summary updated

BibTeX
@misc{chen2023improve,
  author = {Kaifeng Chen and Daniel Salz and Huiwen Chang and Kihyuk Sohn and Dilip Krishnan and Mojtaba Seyedhosseini},
  title = {{Improve Supervised Representation Learning with Masked Image Modeling}},
  year = {2023},
  eprint = {2312.00950},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2312.00950},
}
Figure