Masked Jigsaw Puzzle: A Versatile Position Embedding for Vision Transformers

Bin Ren, Yahui Liu, Yue Song, Wei Bi, Rita Cucchiara +2 more
5/25/2022
cs.CVcs.CR
transformer-attention

Official code: yhlleo/MJP (44 stars, Python, MIT, last commit 2024-12-21).

Abstract

Position Embeddings (PEs), an arguably indispensable component in Vision Transformers (ViTs), have been shown to improve the performance of ViTs on many vision tasks. However, PEs have a potentially high risk of privacy leakage since the spatial information of the input patches is exposed.

Show full abstract

This caveat naturally raises a series of interesting questions about the impact of PEs on the accuracy, privacy, prediction consistency, etc. To tackle these issues, we propose a Masked Jigsaw Puzzle (MJP) position embedding method. In particular, MJP first shuffles the selected patches via our block-wise random jigsaw puzzle shuffle algorithm, and their corresponding PEs are occluded. Meanwhile, for the non-occluded patches, the PEs remain the original ones but their spatial relation is strengthened via our dense absolute localization regressor. The experimental results reveal that 1) PEs explicitly encode the 2D spatial relationship and lead to severe privacy leakage problems under gradient inversion attack; 2) Training ViTs with the naively shuffled patches can alleviate the problem, but it harms the accuracy; 3) Under a certain shuffle ratio, the proposed MJP not only boosts the performance and robustness on large-scale datasets (i.e., ImageNet-1K and ImageNet-C, -A/O) but also improves the privacy preservation ability under typical gradient attacks by a large margin. The source code and trained models are available at~\url{https://github.com/yhlleo/MJP}.

View on arXivView PDF

Code Implementations(1)

yhlleo/MJPOfficial100%
MIT

[CVPR 2023] An official Pytorch implementation of "Masked Jigsaw Puzzle: A Versatile Position Embedding for Vision Transformers".

449Python, ShellMay 26, 20221 years agoMIT
gradient-attackposition-embeddingprivacy-protectionvision-transformer

Similar Papers

Cite this paper

@article{ren2022masked,
  title  = {Masked Jigsaw Puzzle: A Versatile Position Embedding for Vision Transformers},
  author = {Bin Ren and Yahui Liu and Yue Song and Wei Bi and Rita Cucchiara and Nicu Sebe and Wei Wang},
  year   = {2022},
  eprint = {2205.12551},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2205.12551}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2205.12551.svg)](https://codeofpaper.com/paper/2205.12551)

Discussion