Source-linked AI summary

Intrinsic dimension of data representations in deep neural networks

Alessio Ansuini, Alessandro Laio, Jakob H. Macke, Davide Zoccolan

arXiv:1905.12784v2cs.LGstat.ML

TL;DR

The paper asks what geometric structure deep networks learn in their intermediate representations and studies this using intrinsic-dimension estimates from nearest-neighbour statistics. It finds that trained networks form very low-dimensional representations whose ID expands early, contracts late, and predicts test classification accuracy.

  • Problem

    Deep networks transform inputs through nonlinear layers, yet how their representations support generalization despite massive overparameterization remains incompletely understood.

  • Method

    The study uses TwoNN to estimate intrinsic dimension from nearest-neighbour distance ratios across representations sampled from neural-network layers.

  • Results

    CNN representations have intrinsic dimensions orders of magnitude below layer widths, increase early and decrease in final layers, and show lower last-hidden-layer ID for better test classification.

  • Takeaways & Limitations

    Last-hidden-layer intrinsic dimension can serve as a proxy for network generalization ability without estimating performance on an external validation set.

  • Takeaways & Limitations

    For finite samples, estimates above approximately 20 may moderately underestimate the true intrinsic dimension and should be treated as lower bounds.

Abstract

from arXiv · show

Deep neural networks progressively transform their inputs across multiple processing layers. What are the geometrical properties of the representations learned by these networks? Here we study the intrinsic dimensionality (ID) of data-representations, i.e. the minimal number of parameters needed to describe a representation. We find that, in a trained network, the ID is orders of magnitude smaller than the number of units in each layer. Across layers, the ID first increases and then progressively decreases in the final layers. Remarkably, the ID of the last hidden layer predicts classification accuracy on the test set. These results can neither be found by linear dimensionality estimates (e.g., with principal component analysis), nor in representations that had been artificially linearized. They are neither found in untrained networks, nor in networks that are trained on randomized labels. This suggests that neural networks that can generalize are those that transform the data into low-dimensional, but not necessarily flat manifolds.

1 Introduction

The paper frames intrinsic dimension as a geometric lens on why deep networks generalize and asks how representations change across layers. Using TwoNN, it reports low-dimensional representations, a characteristic expand-then-contract profile, and a link between final-layer ID and classification performance.

  • Motivation: Deep networks transform high-dimensional inputs through nonlinear layers, but their generalization despite massive overparameterization remains incompletely understood.Architecture and training choices are still largely guided by heuristics and domain knowledge.
  • Research questions: Intrinsic dimension is the minimal number of coordinates needed to describe representation points without significant information loss.It provides a geometric measure distinct from the number of units or embedding dimension.
  • Research questions: The study asks whether CNNs expand or compress intrinsic dimension, how it differs from linear dimensionality, and whether it predicts generalization.These questions target the geometry of representations across layers and its relation to test performance.
  • Main findings: CNN representations occupy manifolds whose intrinsic dimensionality is typically several orders of magnitude below the number of units in a layer.The paper uses TwoNN, which estimates global ID from nearest-neighbour statistics and applies to curved, topologically complex, non-uniformly sampled manifolds.
  • Main findings: Across architectures, intrinsic dimension first expands in early layers and then decreases monotonically to low values in the final layers.This recurring profile is described as a characteristic shape of learned representations.
  • Main findings: The last hidden-layer ID of the training set accurately predicts test classification accuracy, whereas permuted-label networks retain high ID and memorize rather than generalize.The authors report that lower final-layer ID corresponds to better test-set classification capability.

2 Estimating the intrinsic dimension of data representations

The paper estimates intrinsic dimension from nearest-neighbour distance ratios using the TwoNN method. It validates the estimator in high-dimensional embeddings and identifies finite-sample and scale-related qualifications on the reported estimates.

  • Estimator: TwoNN estimates intrinsic dimension from the ratio between each point’s second- and first-nearest-neighbour distances.The method exploits the dependence of nearest-neighbour statistics on intrinsic dimension.
  • Estimator: TwoNN accommodates curved, topologically complex manifolds and non-uniform sampling under the weak assumption of locally constant density.The density assumption applies on the scale of each point’s second-nearest-neighbour distance.
  • Estimator: The dimension parameter can be estimated by likelihood maximization or by linear regression on the empirical cumulative distribution of distance ratios.Restricting the likelihood to non-intersecting point triplets does not significantly alter estimates in practice.
  • Limitations: For finite samples, estimates are close to the ground-truth ID below approximately 20 but moderately underestimate larger IDs, especially under non-uniform density.Reported values above approximately 20 should therefore be treated as lower bounds.
  • Robustness and scope: ID reliability depends on distance scale, so the analysis assesses approximate scale invariance by progressively decimating datasets.The authors also analyze selected pooling, fully connected, and ResNet-block representations for computational efficiency.
  • Validation: Tests on known-ID data embedded in 100,000 dimensions found no significant accuracy degradation, because the estimator depends on distances rather than embedding dimension.This supports applying TwoNN to representation spaces with dimensions comparable to deep-network layers.

3 Results

CNN representations occupy manifolds whose intrinsic dimension is far below the embedding dimension, typically expanding early and then decreasing toward the final layers. This trained-network profile is associated with generalization, differs from linear estimates and untrained or randomized-label networks, and reflects curved manifolds.

  • The intrinsic dimension is typically several orders of magnitude smaller than the embedding dimension of each layer.The embedding dimension is the number of units in a layer.
  • Across 14 diverse CNNs, ID profiles showed a common hunchback shape, peaking around relative depth 0.2–0.4 before declining.For VGG and ResNet families, peak IDs were between 100 and 120.
  • Last-hidden-layer IDs ranged from ≈12 in ResNet152 to ≈25 in AlexNet and strongly predicted test top-5 performance (r = 0.94).The within-ResNet correlation reached r = 0.99; the proxy can be measured without an external validation set.
  • The low IDs and layerwise profiles are not captured by PCA and indicate nonlinear, curved manifolds rather than largely flat subspaces.PCA showed no clear eigenvalue gap, while TwoNN distinguished the original representations from Gaussian data with matching second-order moments.
  • Training produces the hunchback ID profile: trained networks differ from flat random-weight profiles, and ID growth can continue after embedding dimensionality begins declining.Intermediate-layer ID increases while last-hidden-layer ID decreases relative to its initial value.
  • Adding an irrelevant luminance feature reduced input ID from ≈13 to ≈3, yet the trained MNIST⋆ network still achieved ≈98% accuracy and recovered a hunchback profile.This supports an interpretation in which early layers process or prune irrelevant low-level features.
  • Randomly shuffled labels yielded zero training error but substantial ID growth in the final layers instead of progressive reduction.The authors connect this expansion with fitting inconsistent labels and lack of generalization.

4 Conclusions and Discussion

CNNs first expand representations and then compress them into progressively lower-dimensional manifolds, which are typically curved rather than flat. The last hidden-layer ID predicts generalization performance, while progressive dimensionality reduction—not flattening alone—appears central to obtaining separable representations.

  • 4 Conclusions and Discussion: The learned representations lie on manifolds whose intrinsic dimensionality is far below the embedding-space dimensionality, and these manifolds are typically not hyperplanes.The study systematically examines individual and mixed object manifolds in large, state-of-the-art CNNs.
  • 4 Conclusions and Discussion: CNN representations first increase in intrinsic dimension, then are squeezed into progressively lower-dimensional manifolds across later hidden layers.This pattern appears in both small toy models and large state-of-the-art networks.
  • 4 Conclusions and Discussion: The last hidden-layer intrinsic dimension is a key predictor of a network’s ability to generalize to unseen data.The reported relationship is consistent with an inverse relationship between ID and accuracy, although ID may slightly increase during training without overfitting.
  • 4 Conclusions and Discussion: Intrinsic-dimension estimates are lower than PCA estimates and estimates on linearized data, indicating that the representations lie on curved manifolds.PCA did not qualitatively distinguish trained from randomly initialized networks.
  • 4 Conclusions and Discussion: The findings suggest that progressive reduction of manifold dimensionality, rather than gradual flattening, is associated with linearly separable representations.The authors present this as a refinement of theories emphasizing manifold flattening in visual processing.
  • 4 Conclusions and Discussion: The authors aim for empirical analyses of deep networks to provide intuitions and constraints for future theoretical explanations of their computational capabilities.

A.1 Details of numerical experiments

The experiments were conducted in PyTorch on a Linux workstation equipped with 64GB of RAM and a GeForce GTX 1080 Ti GPU. Code for TwoNN ID estimation and experiment reproduction, along with the data, was made available online.

  • A.1 Details of numerical experiments: Experiments used PyTorch version 1.0 on Linux with 64GB of RAM and a GeForce GTX 1080 Ti NVIDIA GPU.
  • A.1 Details of numerical experiments: The authors released code for computing TwoNN intrinsic-dimension estimates and reproducing the experiments.
  • A.1 Details of numerical experiments: The experimental data was provided through a downloadable Figshare link.

A.1.1 Datasets

The custom dataset contains 1,400 rendered images generated from 40 natural and manmade 3D object models across varied viewpoints and image transformations.

  • A.1.1 Datasets: The custom dataset contains 1,400 images generated from 40 three-dimensional computer-graphics models.
  • A.1.1 Datasets: Each model was rendered in 36 different views combining in-plane and in-depth rotations, horizontal translations, and size variations.
  • A.1.1 Datasets: The image set spans object identities, poses, and low-level features such as luminance, contrast, and position.

A.1.2 Architectures

The experiments used modified and standard CNN architectures, including VGG, AlexNet, ResNet, and a small MNIST network, with representations extracted at pooling and fully connected layers.

  • A.1.2 Architectures: The architectures are described in the order in which they appear in the main text.
  • A.1.2 Architectures: A VGG-16 network was modified by replacing its final hidden layers and fine-tuned for the 40-category custom dataset.
  • A.1.2 Architectures: Fourteen ImageNet-pretrained networks represented AlexNet, VGG variants, and ResNet variants.
  • A.1.2 Architectures: A small convolutional network was trained on MNIST using convolutional, pooling, and fully connected layers.
  • A.1.2 Architectures: A VGG-16 model adapted for CIFAR-10 was trained for experiments on initialization and training dynamics.
  • A.1.2 Architectures: Representations were generally extracted at pooling layers following convolutions or convolutional blocks and at fully connected layers.The MNIST network was analyzed at all layers in specified experiments.

A.1.3 Estimating intrinsic dimension

The analyses estimate intrinsic dimension across network layers using repeated random subsampling of fixed image sets, with results averaged to obtain estimates and errors.

  • The custom-dataset experiment estimated IDs across all network layers using the whole dataset and randomly sampled representations.The VGG-16 network was fine-tuned on approximately 80% of 1440 images, with six images per category reserved for testing.
  • 500 images per ImageNet category were sampled from seven fixed object categories for layer-wise ID estimation.The categories were koalas, shih-tzu, rhodesian, yorkshire, vizsla, setter, and butterfly.
  • At each checkpoint layer, 90% of each category’s representations were randomly subsampled five times before computing category-specific IDs.The category-specific estimates were averaged across the seven categories for each layer.
  • Last-hidden-layer ImageNet IDs used 20 random subsamples of 1800 pooled representations, producing 100 estimates whose mean and standard deviation were reported.These estimates came from random mixtures of all possible object categories in ImageNet.
  • MNIST and CIFAR-10 analyses likewise repeatedly subsampled 90% of fixed representation sets before averaging the resulting ID values.MNIST used 2000 test images, while CIFAR-10 used 500 images from each of its ten classes.

A.1.4 Further results

Further analyses examine whether ID profiles are consistent across object classes and random initializations, and how ID evolves during training.

  • Variability across object categories: ID profiles across the seven AlexNet object classes consistently showed the characteristic hunchback shape across layers.Figure 8 reports individual class profiles alongside the average profile shown in Figure 3.
  • Variability across random initializations: Across 50 VGG-16 CIFAR-10 trainings with different random initializations, last-hidden-layer ID had no correlation with accuracy (r=-0.003).The authors attribute this to little accuracy variation across random initializations and suggest architecture differences explain accuracy differences among well-trained networks.
  • Dynamics: During VGG-16 CIFAR-10 training, intermediate-layer ID and last-hidden-layer ID followed opposite trends.The untrained network had a flat ID profile, while the last-hidden-layer ID evolved non-monotonically during the early training phase.
  • Dynamics: The last-hidden-layer ID was not always a reliable predictor of overfitting onset, even when overfitting was negligible.Whether it predicts overfitting may depend on the architecture and data used.
Loading 1905.12784v2…