Averaging several neural networks is a natural defense against adversarial examples, which are small input changes crafted to flip a model's prediction. The average only helps if the members fail on different inputs. In practice they tend to fail together: members pick up the same fragile features, so a perturbation that fools one usually fools the rest. Methods that try to force members apart measure "apart" with cross-entropy, the standard classification loss. They compare the directions in which each member's cross-entropy loss rises fastest (Improving Adversarial Robustness of Ensembles with Diversity Training), or the probabilities each member assigns to the wrong classes (Improving Adversarial Robustness via Promoting Ensemble Diversity). Attackers no longer use cross-entropy. The strongest transfer attacks and evaluation suites switched to losses built on raw logits, the scores a network outputs before they are turned into probabilities. They switched because cross-entropy saturates: once a model is confident, the loss goes flat and its gradient carries little signal (On Success and Simplicity; Logit Margin Matters; Reliable evaluation of adversarial robustness).
This note argues that defenders are enforcing diversity in a geometry the attacker never uses. Our proposal is to measure and penalize agreement between members in the geometry of a scale-invariant logit margin, the same quantity modern attacks climb. The regularizer should cost about as much as existing gradient-diversity training and much less than multi-step adversarial training. We expect the benefit to grow with the number of classes, because that is where probability-based diversity measures break down.
Core Claim
The claim has a diagnostic half and a constructive half.
The diagnostic half concerns ensembles trained with cross-entropy-based diversity. On confidently classified inputs, their measured diversity overstates how independent their failure modes are. Transfer rates between members, measured with logit-loss attacks, will be substantially higher than the cross-entropy attacks used in the original evaluations reported. The mechanism is simple. When member $k$ assigns probability near one to the true class, its cross-entropy input-gradient is a combination of the runner-up class directions weighted by tiny probabilities. Those weights are idiosyncratic to each member and numerically fragile. The gradient cosines can therefore look dissimilar even when every member's margin toward the same runner-up class shrinks along the same input direction.
The constructive half is a fix. Diversity should be penalized in terms of each member's margin gradient. The margin is the gap between the true-class logit and the strongest wrong-class logit. We normalize it so that it cannot be gamed by rescaling logits, borrowing the shift- and scale-invariance of the Difference of Logits Ratio loss from Reliable evaluation of adversarial robustness:
$$m_k(x) = \frac{z^k_y(x) - \max_{j \ne y} z^k_j(x)}{z^k_{\pi_1}(x) - z^k_{\pi_3}(x) + \epsilon}$$
Here $z^k$ are member $k$'s logits, $y$ is the true label, $\pi_1$ and $\pi_3$ index the largest and third-largest logits, and $\epsilon$ is a small constant for numerical safety. We call the training objective Margin-Gradient Diversity (MGD):
$$\mathcal{L} = \sum_k \mathcal{L}_{CE}(f_k(x), y) + \lambda \cdot \mathrm{LSE}_{k<l}\,\cos\big(\nabla_x m_k(x), \nabla_x m_l(x)\big)$$
$\mathrm{LSE}$ is a LogSumExp smooth maximum over member pairs, as in the Gradient Alignment Loss, and $\lambda$ sets the penalty strength. The margin gradient does not shrink as confidence grows, so the penalty stays informative on exactly the confident training points where cross-entropy gradients go quiet. Because the penalty uses logits rather than probabilities, it avoids the vanishing non-maximal probabilities that ADP's authors flag for large label spaces.
Relation to Prior Work
Three ensemble-diversity methods motivate this work, and each measures diversity in a way we believe misses the attacker. Diversity Training penalizes cosine alignment of cross-entropy input-gradients. It reports that a Conv-4 ensemble on CIFAR-10 keeps 35.0% accuracy under momentum-iterative attack versus 9.0% for a plain ensemble, at a clean-accuracy cost of about 85% down to 82%. Our regularizer has the same form but a different differentiated quantity, so this is the natural head-to-head. ADP orthogonalizes members' wrong-class probability vectors. Its authors note two limits: the vectors vanish numerically as the class count grows, and orthogonality is impossible when members outnumber classes. Logit margins avoid the first limit. Pairwise gradient cosines in input space avoid the second, because input space is thousands of dimensions rather than $L$. DVERGE trains each member on adversarial examples crafted against its peers and cuts inter-member transfer from over 60% to under 6%. It does this with cross-entropy attacks and a round-robin of attack generation whose cost grows with ensemble size.
Two papers constrain the design. On the Diversity of Adversarial Ensemble Learning proves that gradient diversity alone does not determine ensemble adversarial loss. A "cross diversity" term coupling outputs and gradients also matters, and their AdvEOAP, which enforces orthogonal predictions on adversarial inputs, reaches 47.88% AutoAttack accuracy on CIFAR-10. This directly challenges any gradient-only regularizer, including ours. We address it in two ways. First, the margin gradient already folds the output into the gradient: it is the gradient of the quantity whose sign decides the prediction. Second, we test whether adding a prediction-orthogonality term changes the result. The second constraint is that diverse ensembles without per-member adversarial training fall to joint white-box attacks on the averaged output (Diversity Training; DVERGE). We therefore make transfer robustness the primary target and white-box robustness a secondary one. The white-box variant adds cheap single-step training.
The attack papers supply the method and the threat model. On Success and Simplicity shows that plain logit maximization with many iterations beats cross-entropy for transfer. Logit Margin Matters shows that temperature, margin, and angle calibration stop the plateau that cross-entropy hits once the surrogate is fooled. Both are attacker-side only. We move their observation into a defensive training objective, and we use their attacks as the evaluation.
Research Program
The first step is diagnostic and cheap. We train cross-entropy ensembles, Diversity Training ensembles, ADP ensembles, and DVERGE ensembles. We then measure the inter-member transfer matrix under three attack losses at matched perturbation budgets: cross-entropy projected gradient descent, the logit loss of On Success and Simplicity at its long iteration budget, and the temperature-calibrated loss of Logit Margin Matters. For every member pair we also record both diversity measures: the cosine of cross-entropy gradients and the cosine of margin gradients. We then ask which one better predicts the logit-attack transfer rate. We compute this across pairs, checkpoints, and confidence bins, and we expect the gap to be widest on high-confidence inputs.
The second step trains MGD ensembles of three members on CIFAR-10, CIFAR-100, and Tiny ImageNet. This spans 10, 100, and 200 classes, which directly tests the prediction that probability-based methods degrade as classes grow while margin-based diversity does not. Cost is one extra double-backpropagation per member, the same as Diversity Training. No inner-loop attack is needed.
The third step adds white-box resistance within a fixed budget. Each member takes one random-start signed-gradient step on its own margin loss, in the spirit of R+FGSM from Ensemble Adversarial Training, with the diversity penalty applied at the perturbed point. Single-step training is known to fail through catastrophic overfitting (Understanding Catastrophic Overfitting in Single-step Adversarial Training). We test a specific hypothesis about that failure. The sharp local curvature that fools single-step attacks is member-specific. A penalty that forces members' margin gradients apart should therefore make it harder for all members to collapse into the same masked minimum at once. We track multi-step robust accuracy through training to detect collapse.
Baselines
The naive reference is an independently trained cross-entropy ensemble of the same members and size, trained with the same epochs and augmentation. It shows how much diversity any method adds for free. Diversity Training serves as the strongest direct competitor for the transfer question, since it uses the same form of regularizer, costs the same, and needs no adversarial examples. Its reported figure is 35.0% ensemble accuracy under momentum-iterative attack on CIFAR-10 with Conv-4 members. We rerun it with our architectures rather than rely on that number. DVERGE is the strongest method on inter-member transfer, with transfer below 6%. We give it the same GPU-hour budget as MGD rather than its native, larger budget, and we also report it at full budget. ADP is the probability-space competitor we expect to degrade on CIFAR-100 and Tiny ImageNet. Its combination with adversarial training reported a PGD-accuracy gain on CIFAR-10 from 32.8% to 36.2%.
For white-box robustness, the strongest ensemble baseline is AdvEOAP at 47.88% AutoAttack accuracy on CIFAR-10. The strongest single-model reference is SEAT at 51.3% with ResNet-18, compared with 44.37% for standard adversarial training. Both use full multi-step inner loops. We do not expect the single-step variant to match them in absolute terms. We count it as a win if it reaches within a few points of AdvEOAP at a fraction of the GPU-hours. We plot each method's robust accuracy against wall-clock training time on the same hardware and count a win only where MGD dominates that curve.
The key ablation swaps only the differentiated quantity. We compare the Diversity Training loss computed on cross-entropy, on temperature-scaled cross-entropy with temperatures in the range explored by Logit Margin Matters, on the raw unnormalized margin, and on the normalized margin. Architecture, $\lambda$ search budget, and schedule are identical across arms. This isolates whether non-saturation, or scale invariance on top of it, drives any gain. All methods get the same hyperparameter search budget. For transfer to DenseNet-121 in the targeted setting, the relevant attack-side numbers are 77.8% for temperature-calibrated attacks versus 42.7% for cross-entropy from a ResNet-50 surrogate (Logit Margin Matters), and 99.4% for a logit attack from a surrogate ensemble (On Success and Simplicity). These are ImageNet attack figures, and we use them only to calibrate attack strength. We found no reported result on Lacuna for any diversity-trained defense evaluated against logit-loss transfer attacks.
Why not just…?
Why not just use temperature-scaled cross-entropy inside the existing gradient-alignment loss? This is the most serious threat. Softening probabilities with a temperature above one also relieves saturation and is a one-line change. If it matches the normalized margin, the constructive contribution shrinks to "use a temperature." The diagnostic finding and the large-class results would still stand. The ablation above settles the question directly. Two reasons suggest the margin may still win. Logit Margin Matters needed an explicit temperature search. And a fixed temperature cannot track a logit scale that drifts during training, whereas the normalized margin is scale-invariant by construction. We will report the result either way.
Why not just adversarially train each member with multi-step attacks? That buys white-box robustness, as AdvEOAP and SEAT show. It multiplies cost by the number of attack steps for every member, which is the overhead this project is designed to avoid. Accuracy-versus-GPU-hour curves will show whether MGD with single-step training reaches a better operating point or merely a cheaper, weaker one.
Why not just average weights along the training path? SEAT is nearly free, taking 273 minutes versus 272, but it produces a single model and cannot give disjoint failure modes. It also still depends on a multi-step inner loop. We include it only as a single-model reference for white-box accuracy.
Why not just replace cross-entropy with a guided complement loss in each member? Guided Complement Entropy adds margin at no cost, but it shapes each model separately and its authors concede it does not withstand strong multi-step attacks. As a cheap extra arm, we train independent members with it and measure whether it reduces inter-member transfer at all.
Decisive Checks
We will judge the project on four checks. The first is the diagnostic. On CIFAR-10, Diversity Training ensembles should show clearly higher inter-member transfer under logit-loss attacks than under cross-entropy attacks, and margin-gradient cosine should correlate with logit-attack transfer better than cross-entropy-gradient cosine does. If neither holds, the premise fails and we stop.
The second check asks whether MGD lowers the full transfer matrix under the strongest attack, logit loss from an external ensemble of independently trained surrogates. This must hold at equal clean accuracy and equal GPU-hours relative to Diversity Training and budget-matched DVERGE. The third check is the scaling test across 10, 100, and 200 classes. MGD's advantage over ADP should widen with class count. The fourth check is the white-box variant. It must avoid catastrophic overfitting across seeds and survive full AutoAttack, including the gradient-free Square Attack that exposes masking (Reliable evaluation of adversarial robustness). We also run a joint attack on the averaged ensemble logits with the margin loss. A result that holds only against attacks on single members does not count.
References
- Improving Adversarial Robustness of Ensembles with Diversity Training
- Improving Adversarial Robustness via Promoting Ensemble Diversity
- On Success and Simplicity: A Second Look at Transferable Targeted Attacks
- Logit Margin Matters: Improving Transferable Targeted Adversarial Attack by Logit Calibration
- Reliable evaluation of adversarial robustness with an ensemble of diverse parameter-free attacks
- DVERGE: Diversifying Vulnerabilities for Enhanced Robust Generation of Ensembles
- On the Diversity of Adversarial Ensemble Learning
- Ensemble Adversarial Training: Attacks and Defenses
- Understanding Catastrophic Overfitting in Single-step Adversarial Training
- Self-ensemble Adversarial Training for Improved Robustness
- Improving Adversarial Robustness via Guided Complement Entropy