Constrain the Parts, Free the Pose: Selective Adversarial Invariance in Capsule Heads

Making an image classifier resistant to small adversarial perturbations usually costs it accuracy on ordinary, unperturbed images. One common explanation is that robust training forces every internal feature to stay unchanged under perturbation. Some brittle but genuinely predictive patterns cannot survive that requirement, so the model throws them away. This note asks whether a different internal representation lets us choose more carefully what must stay unchanged. Capsule networks replace each scalar neuron with a small vector, a "capsule". The vector's length says whether a part is present, and its direction describes the part's pose: orientation, scale, thickness. Each part also casts a weighted vote for which larger object it belongs to, through a mechanism called routing. The geometry therefore already separates three things: whether a part is there, which whole it belongs to, and how it looks.

Our proposal is to require adversarial invariance only for the first two, existence and part-to-whole assignment, and leave pose free. The training regularizer pulls a perturbed input's capsule lengths and routing weights toward those of the clean input. It never touches capsule directions. The bet is that a lower-dimensional constraint aimed at the structural quantities the decision depends on conflicts less with the clean classification loss. If so, a capsule head on a standard backbone should keep more clean accuracy than full-feature invariance at the same robustness. The note is built so that the cheaper explanation can win: if splitting the features arbitrarily, rather than geometrically, works just as well, the capsule structure contributes nothing and we will say so.

Core Claim and Its Grounding

Two results from the robustness literature motivate the claim. Robustness May Be at Odds with Accuracy argues that clean accuracy falls under robust training because the model must stop using weakly correlated, easily flipped features. Rethinking Invariance Regularization in Adversarial Training (AR-AT) pins much of the practical damage on two causes. The first is gradient conflict between the invariance term and the classification loss. The second is clean and adversarial batches sharing BatchNorm statistics. AR-AT removes both for scalar CNNs by stopping gradients through the clean representation and keeping separate BatchNorm statistics for clean and adversarial batches (Split-BN). Its regularizer still asks the entire feature vector to match.

We supply the missing piece: a principled choice of which part of the representation to constrain. In a scalar CNN that choice has no natural answer. In a capsule layer it does, because length (existence) and orientation (pose) are separated by construction (Dynamic Routing Between Capsules), and routing weights record part-to-whole assignment (STAR-Caps).

The capsule-specific robustness literature constrains the design rather than motivating optimism. On the Vulnerability of Capsule Networks to Adversarial Attacks found that CapsNets on CIFAR-10 are fooled by smaller Carlini-Wagner perturbations than ConvNets: an average L2 norm of 0.23 versus 0.37. CapsAttacks found a 9-layer VGG more robust than a CapsNet on traffic signs and traced the weakness to a narrow gap between the top two class-capsule lengths. These results rule out any claim that capsules are robust by nature. Our claim is narrower and is about training. Once adversarial training is applied, capsule geometry offers a better target for the invariance constraint.

Detecting and Diagnosing Adversarial Images with Class-Conditional Capsule Reconstructions uses capsule reconstructions to flag attacks rather than to classify robustly. Its finding that successful attacks had to change the image toward the target class hints that capsule structure ties decisions to meaningful geometry. We do not use reconstruction for detection. As the authors themselves note, pixel-wise L2 checks scale poorly to colour images.

Research Program

The first stage is measurement, and it is needed regardless of the method. No capsule architecture in the file has been evaluated with AutoAttack, the parameter-free attack ensemble from Reliable evaluation of adversarial robustness, which found 48 of 49 published defenses overestimated. We will attach capsule heads to a WideResNet-34-10 backbone and train them with plain adversarial training. Two routing schemes will be used: three-iteration dynamic routing and STAR-Caps attentive routing. We will then measure how adversarial perturbations change three quantities in the head: lower-capsule lengths, lower-capsule directions, and routing weights. The core claim predicts that the decision flips mainly through changes in existence and routing. If the measurement instead shows the attack works mainly by rotating poses, which then corrupts agreement downstream, the constraint has to move, and we will report that.

The second stage is the regularizer. For a lower capsule $u_i$, let $a_i = \|u_i\|$ be its length. Let $c_{i\cdot}$ be its routing distribution over parent capsules: the agreement-based coefficients in dynamic routing, or the attention estimate $T_{ij}$ in STAR-Caps. Let $x'$ be a perturbation of input $x$ found by an inner attack, and let $\mathrm{sg}$ denote stop-gradient. We train with

$$ \mathcal{L} = \ell(f(x),y) + \ell(f(x'),y) + \lambda \sum_i \Big[ \big(a_i(x') - \mathrm{sg}\,a_i(x)\big)^2 + \mathrm{sg}\,a_i(x)\, \mathrm{KL}\big(\mathrm{sg}\,c_{i\cdot}(x)\,\|\,c_{i\cdot}(x')\big) \Big], $$

where $\ell$ is the capsule margin loss and $\lambda$ sets the trade-off. Weighting the routing term by clean existence means absent parts are not forced to keep a meaningless routing assignment. Directions $u_i/\|u_i\|$ appear nowhere in the penalty.

The stop-gradient on the clean side and Split-BN in the backbone are taken directly from AR-AT. The capsule layers themselves have no batch statistics, because squashing is per-vector. We therefore predict the mixture-of-statistics problem AR-AT identifies is absent in the head, and we test this by comparing shared and split normalization in the backbone only.

The third stage tests whether freeing pose matters beyond the robustness benchmarks. We check viewpoint generalization on SmallNORB, the setting where capsules have their documented advantage (STAR-Caps). Full-vector invariance might erode that advantage, while selective invariance should preserve it.

Baselines

The naive reference points are the same WideResNet-34-10 trained without adversarial examples, with a scalar head and with a capsule head. They show the clean ceiling and the robustness floor. For robust training on the same backbone, the classic baseline is TRADES (Theoretically Principled Trade-off between Robustness and Accuracy). As reported in the AR-AT paper, TRADES reaches 84.33% clean accuracy on CIFAR-10 at robustness comparable to AR-AT.

The strongest existing method is AR-AT with a scalar head. Rethinking Invariance Regularization reports 90.89% clean accuracy and 50.77% AutoAttack robust accuracy on CIFAR-10 with WideResNet-34-10. It is the right competitor because it already solves gradient conflict and normalization mixing in the scalar setting. Any gain we show must therefore come from the capsule-specific choice of target. We will retrain AR-AT ourselves under our attack schedule, epochs and tuning budget, and also quote the published number. Beating it means higher clean accuracy at matched AutoAttack robust accuracy, or the reverse, on a Pareto curve traced by sweeping $\lambda$ for both methods with equal tuning budgets. For CIFAR-10 the bar is concretely above 90.89% clean at no less than 50.77% robust.

Two ablations isolate the key ingredient. The first applies AR-AT-style invariance to the full capsule vector, constraining direction as well. It isolates the effect of freeing pose. The second, the decisive control, applies a matched-dimension invariance constraint to a random subspace of the capsule head, or to a random channel subset of an equal-parameter scalar head. It tests whether the geometric split matters or any partial constraint would do.

We also report the compositional LERA system from Avoiding Robust Misclassifications, which loses only 0.2 points of clean accuracy (97.8% to 97.6%) while greatly increasing robustness, measured at $\epsilon_\infty = 1/255$. It is a reference, not a head-to-head competitor, because it runs two full networks and abstains on some inputs.

Why not just…?

Why not just use AR-AT on a standard CNN, since it already closes much of the gap? This is the real threat. AR-AT's 90.89%/50.77% is a high bar, and capsule heads have historically trailed CNNs on cluttered data: STAR-Caps reached 91.23% clean on CIFAR-10 even without robust training. We reduce this risk by sharing the AR-AT backbone and changing only the head. Even so, if the capsule Pareto curve sits below AR-AT's, the honest conclusion is that capsule geometry does not help on this benchmark. We would report that as the result.

Why not just run TRADES or adversarial training on a capsule network? No study in the file does this, but nothing suggests it would avoid the trade-off. TRADES smooths every output direction and costs clean accuracy even on strong CNNs, falling to 84.33% in the AR-AT comparison. The CapsAttacks narrow-margin finding suggests capsule heads may suffer more from blanket smoothing. The plain-adversarial-training and TRADES capsule baselines measure this directly.

Why not just constrain a lower-dimensional part of a scalar CNN's features? If the benefit comes simply from constraining less, an arbitrary channel subset should match our result. The random-subspace control answers this directly. Our claim survives only if the length-and-routing constraint beats random subsets of equal size at equal $\lambda$ budgets.

Why not just add capacity or a reconstruction detector? CapsAttacks attributes the deeper VGG's robustness partly to depth, so we compare at matched parameter counts. Reconstruction checks detect attacks rather than classify correctly. Detecting and Diagnosing shows a CNN with conditional reconstruction is fooled about 99% of the time by its reconstruction-aware attack, and reconstruction checks do not address clean accuracy at all.

Proposed Experiments and Decisive Checks

The main experiments run on CIFAR-10 and CIFAR-100 under the RobustBench L-infinity threat model (RobustBench). SVHN and GTSRB are secondary, since the earlier capsule-vulnerability papers report on them. Imagenette is a scale check. The file reports no CIFAR-100 numbers for any method, so all CIFAR-100 comparisons will come from our own reruns.

Metrics are clean accuracy, AutoAttack robust accuracy, the area under the clean-versus-robust Pareto curve, and calibration error, since RobustBench notes robust models are underconfident. Iterative routing and Gumbel-Softmax gates can hide gradients from the attacker, a failure known as gradient masking. Beyond AutoAttack, we therefore run adaptive white-box attacks that target class-capsule length gaps and routing weights directly, average gradients over STAR-Caps gate samples, and rely on the black-box Square attack as a check. A model whose robustness holds only against gradient attacks counts as a failure.

Three findings would decide the question. The first is whether selective invariance moves the capsule Pareto curve above full-vector invariance. The second is whether it beats the random-subspace control. The third is whether the resulting curve reaches or passes retrained AR-AT on the shared backbone while preserving SmallNORB viewpoint generalization. The stage-one measurement of where attacks act inside the head will be reported regardless of outcome, because it fills the AutoAttack gap for capsule models left open in the file.