Abstract
We propose a retrieval-augmented convolutional network and propose to train it with local mixup, a novel variant of the recently proposed mixup algorithm. The proposed hybrid architecture combining a convolutional network and an off-the-shelf retrieval engine was designed to mitigate the adverse effect of off-manifold adversarial examples, while the proposed local mixup addresses on-manifold ones by explicitly encouraging the classifier to locally behave linearly on the data manifold. Our evaluation of the proposed approach against five readily-available adversarial attacks on three datasets--CIFAR-10, SVHN and ImageNet--demonstrate the improved robustness compared to the vanilla convolutional network.
Introduction
Adversarial examples—subtle, often imperceptible perturbations that trick neural networks into making confident, wrong predictions—remain one of the most significant hurdles for deploying deep learning in safety-critical real-world applications. While many existing defenses focus on "hardening" the network through adversarial training, this work explores a different paradigm: Retrieval-Augmented Convolutional Neural Networks (RaCNN). By combining a standard classifier with a retrieval engine, the architecture forces the network to stay "grounded" in the reality of its training data, effectively defending the data manifold.
Problem Formulation
Adversarial attacks generally exploit two distinct weaknesses in deep neural networks:
- Off-manifold examples: Perturbations that push an image into regions of the input space that the model never encountered during training.
- On-manifold examples: Perturbations that remain within the data distribution but exploit "non-smooth" decision boundaries where the model is overly sensitive.
Most current defenses attempt to teach the model about these "bad" regions. In contrast, RaCNN aims to prevent the model from ever processing them by projecting inputs back onto a representation derived from known training examples.
Methodology
The proposed RaCNN architecture consists of three main stages:
1. Retrieval
For a given input $x$, an off-the-shelf retrieval engine (such as FAISS or LSH) identifies the $K$ nearest neighbors from the training set in a pretrained feature space. This retrieval process acts as a "bouncer," ensuring that the subsequent classification is based on points that resemble real data.
2. Trainable Projection
Instead of classifying the input $x$ directly, the model constructs a feature-space convex hull using the $K$ retrieved neighbors. An attention mechanism is then employed to project the input $x$ onto this hull. This ensures the classifier only "sees" a representation that is a linear combination of authentic training examples, effectively filtering out off-manifold noise.
3. Local Mixup
To handle on-manifold attacks, we introduce "local mixup," a novel training strategy. Unlike standard mixup, which interpolates between random pairs of images, local mixup interpolates between an image and its actual neighbors. This explicitly encourages the model to behave linearly and smoothly in the local neighborhood of the data manifold.
Experimental Evaluation
The RaCNN was evaluated on three standard benchmarks: CIFAR-10, SVHN (Street View House Numbers), and ImageNet. The latter demonstrates the approach's scalability to high-dimensional, large-scale data.
Performance Against Adversarial Attacks
We tested the RaCNN against five major attacks: FGSM, iFGSM, DeepFool, L-BFGS, and the black-box Boundary attack.
As shown in the results, RaCNN provides significant robustness gains. On CIFAR-10, under a strong FGSM attack, a vanilla CNN's accuracy plummeted to 4.22%, while the RaCNN maintained 33.47% accuracy. The architecture was particularly effective against the black-box Boundary attack, showing almost no degradation in accuracy where the baseline model failed completely.
Scalability and Informed Attackers
Even on the massive ImageNet dataset, RaCNN showed much higher resilience to the DeepFool attack compared to a standard ResNet-18. We also evaluated a "Scenario 2" where the attacker is given access to the feature extractor used for retrieval. While performance dropped compared to the "hidden" retrieval scenario, RaCNN remained significantly more robust than the baseline.
Discussion and Conclusion
The robustness of RaCNN can be attributed to the "Bouncer Effect" of the retrieval engine and the non-differentiability of the retrieval process, which makes gradient-based attacks harder to execute. However, like many defense mechanisms, RaCNN incurs a "robustness tax"—a slight drop in accuracy on unperturbed "clean" images (e.g., from 85.15% to 80.80% on CIFAR-10). Additionally, the $K$-nearest neighbor search adds computational latency, though modern libraries mitigate this overhead.
In conclusion, RaCNN offers a novel approach to adversarial defense by anchoring model decisions to the training data manifold. By combining retrieval-based projection with local mixup training, the model achieves superior robustness against both white-box and black-box attacks across multiple datasets.
Summary updated