Masked Autoencoders

Machine Learning
Introduced by
Kaiming He
Year
2021
Type
Neural network architecture
Family
Deep Learning, Self-Supervised Learning

What does it do?

Masked Autoencoders (MAE) is a self-supervised learning approach introduced by He and colleagues, with the peer-reviewed version presented at CVPR 2022.

It masks a large share of the image patches and trains a model to reconstruct the missing content from the visible patches. Adapting the masked-prediction idea from NLP to vision, MAE learns visual representations without labels.

The intuition behind the method

Masked autoencoders apply the idea of predicting missing context, a self-supervised signal used in NLP, to images. The input image is divided into patches, and most of them are removed. The model sees only the remaining patches and must infer what the removed ones contained. The source reports that masking a high proportion of the image, such as 75%, gives a non-trivial task that still leaves a meaningful learning signal. The design is asymmetric: the encoder processes only the visible patches, while a lightweight decoder receives the encoded patches together with mask tokens and reconstructs the image. Because the encoder does not spend computation on the masked positions, training large models is more efficient. The encoder is what is kept for downstream use.

History

Kaiming He and colleagues introduced Masked Autoencoders in the work published at CVPR 2022. The source reports that self-supervised pre-training with this approach transferred better than supervised pre-training on downstream tasks. The reported accuracy of 87.8% for a ViT-Huge model applies to pre-training on ImageNet-1K data only.

When to use it

Choose MAE when a large pool of unlabelled images is available and the goal is to pre-train a vision encoder that will then be fine-tuned on a downstream task with comparatively few labels. It suits transformer-style vision backbones, which the source uses for its results. The source reports that transfer performance on downstream tasks outperforms supervised pre-training. It does not compare the two approaches for the case where a large labelled dataset already exists for the target task, so that case should be evaluated empirically. Be cautious when the downstream images differ strongly from the pre-training distribution, because transfer may then be weaker.

Limitations and considerations

  • The reconstruction objective is only a proxy: it does not directly measure the task the model is later fine-tuned for, so the pre-training gain can vary between tasks
  • The mask ratio and the masking strategy strongly affect what is learned, and the best settings reported for natural images may not carry over to other image types
  • Representations pre-trained on one image distribution may transfer poorly to tasks whose data differ greatly from the pre-training set

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Learns from unlabelled images, so the method can be applied where annotation is expensive or unavailable
  • The source reports that transfer performance on downstream tasks outperforms supervised pre-training
  • The asymmetric design runs the encoder only on visible patches, which reduces training computation compared with processing every patch
  • The source reports 87.8% accuracy for a ViT-Huge model trained on ImageNet-1K data only, the best accuracy among methods that use only ImageNet-1K data according to the source

Applications

  • Pre-training a vision encoder on unlabelled images before fine-tuning it on a task with a small labelled set
  • Learning visual features in specialised image domains where labelled data are scarce, provided the pre-training images are representative of the target domain
  • Semi-supervised settings in which unlabelled images are plentiful and only a few labels are available

How it works

How it works

1

Patches of the input image are selected at random and removed, so that only a minority of them remain visible (about 25% at the 75% masking level reported in the source). The mask ratio is a key hyperparameter: the source reports that masking a high proportion, such as 75%, yields a nontrivial and meaningful self-supervisory task.

2

The encoder processes only the visible patches, without mask tokens, and learns features from them. Because masked positions are excluded, the encoder does less computation than it would on the full set of patches. Combined with the high mask ratio, this asymmetric design is reported in the source to accelerate training by 3x or more while improving accuracy.

3

The decoder receives the encoded visible patches together with learnable mask tokens placed at the masked positions, and produces an output for every patch position. The lightweight decoder is used only for training.

4

A reconstruction loss is computed on the masked positions by comparing the decoder output with the original content there. The source describes this target as the missing pixels, so the loss drives the model to predict what was hidden.

Common pitfalls

  • A mask ratio far below the 75% reported in the source is not tested in the source. The source reports that high ratios yield a nontrivial task, so lower ratios should be validated empirically rather than assumed to work.
  • A heavy decoder adds computation that is discarded after pre-training, so the decoder should be kept lightweight.
  • The transfer gains reported in the source depend on the downstream setup, so the pre-trained encoder should be evaluated under the target task's own fine-tuning protocol rather than assuming the reported gains carry over.

Frequently asked questions

How does masking in vision differ from masking in NLP?

In NLP, tokens are discrete words. In vision, patches are spatial regions with diverse content. Vision masking in this method uses much higher mask ratios: the source reports that masking 75% of patches still leaves enough visible context for a useful task. As general background on BERT-style masked language modelling, about 15% of tokens are typically masked. Images also require reconstruction of continuous pixel values rather than prediction over a discrete vocabulary.

Why is the encoder-decoder asymmetric?

The encoder processes only the visible patches, which reduces computation. The decoder is lightweight and receives mask tokens along with the encoded patches. After pre-training the decoder is discarded and only the encoder is used, so the design aims to keep training efficient while the representation used downstream is the encoder's output.

What is the right mask ratio?

The source reports that masking 75% of patches yields a nontrivial and meaningful self-supervisory task for ImageNet images. The source does not report results at other ratios, so the effect of lower ratios, such as 30-50%, is not established by the source. The best ratio for a given image domain should be determined empirically.

Related methods

Sources

  1. He, K., Chen, X., Xie, S., Li, Y., Dollár, P., & Girshick, R. (2022). Masked autoencoders are scalable vision learners. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (pp. 16000-16009).

    Open DOI reference