FeatInv: Spatially resolved mapping from feature space to input space using conditional diffusion models

Nils Neukirch, Johanna Vielhaben, Nils Strodthoff

TL;DR

FeatInv maps internal neural network representations back to input space using a ControlNet-style conditional diffusion model conditioned directly on spatially resolved feature maps. Unlike prior inversion techniques that rely on spatially pooled vectors or deterministic decoders, FeatInv produces diverse, photo-realistic images that preserve fine-grained spatial structure and faithfully mirror how vision models perceive an image.

What Problem Does This Paper Address?

Understanding what deep neural networks "see" in their hidden representations is essential for interpretability, safety, and robustness research. However, mapping feature maps back into input images is inherently ill-posed: many different inputs can yield near-identical activations.

Existing inversion techniques suffer from key limitations:

  1. Loss of spatial layout: Many approaches average-pool feature maps into a single global vector, discarding critical spatial coordinates.
  2. Deterministic bias: Single-output models ignore the one-to-many nature of feature inversion.
  3. Crude approximations: Methods like GradCAM rely on naive linear upsampling to localize activations, which fails to capture complex feature relationships.

FeatInv resolves these issues by training a probabilistic generative model conditioned on spatially resolved feature maps across modern convolutional and vision transformer architectures.

Methods

FeatInv adapts the ControlNet framework on top of a locked, pretrained diffusion model (MiniSD, 256×256 resolution):

  • Spatially Resolved Conditioning: Rather than pooling tokens, FeatInv takes the unpooled feature map from the penultimate layer (or intermediate stages) of a classifier (e.g., $7 \times 7 \times 2048$ for ResNet-50).
  • Conditional Input Encoder: Bilinear upsampling scales the feature map to the diffusion model's latent spatial resolution ($32 \times 32$), followed by a shallow convolutional network that projects channels into the diffusion feature space. (The authors empirically found this convolutional encoder outperformed cross-attention Perceiver-style encoders).
  • Probabilistic Generation: Controlled diffusion allows sampling multiple high-fidelity images matching the same internal representation, paired with a generic prompt ("a high-quality, detailed and professional image").

Datasets

  • ImageNet-1k: Used to train the ControlNet models (3 epochs on the training set) and evaluate standard reconstruction performance (10 samples per class, totaling 10,000 validation images).
  • BAID (Artistic Image Aesthetics Assessment): 10,000 images used to evaluate out-of-distribution (OOD) style robustness.
  • ImageNet-A: 7,500 natural adversarial examples used to evaluate model behavior under classification failure modes.
  • ImageNet-C: 19 corruption categories across levels 1 and 5 (noise, blur, weather, digital artifacts) used for perturbation robustness analysis.

Key Insights and Ideas

  • Preserving spatial dimensions is non-negotiable: Conditioning on unpooled feature maps dramatically outclasses pooled representations. Unpooled conditioning drops the Fréchet Inception Distance (FID) from ~31–49 down to 8–12 and more than doubles feature cosine similarity.
  • Modern architectures retain rich visual priors: High-level feature maps of modern backbones (ConvNeXt and SwinV2) preserve surprisingly sharp textures, fine edges, and color schemes compared to ResNet-50, which mostly retains high-level semantic abstractions.
  • Earlier layers reveal pixel-level detail: Inverting earlier network stages (ConvNeXt stages 1–3) faithfully recovers watermarks, fine text, and exact boundaries, demonstrating how geometric precision is progressively filtered down the network.
  • Concept Steering in Input Space (FeatInv-Viz): By decomposing feature spaces into concept subspaces (via Multi-Dimensional Concept Discovery) and attenuating specific concept coefficients, FeatInv directly generates counterfactual difference maps in pixel space. This produces fine-grained, localized visualizations of semantic concepts (e.g., separating bird plumage from branches or background) without coarse bilinear blurring.

Key Results

  • Reconstruction Quality & Image Fidelity:
  • ConvNeXt (unpooled): Cosine similarity of 0.61, 94% top-5 classifier match (77% top-1), and an FID of 8.20 (compared to 0.19 cosine sim and 31.67 FID when pooled).
  • SwinV2 (unpooled): Cosine similarity of 0.53, 95% top-5 match (80% top-1), and an FID of 12.69.
  • ResNet-50 (unpooled): Cosine similarity of 0.46, 91% top-5 match (70% top-1), and an FID of 11.49.
  • Cross-Model Robustness: Images reconstructed from ConvNeXt features achieved a 96% top-5 match when fed into SwinV2, proving that representations align across disparate model families.
  • Competitor Comparison: When evaluating pooled representations against RCDM (Bordes et al., 2022), FeatInv trained significantly faster and demonstrated much better scalability to modern backbones like ConvNeXt (RCDM ConvNeXt top-1 match lagged at 10% vs. FeatInv's 20% pooled and 77% unpooled).
  • OOD & Corruptions: On BAID (OOD art), ConvNeXt achieved an FID of 12.98 and cosine similarity of 0.48. On ImageNet-C, low corruptions (level 1) were reconstructed well, though high-frequency noise and extreme contrast drops (level 5) posed challenges.

Limitations and Future Work

  • Domain Restriction: The approach is currently validated only on natural images; transferring to specialized domains (like medical imaging) requires exploring domain-specific diffusion priors.
  • Pretrained Diffusion Dependency: FeatInv relies on an existing high-quality diffusion model operating in the target image domain.
  • Training Overhead: Each classifier backbone and intermediate layer requires training a dedicated ControlNet adapter (though cross-model transfer and fine-tuning may mitigate this).
  • Out-of-Distribution Feature Handling: Arbitrary or synthetic feature manipulations (e.g., extreme steering or arithmetic) risk pushing activations off the natural feature manifold, highlighting the need for explicit OOD feature detectors.

Summary updated

BibTeX
@article{neukirch2025featinv,
  author = {Nils Neukirch and Johanna Vielhaben and Nils Strodthoff},
  title = {{FeatInv: Spatially resolved mapping from feature space to input space using conditional diffusion models}},
  journal = {Accepted by TMLR},
  year = {2025},
  url = {https://openreview.net/forum?id=UtE1YnPNgZ},
}
Figure