How Deep Neural Networks Learn Compositional Data: The Random Hierarchy Model

Francesco Cagnetta, Leonardo Petrini, Umberto Maria Tomasini, Alessandro Favero, Matthieu Wyart

Abstract

Deep neural networks (DNNs) effectively overcome the "curse of dimensionality," learning high-dimensional functions with far fewer samples than theoretically required for generic functions. This paper explores the Random Hierarchy Model (RHM), a synthetic generative framework designed to quantify how DNNs exploit compositional data structures. We demonstrate that DNNs succeed by progressively building "synonymic" invariants across layers, collapsing the effective dimensionality of the task. Our findings show that sample complexity scales polynomially rather than exponentially, governed by the point where hierarchical signal correlations overcome sampling noise.

Introduction

In high-dimensional spaces, learning a generic function typically requires an astronomical number of samples—a phenomenon known as the curse of dimensionality. For example, ImageNet data, with an effective dimension of approximately 50, should theoretically require $10^{20}$ images to learn; yet, DNNs achieve high performance with only $10^7$. The prevailing hypothesis is that real-world data is compositional, where low-level features combine to form higher-level objects. While it has been shown that DNNs can represent such functions, this study investigates the sample complexity required for gradient descent to actually learn them.

The Random Hierarchy Model (RHM)

To study this quantitatively, researchers introduced the Random Hierarchy Model (RHM). The RHM is a generative model based on an $L$-level grammar. A class label $\alpha$ generates high-level representations, which are then decomposed into sub-features across multiple levels. At each level, features have "synonyms"—different patterns that represent the same underlying feature.

The Random Hierarchy Model defines a generative process where class labels are composed of hierarchical features and their synonyms.

As shown in the figure above, the model defines a hierarchy where a class (e.g., 1 or 2) is represented by a sequence of features (e.g., 'a', 'b'). Each feature is further expanded into synonyms at lower levels (e.g., 'a' can be 'e f' or 'd d'). This structure allows precise control over the number of classes ($n_c$), hierarchy depth ($L$), and the number of synonyms ($m$).

Learning via Synonymic Invariance

The core mechanism behind the success of deep networks in the RHM is the emergence of "synonymic invariance." During training, the network learns to treat different synonymic patterns as identical representations. This process occurs progressively: level-1 synonyms are resolved in early layers, while higher-level synonyms are resolved in deeper layers.

Crucially, this study confirms that shallow (two-layer) networks remain "cursed," requiring exponential samples proportional to the total input space. In contrast, deep networks in the "feature learning" regime—where weights move significantly from initialization—successfully build these invariants to collapse the data's effective dimensionality.

Sample Complexity and Universal Scaling

The researchers found that the sample complexity $P^*$ (the amount of data needed to achieve a target error) scales polynomially with the input dimension $d$. Specifically, $P^*$ is proportional to $n_c m^L$. Given that the input dimension $d = s^L$ (where $s$ is the branching factor), the complexity is $P^* \sim d^{\ln(m)/\ln(s)}$.

Test error curves collapse onto a universal scaling law when the number of samples P is normalized by the predicted complexity $n_c m^L$.

As illustrated in the scaling plots, when the training data size $P$ is rescaled by the predicted complexity $n_c m^L$, the test error curves for various model parameters collapse onto a single universal curve. This demonstrates that the learning threshold is fundamentally determined by the signal-to-noise ratio: the point where the statistical correlation between low-level features and the class label becomes stronger than the random fluctuations in the finite dataset.

Conclusion

The Random Hierarchy Model provides a rigorous framework for understanding how deep networks beat the curse of dimensionality. By learning a hierarchy of invariants, DNNs transform an exponentially difficult search into a series of manageable polynomial tasks. Future work aims to apply this framework to Large Language Models to investigate if similar synonymic structures emerge within their embedding spaces and to further refine the mathematical description of the gradient descent path during feature learning.

Summary updated

BibTeX
@misc{cagnetta2023how,
  author = {Francesco Cagnetta and Leonardo Petrini and Umberto Maria Tomasini and Alessandro Favero and Matthieu Wyart},
  title = {{How Deep Neural Networks Learn Compositional Data: The Random Hierarchy Model}},
  year = {2023},
  eprint = {2307.02129},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2307.02129},
}
Figure