Rethinking PGD Attack: Is Sign Function Necessary?

Junjie Yang, Tianlong Chen, Xuxi Chen, Zhangyang Wang, Yingbin Liang

TL;DR

This paper challenges the long-standing convention of using the sign function in Projected Gradient Descent (PGD) adversarial attacks. By introducing Raw Gradient Descent (RGD), which tracks an unclipped hidden variable to preserve gradient magnitude information, the authors create stronger adversarial attacks and more robust defenses without incurring any additional computational overhead.

What Problem Does This Paper Address?

Adversarial attacks expose critical vulnerabilities in deep neural networks by introducing tiny, human-imperceptible perturbations that cause models to make flagrant misclassifications. In $L_\infty$ norm-constrained white-box attacks (where the absolute magnitude of any single pixel perturbation cannot exceed a threshold $\epsilon$), the standard approach since the introduction of the Fast Gradient Sign Method (FGSM) and PGD has been to apply the sign() function to the gradient. This process discards the gradient's magnitude, keeping only its directional sign (+1 or -1).

While previous attempts to use raw gradients instead of signed gradients failed dramatically, the machine learning community largely accepted the sign function as an absolute necessity for $L_\infty$ attacks. This paper investigates why naive raw gradients fail and asks a fundamental question: Is the sign function truly necessary, or has it merely been a band-aid covering a flaw in how we apply optimization constraints?

Methods

The authors discover that naive raw gradient descent fails primarily because of the clipping operation applied at each step of PGD. In standard PGD, perturbations are clipped back into the $\epsilon$-ball at every iteration. When a pixel's perturbation hits the $\epsilon$ boundary, this clipping operation zeroes out further raw gradient updates in that direction, destroying valuable magnitude information and stalling the attack.

To solve this, the authors propose Raw Gradient Descent (RGD). Instead of updating the clipped perturbation, RGD maintains a hidden, unclipped perturbation variable ($\delta^t$) that is allowed to freely move beyond the $\epsilon$ boundary:

$$\delta^{t+1} = \delta^t + \alpha \nabla_\delta g(x + \delta^t_c)$$

where $\delta^t_c = \sigma_\epsilon(\delta^t)$ is the clipped version used only for the forward pass and gradient computation. This elegant mathematical shift transforms a constrained optimization problem into an unconstrained one, preserving the true gradient magnitude distribution throughout the optimization process.

Datasets

The authors extensively evaluated RGD against standard computer vision benchmarks using models sourced from RobustBench:

  • CIFAR-10
  • CIFAR-100
  • ImageNet

Key Insights and Ideas

  • The Secret to PGD's Success: The sign function works well in standard PGD because it maximizes step-wise perturbation changes, forcing more pixels to the $\epsilon$ boundary quickly.
  • Why Naive Raw Gradients Stalled: Without the unclipped hidden variable, clipping at every step eliminates the magnitude information of the raw gradient. Once elements cross the boundary, their optimization trajectory is effectively ruined.
  • Quality Over Quantity: Interestingly, RGD results in fewer pixels sitting exactly on the $\epsilon$ boundary compared to PGD (e.g., 70.6% vs 86.9% on CIFAR-10). However, because it preserves magnitude information, it learns a much more effective, "genuine" adversarial distribution.
Figure 1: Comparison of update algorithms for perturbation pixel distribution in different steps.

Key Results

  • Stronger Attacks: RGD consistently achieves lower robust accuracy (indicating a more potent attack) than vanilla PGD across multiple datasets and architectures. For instance, on CIFAR-10 with a WideResNet-28 model ($\epsilon = 16/255$), RGD drops the model's robust accuracy to 37.19% compared to PGD's 37.53%.
  • Superior Adversarial Training: When used as the inner loop for adversarial training, RGD significantly boosts the resulting model's robustness. For a standard ResNet on CIFAR-10 (5-step training), switching from PGD to RGD improved robust accuracy from 29.32% to 44.67% (a massive +15.35% absolute jump).
  • Enhanced Transferability: Adversarial examples generated via RGD transfer much better to unknown target models, outperforming signed PGD by at least 5% when attacking clean models.
  • Zero Overhead: Because RGD simply removes the sign operation and retains an unclipped variable in memory, it requires exactly the same computational budget as vanilla PGD.

Limitations and Future Work

  • Diminishing Returns with High Iterations: As the number of attack steps increases significantly (e.g., beyond 20 steps), the performance gap between RGD and PGD narrows. PGD's stable step changes eventually allow it to catch up in later stages.
  • Hyperparameter Sensitivity: RGD requires a much larger step size ($\alpha$) than PGD because raw gradients are typically quite small. This requires careful grid-searching for optimal step sizes depending on the model.
  • Focus on $L_\infty$: The theoretical and empirical focus of this paper is strictly on $L_\infty$ norm constraints. Extending this unconstrained hidden-variable framework to other threat models (like $L_2$ or $L_0$) remains an open direction for future research.

Summary updated

BibTeX
@misc{yang2023rethinking,
  author = {Junjie Yang and Tianlong Chen and Xuxi Chen and Zhangyang Wang and Yingbin Liang},
  title = {{Rethinking PGD Attack: Is Sign Function Necessary?}},
  year = {2023},
  eprint = {2312.01260},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2312.01260},
}
Figure