Evaluating Visual Number Discrimination in Deep Neural Networks

Ivana Kajic, Aida Nematzadeh · DOI

Introduction

Basic numerical competence—the ability to distinguish "few" from "many"—is a foundational cognitive skill shared by human infants and many animal species. While deep learning has revolutionized computer vision, it remains unclear if these models develop a robust, abstract representation of quantity or if they simply "cheat" by latching onto correlated visual cues, such as total edge length or surface area. Researchers from DeepMind investigated whether state-of-the-art vision models possess a "number sense" similar to biological organisms.

Methods

The researchers employed a classic numerical bisection procedure adapted from comparative psychology:

  1. Training: Models are trained to categorize "anchor" numerosities: 1 and 2 are labeled as "few," while 6 and 7 are labeled as "many."
  2. Testing: Models are then tested on intermediate, unseen numbers (3, 4, and 5) to see if they produce an S-shaped psychometric curve, indicating a gradual transition from "few" to "many."

Four architectures were compared: ResNet-50 (CNN), ViT-B (Vision Transformer), Swin-T (Swin Transformer), and a simple MLP baseline.

Datasets and Stimulus Control

To ensure models weren't relying on non-numerical confounds like total luminance or perimeter, the authors used synthetic stimuli consisting of white circles on a black background across six categories that controlled for specific visual features.

Examples of synthetic stimuli used to control for non-numerical visual features, including constant area and contour versions.

These categories included Vary Size, Constant Size, Constant Area (where circles shrink as count increases), and Constant Circumference. Additionally, Contour versions used hollow outlines to test generalization beyond solid textures.

Key Insights

  • Inductive Biases Matter: Models with image-specific inductive biases (Swin and ResNet) significantly outperformed the standard Vision Transformer (ViT) and the MLP. Swin, in particular, produced psychometric curves that most closely resembled biological data.
  • The Transfer Gap: Even high-performing models struggled when the visual "style" changed. A model trained on solid circles often failed to count hollow "contour" circles, suggesting that the concept of "number" remains tied to specific visual features rather than being fully abstracted.
  • Weber’s Law in AI: Models exhibited greater difficulty distinguishing larger numbers (e.g., 5 vs. 6) than smaller ones (e.g., 2 vs. 3). This imprecision at higher magnitudes is a hallmark of biological numerical cognition.
  • Latent Structure: Internal visualizations revealed that Swin's representations clustered by number in an ordered sequence, even when final classification performance was poor. This suggests numerical information is present in the embeddings but not always accessible to the classifier across different distributions.

Key Results

On seen stimulus types, ResNet and Swin achieved near-perfect performance with error rates below 1%. In contrast, ViT struggled, sometimes performing worse than the MLP baseline. As shown in the psychometric curves, Swin and ResNet successfully generalized to intermediate numbers (3, 4, 5), producing the expected S-shaped transition.

Psychometric curves showing the percentage of "many" responses across different architectures. Swin and ResNet show the characteristic S-shape of numerical bisection.

However, in "Out of Distribution" (OOD) tests, performance dropped sharply. For instance, when trained on "Constant Size" and tested on "Constant Area," models often reverted to "all-or-none" responses or inverted their logic, labeling small numbers as "many" due to their larger individual white areas.

Limitations and Future Work

The study's primary limitation is the restricted data regime. Unlike animals that develop numerical sense through rich, multi-modal environmental interactions, these models were trained on narrow sets of static images. Future research should explore whether pre-training on massive naturalistic datasets improves numerical transfer or if specialized "counting" modules are required to achieve true, context-independent numerical abstraction.

Summary updated

BibTeX
@inproceedings{kajic2023evaluating,
  author = {Ivana Kajic and Aida Nematzadeh},
  title = {{Evaluating Visual Number Discrimination in Deep Neural Networks}},
  booktitle = {CogSci},
  year = {2023},
  url = {https://openreview.net/forum?id=NNaU8ZIVeX},
}
Figure