Discriminative Score Function: Turning Pretrained Models into Functional Generative Priors

Junhoo Lee, Hyeonjin Kim, Sangbum Han, Nojun Kwak

TL;DR

The Discriminative Score Function (DSF) is a novel, training-free method that extracts generative capabilities from fixed, pretrained discriminative models (like ResNet classifiers or DINOv2 encoders). By leveraging the model's internal "loss-gradient geometry," DSF can synthesize images, perform inpainting, and provide high-quality calibration data for model quantization—all without needing labels or retraining.

What Problem Does This Paper Address?

In the world of computer vision, we usually have a strict divide: discriminative models (like classifiers) learn to tell things apart, while generative models (like Diffusion or GANs) learn to create data. However, for a classifier to generalize well to new images, it must implicitly understand the "data manifold"—the underlying structure of what a real image looks like.

Previous attempts to "invert" classifiers to generate images often required class labels, specific architectures, or auxiliary generative models to act as a crutch. They also frequently produced "adversarial" artifacts—images that look like noise to humans but "look" like a specific class to the model. The authors ask: Can we expose this implicit manifold knowledge as a standalone generative signal in a general, label-free way for any pretrained model?

Methods

The authors introduce the Discriminative Score Function (DSF). The core intuition is to treat image generation as a process of moving a noisy image toward the data manifold.

Instead of using a standard probability density (which we don't have for a fixed classifier), they use a functional distance induced by the Loss Tangent Kernel (LTK).

The Key Ingredients:

  1. Functional Alignment: Rather than just maximizing a class score, DSF wiggles the pixels of an image so that the image's loss gradient aligns with the model's learned weights.
  2. Weights as a Proxy: The authors argue that a trained model's weights ($\theta$) are essentially a "trace" of all the gradients it saw during training. By aligning a new image's gradient with $-\theta$, they are effectively pushing the image toward the regions of the manifold the model was trained on.
  3. Label-Free Loss: To make this work without labels, they use an augmentation invariance loss. They take two different "views" of the same image (e.g., different crops) and calculate the gradient required to make the model's internal representations of those views match.
Overview of DSF as a functional generative prior

The resulting update rule is training-free and can be applied to almost any architecture, from CNNs (ResNet) to Vision Transformers (DINOv2) and even object detectors (DETR).

Datasets

The paper does not involve new training; instead, it evaluates DSF using several popular pretrained models:

  • ResNet-50: Trained on ImageNet (Classification).
  • DINOv2: A self-supervised ViT trained on LVD-124M (Representation Learning).
  • DETR: A Transformer-based detector trained on COCO (Object Detection).
  • CLIP: Used as an external guidance model for conditional generation.
  • ImageNet: Used to provide "real image" oracle baselines for the quantization experiments.

Key Insights and Ideas

  • Discriminative Training is Generative: The most profound insight is that the act of training a model to discriminate (classify or detect) naturally leaves a "generative functional signal" in its geometry.
  • Functional Space vs. Image Space: Traditional "feature visualization" often fails because it optimizes in a way that exploits model weaknesses. By optimizing for alignment in the loss-gradient functional space, DSF produces much more coherent, manifold-consistent images.
  • Zero-Shot Utility: Because DSF-generated images are "model-matched" (they come from the same geometry as the model being analyzed), they are incredibly effective for tasks like zero-shot quantization calibration, where you need representative data to compress a model but don't have access to the original training set.
The concept of mapping datasets to functional space

Key Results

  • Unconditional Generation: DSF successfully generates recognizable, model-consistent structures from pure noise across different architectures. ResNets produce object-centric patterns, while DINOv2 produces natural textures and DETR produces scene-like compositions.
  • Zero-Shot Quantization: In tests calibrating a DINOv2 model for 4-bit, 6-bit, and 8-bit quantization, DSF-generated images consistently outperformed other "data-free" methods (like Gaussian noise or RegCache). In many cases, DSF matched the performance of using real ImageNet images (the "oracle" baseline).
  • Image Editing and Inpainting: DSF can be used to "nudge" real images toward new semantics (e.g., turning a spot of light into an iguana's head) or to restore missing patches in an image by ensuring the restored area is consistent with the model's learned manifold.

Examples of image editing using DSF Examples of the inpainting task

Limitations and Future Work

  • Not a SOTA Generator: The authors are clear that DSF is not intended to compete with high-fidelity diffusion models for pure art generation. It is a tool for model analysis and utility.
  • Computational Cost: Because the method involves differentiating through a gradient (a mixed second-order derivative), it is slower than simple first-order image optimization, taking about 1.4–1.7 seconds per image on an A6000 GPU.
  • Dependence on Pretraining: The quality of the generative prior is strictly limited by the quality and diversity of the original discriminative model's training.
  • Future Directions: Exploring stronger samplers (like those used in diffusion) and applying DSF to broader domains beyond standard 2D vision are noted as promising next steps.

Summary updated

BibTeX
@inproceedings{lee2026discriminative,
  author = {Junhoo Lee and Hyeonjin Kim and Sangbum Han and Nojun Kwak},
  title = {{Discriminative Score Function: Turning Pretrained Models into Functional Generative Priors}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=zWDlC6eCkN},
}
Figure