Exploring Long-Sequence Masked Autoencoders

Ronghang Hu, Shoubhik Debnath, Saining Xie, Xinlei ChenarXiv 2022

Abstract

Masked Autoencoding (MAE) has emerged as an effective approach for pre-training representations across multiple domains. In contrast to discrete tokens in natural languages, the input for image MAE is continuous and subject to additional specifications. We systematically study each input specification during the pre-training stage, and find sequence length is a key axis that further scales MAE. Our study leads to a long-sequence version of MAE with minimal changes to the original recipe, by just decoupling the mask size from the patch size. For object detection and semantic segmentation, our long-sequence MAE shows consistent gains across all the experimental setups without extra computation cost during the transfer. While long-sequence pre-training is discerned most beneficial for detection and segmentation, we also achieve strong results on ImageNet-1K classification by keeping a standard image size and only increasing the sequence length. We hope our findings can provide new insights and avenues for scaling in computer vision.

Introduction

Masked Autoencoders (MAE) have established themselves as a cornerstone of self-supervised learning in computer vision. The standard MAE paradigm involves partitioning a fixed-resolution image (typically 224x224) into a grid of patches (usually 16x16), masking a significant portion (e.g., 75%), and training a Transformer to reconstruct the original pixel values. While this configuration has proven highly effective for image classification, its suitability for dense downstream tasks—such as object detection and semantic segmentation—remains an open question. These tasks inherently require higher spatial resolution and more granular context than simple classification.

Simply increasing the input resolution or reducing the patch size to provide more detail often encounters a fundamental hurdle: the reconstruction task becomes trivial. If the masked area is too small relative to the local image structure, the model can "cheat" by simply interpolating from adjacent pixels, failing to learn high-level semantic features. This paper identifies sequence length ($L$) as the critical axis for scaling MAE and proposes a simple decoupling strategy to maintain task difficulty while increasing input richness.

Methodology: Decoupling Mask Size

The primary innovation of this work is the decoupling of the mask size from the patch size. In the standard MAE recipe, these two are identical. To scale the sequence length $L = (I/p)^2$ (where $I$ is image size and $p$ is patch size), one must either increase $I$ or decrease $p$.

Overview of the long-sequence MAE framework, illustrating the relationship between image size, patch size, and sequence length.

To prevent the model from exploiting local pixel correlations when $p$ is small, the authors introduce a "Glue" strategy. Instead of masking individual patches, they group adjacent patches into larger blocks (e.g., $m \times m$ blocks) for masking. This ensures that the masked regions remain large enough to force the model to learn meaningful spatial representations, even as the underlying sequence length increases.

Comparison of masking strategies: $m = 1 \times 1$ (standard) vs. $m = 2 \times 2$ (glued). The glued strategy maintains task difficulty for longer sequences.

Crucially, this modification is applied only during the pre-training phase. During downstream transfer, the model uses the standard fine-tuning setup. This "decoupled pre-training and transfer" approach ensures that any performance improvements are a direct result of superior pre-trained features rather than increased computational overhead during inference.

Experimental Setup

The study employs a systematic "Fix One, Vary Two" ablation strategy to isolate the effects of Image Size ($I$), Patch Size ($p$), and Sequence Length ($L$). Models were pre-trained on a variety of datasets, including COCO (including unlabeled data), ImageNet-1K, Open Images, and Places. Evaluation focused on dense tasks:

  • COCO: Object detection and instance segmentation.
  • ADE20K: Semantic segmentation.
  • LVIS: Long-tail instance segmentation using the SimpleFPN architecture.
  • ImageNet-1K: Standard classification for completeness.

Key Insights and Results

The experiments revealed several critical findings regarding the scaling of MAE:

  1. Sequence Length Dominance: $L$ is the primary driver of performance. Whether a long sequence is achieved through higher resolution or smaller patches, the gains are consistent as long as the masking difficulty is preserved via the glue strategy.
  2. Scene-Level Synergy: Long-sequence pre-training is particularly effective on complex datasets like COCO or Places. These datasets contain multiple objects and intricate spatial relationships, unlike ImageNet, which is often dominated by a single, centered object.
  3. Model Capacity: Larger architectures, such as ViT-Large, exhibit a stronger synergy with long sequences than smaller models like ViT-Base, suggesting that scaling model size and input complexity should go hand-in-hand.

Quantitatively, the long-sequence approach yielded significant improvements. For instance, a ViT-Base model pre-trained with a sequence length of 784 (compared to the standard 196) saw a +1.2 point increase in COCO Box AP and a substantial +2.6 mIoU boost on ADE20K. On the challenging LVIS dataset, the improvement reached +2.9 AP. Remarkably, pre-training on the relatively small COCO dataset with long sequences outperformed standard ImageNet pre-training for these dense tasks, highlighting the importance of sequence quality over raw image quantity.

Conclusion and Future Work

This research demonstrates that scaling the input sequence length is a highly effective and "computationally free" (at inference) method for improving MAE representations for dense vision tasks. By decoupling mask size from patch size, the difficulty of the self-supervised task is preserved even as spatial resolution increases.

While the benefits for dense tasks are clear, the gains for standard ImageNet classification are more modest, suggesting that classification may not fully utilize the fine-grained spatial information provided by long sequences. Future work could explore more sophisticated masking patterns or extend these findings to the temporal dimension in video data, where sequence lengths are naturally much larger.

Summary updated

BibTeX
@misc{hu2022exploring,
  author = {Ronghang Hu and Shoubhik Debnath and Saining Xie and Xinlei Chen},
  title = {{Exploring Long-Sequence Masked Autoencoders}},
  year = {2022},
  eprint = {2210.07224},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2210.07224},
}
Figure