Masked Autoencoders Are Scalable Vision Learners
- Publication
- CVPR 2022Conference
- First submitted to arXiv
- arXiv:2111.06377
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{visiontransformersmae2021,
title = {{Masked Autoencoders Are Scalable Vision Learners}},
author = {Kaiming He and Xinlei Chen and Saining Xie and Yanghao Li and Piotr Dollár and Ross Girshick},
year = {2021},
eprint = {2111.06377},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2111.06377}
}
In NLP, masked language modeling has become one of the best-known pretraining tasks: hide about 15% of the text tokens and ask the model to fill them in. This classic recipe gave us models such as BERT, RoBERTa, and ALBERT.
What about images?
Why has vision not had a similarly successful pretraining method?
Define the problem
ViT had already tried something similar. In that paper, the authors masked part of an image and tried predicting the missing content, including pixel and region-level targets; see our ViT note.
The verdict in those experiments: neither approach worked as well as supervised pretraining.
The MAE authors point to a central difference: language and vision have different information densities. Language is made by people and carries explicit semantic units. Images have plenty of spatial redundancy, so a model can restore a few missing patches from nearby ones without working hard to understand parts, objects, or scenes.
It can just interpolate from its neighbors. No wonder the result might disappoint.
Solve the problem
To get around that difference, the authors simply hide most of the patches. How many? Oh, just 75%!
Give the encoder only visible patches
Figure 1 shows the data flow. As in ViT, the image is first split into patches. The patches to hide are sampled at random to avoid a center bias. Masked patches are removed before the encoder, leaving it only the visible quarter. The decoder later inserts mask tokens and reconstructs the image at the original patch positions.
In implementation, patches become tokens with positional information. The tokens are shuffled, and only the visible quarter goes into the encoder. The decoder gets encoded visible tokens, shared learned mask tokens that contain none of the missing pixels, and positional embeddings, then restores their original order. No special sparse operator is needed.
Reconstruction target and loss
MAE reconstructs the input by predicting the pixel values of each masked patch. For an RGB patch of side length , the decoder's final projection outputs pixel values. The default objective is pixel mean squared error (MSE), computed only at masked positions, rather than over the whole image. The decoder also emits values for visible positions, but this loss does not constrain them. A blurry visible region in the reconstruction is therefore a different issue from a wrong masked region.
The authors even give us plenty of pictures to make this easier to follow. In paper Figure 2, each triplet shows the masked input on the left, the decoder's reconstruction in the middle, and the original image on the right. These qualitative examples use 80% masking, rather than the 75% default in the ablations below.
Experimental results and discussion
Most ablations below use ViT-L/16, ImageNet-1K, and 800 pretraining epochs. In the tables, ft means end-to-end encoder fine-tuning, while lin freezes the encoder and trains a linear classifier. Keep the two protocols separate.
Establish the baseline first
The original ViT recipe trained ViT-L/16 from scratch to 76.5% top-1 accuracy. The MAE authors' improved supervised training recipe reached 82.5%. MAE pretraining followed by fine-tuning reached 84.9%. Those first two numbers matter: a strong supervised baseline makes the pretraining gain easier to see.
Why 75% masking?
The top panel of paper Figure 5 shows full fine-tuning and the bottom panel shows linear probing. Fine-tuning remains fairly stable at about 40–80% masking. Linear probing improves up to 73.5% at 75% masking, then falls. The 75% default balances representation quality and compute in these tests; it is not a rule that more masking always helps.
Paper Table 1(c) compares an encoder that receives mask tokens. Its linear-probe accuracy falls from 73.5% to 59.6%, a 13.9-point difference; full fine-tuning moves from 84.9% to 84.2%, only 0.7 point. The authors propose a pretraining-to-downstream input mismatch as one explanation, since downstream images have no mask tokens. The compute saving from fewer encoder tokens is more direct.
The decoder need not match the encoder's weight
Paper Table 1(a)(b) tests decoder depth and width. An eight-block decoder has the best linear-probe result, 73.5%, but depths two, four, and eight all reach 84.9% after full fine-tuning. Width 512 is the default and half the ViT-L encoder's 1024 dimensions. It works well here; a half-width decoder is not a universal rule.
Pixels or tokens as targets?
Paper Table 1(d) gives fine-tuning/linear-probe accuracy for four targets: raw pixels 84.9/73.5, per-patch normalized pixels 85.4/73.9, PCA 84.6/72.3, and dVAE tokens 85.3/71.6. dVAE beats raw pixels after full fine-tuning but trails normalized pixels and needs an extra pretrained tokenizer. Thus, “every alternative is worse than raw pixels” misreads the table.
The retained augmentations
In paper Table 1(e), random resized cropping with horizontal flipping scores 84.9/73.5; fixed-size crop with flip 84.7/73.1; center crop without random augmentation 84.0/65.7; adding color jitter 84.3/71.9. There is no random-rotation ablation. MAE depends less on augmentation than some alternatives, but its default still crops and flips images.
Mask shape changes the task
In paper Table 1(f), random 75% masking reaches 84.9/73.5; block masking at 50% reaches 83.9/72.3, and at 75% drops to 82.8/63.9; grid masking at 75% gives 84.0/66.0. Block masks are harder to reconstruct, while grid masks are easier. A sharper reconstruction does not necessarily yield better recognition features.
Read accuracy with training time
Paper Table 3 uses 1600 epochs and normalized pixels. MAE reaches 83.6% with ViT-B, 85.9% with ViT-L, and 86.9% with ViT-H at 224-pixel input. The 87.8% ViT-H result follows fine-tuning at 448 pixels, not merely enlarging a test image. At publication time, the authors report this above a previous 87.1% result among methods using only ImageNet-1K; that comparison has both a date and a data condition.
Paper Table 2 also states the hardware. With 128 TPU-v3 cores, TensorFlow, 800 epochs, and 75% masking, ViT-L with encoder mask tokens takes 42.4 hours; MAE with an eight-block decoder takes 15.4 hours, a 2.8× speedup. For ViT-H, 119.6 hours is estimated, versus 34.5 hours, about 3.5×. On the same hardware, the paper separately reports 31 hours for 1600-epoch ViT-L MAE and 36 hours for 300-epoch MoCo v3. These support efficiency for the reported implementation.
Conclusion
In image processing, recorded light does not have the clear semantic pieces that words do. Yet MAE can make detailed reconstructions, suggesting that it has learned many important visual concepts.
This is reminiscent of what happened in NLP: vision seems to be following a similar path, though in its own way.
Many later studies borrowed this idea and added MAE-style training to improve their models. We'll share more when we come across them.