FACM: Intermediate Layer Still Retain Effective Features against Adversarial Examples

Xiangyuan Yang, Jie Lin, Hanlin Zhang, Xinyu Yang, Peng Zhao

Abstract

In strong adversarial attacks against deep neural networks (DNN), the generated adversarial example will mislead the DNN-implemented classifier by destroying the output features of the last layer. To enhance the robustness of the classifier, we propose the Feature Analysis and Conditional Matching prediction distribution (FACM) model. FACM utilizes the features of intermediate layers to correct classification. We demonstrate that intermediate layers often retain effective features for the original category—a "correction property." The FACM model consists of Feature Analysis (FA) correction modules, Conditional Matching Prediction Distribution (CMPD) correction modules, and a decision module. Through the diversity property, these modules work synergistically to reduce the adversarial subspace. Our model can be achieved by fine-tuning and combined with other model-specific defenses.

Introduction: Rescuing Robustness from the Inside Out

Deep Neural Networks (DNNs) are notoriously fragile. A tiny, invisible perturbation—an adversarial example—can flip a model's prediction from "dog" to "airplane." Most existing defenses, like Adversarial Training (AT), attempt to make the entire network robust by training on these "broken" examples. However, this is computationally expensive and often results in a "cat-and-mouse" game where new attacks quickly bypass the defense.

The core observation of this work is that while an adversarial attack successfully destroys features in the last layer to cause misclassification, the intermediate layers often still retain effective, "correct" features for the original category. The challenge lies in effectively extracting and using this "hidden" information to correct the final decision without sacrificing performance on clean data.

The FACM Framework

The FACM model is a modular framework designed to be "plugged into" existing classifiers. It consists of three primary components:

The FACM framework architecture, comprising FA modules, CMPD modules, and the Decision module.
  1. Feature Analysis (FA) Correction Modules: These are auxiliary classifiers attached to various intermediate layers of the DNN. They are fine-tuned to predict the correct label based on features at specific depths. Because perturbations are often optimized to fool the final layer, these intermediate "checkpoints" can often see through the noise.
  2. Conditional Matching Prediction Distribution (CMPD) Modules: This sophisticated tool uses a conditional auto-encoder that takes both the input image and intermediate features as "hints" to reconstruct a version of the image matching the original prediction distribution. Using intermediate features as conditions helps the model converge faster and more stably.
  3. Decision Module: Since different adversarial examples might be "fixed" by different layers, a three-layer MLP acts as a manager. It evaluates the outputs of all auxiliary classifiers and determines which correction modules to trust, utilizing a multi-label focal loss to handle varying module accuracies.

A lighter version, fast-FACM, omits the auto-encoders to reduce inference time while still providing significant protection.

Key Insights: Correction and Diversity

The success of FACM rests on two fundamental properties:

  • The Correction Property: The impact of adversarial noise is cumulative; it intensifies as it moves through the network. Consequently, the middle of the network is often "cleaner" than the end, retaining features that can still lead to a correct classification.
  • The Diversity Property: Not all layers fail simultaneously or in the same way. By creating an ensemble of correction modules from different depths, FACM reduces the "adversarial subspace"—the set of possible inputs that can fool the system.
Conceptual illustration of the diversity property and adversarial subspaces.

As shown in the conceptual diagrams, an attacker would have to fool every single auxiliary classifier simultaneously to succeed, which is significantly more difficult than fooling a single output layer.

Experimental Evaluation

The model was evaluated on three standard benchmark datasets: MNIST (using MNISTNet), and CIFAR-10/CIFAR-100 (using WideResNet-16-4). These datasets provide well-documented attack baselines for testing robustness.

Key Results

Quantitative improvements are substantial, particularly in "Grey-box" settings (where the attacker knows the base model but not the FACM defense):

  • Robustness Boost: On CIFAR-10, a naturally trained model has near 0% accuracy under a PGD attack. Adding FACM-grey (with $\tau=3$) increases accuracy to ~48.7%.
  • Black-box Resistance: Against query-based attacks like NATTACK, FACM achieved 80% accuracy on CIFAR-10, compared to just 1.5% for a standard model.
  • Minimal Clean Accuracy Drop: FACM only reduces clean accuracy by about 2.5%, a very favorable trade-off compared to the significant drops often seen with heavy adversarial training.
  • Synergy: FACM acts as a force multiplier. Combining FACM with other defenses, such as randomization (Resize and Padding), creates a much more formidable defense.

Conclusion and Future Work

FACM provides a clever way to "listen" to the internal layers of a network, proving that even when a model is confused at its output, the truth is often still hidden in its intermediate representations.

While the full FACM model introduces some computational overhead (2-3 times slower inference), fast-FACM offers a lighter alternative. Future work includes exploring whether these properties hold in Vision Transformers (ViTs), where global attention mechanisms might distribute adversarial noise differently than CNNs. Currently, FACM requires a separate fine-tuning phase for auxiliary modules, which adds some complexity to the training pipeline.

Summary updated

Abstract

In strong adversarial attacks against deep neural networks (DNN), the generated adversarial example will mislead the DNN-implemented classifier by destroying the output features of the last layer. To enhance the robustness of the classifier, in our paper, a \textbf{F}eature \textbf{A}nalysis and \textbf{C}onditional \textbf{M}atching prediction distribution (FACM) model is proposed to utilize the features of intermediate layers to correct the classification. Specifically, we first prove that the intermediate layers of the classifier can still retain effective features for the original category, which is defined as the correction property in our paper. According to this, we propose the FACM model consisting of \textbf{F}eature \textbf{A}nalysis (FA) correction module, \textbf{C}onditional \textbf{M}atching \textbf{P}rediction \textbf{D}istribution (CMPD) correction module and decision module. The FA correction module is the fully connected layers constructed with the output of the intermediate layers as the input to correct the classification of the classifier. The CMPD correction module is a conditional auto-encoder, which can not only use the output of intermediate layers as the condition to accelerate convergence but also mitigate the negative effect of adversarial example training with the Kullback-Leibler loss to match prediction distribution. Through the empirically verified diversity property, the correction modules can be implemented synergistically to reduce the adversarial subspace. Hence, the decision module is proposed to integrate the correction modules to enhance the DNN classifier's robustness. Specially, our model can be achieved by fine-tuning and can be combined with other model-specific defenses.
BibTeX
@misc{yang2022facm,
  author = {Xiangyuan Yang and Jie Lin and Hanlin Zhang and Xinyu Yang and Peng Zhao},
  title = {{FACM: Intermediate Layer Still Retain Effective Features against Adversarial Examples}},
  year = {2022},
  eprint = {2206.00924},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2206.00924},
}
Figure