Abstract
Position Embeddings (PEs) are essential for Vision Transformers (ViTs) to understand spatial context, yet they introduce a significant privacy vulnerability. By providing a fixed coordinate system, PEs allow attackers to reconstruct private images through gradient inversion attacks. This paper introduces Masked Jigsaw Puzzle (MJP), a novel training strategy that shuffles image patches and masks their positions. MJP effectively mitigates privacy risks while simultaneously improving model accuracy, robustness, and consistency across standard benchmarks like ImageNet-1K.
Introduction
Unlike Convolutional Neural Networks (CNNs), which possess an inherent inductive bias for spatial proximity, Transformers treat an image as a sequence of flattened patches. To regain spatial context, ViTs utilize Position Embeddings (PEs)—vectors added to each patch to define its location in the 2D grid. However, these PEs act as a map for malicious actors. In federated learning, an attacker can exploit model updates via "gradient inversion" to reconstruct original inputs. Because PEs provide a rigid coordinate system, the attacker can easily reassemble shuffled patches into a coherent image.
Methodology: The Masked Jigsaw Puzzle (MJP)
The authors propose MJP to break the exploitable link between patch content and fixed coordinates. The method consists of three integrated components:
- Block-wise Random Jigsaw Shuffle: During training, a subset of image patches (determined by a ratio $\gamma$) is shuffled. This prevents the model from relying on a static 1-to-1 mapping of patch content to position.
- Position Masking: Shuffled patches are assigned a shared, learnable "unknown" embedding ($E_{unk}$) instead of their original PEs. This masks the "leaky" coordinates that attackers use for reconstruction.
- Dense Absolute Localization (DAL): To maintain structural understanding, a self-supervised regressor predicts the absolute coordinates of unshuffled patches. This provides a spatial prior that aids convergence and feature learning.
Visualizing the Privacy Leak
A key contribution of this work is the visual evidence of the privacy liability inherent in standard PEs. Using dimensionality reduction techniques like UMAP and PCA, the authors demonstrate that the learned embeddings in standard ViTs (such as DeiT) perfectly recreate a 2D grid. This coordinate system is exactly what gradient inversion attacks leverage to "re-puzzle" intercepted data.
Key Results and Insights
Performance and Robustness
Contrary to previous shuffling methods that degraded performance, MJP enhances it. On ImageNet-1K, a DeiT-S model with MJP saw a Top-1 accuracy increase from 79.8% to 80.5%. Robustness also improved significantly; on ImageNet-C, the Mean Corruption Error (mCE) dropped from 54.6 to 40.78, indicating better handling of real-world noise and corruptions.
Privacy Preservation
Under the APRIL analytic gradient attack, standard ViTs leaked recognizable images. In contrast, MJP-trained models produced unrecognizable, noisy outputs. Quantitatively, the Mean Square Error (MSE) of recovered images increased from approximately 0.03 to 0.10, representing a substantial barrier to data theft.
The Consistency-Accuracy Trade-off
The researchers identified a "sweet spot" for the shuffle ratio $\gamma$. While total shuffling ensures maximum privacy and consistency, it typically harms accuracy. MJP finds an optimal balance (around $\gamma = 0.15$) where the model achieves higher accuracy than the baseline while remaining robust to spatial permutations.
Conclusion
Masked Jigsaw Puzzle (MJP) represents a significant step forward in making Vision Transformers both more secure and more capable. By replacing rigid spatial anchors with a flexible, masked approach, MJP forces the model to learn more diverse, content-aware features. Future work may extend MJP to other domains where spatial or temporal privacy is critical, such as medical imaging and video processing.
Summary updated