Deep neural networks (DNNs) are notoriously fragile when faced with adversarial attacks—small, often invisible perturbations to an input that can trick a model into making confident, incorrect predictions. To counter this, researchers have developed Constrained Trainable Random Weight (CTRW), a novel defense mechanism that injects trainable noise into neural network weights. By theoretically deriving upper and lower bounds for this noise, CTRW successfully balances the trade-off between a model's "natural" accuracy on clean images and its "robust" accuracy against malicious perturbations, outperforming existing randomized defenses by significant margins.
The Problem with Randomized Defenses
Most powerful adversarial attacks are "white-box," meaning the attacker has full access to the model's gradients to calculate exactly how to flip a prediction. "Randomized defenses" attempt to thwart this by introducing stochasticity during inference. If the model's weights or activations change slightly every time it runs, the attacker cannot rely on a stable gradient to craft their attack.
However, these defenses face a "Goldilocks" problem. If the randomness is too low, the defense is ineffective against strong attacks. If it is too high, the model becomes too noisy to perform its original task accurately. Until now, finding the right amount of randomness required tedious, manual hyperparameter tuning, which often failed to generalize across different datasets or architectures.
Methods: Constrained Trainable Random Weights
The authors propose CTRW, which moves away from manual tuning by making the randomness parameters themselves part of the optimization process.
- Trainable Random Weights: Instead of static weights, a layer uses weights sampled from a Gaussian distribution: $W^r = \mu + \delta \odot \sigma$. Here, $\mu$ (mean) and $\sigma$ (standard deviation) are learned during training using the reparameterization trick (similar to how Variational Autoencoders operate).
- Theoretical Constraints: To solve the Goldilocks problem, the authors derived two mathematical bounds for $\sigma$:
- Lower Bound (for Robustness): Based on "Gradient Similarity." It ensures that the gradients of two different random samples of the model are different enough that an attack generated for one won't easily transfer to the other.
- Upper Bound (for Natural Performance): Based on "Prediction Bias." It ensures the noise doesn't get so large that it overwhelms the actual features of the data, preserving accuracy on clean inputs.
- Optimization: The model is trained using a min-max game (adversarial training) where $\sigma$ is strictly constrained within these theoretically guided bounds.
Key Insights and Ideas
- The First Layer is Key: Through ablation studies, the authors found that injecting randomness at the first convolutional layer (the in-channels) is the most effective strategy. Loading randomness earlier in the network provides better downstream protection than doing so in deeper layers or the final fully connected layer.
- Breaking Gradient Transferability: The core breakthrough is the formalization of gradient similarity. By forcing the model to have low cosine similarity between gradients of different weight samples, CTRW effectively turns a white-box attack into a much harder black-box attack.
- Trainable vs. Fixed Noise: The study demonstrates that trainable noise is vastly superior to fixed noise. A model that can adapt its noise levels to the specific features of the dataset achieves a much better balance of accuracy and defense.
Key Results
The authors evaluated CTRW on standard computer vision benchmarks, including CIFAR-10, CIFAR-100, and ImageNet, across popular architectures like ResNet18, ResNet50, and Wide Residual Networks (WRN34).
CTRW shows a dramatic improvement over both standard baselines and previous state-of-the-art (SOTA) randomized defenses:
- Massive Robustness Gains: On CIFAR-10 with ResNet18, CTRW achieved a robust accuracy 17.32% higher than the baseline under PGD-20 attacks and 25.87% higher on the more rigorous Auto Attack (AA).
- Outperforming SOTA: On Wide ResNets, CTRW outperformed the previous best randomized algorithm by 6.47% on Auto Attack.
- Attack Stability: Unlike many defenses that crumble under "stronger" attacks (more iterations), CTRW's robust accuracy remained stable even as the number of attack steps increased from 10 to 100.
Limitations and Future Work
While highly effective, CTRW has a few limitations that pave the way for future research:
- Focus on CNNs: The current work focuses primarily on Convolutional Neural Networks. Exploring how these trainable random weights behave in Vision Transformers (ViTs) would be a logical next step.
- Computational Overhead: While the sampling process is efficient, any randomized defense requires multiple forward passes or specific training loops that are inherently more expensive than standard training.
- Adaptive Attacks: The "cat-and-mouse" nature of adversarial machine learning means future work will likely need to investigate "Expectation over Transformation" (EoT) attacks specifically designed to bypass this type of stochasticity.
Summary updated