Chip Foundry Services Request Assessment

Random Erasing

Random Erasing in ViT is a data augmentation technique that randomly masks rectangular patches in input images during Vision Transformer training to improve robustness and reduce overfitting.

What Is Random Erasing?

  • Method: Replace random image regions with random values or mean pixel
  • Parameters: Probability, area ratio (0.02-0.4), aspect ratio
  • Effect: Forces model to learn from partial information
  • Origin: Zhong et al. 2017, widely adopted in ViT training

Why Random Erasing Matters

ViTs can overfit to specific image regions. Random erasing encourages attention to diverse features and improves generalization.

Random Erasing Example:Original Image: After Random Erasing:┌─────────────────┐ ┌─────────────────┐│ 🐱 │ │ 🐱 ││ Cat face │ │ Cat███ ││ │ → │ ███ ││ Body │ │ Body ││ │ │ ███████│└─────────────────┘ └─────────────────┘Model must recognize cat without erased patches

Random Erasing in ViT Recipe:

transforms.Compose([
    transforms.RandomResizedCrop(224),
    transforms.RandomHorizontalFlip(),
    transforms.ToTensor(),
    RandomErasing(
        probability=0.25,
        sl=0.02, sh=0.4,  # area ratio
        r1=0.3,           # aspect ratio min
    ),
])

Typical improvement: +0.5-1.5% top-1 accuracy on ImageNet.