Toward a mechanistic understanding of inference in visual cortex and diffusion models

Zeyu Yun, Alexander Belsten, Dasheng Bi, Zahra Kadkhodaie, Yubei Chen, Bruno A. OlshausenarXiv 2026

TL;DR

This paper bridges the gap between biological vision and machine learning by introducing a fully interpretable, single-layer "minimal diffusion model" based on non-factorial sparse coding. By training this recurrent neural circuit on natural images using denoising score matching, the authors demonstrate how primary visual cortex (V1) horizontal connections and an emergent hierarchy of "detached neurons" naturally arise to solve complex image denoising and generation tasks.

What Problem Does This Paper Address?

Modern denoising diffusion models are incredibly powerful, yet they operate as "black boxes." We lack a clear, mechanistic understanding of how their underlying neural networks structurally represent image priors or how they generalize to generate novel images.

Conversely, in neuroscience, it has long been theorized that the primary visual cortex (V1) uses a network of horizontal connections to perform perceptual grouping, such as contour integration. However, classical unsupervised models (like standard sparse coding) assume that latent features are statistically independent, failing to replicate how these horizontal connections emerge from the statistics of natural scenes. This paper addresses both gaps by creating an explicit, mathematically transparent model that explains the internal mechanisms of diffusion models while generating testable hypotheses for neurophysiology.

Methods

The authors extend the classic sparse coding model by introducing a non-factorial prior over the latent variables. Instead of assuming latents are independent, they introduce an unconstrained, pairwise interaction matrix ($M$) that captures how different image features co-occur.

Key methodological innovations include:

  • Denoising Score Matching (DSM): Rather than using standard maximum likelihood estimation, which is computationally intractable for this architecture, the model is trained using a MAP-approximated score function within a DSM objective.
  • MAP-Induced Recurrent Inference: The inference process unfolds as a recurrent neural circuit derived via the Iterative Shrinkage-Thresholding Algorithm (ISTA).
  • Implicit Function Theorem (IFT) Gradients: To train the network efficiently, the authors use the IFT to differentiate directly through the stable fixed point of the recurrent dynamics. This bypasses the massive memory costs of Backpropagation Through Time (BPTT) using an Unrolling-based Phantom Gradient (UPG) approximation.
  • Multi-Scale Convolutional Extension: To handle high-dimensional natural images, the model utilizes a multi-scale Laplacian pyramid structure with an asymmetric sweeping (Gauss-Seidel style) update schedule to accelerate information propagation.

Datasets

The model was trained and evaluated on two primary datasets:

  1. Van Hateren Dataset: A standard collection of luminance-only (gray-scale) natural scenes used to analyze V1-like connectivity and contour integration.
  2. CelebA Dataset: A highly structured face dataset used to evaluate high-level semantic representation and generalization.

Key Insights and Ideas

  • Emergence of Collinear Facilitation: When trained on natural images, the interaction matrix $M$ automatically learns to connect spatially offset neurons whose preferred orientations align along a shared axis. This perfectly mirrors the "association fields" observed in the superficial layers of V1.
Emergence of V1-like connectivity
  • Demystifying the Denoising Jacobian: By expanding the network's Jacobian into an infinite Neumann series, the authors show exactly how sparse gating ($\Sigma$) clamps neural activity, allowing lateral connections to propagate signals exclusively along active contours while suppressing background noise.
  • The "Detached Neuron" Phenomenon: When trained on complex structures like faces, roughly 30% of the neurons learn near-zero dictionary weights, completely decoupling from direct pixel space. Instead of encoding local pixels, these "detached neurons" form an emergent second layer that enforces global semantic consistency (e.g., coordinating the alignment of both eyes).
Semantic generalization and detached neurons
  • State-Dependent Routing: The model reveals that the interaction matrix $M$ is dynamically scaled by noise levels. Under low noise, the network relies on feedforward sensory drive; under high noise, it relies heavily on $M$, providing a mechanistic explanation for why V1 switches from surround suppression to surround facilitation in low-contrast environments.

Key Results

  • Generative Parity with U-Nets: Despite its architectural simplicity, the non-factorial sparse coding model achieves functional equivalence and generative parity with a parameter-matched black-box U-Net, producing visually indistinguishable reverse diffusion samples and comparable denoising PSNRs.
  • Superior Denoising: The non-factorial model significantly outperforms standard factorial sparse coding by successfully completing fragmented contours and suppressing hallucinated, spurious edges in noisy regions.

Limitations and Future Work

  • Manifold Approximation: The model approximates the continuous manifold of natural images by dropping discrete "landmarks" (sparse codes) and interpolating between them. The authors suggest that a more direct parameterization of continuous manifolds could yield even simpler models.
  • Explicit Hierarchies: Although a hierarchical structure emerges naturally via detached neurons, explicitly extending this framework to deep, multi-layer architectures remains an open challenge.
  • Experimental Validation: The model provides concrete, testable hypotheses regarding context-dependent routing in V1 during noisy or low-contrast stimulation, which await validation through future in vivo physiological experiments.

Summary updated

BibTeX
@misc{yun2026toward,
  author = {Zeyu Yun and Alexander Belsten and Dasheng Bi and Zahra Kadkhodaie and Yubei Chen and Bruno A. Olshausen},
  title = {{Toward a mechanistic understanding of inference in visual cortex and diffusion models}},
  year = {2026},
  eprint = {2607.15693},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2607.15693},
}
Figure