In the standard training of neural networks, we use the Softmax function to turn raw model outputs—logits—into a probability distribution. This works well for classification because it penalizes the model heavily when it is wrong. However, when the goal shifts from training a model to attacking one, these same probabilities become a liability.
Researchers across the field of adversarial robustness have found that optimizing perturbations in the raw logit space, rather than the probability space, is the key to bypassing defenses and finding the most efficient vulnerabilities.
The Problem of Vanishing Gradients
The primary obstacle in crafting an adversarial example is the "vanishing gradient." When a model is highly confident in its prediction, the Softmax function "squashes" the output into a region where the gradient is nearly zero. If an attacker uses a standard Cross-Entropy loss to find a perturbation, the optimizer essentially gets lost on a flat plateau; it knows it needs to change the output, but the signal is too weak to show which direction to move.
Hongge Chen, Huan Zhang, and colleagues first highlighted this in their Show-and-Fool algorithm Attacking Visual Language Grounding with Adversarial Examples: A Case Study on Neural Image Captioning. By using raw logits instead of Softmax probabilities, they provided a stable gradient signal that allowed them to force image captioning systems to generate arbitrary, incorrect text. Because logits are unbounded, they do not saturate, ensuring that the attacker always has a clear "slope" to follow toward the target misclassification.
Maximizing the Margin
A recurring mechanism for reliable attacks is the logit difference or margin. Instead of simply minimizing the probability of the correct class, researchers like Ruize Gao and Jiongxiao Wang propose the Minimum-Margin (MM) attack Fast and Reliable Evaluation of Adversarial Robustness with Minimum-Margin Attack.
The intuition is simple: to flip a label, you don't need to make the correct class probability zero; you only need to make the target class logit slightly higher than the correct class logit. By optimizing the difference ($z_{target} - z_{correct}$), the attack avoids the information loss caused by the "squashing" effect of the Softmax denominator. This approach is so efficient that it matches the reliability of the gold-standard AutoAttack while using only 3% of the computation.
Similarly, Maura Pintor and Fabio Roli demonstrate in their Fast Minimum-norm (FMN) attack Fast Minimum-norm Adversarial Attacks through Adaptive Norm Constraints that logit-based objectives prevent "gradient masking"—a phenomenon where models appear robust only because their gradients are too messy or small for standard optimizers to use.
Transferability and Black-Box Success
Logit-based optimization isn't just faster; it produces "better" adversarial examples that are more likely to fool models the attacker has never seen.
Zhengyu Zhao, Martha Larson, and their team found that simple iterative attacks become state-of-the-art for transferability if they swap Cross-Entropy for a straightforward Logit loss On Success and Simplicity: A Second Look at Transferable Targeted Attacks. Because logit optimization focuses on the relative strength of internal features rather than the specific decision boundary of a single model, the resulting perturbations capture more fundamental vulnerabilities that exist across different architectures, such as Vision Transformers and CNNs A Little Robustness Goes a Long Way: Leveraging Robust Features for Targeted Transfer Attacks.
This principle extends even to physical attacks. Cheng Luo and Lijun Zhang 0001 showed that when designing 3D-printed objects to fool LiDAR sensors, optimizing against raw logits is significantly more effective than targeting spatial coordinates Revisiting Physically Realizable Adversarial Object Attack against LiDAR-based Detection: Clarifying Problem Formulation and Experimental Protocols.
Beyond Evasion: GANs and LLMs
The "logit advantage" is a general principle of optimization in deep learning. In the world of Generative Adversarial Networks (GANs), Shashank Sharma and Vinay P. Namboodiri introduced LOGAN No Modes Left Behind: Capturing the Data Distribution Effectively Using GANs. They found that using raw discriminator logits for the generator's loss prevents the generator from "stalling" when the discriminator becomes too powerful.
This same logic is now being applied to Large Language Models. Haoyan Yang and Ting Hua use a min-max logit noise strategy to prevent model stagnation during self-improvement Dynamic Noise Preference Optimization for LLM Self-Improvement via Synthetic Data. By manipulating the logits of negative samples, they force the model to learn more subtle, discriminative features that probability-based losses would ignore.
Summary of Intuition
| Feature | Probability-Based (Softmax) | Logit-Based (Raw) |
|---|---|---|
| Range | Bounded (0 to 1) | Unbounded ($-\infty$ to $+\infty$) |
| Gradients | Vanish when confidence is high | Remain constant and informative |
| Optimization | Can "stall" on flat plateaus | Continuous "slope" to follow |
| Transferability | Overfits to specific boundaries | Captures general feature strengths |
While some recent work, such as the Probability Margin Attack (PMA) by Hanxun Huang and Xingjun Ma, suggests that probability space can offer more "directions" for optimization in million-scale evaluations Towards Million-Scale Adversarial Robustness Evaluation With Stronger Individual Attacks, the consensus remains: for stable, efficient, and transferable adversarial attacks, the raw logit is the superior signal.