Zero-shot counting with a dual-stream neural network model

Jessica A F Thompson, Hannah Sheahan, Tsvetomira Dumbalska, Julian D. Sandbrink, Manuella Piazza, Christopher Summerfield

Abstract

Deep neural networks have provided a computational framework for understanding object recognition, grounded in the neurophysiology of the primate ventral stream, but fail to account for how we process relational aspects of a scene. For example, deep neural networks fail at problems that involve enumerating the number of elements in an array, a problem that in humans relies on parietal cortex. Here, we build a 'dual-stream' neural network model which, equipped with both dorsal and ventral streams, can generalise its counting ability to wholly novel items ('zero-shot' counting). In doing so, it forms spatial response fields and lognormal number codes that resemble those observed in macaque posterior parietal cortex. We use the dual-stream network to make successful predictions about behavioural studies of the human gaze during similar counting tasks.

Introduction: The Gap Between Recognition and Numerosity

Modern deep neural networks (DNNs) excel at identifying objects within complex images. However, their ability to understand the relational structure of a scene—such as the number of objects present—remains limited. While a Convolutional Neural Network (CNN) can reliably detect a "cat," it often struggles to count multiple cats, particularly when those objects differ in appearance from the training data.

In the primate brain, this functional divide is handled by two distinct pathways: the ventral stream (the "what" pathway) for object identity and the dorsal stream (the "where" pathway) for spatial reasoning and numerosity. Standard AI architectures typically attempt to process both identity and quantity within a single stream, leading to poor generalization.

Figure 1: Conceptual distinction between object content (identity) and scene structure (spatial arrangement and quantity).

Architecture: The Dual-Stream Recurrent Neural Network

To address this, we propose a biologically inspired dual-stream recurrent neural network (RNN). The model's design incorporates several key neurophysiological principles:

  1. Sequential Glimpsing: Rather than processing the entire scene in a single pass, the model employs a sequence of 12 "glimpses," mimicking human saccadic eye movements.
  2. Foveated Vision: Each glimpse undergoes a log-polar transform, providing high resolution at the center of the gaze and blurring the periphery, consistent with primate retinal architecture.
  3. Functional Factorization:
    • Ventral Module: A CNN processes the visual content of each glimpse.
  4. Dorsal Module: Receives the $(x, y)$ coordinates of the current glimpse.
  5. Integration in the "PPC": An RNN serves as a proxy for the posterior parietal cortex (PPC), integrating "what" and "where" signals over time to maintain an internal spatial map of targets.
Figure 5: (A) Training and Out-of-Distribution (OOD) test sets. (B-C) Accuracy comparison showing the Dual Stream RNN's robustness compared to a standard CNN. (D-E) Schematic of the brain-inspired architecture and the corresponding neural network modules.

Experimental Results and Zero-Shot Generalization

The model was trained on synthetic grayscale images containing 1–5 target items (letters {B, C, D, E}). To evaluate "zero-shot" counting—the ability to count novel items—we tested the model on Out-of-Distribution (OOD) sets featuring novel shapes ({F, G, H, J}) and luminance levels.

The results demonstrate that factorization is critical for robust numerosity. While a standard CNN's accuracy plummeted to approximately 25% when faced with novel shapes and distractors, the dual-stream RNN maintained a high accuracy of ~95%. By separating identity from location, the model learns that counting is a spatial process independent of object appearance.

Biological Mimicry and Human Behavior

A striking emergent property of the dual-stream RNN is its spontaneous development of neural signatures found in the primate brain. Without explicit programming, the internal units developed "log-normal" tuning curves—where numerical representations become less precise as the count increases—and spatial response fields matching recordings from macaque PPC.

Furthermore, the model successfully predicted human behavioral patterns. In eye-tracking experiments with 24 participants, we found that preventing eye movements (fixed gaze) significantly impaired the ability to count amidst distractors. The dual-stream model accurately replicated this impairment, suggesting that numerosity is an active, enactive process tied to spatial attention.

Conclusion and Future Directions

The dual-stream architecture provides a powerful framework for understanding how the brain separates "what" from "where" to achieve flexible cognition. While currently limited to small numbers (1–5) and 2D stimuli, this approach suggests that moving away from monolithic processing streams is essential for building AI that truly understands the structure of the world. Future work will explore scaling these principles to complex 3D naturalistic scenes and investigating the role of covert attention.

Summary updated

Abstract

To understand a visual scene, observers need to both recognize objects and encode relational structure. For example, a scene comprising three apples requires the observer to encode concepts of ‘‘apple’’ and ‘‘three.’’ In the primate brain, these functions rely on dual (ventral and dorsal) processing streams. Object recognition in primates has been successfully modeled with deep neural networks, but how scene structure (including numerosity) is encoded remains poorly understood. Here, we built a deep learning model, based on the dual-stream architecture of the primate brain, which is able to count items ‘‘zero-shot’’—even if the objects themselves are unfamiliar. Our dual-stream network forms spatial response fields and lognormal number codes that resemble those observed in the macaque posterior parietal cortex. The dual-stream network also makes successful predictions about human counting behavior. Our results provide evidence for an enactive theory of the role of the posterior parietal cortex in visual scene understanding.
BibTeX
@inproceedings{thompson2024zero,
  author = {Jessica A F Thompson and Hannah Sheahan and Tsvetomira Dumbalska and Julian D. Sandbrink and Manuella Piazza and Christopher Summerfield},
  title = {{Zero-shot counting with a dual-stream neural network model}},
  booktitle = {Neuron},
  year = {2024},
  doi = {10.1016/j.neuron.2024.10.008},
}
Figure