NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

API-Net: Robust Generative Classifier via a Single Discriminator

Xinshuai Dong, Hong Liu, Rongrong Ji, Liujuan Cao, Qixiang Ye, Jianzhuang Liu, Qi Tian

Abstract

Deep Neural Networks (DNNs) are notoriously fragile, often falling victim to human-imperceptible adversarial perturbations. While generative classifiers offer a theoretical advantage in robustness by modeling the data distribution $p(x, y)$, they are traditionally difficult to optimize and computationally expensive. This paper introduces API-Net, a framework that bridges the gap between efficient discriminative classifiers and robust generative ones. By employing a novel "Anti-Perturbation Inference" (API) method on a single discriminator, API-Net achieves state-of-the-art robustness while remaining easy to train using standard adversarial training techniques.

Introduction

Researchers generally categorize classifiers into two types: discriminative and generative. Discriminative models focus on the decision boundary $p(y|x)$; they are fast but easily fooled by "off-manifold" examples. Generative models, by contrast, check if an input actually "looks like" a specific class. However, the complexity of training generative models has limited their adoption in robust defense.

API-Net addresses this by treating a single, standard discriminator (such as a ResNet) as the core of a generative model. This allows the model to benefit from the theoretical robustness of generative modeling while utilizing the optimization efficiency of discriminative architectures.

Methodology

The API-Net methodology consists of two primary stages: Anti-Perturbation Inference and Generative Prediction.

Overview of the API-Net methodology, illustrating the two-step process of Anti-Perturbation Inference and Generative Prediction using a single discriminator.

1. Anti-Perturbation Inference (API)

For any input image $x$, the model searches for an "anti-perturbation" $\Delta$. This $\Delta$ is designed to maximize a lower bound of the joint log-likelihood of the input and a potential class. Essentially, the model attempts to "clean" the image by nudging it back toward the nearest valid data manifold for a specific category. This process is defined by: $$\log p(x,y) \geq F(\Sigma, D, \epsilon_{ap}) + \log p(x) + \max_{\Delta} \log p(y|z)$$ where $z = x + \Delta$ and $\|\Delta\|_{\infty} \leq \epsilon_{ap}$.

2. Generative Prediction via Bayes’ Rule

Instead of a standard forward pass, API-Net uses the maximized lower bounds to approximate Bayes' rule. It compares how well the "cleaned" image fits each possible class and selects the best match using a softmax function: $$\hat{p}(y|x) = \text{softmax}_{c=1}^{C} [l^*(x, y_c)]$$

Crucially, because API-Net is built on a single discriminator, it can be trained using standard Adversarial Training (e.g., PGD training), which was previously difficult to apply to generative models.

Experimental Results

The researchers evaluated API-Net on three standard computer vision benchmarks: CIFAR-10, SVHN, and MNIST. API-Net consistently outperformed leading defense methods like Madry, Trades, and ME-Net.

  • CIFAR-10: Under a PGD-40 white-box attack, API-Net achieved 63.13% accuracy, significantly higher than the previous state-of-the-art of 55.40%.
  • SVHN: API-Net reached 74.36% accuracy under PGD-40, compared to the runner-up's 71.90%.
  • MNIST: The model maintained a high performance of 97.10% even under heavy attack.

Tests against BPDA (Backward Pass Differentiable Approximation) attacks confirmed that API-Net's robustness is genuine and not a result of gradient obfuscation. Furthermore, when forced to transform noise into a specific class, API-Net generates perceptually meaningful structures, demonstrating that it has learned the underlying data distribution.

Discussion and Future Work

While API-Net provides a significant safety margin, it introduces new challenges. The inference phase requires an optimization loop to find $\Delta$, making it computationally slower than standard "one-shot" DNNs. Additionally, the model is sensitive to the hyperparameter $\epsilon_{ap}$; if the scope is too large, the model may "hallucinate" features of the wrong class. Future work will focus on improving inference speed and scaling this generative approach to high-resolution datasets like ImageNet.

Summary updated

BibTeX
@inproceedings{dong2020api,
  author = {Xinshuai Dong and Hong Liu and Rongrong Ji and Liujuan Cao and Qixiang Ye and Jianzhuang Liu and Qi Tian},
  title = {{API-Net: Robust Generative Classifier via a Single Discriminator}},
  booktitle = {European Conference on Computer Vision},
  year = {2020},
  doi = {10.1007/978-3-030-58601-0\_23},
}
Figure